Work in progress.

merge-requests/1/head
Teuniz 2015-06-03 17:41:19 +02:00
rodzic 2c2af87db3
commit 443a53cc4e
6 zmienionych plików z 170 dodań i 56 usunięć

Wyświetl plik

@ -32,6 +32,8 @@ void UI_Mainwindow::navDialChanged(int npos)
{
char str[512];
double val;
if(navDial->isSliderDown() == true)
{
navDial_timer->start(100);
@ -43,33 +45,35 @@ void UI_Mainwindow::navDialChanged(int npos)
if(navDialFunc == NAV_DIAL_FUNC_HOLDOFF)
{
val = get_stepsize_divide_by_1000(devparms.triggerholdoff);
if(npos > 93)
{
devparms.triggerholdoff += 1e-1;
devparms.triggerholdoff += (val * 64);
}
else if(npos > 86)
{
devparms.triggerholdoff += 1e-2;
devparms.triggerholdoff += (val * 32);
}
else if(npos > 79)
{
devparms.triggerholdoff += 1e-3;
devparms.triggerholdoff += (val * 16);
}
else if(npos > 72)
{
devparms.triggerholdoff += 1e-4;
devparms.triggerholdoff += (val * 8);
}
else if(npos > 65)
{
devparms.triggerholdoff += 1e-5;
devparms.triggerholdoff += (val * 4);
}
else if(npos > 58)
{
devparms.triggerholdoff += 1e-6;
devparms.triggerholdoff += (val * 2);
}
else if(npos > 51)
{
devparms.triggerholdoff += 1e-7;
devparms.triggerholdoff += val;
}
else if(npos > 49)
{
@ -77,31 +81,31 @@ void UI_Mainwindow::navDialChanged(int npos)
}
else if(npos > 42)
{
devparms.triggerholdoff -= 1e-7;
devparms.triggerholdoff -= val;
}
else if(npos > 35)
{
devparms.triggerholdoff -= 1e-6;
devparms.triggerholdoff -= (val * 2);
}
else if(npos > 28)
{
devparms.triggerholdoff -= 1e-5;
devparms.triggerholdoff -= (val * 4);
}
else if(npos > 21)
{
devparms.triggerholdoff -= 1e-4;
devparms.triggerholdoff -= (val * 8);
}
else if(npos > 14)
{
devparms.triggerholdoff -= 1e-3;
devparms.triggerholdoff -= (val * 16);
}
else if(npos > 7)
{
devparms.triggerholdoff -= 1e-2;
devparms.triggerholdoff -= (val * 32);
}
else
{
devparms.triggerholdoff -= 1e-1;
devparms.triggerholdoff -= (val * 64);
}
@ -117,7 +121,7 @@ void UI_Mainwindow::navDialChanged(int npos)
strcpy(str, "Holdoff: ");
convert_to_metric_suffix(str + strlen(str), devparms.triggerholdoff);
convert_to_metric_suffix(str + strlen(str), devparms.triggerholdoff, 2);
strcat(str, "s");
@ -169,7 +173,7 @@ void UI_Mainwindow::dispButtonClicked()
submenugrid.addAction("None", this, SLOT(set_grid_none()));
menu.addMenu(&submenugrid);
submenugrading.setTitle("Grading");
submenugrading.setTitle("Persistence");
submenugrading.addAction("Minimum", this, SLOT(set_grading_min()));
submenugrading.addAction("0.05", this, SLOT(set_grading_005()));
submenugrading.addAction("0.1", this, SLOT(set_grading_01()));
@ -191,6 +195,8 @@ void UI_Mainwindow::set_grid_full()
{
devparms.displaygrid = 2;
statusLabel->setText("Display grid: full");
tmcdev_write(device, ":DISP:GRID FULL");
}
@ -199,6 +205,8 @@ void UI_Mainwindow::set_grid_half()
{
devparms.displaygrid = 1;
statusLabel->setText("Display grid: half");
tmcdev_write(device, ":DISP:GRID HALF");
}
@ -207,73 +215,97 @@ void UI_Mainwindow::set_grid_none()
{
devparms.displaygrid = 0;
statusLabel->setText("Display grid: none");
tmcdev_write(device, ":DISP:GRID NONE");
}
void UI_Mainwindow::set_grading_min()
{
tmcdev_write(device, ":DISP:GRAD:TIM MIN");
statusLabel->setText("Display grading: Minimum");
tmcdev_write(device, ":DISP:GRAD:TIME MIN");
}
void UI_Mainwindow::set_grading_005()
{
tmcdev_write(device, ":DISP:GRAD:TIM 0.05");
statusLabel->setText("Display grading: 0.05 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 0.05");
}
void UI_Mainwindow::set_grading_01()
{
tmcdev_write(device, ":DISP:GRAD:TIM 0.1");
statusLabel->setText("Display grading: 0.1 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 0.1");
}
void UI_Mainwindow::set_grading_02()
{
tmcdev_write(device, ":DISP:GRAD:TIM 0.2");
statusLabel->setText("Display grading: 0.2 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 0.2");
}
void UI_Mainwindow::set_grading_05()
{
tmcdev_write(device, ":DISP:GRAD:TIM 0.5");
statusLabel->setText("Display grading: 0.5 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 0.5");
}
void UI_Mainwindow::set_grading_1()
{
tmcdev_write(device, ":DISP:GRAD:TIM 1");
statusLabel->setText("Display grading: 1 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 1");
}
void UI_Mainwindow::set_grading_2()
{
tmcdev_write(device, ":DISP:GRAD:TIM 2");
statusLabel->setText("Display grading: 2 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 2");
}
void UI_Mainwindow::set_grading_5()
{
tmcdev_write(device, ":DISP:GRAD:TIM 5");
statusLabel->setText("Display grading: 5 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 5");
}
void UI_Mainwindow::set_grading_10()
{
tmcdev_write(device, ":DISP:GRAD:TIM 10");
statusLabel->setText("Display grading: 10 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 10");
}
void UI_Mainwindow::set_grading_20()
{
tmcdev_write(device, ":DISP:GRAD:TIM 20");
statusLabel->setText("Display grading: 20 Sec.");
tmcdev_write(device, ":DISP:GRAD:TIME 20");
}
void UI_Mainwindow::set_grading_inf()
{
tmcdev_write(device, ":DISP:GRAD:TIM INF");
statusLabel->setText("Display grading: Infinite");
tmcdev_write(device, ":DISP:GRAD:TIME INF");
}
@ -349,7 +381,7 @@ void UI_Mainwindow::adjDialChanged(int new_pos)
if(adjDialFunc == ADJ_DIAL_FUNC_HOLDOFF)
{
if(dir)
if(!dir)
{
if(devparms.triggerholdoff >= 10)
{
@ -360,7 +392,7 @@ void UI_Mainwindow::adjDialChanged(int new_pos)
return;
}
devparms.triggerholdoff += devparms.timebasescale / 10;
devparms.triggerholdoff += get_stepsize_divide_by_1000(devparms.triggerholdoff);
}
else
{
@ -373,12 +405,12 @@ void UI_Mainwindow::adjDialChanged(int new_pos)
return;
}
devparms.triggerholdoff -= devparms.timebasescale / 10;
devparms.triggerholdoff -= get_stepsize_divide_by_1000(devparms.triggerholdoff);
}
strcpy(str, "Holdoff: ");
convert_to_metric_suffix(str + strlen(str), devparms.triggerholdoff);
convert_to_metric_suffix(str + strlen(str), devparms.triggerholdoff, 2);
strcat(str, "s");
@ -477,7 +509,7 @@ void UI_Mainwindow::trigAdjustDialChanged(int new_pos)
strcpy(str, "Trigger level: ");
convert_to_metric_suffix(str + strlen(str), devparms.triggeredgelevel[chn]);
convert_to_metric_suffix(str + strlen(str), devparms.triggeredgelevel[chn], 2);
strcat(str, "V");
@ -593,7 +625,7 @@ void UI_Mainwindow::horScaleDialChanged(int new_pos)
strcpy(str, "Delayed timebase: ");
convert_to_metric_suffix(str + strlen(str), devparms.timebasedelayscale);
convert_to_metric_suffix(str + strlen(str), devparms.timebasedelayscale, 2);
strcat(str, "s");
@ -655,7 +687,7 @@ void UI_Mainwindow::horScaleDialChanged(int new_pos)
strcpy(str, "Timebase: ");
convert_to_metric_suffix(str + strlen(str), devparms.timebasescale);
convert_to_metric_suffix(str + strlen(str), devparms.timebasescale, 2);
strcat(str, "s");
@ -745,7 +777,7 @@ void UI_Mainwindow::horPosDialChanged(int new_pos)
strcpy(str, "Horizontal delay position: ");
convert_to_metric_suffix(str + strlen(str), devparms.timebasedelayoffset);
convert_to_metric_suffix(str + strlen(str), devparms.timebasedelayoffset, 2);
strcat(str, "s");
@ -788,7 +820,7 @@ void UI_Mainwindow::horPosDialChanged(int new_pos)
strcpy(str, "Horizontal position: ");
convert_to_metric_suffix(str + strlen(str), devparms.timebaseoffset);
convert_to_metric_suffix(str + strlen(str), devparms.timebaseoffset, 2);
strcat(str, "s");
@ -886,7 +918,7 @@ void UI_Mainwindow::vertOffsetDialChanged(int new_pos)
sprintf(str, "Channel %i offset: ", chn + 1);
convert_to_metric_suffix(str + strlen(str), devparms.chanoffset[chn]);
convert_to_metric_suffix(str + strlen(str), devparms.chanoffset[chn], 2);
strcat(str, "V");
@ -1010,7 +1042,7 @@ void UI_Mainwindow::vertScaleDialChanged(int new_pos)
sprintf(str, "Channel %i scale: ", chn + 1);
convert_to_metric_suffix(str + strlen(str), devparms.chanscale[chn]);
convert_to_metric_suffix(str + strlen(str), devparms.chanscale[chn], 2);
strcat(str, "V");
@ -1271,6 +1303,10 @@ void UI_Mainwindow::chan_coupling_ac()
devparms.chancoupling[devparms.activechannel] = 2;
sprintf(str, "Channel %i coupling: AC", devparms.activechannel + 1);
statusLabel->setText(str);
sprintf(str, ":CHAN%i:COUP AC", devparms.activechannel + 1);
tmcdev_write(device, str);
@ -1283,6 +1319,10 @@ void UI_Mainwindow::chan_coupling_dc()
devparms.chancoupling[devparms.activechannel] = 1;
sprintf(str, "Channel %i coupling: DC", devparms.activechannel + 1);
statusLabel->setText(str);
sprintf(str, ":CHAN%i:COUP DC", devparms.activechannel + 1);
tmcdev_write(device, str);
@ -1295,6 +1335,10 @@ void UI_Mainwindow::chan_coupling_gnd()
devparms.chancoupling[devparms.activechannel] = 0;
sprintf(str, "Channel %i coupling: GND", devparms.activechannel + 1);
statusLabel->setText(str);
sprintf(str, ":CHAN%i:COUP GND", devparms.activechannel + 1);
tmcdev_write(device, str);
@ -1307,6 +1351,10 @@ void UI_Mainwindow::chan_bwl_off()
devparms.chanbwlimit[devparms.activechannel] = 0;
sprintf(str, "Channel %i bandwidth limit: Off", devparms.activechannel + 1);
statusLabel->setText(str);
sprintf(str, ":CHAN%i:BWL OFF", devparms.activechannel + 1);
tmcdev_write(device, str);
@ -1319,6 +1367,10 @@ void UI_Mainwindow::chan_bwl_20()
devparms.chanbwlimit[devparms.activechannel] = 20;
sprintf(str, "Channel %i bandwidth limit: 20MHz", devparms.activechannel + 1);
statusLabel->setText(str);
sprintf(str, ":CHAN%i:BWL 20M", devparms.activechannel + 1);
tmcdev_write(device, str);
@ -1331,6 +1383,10 @@ void UI_Mainwindow::chan_bwl_250()
devparms.chanbwlimit[devparms.activechannel] = 250;
sprintf(str, "Channel %i bandwidth limit: 250MHz", devparms.activechannel + 1);
statusLabel->setText(str);
sprintf(str, ":CHAN%i:BWL 250M", devparms.activechannel + 1);
tmcdev_write(device, str);
@ -1348,6 +1404,10 @@ void UI_Mainwindow::chan_invert_on()
devparms.chaninvert[devparms.activechannel] = 1;
sprintf(str, "Channel %i inverted: On", devparms.activechannel + 1);
statusLabel->setText(str);
sprintf(str, ":CHAN%i:INV 1", devparms.activechannel + 1);
tmcdev_write(device, str);
@ -1365,6 +1425,10 @@ void UI_Mainwindow::chan_invert_off()
devparms.chaninvert[devparms.activechannel] = 0;
sprintf(str, "Channel %i inverted: Off", devparms.activechannel + 1);
statusLabel->setText(str);
sprintf(str, ":CHAN%i:INV 0", devparms.activechannel + 1);
tmcdev_write(device, str);
@ -1393,7 +1457,7 @@ void UI_Mainwindow::vertOffsetDialClicked(QPoint)
sprintf(str, "Channel %i offset: ", chn + 1);
convert_to_metric_suffix(str + strlen(str), devparms.chanoffset[chn]);
convert_to_metric_suffix(str + strlen(str), devparms.chanoffset[chn], 2);
strcat(str, "V");
@ -1495,7 +1559,7 @@ void UI_Mainwindow::horPosDialClicked(QPoint)
strcpy(str, "Horizontal delay position: ");
convert_to_metric_suffix(str + strlen(str), devparms.timebasedelayoffset);
convert_to_metric_suffix(str + strlen(str), devparms.timebasedelayoffset, 2);
strcat(str, "s");
@ -1511,7 +1575,7 @@ void UI_Mainwindow::horPosDialClicked(QPoint)
strcpy(str, "Horizontal position: ");
convert_to_metric_suffix(str + strlen(str), devparms.timebaseoffset);
convert_to_metric_suffix(str + strlen(str), devparms.timebaseoffset, 2);
strcat(str, "s");
@ -1771,7 +1835,7 @@ void UI_Mainwindow::trigAdjustDialClicked(QPoint)
strcpy(str, "Trigger level: ");
convert_to_metric_suffix(str + strlen(str), devparms.triggeredgelevel[devparms.triggeredgesource]);
convert_to_metric_suffix(str + strlen(str), devparms.triggeredgelevel[devparms.triggeredgesource], 2);
strcat(str, "V");

Wyświetl plik

@ -330,6 +330,10 @@ UI_Mainwindow::UI_Mainwindow()
device = NULL;
QSettings settings;
strcpy(recent_savedir, settings.value("path/savedir").toString().toLocal8Bit().data());
adjDialFunc = ADJ_DIAL_FUNC_NONE;
navDialFunc = NAV_DIAL_FUNC_NONE;
@ -393,6 +397,10 @@ UI_Mainwindow::UI_Mainwindow()
UI_Mainwindow::~UI_Mainwindow()
{
QSettings settings;
settings.setValue("path/savedir", recent_savedir);
delete appfont;
delete monofont;
@ -1801,6 +1809,28 @@ int UI_Mainwindow::get_metric_factor(double value)
}
double UI_Mainwindow::get_stepsize_divide_by_1000(double val)
{
int exp=0;
while(val < 1)
{
val *= 10;
exp--;
}
while(val >= 10)
{
val /= 10;
exp++;
}
return(exp10(exp - 2));
}
void UI_Mainwindow::get_device_model(const char *str)
{
devparms.channel_cnt = 0;

Wyświetl plik

@ -195,6 +195,7 @@ private:
int parse_preamble(char *, int, struct waveform_preamble *, int);
int get_metric_factor(double);
void get_device_model(const char *);
double get_stepsize_divide_by_1000(double);
private slots:

Wyświetl plik

@ -548,7 +548,7 @@ void SignalCurve::drawTopLabels(QPainter *painter)
painter->drawText(125, 20, "H");
convert_to_metric_suffix(str, devparms->timebasescale);
convert_to_metric_suffix(str, devparms->timebasescale, 1);
strcat(str, "s");
@ -558,13 +558,13 @@ void SignalCurve::drawTopLabels(QPainter *painter)
painter->setPen(Qt::gray);
convert_to_metric_suffix(str, devparms->samplerate);
convert_to_metric_suffix(str, devparms->samplerate, 3);
strcat(str, "Sa/s");
painter->drawText(200, -1, 85, 20, Qt::AlignCenter, str);
convert_to_metric_suffix(str, devparms->memdepth);
convert_to_metric_suffix(str, devparms->memdepth, 1);
strcat(str, "pts");
@ -611,7 +611,7 @@ void SignalCurve::drawTopLabels(QPainter *painter)
painter->drawText(555, 20, "D");
convert_to_metric_suffix(str, devparms->timebaseoffset);
convert_to_metric_suffix(str, devparms->timebaseoffset, 3);
strcat(str, "s");
@ -629,7 +629,7 @@ void SignalCurve::drawTopLabels(QPainter *painter)
painter->drawText(670, 20, "T");
convert_to_metric_suffix(str, devparms->triggeredgelevel[devparms->triggeredgesource]);
convert_to_metric_suffix(str, devparms->triggeredgelevel[devparms->triggeredgesource], 2);
strcat(str, "V");
@ -727,7 +727,7 @@ void SignalCurve::drawChanLabel(QPainter *painter, int xpos, int ypos, int chn)
str1[0] = '1' + chn;
str1[1] = 0;
convert_to_metric_suffix(str2, devparms->chanscale[chn]);
convert_to_metric_suffix(str2, devparms->chanscale[chn], 2);
strcat(str2, "V");
@ -1148,7 +1148,7 @@ void SignalCurve::mouseReleaseEvent(QMouseEvent *release_event)
strcpy(str, "Horizontal position: ");
convert_to_metric_suffix(str + strlen(str), devparms->timebaseoffset);
convert_to_metric_suffix(str + strlen(str), devparms->timebaseoffset, 2);
strcat(str, "s");
@ -1189,7 +1189,7 @@ void SignalCurve::mouseReleaseEvent(QMouseEvent *release_event)
sprintf(str, "Trigger level: ");
convert_to_metric_suffix(str + strlen(str), devparms->triggeredgelevel[devparms->triggeredgesource]);
convert_to_metric_suffix(str + strlen(str), devparms->triggeredgelevel[devparms->triggeredgesource], 2);
strcat(str, "V");
@ -1238,7 +1238,7 @@ void SignalCurve::mouseReleaseEvent(QMouseEvent *release_event)
sprintf(str, "Channel %i offset: ", chn + 1);
convert_to_metric_suffix(str + strlen(str), devparms->chanoffset[chn]);
convert_to_metric_suffix(str + strlen(str), devparms->chanoffset[chn], 2);
strcat(str, "V");

27
utils.c
Wyświetl plik

@ -1599,7 +1599,7 @@ void hextobin(char *dest, const char *str)
}
int convert_to_metric_suffix(char *buf, double value)
int convert_to_metric_suffix(char *buf, double value, int decimals)
{
double ltmp;
@ -1665,12 +1665,32 @@ int convert_to_metric_suffix(char *buf, double value)
if(value >= 0)
{
return sprintf(buf, "%.3f%c", ltmp, suffix);
switch(decimals)
{
case 0: return sprintf(buf, "%.0f%c", ltmp, suffix);
break;
case 1: return sprintf(buf, "%.1f%c", ltmp, suffix);
break;
case 2: return sprintf(buf, "%.2f%c", ltmp, suffix);
break;
default: return sprintf(buf, "%.3f%c", ltmp, suffix);
break;
}
}
if(value < 0)
{
return sprintf(buf, "%.3f%c", ltmp * -1, suffix);
switch(decimals)
{
case 0: return sprintf(buf, "%.0f%c", ltmp * -1, suffix);
break;
case 1: return sprintf(buf, "%.1f%c", ltmp * -1, suffix);
break;
case 2: return sprintf(buf, "%.2f%c", ltmp * -1, suffix);
break;
default: return sprintf(buf, "%.3f%c", ltmp * -1, suffix);
break;
}
}
strcpy(buf, "0");
@ -1787,4 +1807,3 @@ double round_down_step125(double val)

Wyświetl plik

@ -86,7 +86,7 @@ void asciitohex(char *, const char *); /* destination must have double the size
void asciitobin(char *, const char *); /* destination must have eight times the size of source! */
void hextobin(char *, const char *); /* destination must have four times the size of source! */
int convert_to_metric_suffix(char *, double);
int convert_to_metric_suffix(char *, double, int);
double round_up_step125(double); /* Rounds the value up to 1-2-5 steps */
double round_down_step125(double); /* Rounds the value down to 1-2-5 steps */