Some small UI requests

tinySA-v0.2
erikkaashoek 6 years ago
parent 7d235a02c3
commit 7f43e46fd9

@ -226,6 +226,7 @@ flash: build/ch.bin
dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D build/ch.bin dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D build/ch.bin
dfu: dfu:
c:/work/dfu/HEX2DFU build/ch.hex build/ch.dfu
-@printf "reset dfu\r" >/dev/cu.usbmodem401 -@printf "reset dfu\r" >/dev/cu.usbmodem401

@ -163,7 +163,7 @@ extern const char *info_about[];
void reset_settings(int); void reset_settings(int);
//void ui_process_touch(void); //void ui_process_touch(void);
void SetPowerGrid(int); void SetPowerGrid(int);
void SetRefLevel(int); void SetRefLevel(float);
void set_refer_output(int); void set_refer_output(int);
void toggle_below_IF(void); void toggle_below_IF(void);
int get_refer_output(void); int get_refer_output(void);
@ -197,8 +197,8 @@ void set_subtract_storage(void);
void toggle_waterfall(void); void toggle_waterfall(void);
void set_mode(int); void set_mode(int);
int GetMode(void); int GetMode(void);
void set_reflevel(int); void set_reflevel(float);
void set_scale(int); void set_scale(float);
void AllDirty(void); void AllDirty(void);
void MenuDirty(void); void MenuDirty(void);
void toggle_LNA(void); void toggle_LNA(void);
@ -338,6 +338,12 @@ enum trace_type {
// Electrical Delay // Electrical Delay
// Phase // Phase
enum unit_type {
U_DBM=0, U_DBMV, U_DBUV, U_VOLT, U_MWATT,
};
float value(float);
typedef struct trace { typedef struct trace {
uint8_t enabled; uint8_t enabled;
uint8_t type; uint8_t type;
@ -533,8 +539,8 @@ typedef struct setting
int agc; int agc;
int lna; int lna;
int auto_reflevel; int auto_reflevel;
int reflevel; float reflevel;
int scale; float scale;
int tracking; int tracking;
int modulation; int modulation;
int step_delay; int step_delay;
@ -556,7 +562,9 @@ typedef struct setting
trace_t _trace[TRACES_MAX]; trace_t _trace[TRACES_MAX];
marker_t _markers[MARKERS_MAX]; marker_t _markers[MARKERS_MAX];
int8_t _active_marker; int8_t _active_marker;
int8_t unit;
uint32_t checksum; uint32_t checksum;
float offset;
}setting_t; }setting_t;
extern setting_t setting; extern setting_t setting;
@ -778,8 +786,9 @@ int get_waterfall(void);
void toggle_tracking(void); void toggle_tracking(void);
void calibrate(void); void calibrate(void);
void reset_calibration(void); void reset_calibration(void);
void set_reflevel(int); void set_reflevel(float);
void set_scale(int); void set_offset(float);
void set_unit(int);
void set_RBW(int); void set_RBW(int);
void set_switches(int); void set_switches(int);
//extern int setting_measurement; //extern int setting_measurement;

@ -451,12 +451,31 @@ draw_on_strut(int v0, int d, int color)
/* /*
* calculate log10(abs(gamma)) * calculate log10(abs(gamma))
*/ */
static float float
logmag(const float *v) value(const float v)
{ {
return v[0]; // raw data is in logmag*10 format switch(setting.unit)
{
case U_DBMV:
return v+ 30.0 + 20.0*log10(sqrt(50));
break;
case U_DBUV:
return v+ 90.0 + 20.0*log10(sqrt(50.0));
break;
case U_VOLT:
return pow(10, (v - 30.0)/20.0) * sqrt(50.0);
break;
case U_MWATT:
return pow(10, v/10.0);
break;
}
// case U_DBM:
return v; // raw data is in logmag*10 format
} }
#ifdef __VNA_ #ifdef __VNA_
/* /*
* calculate phase[-2:2] of coefficient * calculate phase[-2:2] of coefficient
@ -566,14 +585,14 @@ static index_t
trace_into_index(int t, int i, float array[POINTS_COUNT]) trace_into_index(int t, int i, float array[POINTS_COUNT])
{ {
int y, x; int y, x;
float coeff = array[i];
float *coeff = &array[i];
float refpos = NGRIDY - get_trace_refpos(t); float refpos = NGRIDY - get_trace_refpos(t);
float v = refpos; float v = refpos;
float scale = 1 / get_trace_scale(t); float scale = 1 / get_trace_scale(t);
switch (trace[t].type) { switch (trace[t].type) {
case TRC_LOGMAG: case TRC_LOGMAG:
v-= logmag(coeff) * scale; v-= value(coeff) * scale;
break; break;
#ifdef __VNA__ #ifdef __VNA__
case TRC_PHASE: case TRC_PHASE:
@ -777,6 +796,15 @@ trace_get_value_string_delta(int t, char *buf, int len, float array[POINTS_COUNT
} }
#endif #endif
static const char *unit_string[] =
{
"",
"dBmV",
"dBuV",
"V",
"mW"
};
static void trace_get_value_string( static void trace_get_value_string(
int t, char *buf, int len, int t, char *buf, int len,
int i, float coeff[POINTS_COUNT], int i, float coeff[POINTS_COUNT],
@ -812,14 +840,19 @@ static void trace_get_value_string(
plot_printf(&buf2[1], sizeof(buf2) -1, "%3.1f" , (dfreq + 50000) / 1000000.0); plot_printf(&buf2[1], sizeof(buf2) -1, "%3.1f" , (dfreq + 50000) / 1000000.0);
// frequency_string(&buf2[1], sizeof(buf2) -1, dfreq); // frequency_string(&buf2[1], sizeof(buf2) -1, dfreq);
v = logmag(&coeff[i]); v = value(coeff[i]);
if (mtype & M_NOISE) if (mtype & M_NOISE)
v = v - 10*log10(get_actual_RBW()*1000.0); v = v - 10*log10(get_actual_RBW()*1000.0);
if (v == -INFINITY) if (v == -INFINITY)
plot_printf(buf, len, "-INF"); plot_printf(buf, len, "-INF");
else else {
plot_printf(buf, len, "%s %.1f%s", buf2, v - rlevel,(mtype & M_NOISE?"/Hz":"")); if (setting.unit)
plot_printf(buf, len, "%s %.5f%s%s", buf2, v - rlevel,unit_string[setting.unit],(mtype & M_NOISE?"/Hz":""));
else
plot_printf(buf, len, "%s %.1f%s%s", buf2, v - rlevel,unit_string[setting.unit],(mtype & M_NOISE?"/Hz":""));
}
} }
#ifdef __VNA__ #ifdef __VNA__
static int static int
trace_get_info(int t, char *buf, int len) trace_get_info(int t, char *buf, int len)
@ -1911,10 +1944,10 @@ static void cell_draw_marker_info(int x0, int y0)
} }
for (int i = 0; i < MARKER_COUNT; i++) { for (int i = 0; i < MARKER_COUNT; i++) {
if (i >= 2 && setting.measurement == M_OIP3 && markers[2].enabled && markers[3].enabled) { if (i >= 2 && setting.measurement == M_OIP3 && markers[2].enabled && markers[3].enabled) {
float il = logmag(&(actual_t[markers[2].index])); float il = value((actual_t[markers[2].index]));
float ir = logmag(&(actual_t[markers[3].index])); float ir = value((actual_t[markers[3].index]));
float sl = logmag(&(actual_t[markers[0].index])); float sl = value((actual_t[markers[0].index]));
float sr = logmag(&(actual_t[markers[1].index])); float sr = value((actual_t[markers[1].index]));
float ip = sl+ (sr - il)/2; float ip = sl+ (sr - il)/2;
plot_printf(buf, sizeof buf, "OIP3: %4.1fdB", ip); plot_printf(buf, sizeof buf, "OIP3: %4.1fdB", ip);
@ -1978,13 +2011,19 @@ static void cell_draw_marker_info(int x0, int y0)
buf[k++] = 0; buf[k++] = 0;
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(DEFAULT_BG_COLOR);
ili9341_set_foreground(marker_color(markers[i].mtype)); ili9341_set_foreground(marker_color(markers[i].mtype));
cell_drawstring_7x13(buf, xpos, ypos); if (setting.unit)
cell_drawstring(buf, xpos, ypos);
else
cell_drawstring_7x13(buf, xpos, ypos);
xpos += strlen(buf)*7; xpos += strlen(buf)*7;
// cell_drawstring_size(buf, xpos, ypos, 2); // cell_drawstring_size(buf, xpos, ypos, 2);
trace_get_value_string( trace_get_value_string(
t, buf, sizeof buf, t, buf, sizeof buf,
idx, measured[trace[t].channel], frequencies, sweep_points, ridx, markers[i].mtype); idx, measured[trace[t].channel], frequencies, sweep_points, ridx, markers[i].mtype);
cell_drawstring_7x13(buf, xpos, ypos); if (setting.unit)
cell_drawstring(buf, xpos, ypos);
else
cell_drawstring_7x13(buf, xpos, ypos);
// cell_drawstring_size(buf, xpos+3*7, ypos, 2); // cell_drawstring_size(buf, xpos+3*7, ypos, 2);
j++; j++;
} }

@ -70,7 +70,7 @@ VNA_SHELL_FUNCTION(cmd_rbw)
shell_printf("usage: rbw 2..600|auto\r\n"); shell_printf("usage: rbw 2..600|auto\r\n");
return; return;
} }
if (strcmp(argv[0],"auto") == 0) { if (strcmp(argv[0],"auto") == 0 || strcmp(argv[0],"0") == 0) {
set_RBW(0); set_RBW(0);
} else { } else {
int a = my_atoi(argv[0]); int a = my_atoi(argv[0]);
@ -207,7 +207,7 @@ VNA_SHELL_FUNCTION(cmd_o)
VNA_SHELL_FUNCTION(cmd_d) VNA_SHELL_FUNCTION(cmd_d)
{ {
(void) argc; (void) argc;
int32_t a = my_atoi(argv[0]); // int32_t a = my_atoi(argv[0]);
// setting.drive = a; // setting.drive = a;
} }

@ -46,6 +46,7 @@ void reset_settings(int m)
setting.tracking_output = false; setting.tracking_output = false;
setting.measurement = M_OFF; setting.measurement = M_OFF;
setting.frequency_IF = 433800000; setting.frequency_IF = 433800000;
setting.offset = 0.0;
trace[TRACE_STORED].enabled = false; trace[TRACE_STORED].enabled = false;
trace[TRACE_TEMP].enabled = false; trace[TRACE_TEMP].enabled = false;
#ifdef __SPUR__ #ifdef __SPUR__
@ -187,6 +188,12 @@ void set_IF(int f)
dirty = true; dirty = true;
} }
void set_unit(int u)
{
setting.unit = u;
dirty = true;
}
int GetMode(void) int GetMode(void)
{ {
return(setting.mode); return(setting.mode);
@ -195,8 +202,8 @@ int GetMode(void)
#define POWER_STEP 0 // Should be 5 dB but appearently it is lower #define POWER_STEP 0 // Should be 5 dB but appearently it is lower
#define POWER_OFFSET 20 #define POWER_OFFSET 15
#define SWITCH_ATTENUATION 29 #define SWITCH_ATTENUATION 30
int get_attenuation(void) int get_attenuation(void)
{ {
@ -434,7 +441,7 @@ int GetAGC(void)
return(setting.agc); return(setting.agc);
} }
void set_reflevel(int level) void set_reflevel(float level)
{ {
setting.reflevel = (level / setting.scale) * setting.scale; setting.reflevel = (level / setting.scale) * setting.scale;
set_trace_refpos(0, NGRIDY - level / get_trace_scale(0)); set_trace_refpos(0, NGRIDY - level / get_trace_scale(0));
@ -443,11 +450,17 @@ void set_reflevel(int level)
dirty = true; dirty = true;
} }
void set_offset(float offset)
{
setting.offset = offset;
dirty = true;
}
//int GetRefpos(void) { //int GetRefpos(void) {
// return (NGRIDY - get_trace_refpos(2)) * get_trace_scale(2); // return (NGRIDY - get_trace_refpos(2)) * get_trace_scale(2);
//} //}
void set_scale(int s) { void set_scale(float s) {
setting.scale = s; setting.scale = s;
set_trace_scale(0, s); set_trace_scale(0, s);
set_trace_scale(1, s); set_trace_scale(1, s);
@ -978,7 +991,7 @@ again:
signal_path_loss = -5.5; // Loss in dB, -9.5 for v0.1, -12.5 for v0.2 signal_path_loss = -5.5; // Loss in dB, -9.5 for v0.1, -12.5 for v0.2
else else
signal_path_loss = +7; // Loss in dB (+ is gain) signal_path_loss = +7; // Loss in dB (+ is gain)
float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode))+get_level_offset()+ setting.attenuate - signal_path_loss; float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode))+get_level_offset()+ setting.attenuate - signal_path_loss - setting.offset;
#ifdef __SPUR__ #ifdef __SPUR__
if (setting.spur == 1) { // First pass if (setting.spur == 1) { // First pass
spur_RSSI = subRSSI; spur_RSSI = subRSSI;
@ -1115,27 +1128,28 @@ static bool sweep(bool break_on_operation)
scandirty = false; scandirty = false;
draw_cal_status(); draw_cal_status();
} }
if (!in_selftest && setting.mode == M_LOW && setting.auto_attenuation && max_index[0] > 0) { if (!in_selftest && setting.mode == M_LOW && setting.auto_attenuation && max_index[0] > 0) {
if (actual_t[max_index[0]] - setting.attenuate < - 3*setting.scale && setting.attenuate >= setting.scale) { if (actual_t[max_index[0]] - setting.attenuate < - 30 && setting.attenuate >= 10) {
setting.attenuate -= setting.scale; setting.attenuate -= 10;
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)
} else if (actual_t[max_index[0]] - setting.attenuate > - 1.5*setting.scale && setting.attenuate <= 30 - setting.scale) { } else if (actual_t[max_index[0]] - setting.attenuate > - 15 && setting.attenuate <= 20) {
setting.attenuate += setting.scale; setting.attenuate += 10;
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)
} }
} }
if (!in_selftest && MODE_INPUT(setting.mode) && setting.auto_reflevel && max_index[0] > 0) { if (!in_selftest && MODE_INPUT(setting.mode) && setting.auto_reflevel && max_index[0] > 0) {
if (actual_t[max_index[0]] > setting.reflevel - setting.scale/2) { if (value(actual_t[max_index[0]]) > setting.reflevel - setting.scale/2) {
set_reflevel(setting.reflevel + setting.scale); set_reflevel(setting.reflevel + setting.scale);
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)
} else if (temp_min_level < setting.reflevel - 9 * setting.scale - 2 && actual_t[max_index[0]] < setting.reflevel - setting.scale * 3 / 2) { } else if (temp_min_level < setting.reflevel - 9.2 * setting.scale && value(actual_t[max_index[0]]) < setting.reflevel - setting.scale * 1.5) {
set_reflevel(setting.reflevel - setting.scale); set_reflevel(setting.reflevel - setting.scale);
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)
} else if (temp_min_level > setting.reflevel - 9 * setting.scale + setting.scale + 2) { } else if (temp_min_level > setting.reflevel - 7.8 * setting.scale) {
set_reflevel(setting.reflevel + setting.scale); set_reflevel(setting.reflevel + setting.scale);
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
dirty = true; // Must be above if(scandirty!!!!!) dirty = true; // Must be above if(scandirty!!!!!)
@ -1380,8 +1394,8 @@ void draw_cal_status(void)
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(DEFAULT_BG_COLOR);
int yMax = setting.reflevel; float yMax = setting.reflevel;
plot_printf(buf, BLEN, "%ddB", yMax); plot_printf(buf, BLEN, "%f", yMax);
buf[5]=0; buf[5]=0;
if (level_is_calibrated()) { if (level_is_calibrated()) {
if (setting.auto_reflevel) if (setting.auto_reflevel)
@ -1397,7 +1411,7 @@ void draw_cal_status(void)
color = DEFAULT_FG_COLOR; color = DEFAULT_FG_COLOR;
ili9341_set_foreground(color); ili9341_set_foreground(color);
y += YSTEP*2; y += YSTEP*2;
plot_printf(buf, BLEN, "%ddB/",(int)setting.scale); plot_printf(buf, BLEN, "%f/",setting.scale);
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
if (setting.auto_attenuation) if (setting.auto_attenuation)
@ -1496,6 +1510,17 @@ void draw_cal_status(void)
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
} }
if (setting.offset != 0.0) {
ili9341_set_foreground(BRIGHT_COLOR_RED);
y += YSTEP*2;
ili9341_drawstring("Amp:", x, y);
y += YSTEP;
plot_printf(buf, BLEN, "%fdB",setting.offset);
buf[5]=0;
ili9341_drawstring(buf, x, y);
}
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(BRIGHT_COLOR_GREEN);
y += YSTEP*2; y += YSTEP*2;
if (MODE_LOW(setting.mode)) if (MODE_LOW(setting.mode))
@ -1505,7 +1530,7 @@ void draw_cal_status(void)
y = HEIGHT-7 + OFFSETY; y = HEIGHT-7 + OFFSETY;
plot_printf(buf, BLEN, "%ddB", (int)(yMax - setting.scale * NGRIDY)); plot_printf(buf, BLEN, "%f", (yMax - setting.scale * NGRIDY));
buf[5]=0; buf[5]=0;
if (level_is_calibrated()) if (level_is_calibrated())
if (setting.auto_reflevel) if (setting.auto_reflevel)

@ -279,7 +279,7 @@ const uint16_t right_icons [] =
enum { enum {
KM_START=1, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFPOS, KM_SCALE, KM_ATTENUATION, KM_START=1, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFPOS, KM_SCALE, KM_ATTENUATION,
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_10MHZ, KM_REPEAT, KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_10MHZ, KM_REPEAT, KM_OFFSET,
}; };
@ -389,6 +389,7 @@ static const keypads_t * const keypads_mode_tbl[] = {
keypads_level, // KM_NOISE keypads_level, // KM_NOISE
keypads_level, // KM_10MHz keypads_level, // KM_10MHz
keypads_level, // KM_REPEA keypads_level, // KM_REPEA
keypads_level, // KM_OFFSET
}; };
#ifdef __VNA__ #ifdef __VNA__
@ -399,7 +400,7 @@ static const char * const keypad_mode_label[] = {
#ifdef __SA__ #ifdef __SA__
static const char * const keypad_mode_label[] = { static const char * const keypad_mode_label[] = {
"error", "START", "STOP", "CENTER", "SPAN", "FREQ", "REFPOS", "SCALE", // 0-7 "error", "START", "STOP", "CENTER", "SPAN", "FREQ", "REFPOS", "SCALE", // 0-7
"\2ATTENUATE\0 0-31dB", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL", "OFFSET" , "REPEATS"// 8-17 "\2ATTENUATE\0 0-31dB", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL", "OFFSET" , "REPEATS", "OFFSET"// 8-17
}; };
#endif #endif
@ -829,12 +830,23 @@ static void menu_rbw_cb(int item, uint8_t data)
// draw_cal_status(); // draw_cal_status();
} }
int menu_dBper_value[]={1,2,5,10,20}; static void menu_unit_cb (int item, uint8_t data)
{
(void)item;
set_unit(data);
menu_move_back();
ui_mode_normal();
}
enum {
S_20,S_10,S_5,S_2,S_1,S_P5,S_P2,S_P1,S_P05,S_P02,S_P01
};
static const float menu_scale_per_value[11]={20,10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01};
static void menu_dBper_cb(int item, uint8_t data) static void menu_scale_per_cb(int item, uint8_t data)
{ {
(void)item; (void)item;
set_scale(data); set_scale(menu_scale_per_value[data]);
menu_move_back(); menu_move_back();
ui_mode_normal(); ui_mode_normal();
// draw_cal_status(); // draw_cal_status();
@ -910,7 +922,7 @@ static void menu_pause_cb(int item, uint8_t data)
} }
//const int menu_drive_value[]={5,10,15,20}; //const int menu_drive_value[]={5,10,15,20};
const char *menu_drive_text[]={"-36dBm","-34dBm","-32dBm","-30dBm","-28dBm","-26dBm","-24dBm"," -22dBm", " -10dBm"," -7dBm"," -4dBm"," -1dBm"," 2dBm"," 5dBm"," 8dBm"," 11dBm"}; const char *menu_drive_text[]={"-38dBm","-35dBm","-33dBm","-30dBm","-27dBm","-24dBm","-21dBm"," -19dBm", " -7dBm"," -4dBm"," -2dBm"," 1dBm"," 4dBm"," 7dBm"," 10dBm"," 13dBm"};
@ -965,42 +977,42 @@ static const menuitem_t menu_load_preset[] =
}; };
static const menuitem_t menu_drive[] = { static const menuitem_t menu_drive[] = {
{ MT_CALLBACK, 15, " 20dBm", menu_drive_cb}, { MT_CALLBACK, 15, " 15dBm", menu_drive_cb},
{ MT_CALLBACK, 14, " 16dBm", menu_drive_cb}, { MT_CALLBACK, 14, " 12dBm", menu_drive_cb},
{ MT_CALLBACK, 13, " 12dBm", menu_drive_cb}, { MT_CALLBACK, 13, " 9dBm", menu_drive_cb},
{ MT_CALLBACK, 12, " 8dBm", menu_drive_cb}, { MT_CALLBACK, 12, " 6dBm", menu_drive_cb},
{ MT_CANCEL, 255, S_LARROW" BACK", NULL }, { MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_drive_wide3[] = { static const menuitem_t menu_drive_wide3[] = {
{ MT_FORM | MT_CALLBACK, 5, "-26dBm", menu_drive_cb }, { MT_FORM | MT_CALLBACK, 5, "-24dBm", menu_drive_cb },
{ MT_FORM | MT_CALLBACK, 4, "-28dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 4, "-27dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 3, "-30dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 3, "-30dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 2, "-32dBm", menu_drive_cb }, { MT_FORM | MT_CALLBACK, 2, "-33dBm", menu_drive_cb },
{ MT_FORM | MT_CALLBACK, 1, "-34dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 1, "-35dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 0, "-36dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 0, "-38dBm", menu_drive_cb},
{ MT_FORM | MT_CANCEL, 255, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_drive_wide2[] = { static const menuitem_t menu_drive_wide2[] = {
{ MT_FORM | MT_CALLBACK, 10, " -4dBm", menu_drive_cb }, { MT_FORM | MT_CALLBACK, 10, " -2dBm", menu_drive_cb },
{ MT_FORM | MT_CALLBACK, 9, " -7dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 9, " -4dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 8, "-10dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 8, " -7dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 7, "-22dBm", menu_drive_cb }, { MT_FORM | MT_CALLBACK, 7, "-19dBm", menu_drive_cb },
{ MT_FORM | MT_CALLBACK, 6, "-24dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 6, "-21dBm", menu_drive_cb},
{ MT_FORM | MT_SUBMENU, 255, S_RARROW" MORE", menu_drive_wide3}, { MT_FORM | MT_SUBMENU, 255, S_RARROW" MORE", menu_drive_wide3},
{ MT_FORM | MT_CANCEL, 255, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_drive_wide[] = { static const menuitem_t menu_drive_wide[] = {
{ MT_FORM | MT_CALLBACK, 15, " 11dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 15, " 13dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 14, " 8dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 14, " 10dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 13, " 5dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 13, " 7dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 12, " 2dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 12, " 4dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 11, " -1dBm", menu_drive_cb}, { MT_FORM | MT_CALLBACK, 11, " 1dBm", menu_drive_cb},
{ MT_FORM | MT_SUBMENU, 255, S_RARROW" MORE", menu_drive_wide2}, { MT_FORM | MT_SUBMENU, 255, S_RARROW" MORE", menu_drive_wide2},
{ MT_FORM | MT_CANCEL, 255, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
@ -1062,12 +1074,27 @@ static const menuitem_t menu_rbw[] = {
}; };
static const menuitem_t menu_dBper[] = { static const menuitem_t menu_scale_per2[] = {
{ MT_CALLBACK, 1, " 1dB/", menu_dBper_cb}, { MT_CALLBACK, 6, "0.1 /", menu_scale_per_cb},
{ MT_CALLBACK, 2, " 2dB/", menu_dBper_cb}, { MT_CALLBACK, 7, "0.2 /", menu_scale_per_cb},
{ MT_CALLBACK, 5, " 5dB/", menu_dBper_cb}, { MT_CALLBACK, 8, "0.05/", menu_scale_per_cb},
{ MT_CALLBACK, 10," 10dB/", menu_dBper_cb}, { MT_CALLBACK, 9, "0.02/", menu_scale_per_cb},
{ MT_CALLBACK, 20," 20dB/", menu_dBper_cb}, { MT_CALLBACK,10, "0.01/", menu_scale_per_cb},
// { MT_CALLBACK,11, "0.005/", menu_scale_per_cb},
// { MT_SUBMENU, 0, S_RARROW" MORE", menu_scale_per2},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_scale_per[] = {
{ MT_CALLBACK, 0, " 20/", menu_scale_per_cb},
{ MT_CALLBACK, 1, " 10/", menu_scale_per_cb},
{ MT_CALLBACK, 2, " 5/", menu_scale_per_cb},
{ MT_CALLBACK, 3, " 2/", menu_scale_per_cb},
{ MT_CALLBACK, 4, " 1/", menu_scale_per_cb},
{ MT_CALLBACK, 5, "0.5/", menu_scale_per_cb},
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_scale_per2},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -1235,7 +1262,7 @@ static const menuitem_t menu_settings[] =
{ MT_KEYPAD, KM_IF, "\2IF\0FREQ", NULL}, { MT_KEYPAD, KM_IF, "\2IF\0FREQ", NULL},
{ MT_SUBMENU,0, "\2SCAN\0SPEED", menu_scanning_speed}, { MT_SUBMENU,0, "\2SCAN\0SPEED", menu_scanning_speed},
{ MT_KEYPAD, KM_REPEAT, "REPEATS", NULL}, { MT_KEYPAD, KM_REPEAT, "REPEATS", NULL},
{ MT_SUBMENU,0, "\2LO\0DRIVE", menu_drive}, { MT_SUBMENU,0, "\2MIXER\0DRIVE", menu_drive},
#ifdef __ULTRA__ #ifdef __ULTRA__
{ MT_SUBMENU,0, "HARMONIC", menu_harmonic}, { MT_SUBMENU,0, "HARMONIC", menu_harmonic},
#endif #endif
@ -1341,19 +1368,39 @@ static const menuitem_t menu_displayhigh[] = {
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_unit[] =
{
{ MT_CALLBACK,U_DBM, "dBm", menu_unit_cb},
{ MT_CALLBACK,U_DBMV, "dBmV", menu_unit_cb},
{ MT_CALLBACK,U_DBUV, "dBuV", menu_unit_cb},
{ MT_CALLBACK,U_VOLT, "Volt", menu_unit_cb},
{ MT_CALLBACK,U_MWATT, "mWatt", menu_unit_cb},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_levelhigh[] = { static const menuitem_t menu_levelhigh[] = {
{ MT_SUBMENU, 0, "\2REF\0LEVEL", menu_reflevel}, { MT_SUBMENU, 0, "\2REF\0LEVEL", menu_reflevel},
{ MT_SUBMENU, 0, "\2SCALE/\0DIV",menu_dBper}, // { MT_SUBMENU, 0, "\2SCALE/\0DIV",menu_scale_per},
{ MT_KEYPAD, KM_SCALE, "\2SCALE/\0DIV", NULL},
{ MT_SUBMENU,0, "AVER", menu_average}, { MT_SUBMENU,0, "AVER", menu_average},
{ MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_SUBMENU, 0, "UNIT", menu_unit},
{ MT_KEYPAD, KM_OFFSET, "\2EXTERN\0AMP", NULL},
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_level[] = { static const menuitem_t menu_level[] = {
{ MT_SUBMENU, 0, "\2REF\0LEVEL", menu_reflevel}, { MT_SUBMENU, 0, "\2REF\0LEVEL", menu_reflevel},
{ MT_SUBMENU, 0, "\2SCALE/\0DIV",menu_dBper}, // { MT_SUBMENU, 0, "\2SCALE/\0DIV",menu_scale_per},
{ MT_KEYPAD, KM_SCALE, "\2SCALE/\0DIV", NULL},
{ MT_SUBMENU, 0, "ATTEN", menu_atten}, { MT_SUBMENU, 0, "ATTEN", menu_atten},
{ MT_SUBMENU,0, "AVER", menu_average}, { MT_SUBMENU,0, "AVER", menu_average},
{ MT_SUBMENU, 0, "UNIT", menu_unit},
{ MT_KEYPAD, KM_OFFSET, "\2EXTERN\0AMP", NULL},
{ MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -1508,8 +1555,8 @@ static void menu_item_modify_attribute(
if (item == GetAverage()){ if (item == GetAverage()){
mark = true; mark = true;
} }
} else if (menu == menu_dBper) { } else if (menu == menu_scale_per) {
if (data == setting.scale){ if (menu_scale_per_value[data] == setting.scale){
mark = true; mark = true;
} }
} else if (menu == menu_measure && MT_MASK(menu[item].type) == MT_CALLBACK) { } else if (menu == menu_measure && MT_MASK(menu[item].type) == MT_CALLBACK) {
@ -1641,11 +1688,11 @@ static void fetch_numeric_target(void)
break; break;
case KM_SCALE: case KM_SCALE:
uistat.value = setting.scale; uistat.value = setting.scale;
plot_printf(uistat.text, sizeof uistat.text, "%ddB/", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%f/", uistat.value);
break; break;
case KM_REFPOS: case KM_REFPOS:
uistat.value = setting.reflevel; uistat.value = setting.reflevel;
plot_printf(uistat.text, sizeof uistat.text, "%ddB", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%f", uistat.value);
break; break;
case KM_ATTENUATION: case KM_ATTENUATION:
uistat.value = get_attenuation(); uistat.value = get_attenuation();
@ -1687,6 +1734,10 @@ static void fetch_numeric_target(void)
uistat.value = setting_frequency_10mhz; uistat.value = setting_frequency_10mhz;
plot_printf(uistat.text, sizeof uistat.text, "%3.6fMHz", uistat.value / 1000000.0); plot_printf(uistat.text, sizeof uistat.text, "%3.6fMHz", uistat.value / 1000000.0);
break; break;
case KM_OFFSET:
uistat.value = setting.offset;
plot_printf(uistat.text, sizeof uistat.text, "%fdB", uistat.value);
break;
} }
@ -1720,9 +1771,7 @@ set_numeric_value(void)
set_sweep_frequency(ST_CW, uistat.value); set_sweep_frequency(ST_CW, uistat.value);
break; break;
case KM_SCALE: case KM_SCALE:
set_trace_scale(0, uistat.value / 1000.0); set_scale(uistat.value);
set_trace_scale(1, uistat.value / 1000.0);
set_trace_scale(2, uistat.value / 1000.0);
break; break;
case KM_REFPOS: case KM_REFPOS:
setting.auto_reflevel = false; setting.auto_reflevel = false;
@ -1765,5 +1814,8 @@ set_numeric_value(void)
set_10mhz(uistat.value); set_10mhz(uistat.value);
dirty = true; dirty = true;
break; break;
case KM_OFFSET:
set_offset(uistat.value);
break;
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.