Split LO and RX drive

master
erikkaashoek 5 years ago
parent e430685db0
commit a37a40228e

@ -224,7 +224,8 @@ int is_paused(void);
void set_actual_power(float); void set_actual_power(float);
void SetGenerate(int); void SetGenerate(int);
void set_RBW(uint32_t rbw_x10); void set_RBW(uint32_t rbw_x10);
void set_drive(int d); void set_lo_drive(int d);
void set_rx_drive(int d);
void set_IF(int f); void set_IF(int f);
void set_step_delay(int t); void set_step_delay(int t);
void set_offset_delay(int t); void set_offset_delay(int t);
@ -754,7 +755,8 @@ typedef struct setting
int average; int average;
int show_stored; int show_stored;
int subtract_stored; int subtract_stored;
int drive; // 0-7 , 7=+20dBm, 3dB steps int lo_drive; // 0-3 , 3dB steps
int rx_drive; // 0-15 , 7=+20dBm, 3dB steps
int agc; int agc;
int lna; int lna;
int auto_reflevel; int auto_reflevel;

@ -460,7 +460,7 @@ VNA_SHELL_FUNCTION(cmd_d)
(void) argc; (void) argc;
(void) argv; (void) argv;
int32_t a = my_atoi(argv[0]); int32_t a = my_atoi(argv[0]);
setting.drive=a; setting.lo_drive=a;
dirty = true; dirty = true;
} }

