void markmap_all_markers(void); static void menu_marker_type_cb(int item, uint8_t data); void set_sweep_frequency(int type, uint32_t frequency); uint32_t get_sweep_frequency(int type); void clearDisplay(void); //void ui_process_touch(void); void SetPowerGrid(int); void SetRefLevel(int); void set_refer_output(int); int get_refer_output(void); void SetAttenuation(int); void SetPowerLevel(int); void SetGenerate(int); void SetRBW(int); void SetSpur(int); int GetSpur(void); void SetAverage(int); int GetAverage(void); void SetStorage(void); void SetClearStorage(void); void SetSubtractStorage(void); void toggle_waterfall(void); void SetMode(int); int GetMode(void); void AllDirty(void); void MenuDirty(void); void redrawHisto(void); void self_test(void); extern int32_t frequencyExtra; extern int extraVFO; extern int settingDrive; extern int settingLNA; extern int settingAGC; extern int settingSpeed; extern int stepDelay; enum { KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFPOS, KM_SCALE, KM_ATTENUATION, KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE }; #define KP_X(x) (48*(x) + 2 + (320-BUTTON_WIDTH-192)) #define KP_Y(y) (48*(y) + 2) #define KP_PERIOD 10 #define KP_MINUS 11 #define KP_X1 12 #define KP_K 13 #define KP_M 14 #define KP_G 15 #define KP_BS 16 #define KP_INF 17 #define KP_DB 18 #define KP_PLUSMINUS 19 #define KP_KEYPAD 20 #define KP_N 21 #define KP_P 22 typedef struct { uint8_t x:4; uint8_t y:4; int8_t c; } keypads_t; static const keypads_t *keypads; static uint8_t keypads_last_index; static const keypads_t keypads_freq[] = { { 1, 3, KP_PERIOD }, { 0, 3, 0 }, { 0, 2, 1 }, { 1, 2, 2 }, { 2, 2, 3 }, { 0, 1, 4 }, { 1, 1, 5 }, { 2, 1, 6 }, { 0, 0, 7 }, { 1, 0, 8 }, { 2, 0, 9 }, { 3, 0, KP_G }, { 3, 1, KP_M }, { 3, 2, KP_K }, { 3, 3, KP_X1 }, { 2, 3, KP_BS }, { 0, 0, -1 } }; static const keypads_t keypads_scale[] = { { 1, 3, KP_PERIOD }, { 0, 3, 0 }, { 0, 2, 1 }, { 1, 2, 2 }, { 2, 2, 3 }, { 0, 1, 4 }, { 1, 1, 5 }, { 2, 1, 6 }, { 0, 0, 7 }, { 1, 0, 8 }, { 2, 0, 9 }, { 3, 3, KP_X1 }, { 2, 3, KP_BS }, { 0, 0, -1 } }; static const keypads_t keypads_level[] = { { 1, 3, KP_PERIOD }, { 0, 3, 0 }, { 0, 2, 1 }, { 1, 2, 2 }, { 2, 2, 3 }, { 0, 1, 4 }, { 1, 1, 5 }, { 2, 1, 6 }, { 0, 0, 7 }, { 1, 0, 8 }, { 2, 0, 9 }, { 3, 2, KP_MINUS }, { 3, 3, KP_X1 }, { 2, 3, KP_BS }, { 0, 0, -1 } }; static const keypads_t * const keypads_mode_tbl[] = { keypads_freq, // start keypads_freq, // stop keypads_freq, // center keypads_freq, // span keypads_freq, // cw freq keypads_level, // refpos keypads_scale, // scale keypads_scale, // attenuation keypads_level, // actual power keypads_freq, // IF keypads_level, // sample time keypads_scale, // drive }; #ifdef __VNA__ static const char * const keypad_mode_label[] = { "START", "STOP", "CENTER", "SPAN", "CW FREQ", "SCALE", "REFPOS", "EDELAY", "VELOCITY%", "DELAY" }; #endif #ifdef __SA__ static const char * const keypad_mode_label[] = { "START", "STOP", "CENTER", "SPAN", "CW FREQ", "REFPOS", "SCALE", "ATTENUATION", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE" }; #endif // ===[MENU CALLBACKS]========================================================= int generator_enabled = false; static void menu_mode_cb(int item, uint8_t data) { (void)data; switch (item) { case 4: // Change reference output break; default: SetMode(item); menu_move_back(); ui_mode_normal(); draw_cal_status(); break; } } extern int dirty; void menu_autosettings_cb(int item, uint8_t data) { (void)item; (void)data; SetMode(M_LOW); // set_sweep_frequency(ST_START, (int32_t) 0); // set_sweep_frequency(ST_STOP, (int32_t) 300000000); int value = 10; // 10dB/ set_trace_scale(0, value); set_trace_scale(1, value); set_trace_scale(2, value); value = -10; // Top at -10dB set_trace_refpos(0, - value / get_trace_scale(0) + NGRIDY); set_trace_refpos(1, - value / get_trace_scale(0) + NGRIDY); set_trace_refpos(2, - value / get_trace_scale(0) + NGRIDY); active_marker = 0; menu_marker_type_cb(M_REFERENCE,M_REFERENCE); set_refer_output(1); SetAttenuation(0); SetPowerLevel(100); // Reset SetRBW(0); dirty = true; menu_move_back(); ui_mode_normal(); draw_cal_status(); } static void menu_config_cb(int item, uint8_t data) { (void)data; switch (item) { case 0: touch_cal_exec(); redraw_frame(); request_to_redraw_grid(); draw_menu(); break; case 1: touch_draw_test(); redraw_frame(); request_to_redraw_grid(); draw_menu(); break; case 2: menu_move_back(); ui_mode_normal(); self_test(); break; case 3: show_version(); redraw_frame(); request_to_redraw_grid(); draw_menu(); } } static void menu_dfu_cb(int item, uint8_t data) { (void)data; switch (item) { case 0: enter_dfu(); } } int menu_refer_value[]={-1,0,1,2,3,4,5,6}; static void menu_refer_cb(int item, uint8_t data) { (void)data; //Serial.println(item); set_refer_output(menu_refer_value[item]); menu_move_back(); ui_mode_normal(); draw_cal_status(); } static void menu_refer_cb2(int item, uint8_t data) { (void)data; //Serial.println(item); set_refer_output(menu_refer_value[item+5]); menu_move_back(); ui_mode_normal(); draw_cal_status(); } static void menu_spur_cb(int item, uint8_t data) { (void)data; (void)item; if (GetSpur()) SetSpur(0); else SetSpur(1); // must be 0 or 1 !!!! menu_move_back(); ui_mode_normal(); draw_cal_status(); } static void menu_storage_cb(int item, uint8_t data) { (void)data; switch(item) { case 0: SetStorage(); break; case 1: SetClearStorage(); break; case 2: SetSubtractStorage(); break; case 3: toggle_waterfall(); break; } menu_move_back(); ui_mode_normal(); draw_cal_status(); } static void menu_average_cb(int item, uint8_t data) { (void)data; SetAverage(item); menu_move_back(); ui_mode_normal(); draw_cal_status(); } static void menu_marker_type_cb(int item, uint8_t data) { (void)data; if (markers[active_marker].enabled) { if (item == M_REFERENCE) { for (int i = 0; i= 10 && n < 9; n++) x /= 10; uistat.digit = n; } // uistat.previous_value = uistat.value; } static void set_numeric_value(void) { switch (keypad_mode) { case KM_START: set_sweep_frequency(ST_START, uistat.value); break; case KM_STOP: set_sweep_frequency(ST_STOP, uistat.value); break; case KM_CENTER: set_sweep_frequency(ST_CENTER, uistat.value); break; case KM_SPAN: set_sweep_frequency(ST_SPAN, uistat.value); break; case KM_CW: set_sweep_frequency(ST_CW, uistat.value); break; case KM_SCALE: set_trace_scale(0, uistat.value / 1000.0); set_trace_scale(1, uistat.value / 1000.0); set_trace_scale(2, uistat.value / 1000.0); break; case KM_REFPOS: set_trace_refpos(0, NGRIDY - uistat.value / get_trace_scale(0)); set_trace_refpos(1, NGRIDY - uistat.value / get_trace_scale(0)); set_trace_refpos(2, NGRIDY - uistat.value / get_trace_scale(0)); break; case KM_ATTENUATION: SetAttenuation(uistat.value); break; case KM_ACTUALPOWER: SetPowerLevel(uistat.value); config_save(); break; case KM_IF: frequency_IF = uistat.value; config_save(); break; case KM_SAMPLETIME: settingSpeed = uistat.value; break; case KM_DRIVE: settingDrive = uistat.value; break; } }