Full screen mode menu

tinySA
erikkaashoek 6 years ago
parent 44eb6027a9
commit 9fb0638def

@ -122,6 +122,13 @@ enum {
enum { enum {
M_LOW, M_HIGH, M_GENLOW, M_GENHIGH, M_LOW, M_HIGH, M_GENLOW, M_GENHIGH,
}; };
#define MODE_OUTPUT(x) ((x) == M_GENLOW || (x) == M_GENHIGH )
#define MODE_INPUT(x) ((x) == M_LOW || (x) == M_HIGH )
#define MODE_HIGH(x) ((x) == M_HIGH || (x) == M_GENHIGH )
#define MODE_LOW(x) ((x) == M_LOW || (x) == M_GENLOW )
#define MODE_SELECT(x) (MODE_HIGH(x) ? 1 : 0)
#define SWEEP_ENABLE 0x01 #define SWEEP_ENABLE 0x01
#define SWEEP_ONCE 0x02 #define SWEEP_ONCE 0x02
extern int8_t sweep_mode; extern int8_t sweep_mode;
@ -537,6 +544,7 @@ typedef struct uistat {
uint8_t lever_mode; uint8_t lever_mode;
uint8_t marker_delta; uint8_t marker_delta;
uint8_t marker_tracking; uint8_t marker_tracking;
char text[20];
} uistat_t; } uistat_t;
extern uistat_t uistat; extern uistat_t uistat;
@ -576,6 +584,7 @@ extern int settingStepDelay;
extern int actualStepDelay; extern int actualStepDelay;
extern int settingMode; extern int settingMode;
void update_rbw(uint32_t delta_f); void update_rbw(uint32_t delta_f);
int GetActualRBW(void);
#define byte uint8_t #define byte uint8_t
extern volatile int SI4432_Sel; // currently selected SI4432 extern volatile int SI4432_Sel; // currently selected SI4432

