From 1a2664943fb6b4e1395eb7600165e41e9e8e86e2 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sun, 12 Apr 2020 15:21:59 +0200 Subject: [PATCH] Many marker and measurement related updates --- Makefile | 4 +- main.c | 8 +- nanovna.h | 8 +- plot.c | 54 ++++--- sa_core.c | 51 ++++--- ui.c | 113 +++++++++++---- ui_sa.c | 411 ++++++++++++++++++++++++++++++++++++++++-------------- 7 files changed, 464 insertions(+), 185 deletions(-) diff --git a/Makefile b/Makefile index 770ad95..2af90d0 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ # Compiler options here. ifeq ($(USE_OPT),) -# USE_OPT = -O2 -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage - USE_OPT = -fdce -fdse -fmerge-constants -fstore-merging -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage + USE_OPT = -Og -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage +# USE_OPT = -fdce -fdse -fmerge-constants -fstore-merging -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage endif # C specific options here (added to USE_OPT). diff --git a/main.c b/main.c index 337a0ec..59acdd5 100644 --- a/main.c +++ b/main.c @@ -827,10 +827,10 @@ static const trace_t def_trace[TRACES_MAX] = {//enable, type, channel, reserved, }; static const marker_t def_markers[MARKERS_MAX] = { - { M_TRACKING_ENABLED, M_REFERENCE, 30, 0 }, - { M_DISABLED, M_NORMAL, 40, 0 }, - { M_DISABLED, M_NORMAL, 60, 0 }, - { M_DISABLED, M_NORMAL, 80, 0 } + { M_ENABLED, M_REFERENCE | M_TRACKING, 30, 0 }, + { M_DISABLED, M_NORMAL, 40, 0 }, + { M_DISABLED, M_NORMAL, 60, 0 }, + { M_DISABLED, M_NORMAL, 80, 0 } }; // Load propeties default settings diff --git a/nanovna.h b/nanovna.h index 86ef5ce..522505c 100644 --- a/nanovna.h +++ b/nanovna.h @@ -319,11 +319,11 @@ float groupdelay_from_array(int i, float array[POINTS_COUNT][2]); #endif // marker enum { - M_REFERENCE, M_NORMAL, M_DELTA, M_TRACKING + M_NORMAL=0,M_REFERENCE=1, M_DELTA=2, M_NOISE=4, M_TRACKING=8 // Tracking must be last. }; enum { - M_DISABLED, M_ENABLED, M_TRACKING_ENABLED + M_DISABLED = false, M_ENABLED = true }; typedef struct { @@ -333,7 +333,6 @@ typedef struct { uint32_t frequency; } marker_t; - #define MARKERS_MAX 4 extern int8_t previous_marker; @@ -568,6 +567,7 @@ typedef struct uistat { // uint32_t previous_value; uint8_t lever_mode; uint8_t marker_delta; + uint8_t marker_noise; uint8_t marker_tracking; char text[20]; } uistat_t; @@ -647,7 +647,7 @@ void wait_user(void); void calibrate(void); enum { - M_OFF, M_IMD, M_OIP3 + M_OFF, M_IMD, M_OIP3, M_PHASE_NOISE }; /*EOF*/ diff --git a/plot.c b/plot.c index 0e57e0f..8b662c8 100644 --- a/plot.c +++ b/plot.c @@ -63,18 +63,28 @@ typedef uint16_t map_t; typedef uint32_t map_t; #endif -uint16_t marker_color[3] = +uint16_t marker_color(int mtype) { - RGBHEX(0xFFFFFF), - RGBHEX(0xFFFF00), - RGBHEX(0x00FF00) -}; + if (mtype & M_REFERENCE) + return(RGBHEX(0xFFFFFF)); + if (mtype & M_DELTA) + return(RGBHEX(0x00FF00)); + if (mtype & M_NOISE) + return(RGBHEX(0x00FFFF)); + return(RGBHEX(0xFFFF00)); +} + +//#if 4 != M_TRACKING +//#error "Wrong marker numbers" +//#endif -char marker_letter[3] = +char marker_letter[5] = { 'R', + ' ', + 'D', 'N', - 'D' + 'T' }; map_t markmap[2][MAX_MARKMAP_Y]; @@ -782,7 +792,7 @@ static void trace_get_value_string( buf2[0]=' '; uint32_t dfreq = 0; float rlevel = 0; - if (mtype == M_DELTA) { + if (mtype & M_DELTA) { if (ri > i) { dfreq = frequencies[ri] - frequencies[i]; buf2[0] = '-'; @@ -803,10 +813,12 @@ static void trace_get_value_string( // frequency_string(&buf2[1], sizeof(buf2) -1, dfreq); v = logmag(&coeff[i]); + if (mtype & M_NOISE) + v = v - 10*log10(GetActualRBW()*1000.0); if (v == -INFINITY) plot_printf(buf, len, "-INF"); else - plot_printf(buf, len, "%s %.1f", buf2, v - rlevel); + plot_printf(buf, len, "%s %.1f%s", buf2, v - rlevel,(mtype & M_NOISE?"/Hz":"")); } #ifdef __VNA__ static int @@ -1401,12 +1413,12 @@ draw_cell(int m, int n) if (x + MARKER_WIDTH >= 0 && x < CELLWIDTH && y + MARKER_HEIGHT >= 0 && y < CELLHEIGHT) - draw_marker(x, y, marker_color[markers[i].mtype], i); + draw_marker(x, y, marker_color(markers[i].mtype), i); #else if (x + MARKER_WIDTH >= 0 && x - MARKER_WIDTH < CELLWIDTH && y + MARKER_HEIGHT >= 0 && y - MARKER_HEIGHT < CELLHEIGHT) - draw_marker(x, y, marker_color[markers[i].mtype], i); + draw_marker(x, y, marker_color(markers[i].mtype), i); #endif // draw_marker(x, y, config.trace_color[t], i); // } @@ -1820,7 +1832,7 @@ static void cell_draw_marker_info(int x0, int y0) int ref_marker = 0; int j = 0; for (int i = 0; i < MARKER_COUNT; i++) { - if (markers[i].enabled && markers[i].mtype == M_REFERENCE) { + if (markers[i].enabled && markers[i].mtype & M_REFERENCE) { ref_marker = i; break; } @@ -1843,6 +1855,7 @@ static void cell_draw_marker_info(int x0, int y0) cell_drawstring_7x13(buf, xpos, ypos); break; } +#if 0 if (i >= 2 && in_selftest) { plot_printf(buf, sizeof buf, "DO NOT SWITCH OFF!!"); j = 2; @@ -1852,6 +1865,7 @@ static void cell_draw_marker_info(int x0, int y0) cell_drawstring_7x13(buf, xpos, ypos); break; } +#endif if (!markers[i].enabled) continue; int idx = markers[i].index; @@ -1870,25 +1884,31 @@ static void cell_draw_marker_info(int x0, int y0) int k = 0; if (i == active_marker) { // ili9341_set_foreground(DEFAULT_BG_COLOR); -// ili9341_set_background(marker_color[markers[i].mtype]); +// ili9341_set_background(marker_color(markers[i].mtype)); buf[k++] = '\033'; // Right arrow (?) } else { // ili9341_set_background(DEFAULT_BG_COLOR); -// ili9341_set_foreground(marker_color[markers[i].mtype]); +// ili9341_set_foreground(marker_color(markers[i].mtype)); buf[k++] = ' '; // buf[k++] = ' '; } buf[k++] = i+'1'; -// buf[k++] = marker_letter[markers[i].mtype]; + if (markers[i].mtype & M_REFERENCE) + buf[k++] = 'R'; + if (markers[i].mtype & M_DELTA) + buf[k++] = 'D'; + if (markers[i].mtype & M_NOISE) + buf[k++] = 'N'; 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); + xpos += strlen(buf)*7; // cell_drawstring_size(buf, xpos, ypos, 2); trace_get_value_string( t, buf, sizeof buf, idx, measured[trace[t].channel], frequencies, sweep_points, ridx, markers[i].mtype); - cell_drawstring_7x13(buf, xpos+3*7, ypos); + cell_drawstring_7x13(buf, xpos, ypos); // cell_drawstring_size(buf, xpos+3*7, ypos, 2); j++; } diff --git a/sa_core.c b/sa_core.c index da76f41..3820e86 100644 --- a/sa_core.c +++ b/sa_core.c @@ -736,7 +736,7 @@ int binary_search(int f) int avoid_spur(int f) { - int window = ((int)actual_rbw ) * 1000*2; +// int window = ((int)actual_rbw ) * 1000*2; // if (window < 50000) // window = 50000; if (! setting_mode == M_LOW || frequency_IF != spur_IF || actual_rbw > 300.0) @@ -826,7 +826,12 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking) setFreq (1, local_IF + lf); if (MODE_OUTPUT(setting_mode)) // No substepping in output mode return(0); - float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting_mode))+settingLevelOffset()+setting_attenuate; + float signal_path_loss; + if (setting_mode == M_LOW) + signal_path_loss = -9.5; // Loss in dB + else + signal_path_loss = 7; // Loss in dB (+ is gain) + float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting_mode))+settingLevelOffset()+ setting_attenuate - signal_path_loss; if (RSSI < subRSSI) RSSI = subRSSI; t++; @@ -965,11 +970,11 @@ static bool sweep(bool break_on_operation) draw_cal_status(); } if (!in_selftest && setting_mode == M_LOW && setting_auto_attenuation && max_index[0] > 0) { - if (actual_t[max_index[0]] - setting_attenuate < -30 && setting_attenuate >= 10) { + if (actual_t[max_index[0]] - setting_attenuate < -32 && setting_attenuate >= 10) { setting_attenuate -= setting_scale; redraw_request |= REDRAW_CAL_STATUS; dirty = true; // Must be above if(scandirty!!!!!) - } else if (actual_t[max_index[0]] - setting_attenuate > -20 && setting_attenuate <= 20) { + } else if (actual_t[max_index[0]] - setting_attenuate > -18 && setting_attenuate <= 20) { setting_attenuate += setting_scale; redraw_request |= REDRAW_CAL_STATUS; dirty = true; // Must be above if(scandirty!!!!!) @@ -980,11 +985,11 @@ static bool sweep(bool break_on_operation) SetReflevel(setting_reflevel + setting_scale); redraw_request |= REDRAW_CAL_STATUS; dirty = true; // Must be above if(scandirty!!!!!) - } else if (temp_min_level < setting_reflevel - 9 * setting_scale && actual_t[max_index[0]] < setting_reflevel - setting_scale * 3 / 2) { + } else if (temp_min_level < setting_reflevel - 9 * setting_scale - 2 && actual_t[max_index[0]] < setting_reflevel - setting_scale * 3 / 2) { SetReflevel(setting_reflevel - setting_scale); redraw_request |= REDRAW_CAL_STATUS; dirty = true; // Must be above if(scandirty!!!!!) - } else if (temp_min_level > setting_reflevel - 9 * setting_scale + setting_scale * 3 / 2) { + } else if (temp_min_level > setting_reflevel - 9 * setting_scale + setting_scale + 2) { SetReflevel(setting_reflevel + setting_scale); redraw_request |= REDRAW_CAL_STATUS; dirty = true; // Must be above if(scandirty!!!!!) @@ -996,7 +1001,7 @@ static bool sweep(bool break_on_operation) int m = 0; while (i < cur_max) { // For all maxima found while (m < MARKERS_MAX) { - if (markers[m].enabled == M_TRACKING_ENABLED) { // Available marker found + if (markers[m].enabled && markers[m].mtype & M_TRACKING) { // Available marker found markers[m].index = max_index[i]; markers[m].frequency = frequencies[markers[m].index]; m++; @@ -1007,7 +1012,7 @@ static bool sweep(bool break_on_operation) i++; } while (m < MARKERS_MAX) { - if (markers[m].enabled == M_TRACKING_ENABLED ) { // More available markers found + if (markers[m].enabled && markers[m].mtype & M_TRACKING) { // More available markers found markers[m].index = 0; // Enabled but no max markers[m].frequency = frequencies[markers[m].index]; } @@ -1024,8 +1029,8 @@ static bool sweep(bool break_on_operation) l = markers[1].index; r = markers[0].index; } - markers[2].enabled = search_maximum(2, l - (r-l), 10); - markers[3].enabled = search_maximum(3, r + (r-l), 10); + } else if (setting_measurement == M_PHASE_NOISE && markers[0].index > 10) { + markers[1].index = markers[0].index + (setting_mode == M_LOW ? 290/4 : -290/4); // Position phase noise marker at requested offset } peakIndex = max_index[0]; peakLevel = actual_t[peakIndex]; @@ -1238,21 +1243,21 @@ static const struct { float stop; } test_case [TEST_COUNT] = {// Condition Preparation Center Span Pass Width Stop - {TC_BELOW, TP_SILENT, 0.005, 0.01, -10,0, 0}, // 1 Zero Hz leakage - {TC_BELOW, TP_SILENT, 0.01, 0.01, -40, 0, 0}, // 2 Phase noise of zero Hz - {TC_SIGNAL, TP_10MHZ, 20, 7, -40, 30, -90 }, // 3 - {TC_SIGNAL, TP_10MHZ, 30, 7, -30, 30, -90 }, // 4 - {TC_BELOW, TP_SILENT, 200, 100, -75, 0, 0}, // 5 Wide band noise floor low mode - {TC_BELOW, TPH_SILENT, 600, 720, -75, 0, 0}, // 6 Wide band noise floor high mode - {TC_SIGNAL, TP_10MHZEXTRA, 10, 8, -20, 50, -70 }, // 7 BPF loss and stop band - {TC_FLAT, TP_10MHZEXTRA, 10, 4, -25, 20, -70}, // 8 BPF pass band flatness - {TC_BELOW, TP_30MHZ, 430, 60, -75, 0, -85}, // 9 LPF cutoff + {TC_BELOW, TP_SILENT, 0.005, 0.01, 0,0, 0}, // 1 Zero Hz leakage + {TC_BELOW, TP_SILENT, 0.01, 0.01, -30, 0, 0}, // 2 Phase noise of zero Hz + {TC_SIGNAL, TP_10MHZ, 20, 7, -37, 30, -80 }, // 3 + {TC_SIGNAL, TP_10MHZ, 30, 7, -32, 30, -80 }, // 4 + {TC_BELOW, TP_SILENT, 200, 100, -70, 0, 0}, // 5 Wide band noise floor low mode + {TC_BELOW, TPH_SILENT, 600, 720, -65, 0, 0}, // 6 Wide band noise floor high mode + {TC_SIGNAL, TP_10MHZEXTRA, 10, 8, -13, 55, -60 }, // 7 BPF loss and stop band + {TC_FLAT, TP_10MHZEXTRA, 10, 4, -18, 20, -60}, // 8 BPF pass band flatness + {TC_BELOW, TP_30MHZ, 430, 60, -65, 0, -75}, // 9 LPF cutoff {TC_END, 0, 0, 0, 0, 0, 0}, - {TC_MEASURE, TP_30MHZ, 30, 7, -30, 30, -80 }, // 11 Measure power level and noise - {TC_MEASURE, TP_30MHZ, 270, 4, -50, 30, -85 }, // 12 Measure powerlevel and noise - {TC_MEASURE, TPH_30MHZ, 270, 4, -35, 30, -50 }, // 13 Calibrate power high mode + {TC_MEASURE, TP_30MHZ, 30, 7, -22.5, 30, -70 }, // 11 Measure power level and noise + {TC_MEASURE, TP_30MHZ, 270, 4, -45, 30, -75 }, // 12 Measure powerlevel and noise + {TC_MEASURE, TPH_30MHZ, 270, 4, -45, 30, -75 }, // 13 Calibrate power high mode {TC_END, 0, 0, 0, 0, 0, 0}, - {TC_MEASURE, TP_30MHZ, 30, 1, -30, 30, -80 }, // 15 Measure RBW step time + {TC_MEASURE, TP_30MHZ, 30, 1, -20, 30, -70 }, // 15 Measure RBW step time {TC_END, 0, 0, 0, 0, 0, 0}, }; diff --git a/ui.c b/ui.c index 83e9ce9..ba27e04 100644 --- a/ui.c +++ b/ui.c @@ -29,6 +29,7 @@ uistat_t uistat = { current_trace: 0, lever_mode: LM_MARKER, marker_delta: FALSE, + marker_noise: FALSE, marker_tracking : FALSE, text : "", }; @@ -441,6 +442,7 @@ enum { #define MT_FORM 0x80 // Or with menu type to get large button with current value #define MT_BACK 0x40 #define MT_LEAVE 0x20 +#define MT_ICON 0x10 #define MT_MASK(x) (0xF & (x)) typedef void (*menuaction_cb_t)(int item, uint8_t data); @@ -791,7 +793,7 @@ menu_marker_search_cb(int item, uint8_t data) i = marker_search_right(markers[active_marker].index); break; case 4: /* tracking */ - uistat.marker_tracking = !uistat.marker_tracking; + markers[active_marker].mtype ^= M_TRACKING; break; } if (i != -1) @@ -831,7 +833,7 @@ static void menu_marker_sel_cb(int item, uint8_t data) { (void)data; - int t; +// int t; if (item >= 0 && item < MARKERS_MAX) { if (markers[item].enabled) { if (item == active_marker) { @@ -842,19 +844,30 @@ menu_marker_sel_cb(int item, uint8_t data) active_marker_select(item); } } else { - markers[item].enabled = M_ENABLED; // default tracking enabled + markers[item].enabled = M_ENABLED; active_marker_select(item); + markers[item].mtype = M_NORMAL; + markers[item].mtype |= (uistat.marker_delta ? M_DELTA : 0); + markers[item].mtype |= (uistat.marker_noise ? M_NOISE : 0); + markers[item].mtype |= (uistat.marker_tracking ? M_TRACKING : 0); } - if (markers[item].enabled) - menu_push_submenu(menu_marker_type); - + // if (markers[item].enabled) + // menu_push_submenu(menu_marker_type); +#if 0 } else if (item == 4) { /* all off */ for (t = 0; t < MARKERS_MAX; t++) markers[t].enabled = M_DISABLED; previous_marker = -1; active_marker = -1; - } else if (item == 5) { /* marker delta */ +#endif + } else if (item == 4) { /* marker delta */ uistat.marker_delta = !uistat.marker_delta; + } else if (item == 5) { /* marker noise */ + uistat.marker_noise = !uistat.marker_noise; + // if (uistat.marker_noise) uistat.marker_delta = true; //Default behavior + } else if (item == 6) { /* marker tracking */ + uistat.marker_tracking = !uistat.marker_tracking; + // if (uistat.marker_tracking) uistat.marker_noise = false; //Default behavior } redraw_marker(active_marker); draw_menu(); @@ -1554,32 +1567,33 @@ draw_menu_buttons(const menuitem_t *menu) if (menu[i].type & MT_FORM) { ili9341_fill(active_button_start+2, y+2, active_button_width-4, FONT_GET_HEIGHT*2+8, bg); ili9341_drawstring_size(text, active_button_start+6, y+6, 2); -// blit16BitWidthBitmap(240,y+6,16,16,&icons[3*16]); -// blit16BitWidthBitmap(256,y+6,16,16,&icons[0]); - + if (menu[i].type & MT_ICON) { + blit16BitWidthBitmap(240,y+6,16,16,&left_icons[((menu[i].data >>4)&0xf)*16]); + blit16BitWidthBitmap(256,y+6,16,16,&right_icons[((menu[i].data >>0)&0xf)*16]); + } } else { - if (menu_is_multiline(menu[i].label, &l1, &l2)) { + if (menu_is_multiline(menu[i].label, &l1, &l2)) { #define BIG_BUTTON_FONT 1 #ifdef BIG_BUTTON_FONT #undef FONT_HEIGHT #define FONT_HEIGHT 13 - ili9341_fill(active_button_start+1, y+1, active_button_width-2, 13+13 -2, bg); - ili9341_drawstring_7x13(l1, active_button_start+2, y+1); - ili9341_drawstring_7x13(l2, active_button_start+2, y+1+13-1); + ili9341_fill(active_button_start+1, y+1, active_button_width-2, 13+13 -2, bg); + ili9341_drawstring_7x13(l1, active_button_start+2, y+1); + ili9341_drawstring_7x13(l2, active_button_start+2, y+1+13-1); #else - ili9341_fill(active_button_start+3, y+5, active_button_width-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg); - ili9341_drawstring(l1, active_button_start+5, y+7); - ili9341_drawstring(l2, active_button_start+5, y+7+FONT_GET_HEIGHT+1); + ili9341_fill(active_button_start+3, y+5, active_button_width-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg); + ili9341_drawstring(l1, active_button_start+5, y+7); + ili9341_drawstring(l2, active_button_start+5, y+7+FONT_GET_HEIGHT+1); #endif - } else { + } else { #ifdef BIG_BUTTON_FONT - ili9341_fill(active_button_start+1, y+1, active_button_width-2, 13+13 -2, bg); - ili9341_drawstring_7x13(menu[i].label, active_button_start+2, y+6); + ili9341_fill(active_button_start+1, y+1, active_button_width-2, 13+13 -2, bg); + ili9341_drawstring_7x13(menu[i].label, active_button_start+2, y+6); #else - ili9341_fill(active_button_start+3, y+8, active_button_width-6, 2+FONT_GET_HEIGHT+2, bg); - ili9341_drawstring(menu[i].label, active_button_start+5, y+10); + ili9341_fill(active_button_start+3, y+8, active_button_width-6, 2+FONT_GET_HEIGHT+2, bg); + ili9341_drawstring(menu[i].label, active_button_start+5, y+10); #endif - } + } } } } @@ -1799,7 +1813,7 @@ ui_mode_keypad(int _keypad_mode) ui_mode = UI_KEYPAD; area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH; area_height = HEIGHT - 32; - if (!menu_is_form(menu_stack[menu_current_level])) + if (!current_menu_is_form()) draw_menu(); draw_keypad(); draw_numeric_area_frame(); @@ -1821,18 +1835,25 @@ ui_mode_normal(void) static void lever_move_marker(int status) { + int step = 1; + int count = 0; do { if (active_marker >= 0 && markers[active_marker].enabled) { if ((status & EVT_DOWN) && markers[active_marker].index > 0) { - markers[active_marker].index--; + markers[active_marker].index -= step; markers[active_marker].frequency = frequencies[markers[active_marker].index]; redraw_marker(active_marker); } if ((status & EVT_UP) && markers[active_marker].index < sweep_points-1) { - markers[active_marker].index++; + markers[active_marker].index += step; markers[active_marker].frequency = frequencies[markers[active_marker].index]; redraw_marker(active_marker); } + count++; + if (count > 10) { + step *= 2; + count = 0; + } } status = btn_wait_release(); } while (status != 0); @@ -2227,7 +2248,7 @@ ui_process_keypad(void) } redraw_frame(); - if (menu_is_form(menu_stack[menu_current_level])) { + if (current_menu_is_form()) { ui_mode_menu(); //Reactivate menu after keypad selection = -1; ensure_selection(); @@ -2342,6 +2363,41 @@ touch_lever_mode_select(void) return FALSE; } +static int +touch_marker_select(void) +{ + int selected_marker = 0; + int touch_x, touch_y; + touch_position(&touch_x, &touch_y); + if (current_menu_is_form() || touch_x > 320-MENU_BUTTON_WIDTH || touch_x < 25 || touch_y > 30) + return FALSE; + if (touch_y > 15) + selected_marker = 2; + selected_marker += (touch_x >150 ? 1 : 0); + for (int i = 0; i < MARKERS_MAX; i++) { + if (markers[i].enabled) { + if (selected_marker == 0) { + active_marker = i; + break; + } + selected_marker --; + } + } + if (touch_y < 25) { +#ifdef __VNA__ + if (touch_x < FREQUENCIES_XPOS2 && get_electrical_delay() != 0.0) { + select_lever_mode(LM_EDELAY); + } else { +#endif + select_lever_mode(LM_MARKER); +#ifdef __VNA__ + } +#endif + return TRUE; + } + return FALSE; +} + static void ui_process_touch(void) { @@ -2355,11 +2411,14 @@ void ui_process_touch(void) // Try drag marker if (touch_pickup_marker()) break; + if (touch_marker_select()) + break; // Try select lever mode (top and bottom screen) if (touch_lever_mode_select()) { touch_wait_release(); break; } + // switch menu mode after release touch_wait_release(); selection = -1; // hide keyboard mode selection diff --git a/ui_sa.c b/ui_sa.c index 408eb41..e8aefa4 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -65,54 +65,33 @@ extern int setting_step_delay; void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *bitmap); -const uint16_t icons [] = +const uint16_t left_icons [] = { - - /* Character 0 (0x00): - width 16 - +-----------------+ - | | - | *************** | - | * * | - |** * | - | * * * | - | * * * | - | * * * * | - | * * * * | - | * * * * * | - | * * * * * * | - | * * * * * * * | - | * * * * * * * | - |** *********** * | - | * * | - | *************** | - | | - +-----------------+ */ +#define I_EMPTY 0*16 + 0x0000, + 0x0000, + 0x0000, + 0x0001, + 0x0001, + 0x0001, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0001, + 0x0001, + 0x0001, + 0x0000, 0x0000, - 0x7fff, - 0x4001, - 0xc001, - 0x4001, - 0x4001, - 0x4801, - 0x4801, - 0x4a89, - 0x4aa9, - 0x4aa9, - 0x5ffd, - 0xc001, - 0x4001, - 0x7fff, 0x0000, - /* Character 1 (0x01: - width 16 - +-----------------+ +#define I_HIGH_INPUT 1*16 + /* +-----------------+ | | | ** | - | **** | + | *** | | ************ | - | **** | + | *** | | ** | | | | | @@ -126,25 +105,24 @@ const uint16_t icons [] = | | +-----------------+ */ 0x0000, + 0x0000, 0x0060, - 0x0038, - 0x0ffe, - 0x0038, + 0x0039, + 0x0fff, + 0x0039, 0x0060, 0x0000, 0x0000, 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, + 0x0001, + 0x0001, + 0x0001, 0x0000, 0x0000, 0x0000, - /* Character 2 (0x02): - width 16 - +-----------------+ +#define I_LOW_INPUT 2*16 + /* +-----------------+ | | | | | | @@ -165,38 +143,194 @@ const uint16_t icons [] = 0x0000, 0x0000, 0x0000, - 0x0000, - 0x0000, - 0x0000, + 0x0001, + 0x0001, + 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0060, - 0x0038, - 0x0ffe, - 0x0038, + 0x0039, + 0x0fff, + 0x0039, 0x0060, 0x0000, - /* High arrow left 0x03 */ +#define I_LOW_OUTPUT 3*16 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, + 0b0000000000000001, + 0b0000000000000001, + 0b0000000000000001, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, + 0b0000000110000000, + 0b0000011110000001, + 0b0000111111111111, + 0b0000011110000001, + 0b0000000110000000, 0b0000000000000000, 0b0000000000000000, + +#define I_HIGH_OUTPUT 4*16 + 0b0000000000000000, 0b0000000000000000, 0b0000000110000000, - 0b0000011110000000, - 0b0000111111111110, - 0b0000011110000000, + 0b0000011110000001, + 0b0000111111111111, + 0b0000011110000001, 0b0000000110000000, 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000001, + 0b0000000000000001, + 0b0000000000000001, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + +#define I_CONNECT 5*16 + + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000110000, + 0b0000000000111101, + 0b0000001111111111, + 0b0000010000111101, + 0b0000100000110000, + 0b0001000000000000, + 0b0001000000000000, + 0b0000100000110000, + 0b0000010000111101, + 0b0000001111111111, + 0b0000000000111101, + 0b0000000000110000, + 0b0000000000000000, + 0b0000000000000000, + +}; + +const uint16_t right_icons [] = +{ +#define I_SA 0 + /* Character 0 (0x00): + width 16 + +-----------------+ + | | + | *************** | + | * * | + |** * | + | * * * | + | * * * | + | * * * * | + | * * * * | + | * * * * * | + | * * * * * * | + | * * * * * * * | + | * * * * * * * | + |** *********** * | + | * * | + | *************** | + | | + +-----------------+ */ + 0x0000, + 0x7fff, + 0x4001, + 0xc001, + 0xc001, + 0xc001, + 0x4801, + 0x4801, + 0x4a89, + 0x4aa9, + 0xcaa9, + 0xdffd, + 0xc001, + 0x4001, + 0x7fff, + 0x0000, + +#define I_GEN 1 + /* Character 0 (0x00): + width 16 + +-----------------+ + | | + | *************** | + | * * | + |** * | + | * ***** ** * | + | * * * * * | + | * * * * * | + | * * * * * | + | * * * * * | + | * * * * * | + | * * * * * | + | * ** ***** * | + |** * | + | * * | + | *************** | + | | + +-----------------+ */ + 0x0000, + 0x7fff, + 0x4001, + 0xc001, + 0xcf8d, + 0xc889, + 0x4889, + 0x4889, + 0x4889, + 0x4889, + 0xc889, + 0xd8f9, + 0xc001, + 0x4001, + 0x7fff, + 0x0000, + +#define I_CONFIG 2 + + 0b0000000000000000, + 0b0111111111111111, + 0b0100000000000001, + 0b1100000011000001, + 0b1100001110001001, + 0b1100011100011101, + 0b0100001110111001, + 0b0100001111111001, + 0b0100011111110001, + 0b0100111110000001, + 0b1101111100000001, + 0b1101111000000001, + 0b1100100000000001, + 0b0100000000000001, + 0b0111111111111111, + 0b0000000000000000, + +#define I_SINUS 3 + + 0b0000000000000000, + 0b0111111111111111, // 1 + 0b0100000000000001, // 2 + 0b1100000000000001, // 3 + 0b1100000000110001, // 4 + 0b1100000001001001, // 5 + 0b0100000010000101, // 6 + 0b0101000010000101, // 7 + 0b0101000010000101, // 8 + 0b0101000010000001, // 9 + 0b1100100100000001, //10 + 0b1100011000000001, //11 + 0b1100000000000001, //12 + 0b0100000000000001, //13 + 0b0111111111111111, //14 + 0b0000000000000000, }; @@ -369,8 +503,8 @@ void menu_autosettings_cb(int item, uint8_t data) for (int i = 1; i= 0 && markers[active_marker].enabled) { - if (item == 3 && markers[active_marker].enabled == M_TRACKING_ENABLED) + } else if (menu == menu_marker_type && active_marker >= 0 && markers[active_marker].enabled == M_ENABLED) { + if (data & markers[active_marker].mtype) + mark = true; + else if (data==markers[active_marker].mtype) // This catches the M_NORMAL case mark = true; - else if (item == markers[active_marker].mtype) + } else if (menu == menu_marker_search) { + if (item == 4 && markers[active_marker].mtype & M_TRACKING) mark = true; } else if (menu == menu_marker_sel) { if (item < MARKERS_MAX && markers[item].enabled) mark = true; + else if (item == 4 && uistat.marker_delta) + mark = true; + else if (item == 5 && uistat.marker_noise) + mark = true; + else if (item == 6 && uistat.marker_tracking) + mark = true; } else if (menu == menu_reflevel) { if ((item == 0 && setting_auto_reflevel) || (item == 1 && !setting_auto_reflevel)) mark = true;