diff --git a/main.c b/main.c index eb360be..8252e5e 100644 --- a/main.c +++ b/main.c @@ -2686,15 +2686,19 @@ int main(void) if (has_new_switch) config.switch_offset = -5.0; #endif - if(config_recall()) { - clear_backup(); + int reset_state = btn_side(); + + if (!reset_state) { + if(config_recall()) { + clear_backup(); + } } config.cor_am = 0; // Should be removed from config config.cor_nfm = 0; config.cor_wfm = 0; ili9341_flip(config.flip); - if (caldata_recall(0) == -1) { + if (reset_state || caldata_recall(0) == -1) { load_LCD_properties(); } #ifdef __ULTRA__ @@ -2738,11 +2742,11 @@ int main(void) sweep(false); #endif - if (caldata_recall(0) == -1) { + if (reset_state|| (caldata_recall(0) == -1)) { load_LCD_properties(); } ui_mode_normal(); - if (!(config._mode & _MODE_DONT_SAVE_STATE)) { + if ((!reset_state) && !(config._mode & _MODE_DONT_SAVE_STATE) ) { backup_t b; uint32_t *f = &backup; uint32_t *t = (uint32_t *)&b; diff --git a/nanovna.h b/nanovna.h index 36d928f..0ef510e 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1479,6 +1479,7 @@ void refresh_sweep_menu(int i); void save_to_sd(int mask); void drawMessageBox(const char *header, char *text, uint32_t delay); bool isFullScreenMode(void); +int btn_side(void); // Irq operation process set #define OP_NONE 0x00 diff --git a/ui.c b/ui.c index 01b13d7..c9961ab 100644 --- a/ui.c +++ b/ui.c @@ -173,6 +173,14 @@ bool isFullScreenMode(void) { #endif } +int btn_side(void) +{ + uint16_t cur_button = READ_PORT() & BUTTON_MASK; + if (cur_button & (1<