@ -1,5 +1,4 @@
/* /* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
* All rights reserved. * All rights reserved.
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
@ -796,12 +795,19 @@ static void trace_get_value_string(
} else { } else {
dfreq = frequencies[i]; dfreq = frequencies[i];
} }
frequency_string(&buf2[1], sizeof(buf2) -1, dfreq); if (GetActualRBW() < 10)
plot_printf(&buf2[1], sizeof(buf2) -1, "%3.3f" , (dfreq + 500) / 1000000.0);
else if (GetActualRBW() < 100)
plot_printf(&buf2[1], sizeof(buf2) -1, "%3.2f" , (dfreq + 5000) / 1000000.0);
else
plot_printf(&buf2[1], sizeof(buf2) -1, "%3.1f" , (dfreq + 50000) / 1000000.0);
// frequency_string(&buf2[1], sizeof(buf2) -1, dfreq);
v = logmag(&coeff[i]); v = logmag(&coeff[i]);
if (v == -INFINITY) if (v == -INFINITY)
plot_printf(buf, len, "-INF"); plot_printf(buf, len, "-INF");
else else
plot_printf(buf, len, " %s %.2f", buf2, v - rlevel); plot_printf(buf, len, "%s %.1f", buf2, v - rlevel);
} }
#ifdef __VNA__ #ifdef __VNA__
static int static int
@ -1817,26 +1823,35 @@ static void cell_draw_marker_info(int x0, int y0)
continue; continue;
#if 1 #if 1
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0; int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
int ypos = 1 + (j/2)*(13) - y0; // int ypos = 1 + (j/2)*(13) - y0;
int ypos = 1 + (j/2)*(16) - y0;
#else #else
int xpos = 1 + CELLOFFSETX - x0; int xpos = 1 + CELLOFFSETX - x0;
int ypos = 1 + j*(FONT_GET_HEIGHT*2+1) - y0; int ypos = 1 + j*(FONT_GET_HEIGHT*2+1) - y0;
#endif #endif
int k = 0; int k = 0;
if (i == active_marker) if (i == active_marker) {
// ili9341_set_foreground(DEFAULT_BG_COLOR);
// ili9341_set_background(marker_color[markers[i].mtype]);
buf[k++] = '\033'; // Right arrow (?) buf[k++] = '\033'; // Right arrow (?)
else } else {
// ili9341_set_background(DEFAULT_BG_COLOR);
// ili9341_set_foreground(marker_color[markers[i].mtype]);
buf[k++] = ' '; buf[k++] = ' ';
// buf[k++] = ' ';
}
buf[k++] = i+'1'; buf[k++] = i+'1';
buf[k++] = marker_letter[markers[i].mtype]; // buf[k++] = marker_letter[markers[i].mtype];
buf[k++] = 0; buf[k++] = 0;
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); cell_drawstring_7x13(buf, xpos, ypos);
// 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(w, h, buf, xpos+2*7, ypos, config.trace_color[t]); cell_drawstring_7x13(buf, xpos+3*7, ypos);
cell_drawstring_7x13(buf, xpos+4*7, ypos); // cell_drawstring_size(buf, xpos+3*7, ypos, 2);
j++; j++;
} }
} }

@ -75,12 +75,14 @@ int settingSpur = 0;
int settingAverage = 0; int settingAverage = 0;
int settingShowStorage = 0; int settingShowStorage = 0;
int settingSubtractStorage = 0; int settingSubtractStorage = 0;
int settingMode = 0; int settingMode = M_LOW;
int settingDrive=0; // 0-3 , 3=+20dBm int settingDrive=0; // 0-3 , 3=+20dBm
int settingAGC = true; int settingAGC = true;
int settingLNA = false; int settingLNA = false;
int extraVFO = false; int extraVFO = false;
int settingStepDelay = 0; int settingStepDelay = 0;
float rbw = 0;
float vbw = 0;
uint32_t minFreq = 0; uint32_t minFreq = 0;
uint32_t maxFreq = 520000000; uint32_t maxFreq = 520000000;
@ -122,21 +124,31 @@ int GetMode(void)
void SetMode(int m) void SetMode(int m)
{ {
if (settingMode == m)
return;
settingMode = m; settingMode = m;
switch(m) { switch(m) {
case M_LOW: case M_LOW:
set_sweep_frequency(ST_START, (int32_t) 0);
set_sweep_frequency(ST_STOP, (int32_t) 300000000);
goto min_max_low;
case M_GENLOW: case M_GENLOW:
set_sweep_frequency(ST_CENTER, (int32_t) 10000000);
set_sweep_frequency(ST_SPAN, 0);
min_max_low:
minFreq = 0; minFreq = 0;
maxFreq = 520000000; maxFreq = 520000000;
set_sweep_frequency(ST_START, (int32_t) 0);
set_sweep_frequency(ST_STOP, (int32_t) 300000000);
break; break;
case M_HIGH: case M_HIGH:
case M_GENHIGH:
minFreq = 260000000;
maxFreq = 960000000;
set_sweep_frequency(ST_START, (int32_t) 300000000); set_sweep_frequency(ST_START, (int32_t) 300000000);
set_sweep_frequency(ST_STOP, (int32_t) 960000000); set_sweep_frequency(ST_STOP, (int32_t) 960000000);
goto min_max_high;
case M_GENHIGH:
set_sweep_frequency(ST_CENTER, (int32_t) 300000000);
set_sweep_frequency(ST_SPAN, 0);
min_max_high:
minFreq = 240000000;
maxFreq = 960000000;
break; break;
} }
dirty = true; dirty = true;
@ -192,9 +204,9 @@ extern float peakLevel;
void SetPowerLevel(int o) void SetPowerLevel(int o)
{ {
if (o != 100) { if (o != 100) {
if (settingMode & 1) if (settingMode == M_HIGH)
config.high_level_offset = o - peakLevel - settingAttenuate + settingLevelOffset(); config.high_level_offset = o - peakLevel - settingAttenuate + settingLevelOffset();
else else if (settingMode == M_LOW)
config.low_level_offset = o - peakLevel - settingAttenuate + settingLevelOffset(); config.low_level_offset = o - peakLevel - settingAttenuate + settingLevelOffset();
} }
else { else {
@ -206,10 +218,11 @@ void SetPowerLevel(int o)
int settingLevelOffset(void) int settingLevelOffset(void)
{ {
if (settingMode & 1) if (settingMode == M_HIGH)
return(config.high_level_offset); return(config.high_level_offset);
dirty = true; if (settingMode == M_LOW)
return(config.low_level_offset); return(config.high_level_offset);
return(0);
} }
void SetRBW(int v) void SetRBW(int v)
@ -224,6 +237,10 @@ int GetRBW(void)
return(settingBandwidth); return(settingBandwidth);
} }
int GetActualRBW(void)
{
return((int) rbw);
}
void SetSpur(int v) void SetSpur(int v)
{ {
settingSpur = v; settingSpur = v;
@ -287,8 +304,6 @@ int temppeakIndex;
#define BARSTART 24 #define BARSTART 24
float rbw = 0;
float vbw = 0;
int vbwSteps = 1; int vbwSteps = 1;
#if 0 #if 0
@ -586,7 +601,7 @@ void update_rbw(uint32_t delta_f)
rbw = 2.6; rbw = 2.6;
if (rbw > 600) if (rbw > 600)
rbw = 600; rbw = 600;
SI4432_Sel = (settingMode & 1); SI4432_Sel = MODE_SELECT(settingMode);
rbw = SI4432_SET_RBW(rbw); rbw = SI4432_SET_RBW(rbw);
vbwSteps = ((int)(2 * vbw / rbw)); vbwSteps = ((int)(2 * vbw / rbw));
if (vbwSteps < 1) if (vbwSteps < 1)
@ -598,7 +613,7 @@ static int old_lf = -1;
float perform(bool break_on_operation, int i, int32_t f, int extraV) float perform(bool break_on_operation, int i, int32_t f, int extraV)
{ {
long local_IF = ((settingMode & 1) == 0?frequency_IF + (int)(rbw < 300.0?settingSpur * 1000 * rbw :0):0); long local_IF = (MODE_LOW(settingMode)?frequency_IF + (int)(rbw < 300.0?settingSpur * 1000 * rbw :0):0);
if (i == 0 && dirty) { if (i == 0 && dirty) {
if (settingStepDelay == 0){ if (settingStepDelay == 0){
if (rbw < 10.0) if (rbw < 10.0)
@ -636,11 +651,11 @@ float perform(bool break_on_operation, int i, int32_t f, int extraV)
if (lf != old_lf) // only set on change if (lf != old_lf) // only set on change
setFreq (1, local_IF + lf); setFreq (1, local_IF + lf);
old_lf = lf; old_lf = lf;
float subRSSI = SI4432_RSSI(lf, (settingMode & 1))+settingLevelOffset()+settingAttenuate; float subRSSI = SI4432_RSSI(lf, MODE_SELECT(settingMode))+settingLevelOffset()+settingAttenuate;
if (RSSI < subRSSI) if (RSSI < subRSSI)
RSSI = subRSSI; RSSI = subRSSI;
t++; t++;
if ((operation_requested && break_on_operation ) || (settingMode & 2 )) // output modes do not step. if ((operation_requested && break_on_operation ) || (MODE_OUTPUT(settingMode))) // output modes do not step.
subSteps = 0; // abort subSteps = 0; // abort
} while (subSteps-- > 0); } while (subSteps-- > 0);
return(RSSI); return(RSSI);
@ -944,10 +959,9 @@ static void test_acquire(int i)
{ {
pause_sweep(); pause_sweep();
if (test_case[i].center < 300) if (test_case[i].center < 300)
settingMode = 0; settingMode = M_LOW;
else else
settingMode = 1; settingMode = M_HIGH;
set_sweep_frequency(ST_CENTER, (int32_t)test_case[i].center * 1000000); set_sweep_frequency(ST_CENTER, (int32_t)test_case[i].center * 1000000);
set_sweep_frequency(ST_SPAN, (int32_t)test_case[i].span * 1000000); set_sweep_frequency(ST_SPAN, (int32_t)test_case[i].span * 1000000);
sweep(false); sweep(false);
@ -1174,7 +1188,7 @@ void self_test(void)
set_trace_refpos(1, NGRIDY - (-10) / get_trace_scale(0)); set_trace_refpos(1, NGRIDY - (-10) / get_trace_scale(0));
set_trace_refpos(2, NGRIDY - (-10) / get_trace_scale(0)); set_trace_refpos(2, NGRIDY - (-10) / get_trace_scale(0));
set_refer_output(0); set_refer_output(0);
settingMode = 0; settingMode = M_LOW;
draw_cal_status(); draw_cal_status();
menu_autosettings_cb(0); menu_autosettings_cb(0);

84
ui.c

@ -1,5 +1,4 @@
/* /* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
* All rights reserved. * All rights reserved.
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
@ -31,6 +30,7 @@ uistat_t uistat = {
lever_mode: LM_MARKER, lever_mode: LM_MARKER,
marker_delta: FALSE, marker_delta: FALSE,
marker_tracking : FALSE, marker_tracking : FALSE,
text : "",
}; };
#define NO_EVENT 0 #define NO_EVENT 0
@ -433,8 +433,11 @@ enum {
MT_SUBMENU, MT_SUBMENU,
MT_CALLBACK, MT_CALLBACK,
MT_CANCEL, MT_CANCEL,
MT_TITLE,
MT_CLOSE MT_CLOSE
}; };
#define MT_FORM 0x80 // Or with menu type to get large button with current value
#define MT_MASK(x) (0x7F & (x))
typedef void (*menuaction_cb_t)(int item, uint8_t data); typedef void (*menuaction_cb_t)(int item, uint8_t data);
@ -1048,6 +1051,7 @@ const menuitem_t menu_top[] = {
#define MENU_BUTTON_WIDTH 60 #define MENU_BUTTON_WIDTH 60
#define MENU_FORM_WIDTH 290
#define MENU_BUTTON_HEIGHT 30 #define MENU_BUTTON_HEIGHT 30
#define NUM_INPUT_HEIGHT 30 #define NUM_INPUT_HEIGHT 30
@ -1055,7 +1059,7 @@ const menuitem_t menu_top[] = {
#define MENU_STACK_DEPTH_MAX 4 #define MENU_STACK_DEPTH_MAX 4
const menuitem_t *menu_stack[MENU_STACK_DEPTH_MAX] = { const menuitem_t *menu_stack[MENU_STACK_DEPTH_MAX] = {
menu_top, NULL, NULL, NULL menu_mode, NULL, NULL, NULL
}; };
static void static void
@ -1063,7 +1067,7 @@ ensure_selection(void)
{ {
const menuitem_t *menu = menu_stack[menu_current_level]; const menuitem_t *menu = menu_stack[menu_current_level];
int i; int i;
for (i = 0; menu[i].type != MT_NONE; i++) for (i = 0; MT_MASK(menu[i].type) != MT_NONE; i++)
; ;
if (selection >= i) if (selection >= i)
selection = i-1; selection = i-1;
@ -1074,20 +1078,20 @@ menu_move_back(void)
{ {
if (menu_current_level == 0) if (menu_current_level == 0)
return; return;
erase_menu_buttons();
menu_current_level--; menu_current_level--;
ensure_selection(); ensure_selection();
erase_menu_buttons();
draw_menu(); draw_menu();
} }
static void static void
menu_push_submenu(const menuitem_t *submenu) menu_push_submenu(const menuitem_t *submenu)
{ {
erase_menu_buttons();
if (menu_current_level < MENU_STACK_DEPTH_MAX-1) if (menu_current_level < MENU_STACK_DEPTH_MAX-1)
menu_current_level++; menu_current_level++;
menu_stack[menu_current_level] = submenu; menu_stack[menu_current_level] = submenu;
ensure_selection(); ensure_selection();
erase_menu_buttons();
if (menu_is_form(submenu)) { if (menu_is_form(submenu)) {
redraw_frame(); redraw_frame();
area_width = 0; area_width = 0;
@ -1264,6 +1268,7 @@ draw_keypad(void)
ili9341_set_background(bg); ili9341_set_background(bg);
int x = KP_GET_X(keypads[i].x); int x = KP_GET_X(keypads[i].x);
int y = KP_GET_Y(keypads[i].y); int y = KP_GET_Y(keypads[i].y);
// ili9341_fill(x, y, KP_WIDTH, KP_HEIGHT, DEFAULT_MENU_TEXT_COLOR); // black area around button, causes flicker....
ili9341_fill(x+2, y+2, KP_WIDTH-4, KP_HEIGHT-4, bg); ili9341_fill(x+2, y+2, KP_WIDTH-4, KP_HEIGHT-4, bg);
ili9341_drawfont(keypads[i].c, ili9341_drawfont(keypads[i].c,
x + (KP_WIDTH - NUM_FONT_GET_WIDTH) / 2, x + (KP_WIDTH - NUM_FONT_GET_WIDTH) / 2,
@ -1414,30 +1419,55 @@ static void
draw_menu_buttons(const menuitem_t *menu) draw_menu_buttons(const menuitem_t *menu)
{ {
int i = 0; int i = 0;
char text[30];
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
const char *l1, *l2; const char *l1, *l2;
if (menu[i].type == MT_NONE) if (MT_MASK(menu[i].type) == MT_NONE)
break; break;
if (menu[i].type == MT_BLANK) if (MT_MASK(menu[i].type) == MT_BLANK)
continue; continue;
int y = MENU_BUTTON_HEIGHT*i; int y = MENU_BUTTON_HEIGHT*i;
uint16_t bg = config.menu_normal_color; uint16_t bg;
uint16_t fg = DEFAULT_MENU_TEXT_COLOR; uint16_t fg;
if (MT_MASK(menu[i].type) == MT_TITLE) {
fg = config.menu_normal_color;
bg = DEFAULT_MENU_TEXT_COLOR;
} else {
bg = config.menu_normal_color;
fg = DEFAULT_MENU_TEXT_COLOR;
}
// focus only in MENU mode but not in KEYPAD mode // focus only in MENU mode but not in KEYPAD mode
if (ui_mode == UI_MENU && i == selection) if (ui_mode == UI_MENU && i == selection)
bg = config.menu_active_color; bg = config.menu_active_color;
ili9341_fill(320-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT-2, bg);
uint16_t old_bg = bg;
menu_item_modify_attribute(menu, i, &fg, &bg); int active_button_width;
menu_item_modify_attribute(menu, i, &fg, &bg); // before plot_printf to create status text
if (menu[i].type & MT_FORM) {
active_button_width = MENU_FORM_WIDTH;
if (MT_MASK(menu[i].type) == MT_CALLBACK) { // Only callback can have value
keypad_mode = menu[i].data;
fetch_numeric_target();
}
plot_printf(text, sizeof text, menu[i].label, uistat.text);
}
else
active_button_width = MENU_BUTTON_WIDTH;
ili9341_fill(320-active_button_width, y, active_button_width, MENU_BUTTON_HEIGHT-2, old_bg); // Set button to unmodified background color
ili9341_set_foreground(fg); ili9341_set_foreground(fg);
ili9341_set_background(bg); ili9341_set_background(bg);
if (menu[i].type & MT_FORM) {
ili9341_fill(320-active_button_width+3, y+8, active_button_width-6, 2+FONT_GET_HEIGHT*2+2, bg);
ili9341_drawstring_size(text, 320-active_button_width+5, y+10, 2);
} else {
if (menu_is_multiline(menu[i].label, &l1, &l2)) { if (menu_is_multiline(menu[i].label, &l1, &l2)) {
ili9341_fill(320-MENU_BUTTON_WIDTH+3, y+5, MENU_BUTTON_WIDTH-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg); ili9341_fill(320-active_button_width+3, y+5, active_button_width-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg);
ili9341_drawstring(l1, 320-MENU_BUTTON_WIDTH+5, y+7); ili9341_drawstring(l1, 320-active_button_width+5, y+7);
ili9341_drawstring(l2, 320-MENU_BUTTON_WIDTH+5, y+7+FONT_GET_HEIGHT+1); ili9341_drawstring(l2, 320-active_button_width+5, y+7+FONT_GET_HEIGHT+1);
} else { } else {
ili9341_fill(320-MENU_BUTTON_WIDTH+3, y+8, MENU_BUTTON_WIDTH-6, 2+FONT_GET_HEIGHT+2, bg); ili9341_fill(320-active_button_width+3, y+8, active_button_width-6, 2+FONT_GET_HEIGHT+2, bg);
ili9341_drawstring(menu[i].label, 320-MENU_BUTTON_WIDTH+5, y+10); ili9341_drawstring(menu[i].label, 320-active_button_width+5, y+10);
}
} }
} }
} }
@ -1461,12 +1491,18 @@ menu_apply_touch(void)
touch_position(&touch_x, &touch_y); touch_position(&touch_x, &touch_y);
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (menu[i].type == MT_NONE) if (MT_MASK(menu[i].type) == MT_NONE)
break; break;
if (menu[i].type == MT_BLANK) if (MT_MASK(menu[i].type == MT_BLANK) || MT_MASK(menu[i].type) == MT_TITLE)
continue; continue;
int y = MENU_BUTTON_HEIGHT*i; int y = MENU_BUTTON_HEIGHT*i;
if (y < touch_y && touch_y < y+MENU_BUTTON_HEIGHT && 320-MENU_BUTTON_WIDTH < touch_x) { int active_button_width;
if (menu[i].type & MT_FORM)
active_button_width = MENU_FORM_WIDTH;
else
active_button_width = MENU_BUTTON_WIDTH;
if (y < touch_y && touch_y < y+MENU_BUTTON_HEIGHT && 320-active_button_width < touch_x) {
menu_select_touch(i); menu_select_touch(i);
return; return;
} }
@ -1486,7 +1522,8 @@ draw_menu(void)
static void static void
erase_menu_buttons(void) erase_menu_buttons(void)
{ {
ili9341_fill(320-MENU_BUTTON_WIDTH, 0, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*7, DEFAULT_BG_COLOR); ili9341_fill(area_width, 0, 320 - area_width, area_height, DEFAULT_BG_COLOR);
// ili9341_fill(320-MENU_BUTTON_WIDTH, 0, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*7, DEFAULT_BG_COLOR);
} }
static void static void
@ -1649,7 +1686,8 @@ ui_mode_keypad(int _keypad_mode)
ui_mode = UI_KEYPAD; ui_mode = UI_KEYPAD;
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH; area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
area_height = HEIGHT - 32; area_height = HEIGHT - 32;
draw_menu(); if (!menu_is_form(menu_stack[menu_current_level]))
draw_menu();
draw_keypad(); draw_keypad();
draw_numeric_area_frame(); draw_numeric_area_frame();
draw_numeric_input(""); draw_numeric_input("");

@ -41,11 +41,14 @@ extern int settingAGC;
// extern int settingSpeed; // extern int settingSpeed;
extern int settingStepDelay; extern int settingStepDelay;
enum { enum {
KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFPOS, KM_SCALE, KM_ATTENUATION, KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE 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
}; };
#define KP_X(x) (48*(x) + 2 + (320-BUTTON_WIDTH-192)) #define KP_X(x) (48*(x) + 2 + (320-BUTTON_WIDTH-192))
#define KP_Y(y) (48*(y) + 2) #define KP_Y(y) (48*(y) + 2)
@ -166,27 +169,28 @@ int generator_enabled = false;
extern const menuitem_t menu_lowoutputmode[]; extern const menuitem_t menu_lowoutputmode[];
extern const menuitem_t menu_highoutputmode[]; extern const menuitem_t menu_highoutputmode[];
extern const menuitem_t menu_top[];
static void menu_mode_cb(int item, uint8_t data) static void menu_mode_cb(int item, uint8_t data)
{ {
(void)data; (void)data;
SetMode(item-1);
draw_cal_status();
switch (item) { switch (item) {
case 4: // Change reference output, should not happen!!! case 1:
break; menu_push_submenu(menu_top);
default: break;
SetMode(item); case 2:
draw_cal_status(); menu_push_submenu(menu_top);
if (item == 2) { // Activate menu_lowoutputmode as input form break;
set_sweep_frequency(ST_SPAN, 0); case 3:
menu_push_submenu(menu_lowoutputmode); menu_push_submenu(menu_lowoutputmode);
} else if (item == 3) { // Activate menu_highoutputmode as input form break;
set_sweep_frequency(ST_SPAN, 0); case 4:
menu_push_submenu(menu_highoutputmode); menu_push_submenu(menu_highoutputmode);
} else
ui_mode_normal(); // Exit menu after setting the mode
break; break;
} }
draw_cal_status();
} }
extern int dirty; extern int dirty;
@ -260,24 +264,25 @@ static void menu_dfu_cb(int item, uint8_t data)
} }
} }
int menu_refer_value[]={-1,0,1,2,3,4,5,6}; int menu_reffer_value[]={-1,0,1,2,3,4,5,6};
static void menu_refer_cb(int item, uint8_t data) char *menu_reffer_text[]={"OFF","30MHz","15MHz","10MHz","4MHz","3MHz","2MHz","1MHz"};
static void menu_reffer_cb(int item, uint8_t data)
{ {
(void)data; (void)data;
//Serial.println(item); //Serial.println(item);
set_refer_output(menu_refer_value[item]); set_refer_output(menu_reffer_value[item]);
menu_move_back(); menu_move_back();
ui_mode_normal(); // ui_mode_normal(); // Stay in menu mode
draw_cal_status(); draw_cal_status();
} }
static void menu_refer_cb2(int item, uint8_t data) static void menu_reffer_cb2(int item, uint8_t data)
{ {
(void)data; (void)data;
//Serial.println(item); //Serial.println(item);
set_refer_output(menu_refer_value[item+5]); set_refer_output(menu_reffer_value[item+5]);
menu_move_back(); menu_move_back();
ui_mode_normal(); // ui_mode_normal(); // Stay in menu mode
draw_cal_status(); draw_cal_status();
} }
@ -560,16 +565,18 @@ static const menuvalue_t menu_value[] = {
// ===[MENU DEFINITION]========================================================= // ===[MENU DEFINITION]=========================================================
const menuitem_t menu_lowoutputmode[] = { const menuitem_t menu_lowoutputmode[] = {
{ MT_CALLBACK, KM_CENTER, "FREQUENCY", menu_lowoutputmode_cb}, { MT_FORM | MT_TITLE, 0, "LOW OUTPUT", NULL},
{ MT_CALLBACK, KM_ATTENUATION,"LEVEL", menu_lowoutputmode_cb}, { MT_FORM | MT_CALLBACK, KM_CENTER, "FREQ: %s", menu_lowoutputmode_cb},
{ MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_FORM | MT_CALLBACK, KM_ATTENUATION,"LEVEL: %s", menu_lowoutputmode_cb},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
const menuitem_t menu_highoutputmode[] = { const menuitem_t menu_highoutputmode[] = {
{ MT_CALLBACK, KM_CENTER, "FREQUENCY", menu_highoutputmode_cb}, { MT_FORM | MT_TITLE, 0, "HIGH OUTPUT", NULL},
{ MT_CALLBACK, KM_DRIVE, "LEVEL", menu_highoutputmode_cb}, { MT_FORM | MT_CALLBACK, KM_CENTER, "FREQ: %s", menu_highoutputmode_cb},
{ MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_FORM | MT_CALLBACK, KM_DRIVE, "LEVEL", menu_highoutputmode_cb},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -615,22 +622,22 @@ static const menuitem_t menu_dBper[] = {
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_refer2[] = { static const menuitem_t menu_reffer2[] = {
{ MT_CALLBACK, 0, "3MHz" , menu_refer_cb2}, { MT_FORM | MT_CALLBACK, 0, "3MHz" , menu_reffer_cb2},
{ MT_CALLBACK, 0, "2MHz" , menu_refer_cb2}, { MT_FORM | MT_CALLBACK, 0, "2MHz" , menu_reffer_cb2},
{ MT_CALLBACK, 0, "1MHz" , menu_refer_cb2}, { MT_FORM | MT_CALLBACK, 0, "1MHz" , menu_reffer_cb2},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_refer[] = { static const menuitem_t menu_reffer[] = {
{ MT_CALLBACK, 0, "OFF" , menu_refer_cb}, { MT_FORM | MT_CALLBACK, 0, "OFF" , menu_reffer_cb},
{ MT_CALLBACK, 0, "30MHz", menu_refer_cb}, { MT_FORM | MT_CALLBACK, 0, "30MHz", menu_reffer_cb},
{ MT_CALLBACK, 0, "15MHz", menu_refer_cb}, { MT_FORM | MT_CALLBACK, 0, "15MHz", menu_reffer_cb},
{ MT_CALLBACK, 0, "10MHz", menu_refer_cb}, { MT_FORM | MT_CALLBACK, 0, "10MHz", menu_reffer_cb},
{ MT_CALLBACK, 0, "4MHz" , menu_refer_cb}, { MT_FORM | MT_CALLBACK, 0, "4MHz" , menu_reffer_cb},
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_refer2}, { MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_reffer2},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -693,16 +700,6 @@ static const menuitem_t menu_dfu[] = {
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_mode[] = {
{ MT_CALLBACK, 0, "\2LOW\0INPUT", menu_mode_cb},
{ MT_CALLBACK, 0, "\2HIGH\0INPUT",menu_mode_cb},
{ MT_CALLBACK, 0, "\2LOW\0OUTPUT", menu_mode_cb},
{ MT_CALLBACK, 0, "\2HIGH\0OUTPUT",menu_mode_cb},
{ MT_SUBMENU, 0, "\2REFER\0OUTPUT",menu_refer},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_settings2[] = static const menuitem_t menu_settings2[] =
{ {
// { MT_CALLBACK, 0, "TRACK", menu_settings2_cb}, // { MT_CALLBACK, 0, "TRACK", menu_settings2_cb},
@ -738,14 +735,25 @@ static const menuitem_t menu_config[] = {
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_top[] = { static const menuitem_t menu_mode[] = {
{ MT_CALLBACK, 0, "AUTO", menu_autosettings_cb}, { MT_FORM | MT_TITLE, 0, "MODE", NULL},
{ MT_SUBMENU, 0, "SCAN", menu_stimulus}, { MT_FORM | MT_CALLBACK, 0, "LOW INPUT", menu_mode_cb},
{ MT_SUBMENU, 0, "MARKER", menu_marker}, { MT_FORM | MT_CALLBACK, 0, "HIGH INPUT",menu_mode_cb},
{ MT_SUBMENU, 0, "DISPLAY", menu_scale}, { MT_FORM | MT_CALLBACK, 0, "LOW OUTPUT", menu_mode_cb},
{ MT_SUBMENU, 0, "STORAGE", menu_storage}, { MT_FORM | MT_CALLBACK, 0, "HIGH OUTPUT",menu_mode_cb},
{ MT_SUBMENU, 0, "MODE", menu_mode}, { MT_FORM | MT_SUBMENU, 0, "CAL OUTPUT: %s",menu_reffer},
{ MT_SUBMENU, 0, "CONFIG", menu_config}, // { MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
const menuitem_t menu_top[] = {
{ MT_CALLBACK, 0, "AUTO", menu_autosettings_cb},
{ MT_SUBMENU, 0, "SCAN", menu_stimulus},
{ MT_SUBMENU, 0, "MARKER", menu_marker},
{ MT_SUBMENU, 0, "DISPLAY", menu_scale},
{ MT_SUBMENU, 0, "STORAGE", menu_storage},
{ MT_SUBMENU, 0, "CONFIG", menu_config},
{ MT_CANCEL, 0, S_LARROW" MODE",NULL},
{ MT_NONE, 0, NULL, NULL } // sentinel, { MT_NONE, 0, NULL, NULL } // sentinel,
// MENUITEM_CLOSE, // MENUITEM_CLOSE,
}; };
@ -761,24 +769,29 @@ void frequency_string(char *buf, size_t len, int32_t freq);
int menu_is_form(const menuitem_t *menu) int menu_is_form(const menuitem_t *menu)
{ {
return(menu == menu_lowoutputmode || int i;
menu == menu_highoutputmode); for (i = 0; MT_MASK(menu[i].type) != MT_NONE; i++)
if (menu[i].type & MT_FORM)
return (true);
return(false);
} }
static void menu_item_modify_attribute( static void menu_item_modify_attribute(
const menuitem_t *menu, int item, uint16_t *fg, uint16_t *bg) const menuitem_t *menu, int item, uint16_t *fg, uint16_t *bg)
{ {
if (menu == menu_mode) { if (menu == menu_mode) {
if (item == GetMode()){ if (item == GetMode()+1) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = DEFAULT_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} else if (item == 5) {
plot_printf(uistat.text, sizeof uistat.text, menu_reffer_text[get_refer_output()+1]);
} }
} else if (menu == menu_refer) { } else if (menu == menu_reffer) {
if (item < 5 && item == get_refer_output() + 1){ if (item < 5 && item == get_refer_output() + 1){
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = DEFAULT_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (menu == menu_refer2) { } else if (menu == menu_reffer2) {
if (item == get_refer_output() - 4){ if (item == get_refer_output() - 4){
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = DEFAULT_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
@ -837,44 +850,46 @@ static void menu_item_modify_attribute(
} }
} }
if (ui_mode == UI_MENU && menu_is_form(menu)) { if (ui_mode == UI_MENU && menu_is_form(menu)) {
// if (item == 0) // if (item == 0)
// redraw_frame(); // redraw_frame();
if (item <= 1) { if (item <= 1) {
area_width = 0; area_width = 0;
// area_height = HEIGHT - 32; #if 0
int y = MENU_BUTTON_HEIGHT*item; // area_height = HEIGHT - 32;
uint16_t bg = config.menu_normal_color; int y = MENU_BUTTON_HEIGHT*item;
uint16_t fg = DEFAULT_MENU_TEXT_COLOR; uint16_t bg = config.menu_normal_color;
// ili9341_fill(320-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT-2, bg); uint16_t fg = DEFAULT_MENU_TEXT_COLOR;
ili9341_set_foreground(fg); // ili9341_fill(320-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT-2, bg);
ili9341_set_background(bg); ili9341_set_foreground(fg);
char buf[15]; ili9341_set_background(bg);
ili9341_fill(50+25, y, 170, MENU_BUTTON_HEIGHT-2, bg); char buf[15];
if (menu == menu_lowoutputmode) { ili9341_fill(50+25, y, 170, MENU_BUTTON_HEIGHT-2, bg);
switch (item) { if (menu == menu_lowoutputmode) {
case 0: switch (item) {
set_sweep_frequency(ST_SPAN, 0); // For CW sweep mode case 0:
plot_printf(buf, sizeof buf, "%3.3fMHz", frequency0 / 1000000.0); set_sweep_frequency(ST_SPAN, 0); // For CW sweep mode
break; plot_printf(buf, sizeof buf, "%3.3fMHz", frequency0 / 1000000.0);
case 1: break;
plot_printf(buf, sizeof buf, "%ddB", -10 - settingAttenuate); case 1:
break; plot_printf(buf, sizeof buf, "%ddB", -10 - settingAttenuate);
} break;
} }
if (menu == menu_highoutputmode) { }
switch (item) { if (menu == menu_highoutputmode) {
case 0: switch (item) {
set_sweep_frequency(ST_SPAN, 0); // For CW sweep mode case 0:
frequency_string(buf, sizeof buf, frequency0); set_sweep_frequency(ST_SPAN, 0); // For CW sweep mode
break; plot_printf(buf, sizeof buf, "%3.3fMHz", frequency0 / 1000000.0);
case 1: break;
plot_printf(buf, sizeof buf, "%ddB", -10 - settingDrive); case 1:
break; plot_printf(buf, sizeof buf, "%ddB", -10 - settingDrive);
} break;
}
}
ili9341_drawstring_size(buf, 130, y+6, 2);
#endif
} }
ili9341_drawstring_size(buf, 130, y+6, 2);
}
}else{ }else{
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH; area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
} }
@ -885,39 +900,53 @@ static void fetch_numeric_target(void)
switch (keypad_mode) { switch (keypad_mode) {
case KM_START: case KM_START:
uistat.value = get_sweep_frequency(ST_START); uistat.value = get_sweep_frequency(ST_START);
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break; break;
case KM_STOP: case KM_STOP:
uistat.value = get_sweep_frequency(ST_STOP); uistat.value = get_sweep_frequency(ST_STOP);
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break; break;
case KM_CENTER: case KM_CENTER:
uistat.value = get_sweep_frequency(ST_CENTER); uistat.value = get_sweep_frequency(ST_CENTER);
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break; break;
case KM_SPAN: case KM_SPAN:
uistat.value = get_sweep_frequency(ST_SPAN); uistat.value = get_sweep_frequency(ST_SPAN);
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break; break;
case KM_CW: case KM_CW:
uistat.value = get_sweep_frequency(ST_CW); uistat.value = get_sweep_frequency(ST_CW);
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break; break;
case KM_SCALE: case KM_SCALE:
uistat.value = get_trace_scale(uistat.current_trace) * 1000; uistat.value = get_trace_scale(uistat.current_trace) * 1000;
plot_printf(uistat.text, sizeof uistat.text, "%ddB/", uistat.value / 1000);
break; break;
case KM_REFPOS: case KM_REFPOS:
uistat.value = get_trace_refpos(uistat.current_trace) * 1000; uistat.value = get_trace_refpos(uistat.current_trace) * 1000;
plot_printf(uistat.text, sizeof uistat.text, "%ddB", uistat.value / 1000);
break; break;
case KM_ATTENUATION: case KM_ATTENUATION:
uistat.value = settingAttenuate; uistat.value = settingAttenuate;
if (GetMode() == M_GENLOW)
uistat.value += 10; // compensation for dB offset during low output mode
plot_printf(uistat.text, sizeof uistat.text, "%ddB", uistat.value);
break; break;
case KM_ACTUALPOWER: case KM_ACTUALPOWER:
uistat.value = settingLevelOffset(); uistat.value = settingLevelOffset();
plot_printf(uistat.text, sizeof uistat.text, "%ddB", uistat.value);
break; break;
case KM_IF: case KM_IF:
uistat.value = frequency_IF; uistat.value = frequency_IF;
plot_printf(uistat.text, sizeof uistat.text, "%3.3fMHz", uistat.value / 1000000.0);
break; break;
case KM_SAMPLETIME: case KM_SAMPLETIME:
uistat.value = settingStepDelay; uistat.value = settingStepDelay;
plot_printf(uistat.text, sizeof uistat.text, "%3duS", uistat.value);
break; break;
case KM_DRIVE: case KM_DRIVE:
uistat.value = settingDrive; uistat.value = settingDrive;
plot_printf(uistat.text, sizeof uistat.text, "%3ddB", uistat.value);
break; break;
} }
@ -962,6 +991,8 @@ set_numeric_value(void)
set_trace_refpos(2, NGRIDY - uistat.value / get_trace_scale(0)); set_trace_refpos(2, NGRIDY - uistat.value / get_trace_scale(0));
break; break;
case KM_ATTENUATION: case KM_ATTENUATION:
if (GetMode() == M_GENLOW)
uistat.value -= 10; // compensation for dB offset during low output mode
SetAttenuation(uistat.value); SetAttenuation(uistat.value);
break; break;
case KM_ACTUALPOWER: case KM_ACTUALPOWER:

Loading…
Cancel
Save

Powered by TurnKey Linux.