Added ultra and extra_lna

Removed_REF_marker
erikkaashoek 5 years ago
parent 183b932157
commit 2d2f52d52f

@ -55,7 +55,7 @@
/* on-board */ /* on-board */
#if 0 #if 1 // Set to 1 to build for prototype HW
#define TINYSA4_PROTO #define TINYSA4_PROTO
#define GPIO_LED 0 #define GPIO_LED 0
#define LINE_LED PAL_LINE(GPIOA,GPIO_LED) #define LINE_LED PAL_LINE(GPIOA,GPIO_LED)

@ -894,6 +894,7 @@ config_t config = {
.cor_am = -14, .cor_am = -14,
.cor_wfm = -17, .cor_wfm = -17,
.cor_nfm = -17, .cor_nfm = -17,
.ultra = true,
}; };
//properties_t current_props; //properties_t current_props;
@ -2399,6 +2400,8 @@ static const VNAShellCommand commands[] =
{ "rbw", cmd_rbw, 0 }, { "rbw", cmd_rbw, 0 },
{ "mode", cmd_mode, CMD_WAIT_MUTEX }, { "mode", cmd_mode, CMD_WAIT_MUTEX },
{ "spur", cmd_spur, 0 }, { "spur", cmd_spur, 0 },
{ "lna", cmd_lna, 0 },
{ "ultra", cmd_ultra, 0 },
{ "load", cmd_load, 0 }, { "load", cmd_load, 0 },
{ "offset", cmd_offset, 0}, { "offset", cmd_offset, 0},
{ "output", cmd_output, 0 }, { "output", cmd_output, 0 },

