From 90b9045a909fa788ea3cfab071c7551b735cff16 Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Wed, 25 Feb 2026 22:19:44 +1100 Subject: [PATCH] contacts export function - save to SD card from contacts screen with toaster pop up confimation once completed --- examples/companion_radio/main.cpp | 25 +++++++++++++++---- .../companion_radio/ui-new/Contactsscreen.h | 8 +++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index fd03ac2..9473047 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1786,14 +1786,22 @@ void handleKeyboardInput() { // Export contacts to SD card (contacts screen only) if (ui_task.isOnContactsScreen()) { Serial.println("Contacts: Exporting to SD..."); + // Show "working" toaster immediately (force e-ink render before blocking SD I/O) + ui_task.showAlert("Exporting to SD...", 10000); + ui_task.forceRefresh(); + ui_task.loop(); // immediate render so user sees the popup + int exported = exportContactsToSD(); + + // Update toaster with result if (exported >= 0) { char alertBuf[48]; snprintf(alertBuf, sizeof(alertBuf), "Exported %d to SD", exported); - ui_task.showAlert(alertBuf, 2000); + ui_task.showAlert(alertBuf, 2500); } else { - ui_task.showAlert("Export failed (no SD?)", 2000); + ui_task.showAlert("Export failed (no SD?)", 2500); } + ui_task.forceRefresh(); } break; @@ -1801,9 +1809,15 @@ void handleKeyboardInput() { // Import/merge contacts from SD backup (contacts screen only) if (ui_task.isOnContactsScreen()) { Serial.println("Contacts: Importing from SD..."); + // Show "working" toaster immediately (force e-ink render before blocking SD I/O) + ui_task.showAlert("Importing from SD...", 10000); + ui_task.forceRefresh(); + ui_task.loop(); // immediate render so user sees the popup + int added = importContactsFromSD(); + + // Update toaster with result if (added > 0) { - // Invalidate the contacts screen cache so it rebuilds ContactsScreen* cs2 = (ContactsScreen*)ui_task.getContactsScreen(); if (cs2) cs2->invalidateCache(); char alertBuf[48]; @@ -1811,10 +1825,11 @@ void handleKeyboardInput() { added, (int)the_mesh.getNumContacts()); ui_task.showAlert(alertBuf, 2500); } else if (added == 0) { - ui_task.showAlert("No new contacts to add", 2000); + ui_task.showAlert("No new contacts to add", 2500); } else { - ui_task.showAlert("Import failed (no backup?)", 2000); + ui_task.showAlert("Import failed (no backup?)", 2500); } + ui_task.forceRefresh(); } break; diff --git a/examples/companion_radio/ui-new/Contactsscreen.h b/examples/companion_radio/ui-new/Contactsscreen.h index 7a4123c..9f79da9 100644 --- a/examples/companion_radio/ui-new/Contactsscreen.h +++ b/examples/companion_radio/ui-new/Contactsscreen.h @@ -286,17 +286,17 @@ public: display.drawRect(0, footerY - 2, display.width(), 1); display.setColor(DisplayDriver::YELLOW); - // Left: Q:Bk X:Exp + // Left: Q:Back display.setCursor(0, footerY); - display.print("Q:Bk X:Exp"); + display.print("Q:Back"); // Center: A/D:Filter const char* mid = "A/D:Filtr"; display.setCursor((display.width() - display.getTextWidth(mid)) / 2, footerY); display.print(mid); - // Right: R:Imp W/S - const char* right = "R:Imp W/S"; + // Right: W/S:Scroll + const char* right = "W/S:Scrll"; display.setCursor(display.width() - display.getTextWidth(right) - 2, footerY); display.print(right);