Rename offset to external_gain

Removed_REF_marker
erikkaashoek 5 years ago
parent 3d93962d5a
commit 5603bf384e

@ -2462,7 +2462,7 @@ static const VNAShellCommand commands[] =
{ "ultra_start", cmd_ultra_start, CMD_WAIT_MUTEX }, { "ultra_start", cmd_ultra_start, CMD_WAIT_MUTEX },
#endif #endif
{ "load", cmd_load, 0 }, { "load", cmd_load, 0 },
{ "offset", cmd_offset, 0}, { "ext_gain", cmd_ext_gain, 0},
{ "output", cmd_output, 0 }, { "output", cmd_output, 0 },
{ "deviceid", cmd_deviceid, 0 }, { "deviceid", cmd_deviceid, 0 },
{ "selftest", cmd_selftest, 0 }, { "selftest", cmd_selftest, 0 },

@ -69,9 +69,9 @@
#define __QUASI_PEAK__ // Add quasi peak average option #define __QUASI_PEAK__ // Add quasi peak average option
#define __REMOTE_DESKTOP__ // Add remote desktop option #define __REMOTE_DESKTOP__ // Add remote desktop option
#define __LISTEN__ #define __LISTEN__
#ifdef TINYSA4
#define __CHANNEL_POWER__ #define __CHANNEL_POWER__
#define __LIMITS__ #define __LIMITS__
#ifdef TINYSA4
#define __HARMONIC__ #define __HARMONIC__
#else #else
#endif #endif
@ -917,7 +917,7 @@ typedef struct setting
uint8_t measurement; // enum uint8_t measurement; // enum
uint8_t spur_removal; // enum uint8_t spur_removal; // enum
int8_t tracking; // -1...1 !!! need convert to bool int8_t tracking; // -1...1 Can NOT convert to bool!!!!!!
uint8_t atten_step; // 0...1 !!! need convert to bool uint8_t atten_step; // 0...1 !!! need convert to bool
int8_t _active_marker; // -1...MARKER_MAX int8_t _active_marker; // -1...MARKER_MAX
uint8_t unit_scale_index; // table index uint8_t unit_scale_index; // table index
@ -956,7 +956,7 @@ typedef struct setting
float reflevel; float reflevel;
float scale; float scale;
float offset; float external_gain;
float trigger_level; float trigger_level;
float level; float level;
float level_sweep; float level_sweep;
@ -1287,7 +1287,7 @@ void toggle_tracking(void);
void toggle_hambands(void); void toggle_hambands(void);
void reset_calibration(void); void reset_calibration(void);
void set_reflevel(float); void set_reflevel(float);
void set_offset(float); void set_external_gain(float);
void set_unit(int); void set_unit(int);
void set_switches(int); void set_switches(int);
void set_gridlines(int); void set_gridlines(int);

