From ac6dd842503d331195dc07509c8f89f97e85400c Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 18 Dec 2020 10:47:37 +0100 Subject: [PATCH] Added external amp in output mode --- nanovna.h | 2 +- sa_core.c | 4 ++-- ui.c | 4 ++-- ui_sa.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/nanovna.h b/nanovna.h index ac84335..df82b24 100644 --- a/nanovna.h +++ b/nanovna.h @@ -992,7 +992,7 @@ typedef struct uistat { uint8_t marker_noise; uint8_t marker_tracking; uint8_t auto_center_marker; - char text[20]; + char text[28]; } uistat_t; typedef struct ui_button { diff --git a/sa_core.c b/sa_core.c index 50854d3..d8b6a75 100644 --- a/sa_core.c +++ b/sa_core.c @@ -303,8 +303,8 @@ void set_sweep_time_us(uint32_t t) // Set the sweep time as the user wa if (t > MAXIMUM_SWEEP_TIME) t = MAXIMUM_SWEEP_TIME; setting.sweep_time_us = t; - if (MODE_OUTPUT(setting.mode)) - setting.actual_sweep_time_us = t; // To ensure time displayed is correct before first sweep is completed +// if (MODE_OUTPUT(setting.mode)) +// setting.actual_sweep_time_us = t; // To ensure time displayed is correct before first sweep is completed #if 0 uint32_t ta = calc_min_sweep_time_us(); // Can not be faster than minimum sweep time if (ta < t) diff --git a/ui.c b/ui.c index 32a591c..29a4dec 100644 --- a/ui.c +++ b/ui.c @@ -491,8 +491,8 @@ enum { MT_LOW = 0x40, // Only applicable to low mode MT_FORM = 0x80, // Large button menu }; -#define MT_BACK 0x40 -#define MT_LEAVE 0x20 +//#define MT_BACK 0x40 +//#define MT_LEAVE 0x20 #define MT_MASK(x) (0xF & (x)) // Call back functions for MT_CALLBACK type diff --git a/ui_sa.c b/ui_sa.c index e4d9167..857bb4a 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -455,6 +455,7 @@ static const menuitem_t menu_top[]; static const menuitem_t menu_reffer[]; static const menuitem_t menu_modulation[]; static const menuitem_t menu_drive_wide[]; +static const menuitem_t menu_sweep[]; #ifdef __ULTRA__ static const menuitem_t menu_tophigh[]; static const menuitem_t menu_topultra[]; @@ -462,6 +463,25 @@ static const menuitem_t menu_topultra[]; #define AUTO_ICON(S) (S>=2?BUTTON_ICON_CHECK_AUTO:S) // Depends on order of ICONs!!!!! +static UI_FUNCTION_ADV_CALLBACK(menu_sweep_acb) +{ + (void)data; + if (b){ + if (setting.level_sweep != 0 || get_sweep_frequency(ST_SPAN) != 0) { + plot_printf(uistat.text, sizeof uistat.text, "SW:%3.2fMHz %+ddB %.3Fs", + get_sweep_frequency(ST_SPAN) / 1000000.0, + (int)setting.level_sweep, + setting.sweep_time_us/(float)ONE_SECOND_TIME); + b->param_1.text = uistat.text; + } + else + b->param_1.text = "SWEEP: OFF"; + return; + } + menu_push_submenu(menu_sweep); +} + + static UI_FUNCTION_ADV_CALLBACK(menu_mode_acb) { (void)data; @@ -701,7 +721,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_drive_acb) { (void)item; if(b){ - b->param_1.i = menu_drive_value[data]; + b->param_1.i = menu_drive_value[data] + (setting.mode==M_GENHIGH ? setting.offset : 0); b->icon = data == setting.drive ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; return; } @@ -716,7 +736,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sdrive_acb){ (void)item; (void)data; if(b){ - b->param_1.i = menu_drive_value[setting.drive]; + b->param_1.i = menu_drive_value[setting.drive] + (setting.mode==M_GENHIGH ? setting.offset : 0); return; } menu_push_submenu(menu_drive_wide); @@ -1448,14 +1468,25 @@ static const menuitem_t menu_modulation[] = { { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; +static const menuitem_t menu_sweep[] = { + { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, + { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVEL CHANGE: %s", "-70..70"}, + { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"}, + { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel +}; + + static const menuitem_t menu_lowoutputmode[] = { { MT_FORM | MT_ADV_CALLBACK, 0, "LOW OUTPUT %s", menu_outputmode_acb}, { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", "10kHz..350MHz"}, { MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", "-76..-6"}, { MT_FORM | MT_ADV_CALLBACK, 0, "MOD: %s", menu_smodulation_acb}, - { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, - { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVEL CHANGE: %s", "-70..70"}, - { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"}, + { MT_FORM | MT_ADV_CALLBACK, 0, "%s", menu_sweep_acb}, +// { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, +// { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVEL CHANGE: %s", "-70..70"}, +// { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"}, + { MT_FORM | MT_KEYPAD, KM_OFFSET, "AMP: %s", "-100..+100"}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; @@ -1467,6 +1498,7 @@ static const menuitem_t menu_highoutputmode[] = { { MT_FORM | MT_ADV_CALLBACK, 0, "MOD: %s", menu_smodulation_acb}, { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME,"SWEEP TIME: %s", "0..600 seconds"}, + { MT_FORM | MT_KEYPAD, KM_OFFSET, "AMP: %s", "-100..+100"}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; @@ -2042,6 +2074,8 @@ static void fetch_numeric_target(void) end_level = -76; if (end_level > -6) end_level = -6; + uistat.value += setting.offset; + end_level += setting.offset; if (setting.level_sweep != 0) plot_printf(uistat.text, sizeof uistat.text, "%d to %ddBm", ((int32_t)uistat.value), end_level); else @@ -2164,7 +2198,7 @@ set_numeric_value(void) set_drive(uistat.value); break; case KM_LOWOUTLEVEL: - set_level(uistat.value); + set_level(uistat.value - setting.offset); break; case KM_DECAY: set_decay(uistat.value);