Skip to content

Commit

Permalink
fixed save/restore NMEA sentences
Browse files Browse the repository at this point in the history
  • Loading branch information
barry-ha committed Feb 13, 2024
1 parent 3264ce3 commit c5ba901
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions cfg_nmea.h
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion cfg_rotation.h
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions cfg_volume.h
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion save_restore.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c5ba901

Please sign in to comment.