diff --git a/global.h b/global.h index 7efd2be..53bb46a 100644 --- a/global.h +++ b/global.h @@ -35,7 +35,7 @@ #define PROGRAM_NAME "DSRemote" -#define PROGRAM_VERSION "0.34_1701021130" +#define PROGRAM_VERSION "0.34_1701061734" #define MAX_PATHLEN 4096 diff --git a/save_data.cpp b/save_data.cpp index 7e2f89d..ca6b80d 100644 --- a/save_data.cpp +++ b/save_data.cpp @@ -302,6 +302,9 @@ void UI_Mainwindow::save_memory_waveform(int job) continue; } + sprintf(str, "Downloading channel %i waveform data...", chn + 1); + progress.setLabelText(str); + sprintf(str, ":WAV:SOUR CHAN%i", chn + 1); tmc_write(str); diff --git a/utils.c b/utils.c index 6532ff3..64dd691 100644 --- a/utils.c +++ b/utils.c @@ -1599,13 +1599,64 @@ void hextobin(char *dest, const char *str) } +double round_to_3digits(double val) +{ + int i, exp=0, polarity=1; + + if(!dblcmp(val, 0.0)) + { + return 0; + } + + if(val < 0) + { + polarity = -1; + + val *= -1; + } + + while(val < 99.999) + { + val *= 10; + + exp--; + } + + while(val > 999.999) + { + val /= 10; + + exp++; + } + + val = nearbyint(val); + + for(i=0; iexp; i--) + { + val /= 10; + } + + return val * polarity; +} + + double round_up_step125(double val, double *ratio) { int i, exp=0; double ltmp; - while(val < 0.999) + if(!dblcmp(val, 0.0)) + { + return 0; + } + + while(val < 0.999) { val *= 10; @@ -1674,6 +1725,11 @@ double round_down_step125(double val, double *ratio) double ltmp; + if(!dblcmp(val, 0.0)) + { + return 0; + } + while(val < 0.999) { val *= 10; diff --git a/utils.h b/utils.h index 13a739f..311baea 100644 --- a/utils.h +++ b/utils.h @@ -92,6 +92,7 @@ int convert_to_metric_suffix(char *, double, int); double round_up_step125(double, double *); /* Rounds the value up to 1-2-5 steps */ double round_down_step125(double, double *); /* Rounds the value down to 1-2-5 steps */ +double round_to_3digits(double); /* Rounds the value to max 3 digits */ int strtoipaddr(unsigned int *, const char *); /* convert a string "192.168.1.12" to an integer */ diff --git a/wave_dialog.cpp b/wave_dialog.cpp index dd2d640..72ed7ac 100644 --- a/wave_dialog.cpp +++ b/wave_dialog.cpp @@ -38,7 +38,7 @@ UI_wave_window::UI_wave_window(struct device_settings *p_devparms, short *wbuf[M mainwindow = (UI_Mainwindow *)parnt; - setMinimumSize(840, 635); + setMinimumSize(840, 655); setWindowTitle("Wave Inspector"); devparms = (struct device_settings *)calloc(1, sizeof(struct device_settings)); @@ -90,7 +90,16 @@ UI_wave_window::UI_wave_window(struct device_settings *p_devparms, short *wbuf[M devparms->wave_mem_view_sample_start = wavslider->value(); + menubar = new QMenuBar(this); + + helpmenu = new QMenu(this); + helpmenu->setTitle("Help"); + helpmenu->addAction("How to operate", mainwindow, SLOT(helpButtonClicked())); + helpmenu->addAction("About", mainwindow, SLOT(show_about_dialog())); + menubar->addMenu(helpmenu); + g_layout = new QGridLayout(this); + g_layout->setMenuBar(menubar); g_layout->addWidget(wavcurve, 0, 0); g_layout->addWidget(wavslider, 1, 0); @@ -162,6 +171,9 @@ void UI_wave_window::wavslider_value_changed(int val) devparms->viewer_center_position = (double)(((devparms->wavebufsz - (devparms->hordivisions * samples_per_div)) / 2) - devparms->wave_mem_view_sample_start) / devparms->samplerate * -1.0; + + devparms->viewer_center_position = round_to_3digits(devparms->viewer_center_position); + wavcurve->update(); } diff --git a/wave_dialog.h b/wave_dialog.h index c11f165..3afd9c3 100644 --- a/wave_dialog.h +++ b/wave_dialog.h @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include "mainwindow.h" #include "global.h" @@ -66,6 +68,10 @@ struct device_settings *devparms; UI_Mainwindow *mainwindow; +QMenuBar *menubar; + +QMenu *helpmenu; + QGridLayout *g_layout; WaveCurve *wavcurve;