From c5ba901ed8826a30dc67c124e55b57386b9df57a Mon Sep 17 00:00:00 2001 From: barry-ha Date: Mon, 12 Feb 2024 19:24:33 -0800 Subject: [PATCH] fixed save/restore NMEA sentences --- cfg_nmea.h | 9 ++++++--- cfg_rotation.h | 2 +- cfg_volume.h | 4 ++-- save_restore.cpp | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cfg_nmea.h b/cfg_nmea.h index f54ea83..ee03fd2 100644 --- a/cfg_nmea.h +++ b/cfg_nmea.h @@ -101,17 +101,19 @@ class ViewCfgNMEA : public View { // label origin size touch-target // text x,y w,h x,y w,h radius color functionID {"Send NMEA", xButton, yButton1, 150, 40, {130, yButton1, 184, 50}, 4, cVALUE, eSTART_NMEA}, - {"None", xButton, yButton2, 150, 40, {130, yButton2, 184, 60}, 4, cVALUE, eSTOP_NMEA}, + {"No report", xButton, yButton2, 150, 40, {130, yButton2, 184, 60}, 4, cVALUE, eSTOP_NMEA}, }; // clang-format on // ---------- local functions for this derived class ---------- void fStartNMEA() { + selectedOption = SEND_NMEA; start_nmea(); // start sending nmea sentences this->updateScreen(); } void fStopNMEA() { + selectedOption = SILENT; stop_nmea(); // stop nmea this->updateScreen(); } @@ -230,8 +232,8 @@ void ViewCfgNMEA::loadConfig() { // resource-heavy functions like updateScreen() SaveRestore config(NMEA_CONFIG_FILE, NMEA_CONFIG_VERSION); - byte tempOption; - int result = config.readConfig((byte *)&tempOption, sizeof(tempOption)); + int tempOption = 0; + int result = config.readConfig((byte *)&tempOption, sizeof(tempOption)); if (result) { switch (tempOption) { case SEND_NMEA: @@ -262,6 +264,7 @@ void ViewCfgNMEA::loadConfig() { // ----- save to SDRAM ----- void ViewCfgNMEA::saveConfig() { SaveRestore config(NMEA_CONFIG_FILE, NMEA_CONFIG_VERSION); + logger.info("Saving value: %d", selectedOption); int rc = config.writeConfig((byte *)&selectedOption, sizeof(selectedOption)); logger.info("Finished ViewCfgRotation::saveConfig(%d) with rc = %d", selectedOption, rc); // debug } diff --git a/cfg_rotation.h b/cfg_rotation.h index 8808bf9..e928a48 100644 --- a/cfg_rotation.h +++ b/cfg_rotation.h @@ -186,7 +186,7 @@ void ViewCfgRotation::startScreen() { tft->drawCircle(xCenter, yCenter, 7, cVALUE); } - showProgressBar(6, 7); // draw marker for advancing through settings + showProgressBar(7, 7); // draw marker for advancing through settings updateScreen(); // update UI immediately, don't wait for laggy mainline loop } // end startScreen() diff --git a/cfg_volume.h b/cfg_volume.h index a255f10..d1894f3 100644 --- a/cfg_volume.h +++ b/cfg_volume.h @@ -320,8 +320,8 @@ bool ViewVolume::onTouch(Point touch) { // ----- load from SDRAM ----- void ViewVolume::loadConfig() { SaveRestore config(VOLUME_CONFIG_FILE, CONFIG_VOLUME_VERSION); - int tempVolIndex; - int result = config.readConfig((byte *)&tempVolIndex, sizeof(tempVolIndex)); + int tempVolIndex = 0; + int result = config.readConfig((byte *)&tempVolIndex, sizeof(tempVolIndex)); if (result) { gVolIndex = constrain(tempVolIndex, 0, 10); // global volume index setVolume(gVolIndex); // set the hardware to this volume index diff --git a/save_restore.cpp b/save_restore.cpp index 041e5e0..6037463 100644 --- a/save_restore.cpp +++ b/save_restore.cpp @@ -77,7 +77,7 @@ int SaveRestore::deleteFile(const char *vFilename) { int SaveRestore::readConfig(byte *pData, const unsigned int sizeData) { // returns 1=success, 0=failure int result = 1; // assume success - logger.info("Starting to read config from SDRAM..."); + logger.info("Reading config from SDRAM..."); logger.info(". ", fqFilename); result = openFlash(); // open file system and report errors @@ -137,6 +137,7 @@ int SaveRestore::readConfig(byte *pData, const unsigned int sizeData) { } logger.info(". Data length: %d", sizeData); + // logger.info(". Data value: %d", *pData); // close files and clean up readFile.close();