@ -1300,16 +1300,16 @@ static void cell_draw_marker_info(int x0, int y0)
} }
#ifdef __CHANNEL_POWER__ #ifdef __CHANNEL_POWER__
if (setting.measurement==M_CP) { if (setting.measurement==M_CP) {
char *p_label[3] = { "Left", "Mid", "Right" };
for (int c=0; c<3;c++) { for (int c=0; c<3;c++) {
if (c == 1) plot_printf(buf, sizeof buf, "%4.1fdB", channel_power[c]);
plot_printf(buf, sizeof buf, "%s: %4.1fdB %4.1f%%", p_label[c], channel_power[1], 100.0 * (channel_power_watt[1] - channel_power_watt[0] - channel_power_watt[2]) /channel_power_watt[1] );
else
plot_printf(buf, sizeof buf, "%s: %4.1fdB", p_label[c], channel_power[c]);
int xpos = 10 + (c)*(WIDTH/3) + CELLOFFSETX - x0; int xpos = 10 + (c)*(WIDTH/3) + CELLOFFSETX - x0;
int ypos = 1 - y0; int ypos = 1 - y0;
ili9341_set_foreground(LCD_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
cell_drawstring_7x13(buf, xpos, ypos); cell_drawstring_7x13(buf, xpos, ypos);
plot_printf(buf, sizeof buf, "%4.1f%%", 100.0 * channel_power_watt[c] /(channel_power_watt[0] + channel_power_watt[1] + channel_power_watt[2]) );
ypos = 14 - y0;
ili9341_set_foreground(LCD_FG_COLOR);
cell_drawstring_7x13(buf, xpos, ypos);
} }
return; return;
} }
@ -1449,8 +1449,8 @@ static void cell_draw_marker_info(int x0, int y0)
ili9341_set_background(LCD_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
uint16_t color; uint16_t color;
if ((!setting.subtract_stored) && // Disabled when normalized if ((!setting.subtract_stored) && // Disabled when normalized
((setting.mode == M_LOW && temppeakLevel - get_attenuation() + setting.offset > -10) || ((setting.mode == M_LOW && temppeakLevel - get_attenuation() > -10) || // Ignore external_gain in overload detection
(setting.mode == M_HIGH && temppeakLevel - get_attenuation()+ setting.offset > -29) )) (setting.mode == M_HIGH && temppeakLevel - get_attenuation() > -29) ))
color = LCD_BRIGHT_COLOR_RED; color = LCD_BRIGHT_COLOR_RED;
else else
color = marker_color(markers[i].mtype); color = marker_color(markers[i].mtype);

@ -267,14 +267,14 @@ VNA_SHELL_FUNCTION(cmd_sweeptime)
VNA_SHELL_FUNCTION(cmd_offset) VNA_SHELL_FUNCTION(cmd_ext_gain)
{ {
if (argc != 1) { if (argc != 1) {
shell_printf("usage: offset -100.0..+100.0\r\n"); shell_printf("usage: ext_gain -100.0..+100.0\r\n");
return; return;
} }
float o = my_atof(argv[0]); float o = my_atof(argv[0]);
set_offset(o); set_external_gain(o);
} }

@ -225,8 +225,8 @@ void reset_settings(int m)
setting.frequency_IF = DEFAULT_IF; setting.frequency_IF = DEFAULT_IF;
#endif #endif
setting.auto_IF = true; setting.auto_IF = true;
set_offset(0.0); // This also updates the help text!!!!! set_external_gain(0.0); // This also updates the help text!!!!!
//setting.offset = 0.0; //setting.external_gain = 0.0;
setting.trigger = T_AUTO; setting.trigger = T_AUTO;
setting.trigger_direction = T_UP; setting.trigger_direction = T_UP;
setting.trigger_mode = T_MID; setting.trigger_mode = T_MID;
@ -1212,13 +1212,13 @@ void set_scale(float t) {
extern char low_level_help_text[12]; extern char low_level_help_text[12];
void set_offset(float offset) void set_external_gain(float external_gain)
{ {
setting.offset = offset; setting.external_gain = external_gain;
int min,max; int min,max;
min = level_min; min = level_min;
max = min + level_range; max = min + level_range;
plot_printf(low_level_help_text, sizeof low_level_help_text, "%+d..%+d", min + (int)offset, max + (int)offset); plot_printf(low_level_help_text, sizeof low_level_help_text, "%+d..%+d", min + (int)external_gain, max + (int)external_gain);
redraw_request|=REDRAW_AREA; redraw_request|=REDRAW_AREA;
dirty = true; // No HW update required, only status panel refresh but need to ensure the cached value is updated in the calculation of the RSSI dirty = true; // No HW update required, only status panel refresh but need to ensure the cached value is updated in the calculation of the RSSI
} }
@ -2242,7 +2242,7 @@ static void calculate_static_correction(void) // Calculate the
- (S_STATE(setting.lna)? 0 : 0) - (S_STATE(setting.lna)? 0 : 0)
+ (setting.extra_lna ? -23.0 : 0) // TODO <------------------------- set correct value + (setting.extra_lna ? -23.0 : 0) // TODO <------------------------- set correct value
#endif #endif
- setting.offset); - setting.external_gain);
} }
int hsical = -1; int hsical = -1;
@ -3454,7 +3454,7 @@ sweep_again: // stay in sweep loop when output mo
setting.atten_step = false; // No step attenuate in low mode auto attenuate setting.atten_step = false; // No step attenuate in low mode auto attenuate
int changed = false; int changed = false;
int delta = 0; int delta = 0;
int actual_max_level = (max_index[0] == 0 ? -100 :(int) (actual_t[max_index[0]] - get_attenuation()) ); // If no max found reduce attenuation int actual_max_level = (max_index[0] == 0 ? -100 :(int) (actual_t[max_index[0]] - get_attenuation()) ) - setting.external_gain; // If no max found reduce attenuation
if (actual_max_level < AUTO_TARGET_LEVEL && setting.attenuate_x2 > 0) { if (actual_max_level < AUTO_TARGET_LEVEL && setting.attenuate_x2 > 0) {
delta = - (AUTO_TARGET_LEVEL - actual_max_level); delta = - (AUTO_TARGET_LEVEL - actual_max_level);
} else if (actual_max_level > AUTO_TARGET_LEVEL && setting.attenuate_x2 < 60) { } else if (actual_max_level > AUTO_TARGET_LEVEL && setting.attenuate_x2 < 60) {
@ -3497,7 +3497,7 @@ sweep_again: // stay in sweep loop when output mo
#ifdef __SI4432__ #ifdef __SI4432__
if (!in_selftest && MODE_INPUT(setting.mode)) { if (!in_selftest && MODE_INPUT(setting.mode)) {
if (S_IS_AUTO(setting.agc)) { if (S_IS_AUTO(setting.agc)) {
int actual_max_level = actual_t[max_index[0]] - get_attenuation(); // No need to use float int actual_max_level = actual_t[max_index[0]] - get_attenuation() - setting.external_gain; // No need to use float
if (UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode if (UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode
if (actual_max_level > - 45) if (actual_max_level > - 45)
auto_set_AGC_LNA(false, 0); // Strong signal, no AGC and no LNA auto_set_AGC_LNA(false, 0); // Strong signal, no AGC and no LNA
@ -3693,7 +3693,7 @@ sweep_again: // stay in sweep loop when output mo
} else if (setting.measurement == M_AM) { // ----------------AM measurement } else if (setting.measurement == M_AM) { // ----------------AM measurement
if (S_IS_AUTO(setting.agc )) { if (S_IS_AUTO(setting.agc )) {
#ifdef __SI4432__ #ifdef __SI4432__
int actual_level = actual_t[max_index[0]] - get_attenuation(); // no need for float int actual_level = actual_t[max_index[0]] - get_attenuation() - setting.external_gain; // no need for float
if (actual_level > -20 ) { if (actual_level > -20 ) {
setting.agc = S_AUTO_OFF; setting.agc = S_AUTO_OFF;
setting.lna = S_AUTO_OFF; setting.lna = S_AUTO_OFF;

@ -2072,7 +2072,7 @@ menu_select_touch(int i, int pos)
check_frequency_slider(slider_freq); check_frequency_slider(slider_freq);
} }
} else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_LOWOUTLEVEL) { } else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_LOWOUTLEVEL) {
uistat.value = setting.offset + ((touch_x - OFFSETX+4) * level_range ) / (MENU_FORM_WIDTH-8) + level_min ; uistat.value = setting.external_gain + ((touch_x - OFFSETX+4) * level_range ) / (MENU_FORM_WIDTH-8) + level_min ;
apply_step: apply_step:
set_keypad_value(keypad); set_keypad_value(keypad);
apply: apply:
@ -2112,7 +2112,7 @@ menu_select_touch(int i, int pos)
step = +10; step = +10;
break; break;
} }
uistat.value = setting.offset + get_level() + step; uistat.value = setting.external_gain + get_level() + step;
do_exit = true; do_exit = true;
goto apply_step; goto apply_step;
} else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_CENTER) { } else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_CENTER) {

@ -411,7 +411,7 @@ enum {
KM_10MHZ, KM_10MHZ,
#endif #endif
// #15 // #15
KM_REPEAT, KM_OFFSET, KM_TRIGGER, KM_LEVELSWEEP, KM_SWEEP_TIME, KM_REPEAT, KM_EXT_GAIN, KM_TRIGGER, KM_LEVELSWEEP, KM_SWEEP_TIME,
// #20 // #20
KM_OFFSET_DELAY, KM_FAST_SPEEDUP, KM_GRIDLINES, KM_MARKER, KM_MODULATION, KM_OFFSET_DELAY, KM_FAST_SPEEDUP, KM_GRIDLINES, KM_MARKER, KM_MODULATION,
// #25 // #25
@ -453,7 +453,7 @@ static const struct {
{keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE {keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE
{keypads_freq , "FREQ"}, // KM_30MHz | KM_10MHz {keypads_freq , "FREQ"}, // KM_30MHz | KM_10MHz
{keypads_positive , "SAMPLE\nREPEAT"}, // KM_REPEA #15 {keypads_positive , "SAMPLE\nREPEAT"}, // KM_REPEA #15
{keypads_plusmin , "OFFSET"}, // KM_OFFSET {keypads_plusmin , "EXT\nGAIN"}, // KM_EXT_GAIN
{keypads_plusmin_unit, "TRIGGER\nLEVEL"}, // KM_TRIGGER {keypads_plusmin_unit, "TRIGGER\nLEVEL"}, // KM_TRIGGER
{keypads_plusmin , "LEVEL\nSWEEP"}, // KM_LEVELSWEEP {keypads_plusmin , "LEVEL\nSWEEP"}, // KM_LEVELSWEEP
{keypads_time , "SWEEP\nSECONDS"}, // KM_SWEEP_TIME {keypads_time , "SWEEP\nSECONDS"}, // KM_SWEEP_TIME
@ -818,7 +818,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sdrive_acb){
#ifdef TINYSA4 #ifdef TINYSA4
b->param_1.i = setting.lo_drive; b->param_1.i = setting.lo_drive;
#else #else
b->param_1.i = drive_dBm[setting.lo_drive] + (setting.mode==M_GENHIGH ? setting.offset : 0); b->param_1.i = drive_dBm[setting.lo_drive] + (setting.mode==M_GENHIGH ? setting.external_gain : 0);
#endif #endif
return; return;
} }
@ -1677,7 +1677,7 @@ static const menuitem_t menu_lowoutputmode[] = {
// { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, // { 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 | 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_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"},
{ MT_FORM | MT_KEYPAD, KM_OFFSET, "EXTERNAL AMP: %s", "-100..+100"}, { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL AMP: %s", "-100..+100"},
{ MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_CANCEL, 0, "MODE", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -1697,7 +1697,7 @@ static const menuitem_t menu_highoutputmode[] = {
{ MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", NULL}, { 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_SWEEP_TIME,"SWEEP TIME: %s", "0..600 seconds"},
#endif #endif
{ MT_FORM | MT_KEYPAD, KM_OFFSET, "EXTERNAL AMP: %s", "-100..+100"}, { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL AMP: %s", "-100..+100"},
{ MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_CANCEL, 0, "MODE", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -2200,7 +2200,7 @@ static const menuitem_t menu_level[] = {
{ MT_SUBMENU, 0, "ATTENUATE", menu_atten}, { MT_SUBMENU, 0, "ATTENUATE", menu_atten},
// { MT_SUBMENU,0, "CALC", menu_average}, // { MT_SUBMENU,0, "CALC", menu_average},
{ MT_SUBMENU, 0, "UNIT", menu_unit}, { MT_SUBMENU, 0, "UNIT", menu_unit},
{ MT_KEYPAD, KM_OFFSET, "EXTERNAL\nAMP",NULL}, { MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL\nAMP",NULL},
#ifdef TINYSA4 #ifdef TINYSA4
{ MT_ADV_CALLBACK | MT_LOW ,0,"LNA", menu_extra_lna_acb}, { MT_ADV_CALLBACK | MT_LOW ,0,"LNA", menu_extra_lna_acb},
#endif #endif
@ -2367,8 +2367,8 @@ static void fetch_numeric_target(void)
end_level = level_min; end_level = level_min;
if (end_level > level_max) if (end_level > level_max)
end_level = level_max; end_level = level_max;
uistat.value += setting.offset; uistat.value += setting.external_gain;
end_level += setting.offset; end_level += setting.external_gain;
if (setting.level_sweep != 0) if (setting.level_sweep != 0)
plot_printf(uistat.text, sizeof uistat.text, "%.1f to %.1fdBm", uistat.value, end_level); plot_printf(uistat.text, sizeof uistat.text, "%.1f to %.1fdBm", uistat.value, end_level);
else else
@ -2376,7 +2376,7 @@ static void fetch_numeric_target(void)
break; break;
case KM_HIGHOUTLEVEL: case KM_HIGHOUTLEVEL:
uistat.value = get_level(); // compensation for dB offset during low output mode uistat.value = get_level(); // compensation for dB offset during low output mode
uistat.value += setting.offset; uistat.value += setting.external_gain;
plot_printf(uistat.text, sizeof uistat.text, "%.1fdBm", uistat.value); plot_printf(uistat.text, sizeof uistat.text, "%.1fdBm", uistat.value);
break; break;
case KM_DECAY: case KM_DECAY:
@ -2420,8 +2420,8 @@ static void fetch_numeric_target(void)
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;
#endif #endif
case KM_OFFSET: case KM_EXT_GAIN:
uistat.value = setting.offset; uistat.value = setting.external_gain;
plot_printf(uistat.text, sizeof uistat.text, "%.1fdB", uistat.value); plot_printf(uistat.text, sizeof uistat.text, "%.1fdB", uistat.value);
break; break;
case KM_LEVELSWEEP: case KM_LEVELSWEEP:
@ -2533,10 +2533,10 @@ set_numeric_value(void)
set_repeat(uistat.value); set_repeat(uistat.value);
break; break;
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
set_level(uistat.value - setting.offset); set_level(uistat.value - setting.external_gain);
break; break;
case KM_HIGHOUTLEVEL: case KM_HIGHOUTLEVEL:
set_level(uistat.value - setting.offset); set_level(uistat.value - setting.external_gain);
break; break;
case KM_DECAY: case KM_DECAY:
set_decay(uistat.value); set_decay(uistat.value);
@ -2574,8 +2574,8 @@ set_numeric_value(void)
set_10mhz(uistat.value); set_10mhz(uistat.value);
break; break;
#endif #endif
case KM_OFFSET: case KM_EXT_GAIN:
set_offset(uistat.value); set_external_gain(uistat.value);
break; break;
case KM_LEVELSWEEP: case KM_LEVELSWEEP:
setting.modulation = MO_NONE; setting.modulation = MO_NONE;
@ -2925,12 +2925,12 @@ redraw_cal_status:
} }
// Offset // Offset
if (setting.offset != 0.0) { if (setting.external_gain != 0.0) {
ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
ili9341_drawstring("Amp:", x, y); ili9341_drawstring("Amp:", x, y);
y += YSTEP; y += YSTEP;
plot_printf(buf, BLEN, "%.1fdB",setting.offset); plot_printf(buf, BLEN, "%.1fdB",setting.external_gain);
y = add_quick_menu(buf, x, y,(menuitem_t *)KM_OFFSET); y = add_quick_menu(buf, x, y,(menuitem_t *)KM_EXT_GAIN);
} }
// Repeat // Repeat

Loading…
Cancel
Save

Powered by TurnKey Linux.