diff --git a/plot.c b/plot.c index fe167ea..9d314fa 100644 --- a/plot.c +++ b/plot.c @@ -12,9 +12,6 @@ void frequency_string(char *buf, size_t len, uint32_t freq, char *prefix); void frequency_string_short(char *buf, size_t len, int32_t freq, char prefix); void markmap_all_markers(void); -//#define GRID_COLOR 0x0863 -//uint16_t grid_color = 0x1084; - /* indicate dirty cells */ uint16_t markmap[2][8]; uint16_t current_mappage = 0; @@ -294,16 +291,16 @@ smith_grid2(int x, int y, float scale) #endif const int cirs[][4] = { - { 0, 58/2, 58/2, 0 }, // Constant Reactance Circle: 2j : R/2 = 58 - { 29/2, 0, 29/2, 1 }, // Constant Resistance Circle: 3 : R/4 = 29 - { 0, 115/2, 115/2, 0 }, // Constant Reactance Circle: 1j : R = 115 - { 58/2, 0, 58/2, 1 }, // Constant Resistance Circle: 1 : R/2 = 58 - { 0, 230/2, 230/2, 0 }, // Constant Reactance Circle: 1/2j : R*2 = 230 - { 86/2, 0, 86/2, 1 }, // Constant Resistance Circle: 1/3 : R*3/4 = 86 - { 0, 460/2, 460/2, 0 }, // Constant Reactance Circle: 1/4j : R*4 = 460 - { 115/2, 0, 115/2, 1 }, // Constant Resistance Circle: 0 : R - { 173/2, 0, 173/2, 1 }, // Constant Resistance Circle: -1/3 : R*3/2 = 173 - { 0, 0, 0, 0 } // sentinel + { 0, 58/2, 58/2, 0 }, // Constant Reactance Circle: 2j : R/2 = 58 + { 29/2, 0, 29/2, 1 }, // Constant Resistance Circle: 3 : R/4 = 29 + { 0, 115/2, 115/2, 0 }, // Constant Reactance Circle: 1j : R = 115 + { 58/2, 0, 58/2, 1 }, // Constant Resistance Circle: 1 : R/2 = 58 + { 0, 230/2, 230/2, 0 }, // Constant Reactance Circle: 1/2j : R*2 = 230 + { 86/2, 0, 86/2, 1 }, // Constant Resistance Circle: 1/3 : R*3/4 = 86 + { 0, 460/2, 460/2, 0 }, // Constant Reactance Circle: 1/4j : R*4 = 460 + { 115/2, 0, 115/2, 1 }, // Constant Resistance Circle: 0 : R + { 173/2, 0, 173/2, 1 }, // Constant Resistance Circle: -1/3 : R*3/2 = 173 + { 0, 0, 0, 0 } // sentinel }; int @@ -500,18 +497,6 @@ cartesian_scale(float re, float im, int *xp, int *yp, float scale) float groupdelay_from_array(int i, float array[POINTS_COUNT][2]) { -/* - if (i == 0) { - float deltaf = frequencies[1] - frequencies[0]; - return groupdelay(array[0], array[1], deltaf); - } else if (i == 100) { - float deltaf = frequencies[i] - frequencies[i-1]; - return groupdelay(array[i-1], array[i], deltaf); - } else { - float deltaf = frequencies[i+1] - frequencies[i-1]; - return groupdelay(array[i-1], array[i+1], deltaf); - } -*/ int bottom = (i == 0) ? 0 : i - 1; int top = (i == POINTS_COUNT-1) ? POINTS_COUNT-1 : i + 1; float deltaf = frequencies[top] - frequencies[bottom]; diff --git a/ui.c b/ui.c index f52b74a..31f9b19 100644 --- a/ui.c +++ b/ui.c @@ -33,7 +33,6 @@ uistat_t uistat = { marker_delta: FALSE, }; - #define NO_EVENT 0 #define EVT_BUTTON_SINGLE_CLICK 0x01 #define EVT_BUTTON_DOUBLE_CLICK 0x02 @@ -72,9 +71,9 @@ enum { KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_SCALE, KM_REFPOS, KM_EDELAY, KM_VELOCITY_FACTOR, KM_SCALEDELAY }; -uint8_t ui_mode = UI_NORMAL; -uint8_t keypad_mode; -int8_t selection = 0; +static uint8_t ui_mode = UI_NORMAL; +static uint8_t keypad_mode; +static int8_t selection = 0; // Set structure align as WORD (save flash memory) #pragma pack(push, 2) @@ -86,9 +85,11 @@ typedef struct { } menuitem_t; #pragma pack(pop) -int8_t last_touch_status = FALSE; -int16_t last_touch_x; -int16_t last_touch_y; +// Touch screen +static int8_t last_touch_status = FALSE; +static int16_t last_touch_x; +static int16_t last_touch_y; + //int16_t touch_cal[4] = { 1000, 1000, 10*16, 12*16 }; //int16_t touch_cal[4] = { 620, 600, 130, 180 }; #define EVT_TOUCH_NONE 0 @@ -108,7 +109,6 @@ int awd_count; char kp_buf[11]; int8_t kp_index = 0; - void ui_mode_normal(void); void ui_mode_menu(void); void ui_mode_numeric(int _keypad_mode); @@ -439,7 +439,6 @@ enter_dfu(void) NVIC_SystemReset(); } - // type of menu item enum { MT_NONE, @@ -574,6 +573,7 @@ choose_active_trace(void) static void menu_trace_cb(int item, uint8_t data) { + (void)item; if (trace[data].enabled) { if (data == uistat.current_trace) { // disable if active trace is selected @@ -581,11 +581,11 @@ menu_trace_cb(int item, uint8_t data) choose_active_trace(); } else { // make active selected trace - uistat.current_trace = item; + uistat.current_trace = data; } } else { trace[data].enabled = TRUE; - uistat.current_trace = item; + uistat.current_trace = data; } request_to_redraw_grid(); draw_menu(); @@ -740,7 +740,7 @@ menu_marker_op_cb(int item, uint8_t data) if (previous_marker == -1 || active_marker == previous_marker) { // if only 1 marker is active, keep center freq and make span the marker comes to the edge uint32_t center = get_sweep_frequency(ST_CENTER); - uint32_t span = center > freq ? center - freq : freq - center; + uint32_t span = get_sweep_frequency(ST_SPAN); set_sweep_frequency(ST_SPAN, span * 2); } else { // if 2 or more marker active, set start and stop freq to each marker @@ -1480,8 +1480,7 @@ erase_menu_buttons(void) void erase_numeric_input(void) { - uint16_t bg = 0; - ili9341_fill(0, 240-32, 320, 32, bg); + ili9341_fill(0, 240-32, 320, 32, DEFAULT_BG_COLOR); } void @@ -1571,7 +1570,7 @@ void set_numeric_value(void) set_electrical_delay(uistat.value); break; case KM_VELOCITY_FACTOR: - velocity_factor = uistat.value; + velocity_factor = uistat.value/100.0; break; } } @@ -1584,7 +1583,6 @@ draw_numeric_area(void) draw_numeric_input(buf); } - void ui_mode_menu(void) { @@ -1718,12 +1716,11 @@ lever_zoom_span(int status) uint32_t span = get_sweep_frequency(ST_SPAN); if (status & EVT_UP) { span = step_round(span - 1); - set_sweep_frequency(ST_SPAN, span); } else if (status & EVT_DOWN) { span = step_round(span + 1); span = step_round(span * 3); - set_sweep_frequency(ST_SPAN, span); } + set_sweep_frequency(ST_SPAN, span); } static void