fix wifi & flash + eink screen on core 1, by using queue
This commit is contained in:
@@ -58,7 +58,7 @@ static bool execute_command(CommandAction action, const char* input) {
|
||||
if (parsed < 2) {
|
||||
printf("Usage: /connect <ssid> <password>\n");
|
||||
if (g_display_manager) g_display_manager->refresh("Usage: /connect <ssid> <pass>", nullptr);
|
||||
// epaper_send_update("Usage: /connect <ssid> <pass>", true);
|
||||
epaper_send_update("Usage: /connect <ssid> <pass>", true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,11 +67,18 @@ static bool execute_command(CommandAction action, const char* input) {
|
||||
|
||||
if (wifi_connect(ssid, password)) {
|
||||
if (g_display_manager) g_display_manager->refresh("Connected!", ssid);
|
||||
// epaper_send_update("Connected!", true);
|
||||
// wifi_save_credentials(ssid, password);
|
||||
int rc = wifi_save_credentials(ssid, password);
|
||||
if (rc != 0) {
|
||||
char err_msg[32];
|
||||
snprintf(err_msg, sizeof(err_msg), "Flash Error: %d", rc);
|
||||
if (g_display_manager) g_display_manager->refresh(err_msg, nullptr);
|
||||
epaper_send_update(err_msg, true);
|
||||
} else {
|
||||
epaper_send_update("Connected!", true);
|
||||
}
|
||||
} else {
|
||||
if (g_display_manager) g_display_manager->refresh("Connection Failed", nullptr);
|
||||
// epaper_send_update("Connection Failed", true);
|
||||
epaper_send_update("Connection Failed", true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -219,20 +226,13 @@ int main() {
|
||||
sleep_ms(3000); // Give time for power to settle and serial to connect
|
||||
printf("System Booting...\n");
|
||||
|
||||
// Launch display initialization on core 1
|
||||
// Launch display initialization on core 1, WIFI and Flash safe execute
|
||||
epaper_start_background_thread();
|
||||
|
||||
DisplayManager display;
|
||||
display.init();
|
||||
g_display_manager = &display;
|
||||
|
||||
if (wifi_try_auto_connect()) {
|
||||
display.refresh("WiFi Auto-Connected", nullptr);
|
||||
epaper_send_update("WiFi Auto-Connected", true);
|
||||
} else {
|
||||
display.refresh("Waiting for Keyboard", nullptr);
|
||||
}
|
||||
|
||||
printf("Initializing TinyUSB Host...\n");
|
||||
tuh_init(BOARD_TUH_RHPORT);
|
||||
printf("TinyUSB Host Initialized.\n");
|
||||
|
||||
Reference in New Issue
Block a user