diff --git a/main.c b/main.c index 9bb3b95..62250fb 100644 --- a/main.c +++ b/main.c @@ -118,6 +118,10 @@ static THD_FUNCTION(Thread1, arg) (void)arg; chRegSetThreadName("sweep"); +#ifdef __SD_CARD_LOAD__ + sd_card_load_config("autoload.ini"); +#endif + #ifndef TINYSA4 ui_process(); #endif @@ -241,10 +245,12 @@ toggle_sweep(void) int shell_printf(const char *fmt, ...) { va_list ap; - int formatted_bytes; - va_start(ap, fmt); - formatted_bytes = chvprintf(shell_stream, fmt, ap); - va_end(ap); + int formatted_bytes = 0; + if (shell_stream) { + va_start(ap, fmt); + formatted_bytes = chvprintf(shell_stream, fmt, ap); + va_end(ap); + } return formatted_bytes; } @@ -2024,6 +2030,9 @@ void sd_card_load_config(char *filename){ if (f_open(fs_file, filename, FA_OPEN_EXISTING | FA_READ) != FR_OK) return; + BaseSequentialStream *old_shell_stream = shell_stream; + shell_stream = (BaseSequentialStream *)NULL; + char *buf = (char *)spi_buffer; UINT size = 0; @@ -2052,6 +2061,7 @@ void sd_card_load_config(char *filename){ } } f_close(fs_file); + shell_stream = old_shell_stream; return; } #endif @@ -2272,10 +2282,6 @@ int main(void) chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL); -#ifdef __SD_CARD_LOAD__ - sd_card_load_config("config.ini"); -#endif - while (1) { // if (SDU1.config->usbp->state == USB_ACTIVE) { if (shell_check_connect()) { diff --git a/ui_sa.c b/ui_sa.c index 06ce952..4e48454 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -790,7 +790,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_store_preset_acb) UI_FUNCTION_CALLBACK(menu_load_config_cb) { (void)item; - sd_card_load_config((data?"config.ini":"setting.ini")); + sd_card_load_config("config.ini"); ui_mode_normal(); } #endif @@ -2518,7 +2518,7 @@ static const menuitem_t menu_settings4[] = #endif #ifdef __SD_CARD_LOAD__ { MT_CALLBACK, 0 , "LOAD\nCONFIG.INI", menu_load_config_cb}, - { MT_CALLBACK, 1 , "LOAD\nSETTING.INI", menu_load_config_cb}, +// { MT_CALLBACK, 1 , "LOAD\nSETTING.INI", menu_load_config_cb}, #endif { MT_CALLBACK, 0 , "CLEAR\nCONFIG", menu_clearconfig_cb}, #ifdef __HARMONIC__