From 3c79a47c85176b365785b8ccd9313d50e6a74114 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 17 Nov 2020 09:42:19 +0100 Subject: [PATCH] Palette error and cmd error corrected --- ili9341.c | 6 ++++-- sa_cmd.c | 39 +++++++++++++++++++++++++++++---------- sa_core.c | 14 +++++++------- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/ili9341.c b/ili9341.c index f32ff19..d981ac0 100644 --- a/ili9341.c +++ b/ili9341.c @@ -555,8 +555,10 @@ void ili9341_clear_screen(void) #ifndef ili9341_set_foreground void ili9341_set_foreground(uint16_t fg_idx) { -// if (fg_idx >= 32) fg_idx = 0; - foreground_color = GET_PALTETTE_COLOR(fg_idx); + if (fg_idx >= 32) + foreground_color = fg_idx; + else + foreground_color = GET_PALTETTE_COLOR(fg_idx); } #endif diff --git a/sa_cmd.c b/sa_cmd.c index 212bcfb..fd2c59b 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -78,24 +78,38 @@ VNA_SHELL_FUNCTION(cmd_modulation ) } } -VNA_SHELL_FUNCTION(cmd_spur) +int generic_option_cmd( const char *cmd, const char *cmd_list, int argc, char *argv) { if (argc != 1) { usage: - shell_printf("usage: spur on|off\r\n"); - return; + shell_printf("usage: %s %s\r\n", cmd, cmd_list); + return -1; } - if (strcmp(argv[0],"on") == 0) { - set_spur(1); - } else if (strcmp(argv[0],"off") == 0) { - set_spur(0); - } else + int m = get_str_index(argv, cmd_list); + if (m < 0) goto usage; - redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA; + return m; +} + + +VNA_SHELL_FUNCTION(cmd_spur) +{ +// static const char cmd[] = "off|on"; +// if (argc != 1) { +// usage: +// shell_printf("usage: spur %s\r\n", cmd); +// return; +// } + int m = generic_option_cmd("spur", "off|on", argc, argv[0]); + if (m>=0) { + set_spur(m); + redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA; + } } VNA_SHELL_FUNCTION(cmd_output) { +#if 0 if (argc != 1) { usage: shell_printf("usage: output on|off\r\n"); @@ -107,7 +121,12 @@ VNA_SHELL_FUNCTION(cmd_output) setting.mute = true; } else goto usage; - dirty = true; +#endif + int m = generic_option_cmd("output", "off|on", argc, argv[0]); + if (m>=0) { + setting.mute = m; + dirty = true; + } } VNA_SHELL_FUNCTION(cmd_load) diff --git a/sa_core.c b/sa_core.c index a6c5752..c7ebb0d 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1663,7 +1663,7 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking) if (i == 0 || setting.frequency_step != 0) correct_RSSI_freq = get_frequency_correction(f); } - int *current_fm_modulation; + int *current_fm_modulation = 0; if (MODE_OUTPUT(setting.mode)) { if (setting.modulation != MO_NONE && setting.modulation != MO_EXTERNAL && setting.modulation_frequency != 0) { modulation_delay = (1000000/ MODULATION_STEPS ) / setting.modulation_frequency; // 5 steps so 1MHz/5 @@ -1697,7 +1697,7 @@ modulation_again: PE4302_Write_Byte(p); #endif } - else if (setting.modulation == MO_NFM || setting.modulation == MO_WFM ) { //FM modulation + else if (current_fm_modulation) { // setting.modulation == MO_NFM || setting.modulation == MO_WFM //FM modulation #ifdef __SI4432__ SI4432_Sel = SI4432_LO ; int offset = current_fm_modulation[modulation_counter]; @@ -3171,7 +3171,7 @@ void cell_draw_test_info(int x0, int y0) i++; int xpos = 25 - x0; int ypos = 50+i*INFO_SPACING - y0; - unsigned int color = RGBHEX(0xFFFFFF); + unsigned int color = LCD_FG_COLOR; if (i == -1) { plot_printf(self_test_status_buf, sizeof self_test_status_buf, "Self test status:"); } else if (test_case[i].kind == TC_END) { @@ -3182,13 +3182,13 @@ void cell_draw_test_info(int x0, int y0) } else { plot_printf(self_test_status_buf, sizeof self_test_status_buf, "Test %d: %s%s", i+1, test_fail_cause[i], test_text[test_status[i]] ); if (test_status[i] == TS_PASS) - color = RGBHEX(0x00FF00); + color = LCD_BRIGHT_COLOR_GREEN; else if (test_status[i] == TS_CRITICAL) - color = RGBHEX(0xFFFF00); + color = LCD_TRACE_3_COLOR; // Yellow else if (test_status[i] == TS_FAIL) - color = RGBHEX(0xFF7F7F); + color = LCD_BRIGHT_COLOR_RED; else - color = RGBHEX(0x0000FF); + color = LCD_BRIGHT_COLOR_BLUE; } ili9341_set_foreground(color); cell_drawstring(self_test_status_buf, xpos, ypos);