@ -160,6 +160,8 @@ int shell_printf(const char *fmt, ...);
void set_marker_frequency(int m, uint32_t f); void set_marker_frequency(int m, uint32_t f);
void toggle_sweep(void); void toggle_sweep(void);
void toggle_mute(void); void toggle_mute(void);
void toggle_extra_lna(void);
void set_extra_lna(int t);
void load_default_properties(void); void load_default_properties(void);
enum { enum {
@ -507,6 +509,7 @@ typedef struct config {
int8_t cor_am; int8_t cor_am;
int8_t cor_wfm; int8_t cor_wfm;
int8_t cor_nfm; int8_t cor_nfm;
int8_t ultra;
int8_t dummy; int8_t dummy;
// uint8_t _reserved[22]; // uint8_t _reserved[22];
uint32_t checksum; uint32_t checksum;
@ -792,7 +795,7 @@ typedef struct setting
float normalize_level; // Level to set normalize to, zero if not doing anything float normalize_level; // Level to set normalize to, zero if not doing anything
int modulation_frequency; int modulation_frequency;
uint32_t checksum; uint32_t checksum;
int ultra; int extra_lna;
}setting_t; }setting_t;
extern setting_t setting; extern setting_t setting;

@ -107,6 +107,36 @@ VNA_SHELL_FUNCTION(cmd_spur)
} }
} }
VNA_SHELL_FUNCTION(cmd_lna)
{
// static const char cmd[] = "off|on";
// if (argc != 1) {
// usage:
// shell_printf("usage: spur %s\r\n", cmd);
// return;
// }
int m = generic_option_cmd("lna", "off|on", argc, argv[0]);
if (m>=0) {
set_extra_lna(m);
redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA;
}
}
VNA_SHELL_FUNCTION(cmd_ultra)
{
// static const char cmd[] = "off|on";
// if (argc != 1) {
// usage:
// shell_printf("usage: spur %s\r\n", cmd);
// return;
// }
int m = generic_option_cmd("ultra", "off|on", argc, argv[0]);
if (m>=0) {
config.ultra = m;
update_min_max_freq();
}
}
VNA_SHELL_FUNCTION(cmd_output) VNA_SHELL_FUNCTION(cmd_output)
{ {
#if 0 #if 0

@ -66,7 +66,10 @@ void update_min_max_freq(void)
switch(setting.mode) { switch(setting.mode) {
case M_LOW: case M_LOW:
minFreq = 0; minFreq = 0;
maxFreq = 3000000000; // DEFAULT_MAX_FREQ; <---------------- TODO if (config.ultra)
maxFreq = 2900000000;
else
maxFreq = 850000000;
break; break;
#ifdef __ULTRA__ #ifdef __ULTRA__
case M_ULTRA: case M_ULTRA:
@ -149,6 +152,9 @@ void reset_settings(int m)
case M_LOW: case M_LOW:
set_sweep_frequency(ST_START, minFreq); set_sweep_frequency(ST_START, minFreq);
set_sweep_frequency(ST_STOP, maxFreq); set_sweep_frequency(ST_STOP, maxFreq);
if (config.ultra)
set_sweep_frequency(ST_STOP, 2900000000); // TODO <----------------- temp ----------------------
else
set_sweep_frequency(ST_STOP, 800000000); // TODO <----------------- temp ---------------------- set_sweep_frequency(ST_STOP, 800000000); // TODO <----------------- temp ----------------------
setting.attenuate = 0.0; // <---------------- WARNING ----------------- setting.attenuate = 0.0; // <---------------- WARNING -----------------
setting.auto_attenuation = false; // <---------------- WARNING ----------------- setting.auto_attenuation = false; // <---------------- WARNING -----------------
@ -330,6 +336,18 @@ void toggle_tracking_output(void)
dirty = true; dirty = true;
} }
void toggle_extra_lna(void)
{
setting.extra_lna = !setting.extra_lna;
dirty = true;
}
void set_extra_lna(int t)
{
setting.extra_lna = t;
dirty = true;
}
void toggle_mirror_masking(void) void toggle_mirror_masking(void)
{ {
setting.mirror_masking = !setting.mirror_masking; setting.mirror_masking = !setting.mirror_masking;
@ -1125,7 +1143,7 @@ void setupSA(void)
#endif #endif
ADF4351_Setup(); ADF4351_Setup();
enable_lna(false); enable_extra_lna(false);
enable_ultra(false); enable_ultra(false);
enable_rx_output(false); enable_rx_output(false);
enable_high(false); enable_high(false);
@ -1306,8 +1324,8 @@ case M_ULTRA:
#endif #endif
enable_rx_output(false); enable_rx_output(false);
enable_high(false); enable_high(false);
enable_lna(setting.lna); enable_extra_lna(setting.extra_lna);
enable_ultra(setting.ultra); enable_ultra(false);
break; break;
case M_HIGH: // Direct into 1 case M_HIGH: // Direct into 1
mute: mute:
@ -1335,7 +1353,7 @@ mute:
enable_rx_output(false); enable_rx_output(false);
enable_high(true); enable_high(true);
enable_lna(false); enable_extra_lna(false);
enable_ultra(false); enable_ultra(false);
break; break;
@ -1375,7 +1393,7 @@ case M_GENLOW: // Mixed output from 0
} }
SI4463_set_output_level(setting.rx_drive); SI4463_set_output_level(setting.rx_drive);
enable_high(false); enable_high(false);
enable_lna(false); enable_extra_lna(false);
enable_ultra(false); enable_ultra(false);
break; break;
case M_GENHIGH: // Direct output from 1 case M_GENHIGH: // Direct output from 1
@ -1408,7 +1426,7 @@ case M_GENHIGH: // Direct output from 1
ADF4351_aux_drive(setting.lo_drive); ADF4351_aux_drive(setting.lo_drive);
enable_rx_output(false); enable_rx_output(false);
enable_high(true); enable_high(true);
enable_lna(false); enable_extra_lna(false);
enable_ultra(false); enable_ultra(false);
break; break;
} }
@ -1687,6 +1705,7 @@ static void calculate_static_correction(void) // Calculate the
+ float_TO_PURE_RSSI( + float_TO_PURE_RSSI(
+ get_level_offset() + get_level_offset()
+ get_attenuation() + get_attenuation()
+ (setting.extra_lna ? -20.0 : 0) // TODO <------------------------- set correct value
- setting.offset); - setting.offset);
} }
@ -1847,6 +1866,11 @@ modulation_again:
my_microsecond_delay(modulation_delay); my_microsecond_delay(modulation_delay);
} }
} }
// -------------- set ultra ---------------------------------
if (setting.mode == M_LOW && config.ultra && f > 850000000U ) {
enable_ultra(true);
} else
enable_ultra(false);
// -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------ // -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------
pureRSSI_t RSSI = float_TO_PURE_RSSI(-150); pureRSSI_t RSSI = float_TO_PURE_RSSI(-150);
@ -3093,6 +3117,15 @@ void draw_cal_status(void)
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
} }
#endif #endif
if (setting.extra_lna) {
ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
y += YSTEP + YSTEP/2 ;
ili9341_drawstring("LNA:", x, y);
y += YSTEP;
plot_printf(buf, BLEN, "ON");
ili9341_drawstring(buf, x, y);
}
if (setting.subtract_stored) { if (setting.subtract_stored) {
ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);

@ -2302,13 +2302,17 @@ again:
prev_band = -1; // 433MHz prev_band = -1; // 433MHz
} }
void enable_lna(int s) void enable_extra_lna(int s)
{ {
#ifdef TINYSA4_PROTO #ifdef TINYSA4_PROTO
static int old_extra_lna = -1;
if (s != old_extra_lna) {
if (s) if (s)
palClearLine(LINE_LNA); // Inverted logic!!! palClearLine(LINE_LNA); // Inverted logic!!!
else else
palSetLine(LINE_LNA); palSetLine(LINE_LNA);
old_extra_lna = s;
}
#else #else
(void)s; (void)s;
#endif #endif
@ -2317,10 +2321,14 @@ void enable_lna(int s)
void enable_ultra(int s) void enable_ultra(int s)
{ {
#ifdef TINYSA4_PROTO #ifdef TINYSA4_PROTO
static int old_ultra = -1;
if (s != old_ultra) {
if (s) if (s)
palSetLine(LINE_ULTRA); palSetLine(LINE_ULTRA);
else else
palClearLine(LINE_ULTRA); palClearLine(LINE_ULTRA);
old_ultra = s;
}
#else #else
(void)s; (void)s;
#endif #endif

@ -197,7 +197,7 @@ void SI4463_init(void);
#endif #endif
#ifdef TINYSA4 #ifdef TINYSA4
void enable_lna(int s); void enable_extra_lna(int s);
void enable_ultra(int s); void enable_ultra(int s);
void enable_rx_output(int s); void enable_rx_output(int s);
void enable_high(int s); void enable_high(int s);

@ -767,6 +767,19 @@ static UI_FUNCTION_ADV_CALLBACK(menu_spur_acb)
} }
#endif #endif
static UI_FUNCTION_ADV_CALLBACK(menu_extra_lna_acb)
{
(void)data;
(void)item;
if (b){
b->icon = setting.extra_lna == 0 ? BUTTON_ICON_NOCHECK : BUTTON_ICON_CHECK;
return;
}
toggle_extra_lna();
// menu_move_back();
ui_mode_normal();
}
static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
{ {
(void)item; (void)item;
@ -1875,8 +1888,9 @@ static const menuitem_t menu_level[] = {
// { 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_OFFSET, "EXTERNAL\nAMP",NULL},
{ MT_ADV_CALLBACK | MT_LOW ,0,"LNA", menu_extra_lna_acb},
{ MT_SUBMENU, 0, "TRIGGER", menu_trigger}, { MT_SUBMENU, 0, "TRIGGER", menu_trigger},
{ 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
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.