@ -93,7 +93,8 @@ void reset_settings(int m)
setting.auto_attenuation = false; setting.auto_attenuation = false;
setting.subtract_stored = 0; setting.subtract_stored = 0;
setting.normalize_level = 0.0; setting.normalize_level = 0.0;
setting.drive=13; setting.lo_drive=13;
setting.rx_drive=8;
setting.atten_step = 0; // Only used in low output mode setting.atten_step = 0; // Only used in low output mode
setting.agc = S_AUTO_ON; setting.agc = S_AUTO_ON;
setting.lna = S_AUTO_OFF; setting.lna = S_AUTO_OFF;
@ -152,7 +153,8 @@ void reset_settings(int m)
break; break;
#endif #endif
case M_GENLOW: case M_GENLOW:
setting.drive=8; setting.rx_drive=8;
setting.lo_drive=13;
set_sweep_frequency(ST_CENTER, 10000000); set_sweep_frequency(ST_CENTER, 10000000);
set_sweep_frequency(ST_SPAN, 0); set_sweep_frequency(ST_SPAN, 0);
setting.sweep_time_us = 10*ONE_SECOND_TIME; setting.sweep_time_us = 10*ONE_SECOND_TIME;
@ -163,7 +165,7 @@ void reset_settings(int m)
setting.sweep_time_us = 0; setting.sweep_time_us = 0;
break; break;
case M_GENHIGH: case M_GENHIGH:
setting.drive=8; setting.lo_drive=8;
set_sweep_frequency(ST_CENTER, 300000000); set_sweep_frequency(ST_CENTER, 300000000);
set_sweep_frequency(ST_SPAN, 0); set_sweep_frequency(ST_SPAN, 0);
setting.sweep_time_us = 10*ONE_SECOND_TIME; setting.sweep_time_us = 10*ONE_SECOND_TIME;
@ -283,10 +285,15 @@ void set_measurement(int m)
#endif #endif
dirty = true; dirty = true;
} }
void set_lo_drive(int d)
{
setting.lo_drive = d;
dirty = true;
}
void set_drive(int d) void set_rx_drive(int d)
{ {
setting.drive = d; setting.rx_drive = d;
dirty = true; dirty = true;
} }
@ -441,7 +448,7 @@ float get_attenuation(void)
if (setting.atten_step) if (setting.atten_step)
return ( -(POWER_OFFSET + setting.attenuate - (setting.atten_step-1)*POWER_STEP + SWITCH_ATTENUATION)); return ( -(POWER_OFFSET + setting.attenuate - (setting.atten_step-1)*POWER_STEP + SWITCH_ATTENUATION));
else else
return ( -POWER_OFFSET - setting.attenuate + (setting.drive & 7) * 3); return ( -POWER_OFFSET - setting.attenuate + (setting.rx_drive & 7) * 3);
} else if (setting.atten_step) { } else if (setting.atten_step) {
if (setting.mode == M_LOW) if (setting.mode == M_LOW)
return setting.attenuate + RECEIVE_SWITCH_ATTENUATION; return setting.attenuate + RECEIVE_SWITCH_ATTENUATION;
@ -471,7 +478,7 @@ void set_level(float v) // Set the drive level of the LO
d++; d++;
if (d == 8 && v < -12) // Round towards closest level if (d == 8 && v < -12) // Round towards closest level
d = 7; d = 7;
set_drive(d); set_lo_drive(d);
} else { } else {
setting.level = v; setting.level = v;
set_attenuation((int)v); set_attenuation((int)v);
@ -484,16 +491,16 @@ void set_attenuation(float a) // Is used both in output mode and input mod
if (setting.mode == M_GENLOW) { if (setting.mode == M_GENLOW) {
a = a + POWER_OFFSET; a = a + POWER_OFFSET;
if (a > 6) { // +9dB if (a > 6) { // +9dB
setting.drive = 11; // Maximum save drive for SAW filters. setting.rx_drive = 11; // Maximum save drive for SAW filters.
a = a - 9; a = a - 9;
} else if (a > 3) { // +6dB } else if (a > 3) { // +6dB
setting.drive = 10; setting.rx_drive = 10;
a = a - 6; a = a - 6;
} else if (a > 0) { // +3dB } else if (a > 0) { // +3dB
setting.drive = 9; setting.rx_drive = 9;
a = a - 3; a = a - 3;
} else } else
setting.drive = 8; // defined as 0dB level setting.rx_drive = 8; // defined as 0dB level
if (a > 0) if (a > 0)
a = 0; a = 0;
if( a > - SWITCH_ATTENUATION) { if( a > - SWITCH_ATTENUATION) {
@ -1257,7 +1264,7 @@ case M_ULTRA:
else else
set_switch_off(); set_switch_off();
// SI4432_Receive(); For noise testing only // SI4432_Receive(); For noise testing only
SI4432_Transmit(setting.drive); SI4432_Transmit(setting.lo_drive);
// set_calibration_freq(setting.refer); // set_calibration_freq(setting.refer);
#endif #endif
break; break;
@ -1290,7 +1297,7 @@ case M_GENLOW: // Mixed output from 0
} else { } else {
set_switch_transmit(); set_switch_transmit();
} }
SI4432_Transmit(setting.drive); SI4432_Transmit(setting.rx_drive);
SI4432_Sel = SI4432_LO ; SI4432_Sel = SI4432_LO ;
if (setting.modulation == MO_EXTERNAL) { if (setting.modulation == MO_EXTERNAL) {
@ -1311,12 +1318,12 @@ case M_GENHIGH: // Direct output from 1
set_switch_receive(); set_switch_receive();
SI4432_Sel = SI4432_LO ; SI4432_Sel = SI4432_LO ;
if (setting.drive < 8) { if (setting.lo_drive < 8) {
set_switch_off(); // use switch as attenuator set_switch_off(); // use switch as attenuator
} else { } else {
set_switch_transmit(); set_switch_transmit();
} }
SI4432_Transmit(setting.drive); SI4432_Transmit(setting.lo_drive);
#endif #endif
break; break;
} }

@ -1871,10 +1871,11 @@ menu_select_touch(int i)
fetch_numeric_target(); fetch_numeric_target();
float m = 1.0; float m = 1.0;
#define TOUCH_DEAD_ZONE 5 #define TOUCH_DEAD_ZONE 5
#define PULL_SPEED 25.0
if (touch_x < LCD_WIDTH/2 - TOUCH_DEAD_ZONE) { if (touch_x < LCD_WIDTH/2 - TOUCH_DEAD_ZONE) {
m = 1 / (1 + pow(10, -6 + ((LCD_WIDTH/2 - TOUCH_DEAD_ZONE) - touch_x)/20.0)); m = 1 / (1 + pow(10, -6 + ((float)((LCD_WIDTH/2 - TOUCH_DEAD_ZONE) - touch_x))/PULL_SPEED));
} else if (touch_x > LCD_WIDTH/2 + 10) { } else if (touch_x > LCD_WIDTH/2 + TOUCH_DEAD_ZONE) {
m = 1 + pow(10, -6 + (touch_x - (LCD_WIDTH/2 + TOUCH_DEAD_ZONE))/20.0); m = 1 + pow(10, -6 + ((float)(touch_x - (LCD_WIDTH/2 + TOUCH_DEAD_ZONE)))/PULL_SPEED);
} }
uistat.value *= m; uistat.value *= m;
set_numeric_value(); set_numeric_value();

@ -425,7 +425,7 @@ static const struct {
{keypads_plusmin_unit, "ACTUAL\nPOWER"}, // actual power {keypads_plusmin_unit, "ACTUAL\nPOWER"}, // actual power
{keypads_freq , "IF"}, // IF {keypads_freq , "IF"}, // IF
{keypads_positive , "SAMPLE\nDELAY"}, // sample delay {keypads_positive , "SAMPLE\nDELAY"}, // sample delay
{keypads_positive , "DRIVE"}, // drive {keypads_positive , "DRIVE"}, // KM_DRIVE
{keypads_plusmin , "LEVEL"}, // KM_LOWOUTLEVEL {keypads_plusmin , "LEVEL"}, // KM_LOWOUTLEVEL
{keypads_positive , "DECAY"}, // KM_DECAY {keypads_positive , "DECAY"}, // KM_DECAY
{keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE {keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE
@ -717,16 +717,16 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sreffer_acb){
} }
const int8_t menu_drive_value[]={-38,-35,-33,-30,-27,-24,-21,-19, -7,-4,-2,1,4,7,10,13}; const int8_t menu_drive_value[]={-38,-35,-33,-30,-27,-24,-21,-19, -7,-4,-2,1,4,7,10,13};
static UI_FUNCTION_ADV_CALLBACK(menu_drive_acb) static UI_FUNCTION_ADV_CALLBACK(menu_lo_drive_acb)
{ {
(void)item; (void)item;
if(b){ if(b){
b->param_1.i = menu_drive_value[data] + (setting.mode==M_GENHIGH ? setting.offset : 0); 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; b->icon = data == setting.lo_drive ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return; return;
} }
//Serial.println(item); //Serial.println(item);
set_drive(data); set_lo_drive(data);
menu_move_back(); menu_move_back();
// ui_mode_normal(); // ui_mode_normal();
// draw_cal_status(); // draw_cal_status();
@ -736,7 +736,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sdrive_acb){
(void)item; (void)item;
(void)data; (void)data;
if(b){ if(b){
b->param_1.i = menu_drive_value[setting.drive] + (setting.mode==M_GENHIGH ? setting.offset : 0); b->param_1.i = menu_drive_value[setting.lo_drive] + (setting.mode==M_GENHIGH ? setting.offset : 0);
return; return;
} }
menu_push_submenu(menu_drive_wide); menu_push_submenu(menu_drive_wide);
@ -1414,43 +1414,43 @@ static const menuitem_t menu_load_preset[] =
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_drive[] = { static const menuitem_t menu_lo_drive[] = {
{ MT_ADV_CALLBACK, 15, "%+ddBm", menu_drive_acb}, { MT_ADV_CALLBACK, 15, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 14, "%+ddBm", menu_drive_acb}, { MT_ADV_CALLBACK, 14, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 13, "%+ddBm", menu_drive_acb}, { MT_ADV_CALLBACK, 13, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 12, "%+ddBm", menu_drive_acb}, { MT_ADV_CALLBACK, 12, "%+ddBm", menu_lo_drive_acb},
{ 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_ADV_CALLBACK, 5, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 5, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 4, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 4, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 3, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 3, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 2, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 2, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 1, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 1, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 0, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 0, "%+ddBm", menu_lo_drive_acb},
{ 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_ADV_CALLBACK, 10, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 10, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 9, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 9, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 8, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 8, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 7, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 7, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 6, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 6, "%+ddBm", menu_lo_drive_acb},
{ 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_ADV_CALLBACK, 15, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 15, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 14, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 14, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 13, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 13, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 12, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 12, "%+ddBm", menu_lo_drive_acb},
{ MT_FORM | MT_ADV_CALLBACK, 11, "%+ddBm", menu_drive_acb}, { MT_FORM | MT_ADV_CALLBACK, 11, "%+ddBm", menu_lo_drive_acb},
{ 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
@ -1759,7 +1759,7 @@ static const menuitem_t menu_settings[] =
{ MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "Set to zero for auto IF"}, { MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "Set to zero for auto IF"},
{ MT_SUBMENU,0, "SCAN SPEED", menu_scanning_speed}, { MT_SUBMENU,0, "SCAN SPEED", menu_scanning_speed},
{ MT_KEYPAD, KM_REPEAT, "SAMPLE\nREPEAT", "1..100"}, { MT_KEYPAD, KM_REPEAT, "SAMPLE\nREPEAT", "1..100"},
{ MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_drive}, { MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_lo_drive},
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settings2}, { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings2},
{ 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
@ -2064,7 +2064,7 @@ static void fetch_numeric_target(void)
plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%2d", ((int32_t)uistat.value));
break; break;
case KM_DRIVE: case KM_DRIVE:
uistat.value = setting.drive; uistat.value = setting.rx_drive;
plot_printf(uistat.text, sizeof uistat.text, "%3ddB", ((int32_t)uistat.value)); plot_printf(uistat.text, sizeof uistat.text, "%3ddB", ((int32_t)uistat.value));
break; break;
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
@ -2195,7 +2195,7 @@ set_numeric_value(void)
set_repeat(uistat.value); set_repeat(uistat.value);
break; break;
case KM_DRIVE: case KM_DRIVE:
set_drive(uistat.value); set_rx_drive(uistat.value);
break; break;
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
set_level(uistat.value - setting.offset); set_level(uistat.value - setting.offset);

Loading…
Cancel
Save

Powered by TurnKey Linux.