Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USE_DUMMY_EEPROM = true gives compile errors #236

Open
anjok opened this issue Sep 29, 2023 · 0 comments
Open

USE_DUMMY_EEPROM = true gives compile errors #236

anjok opened this issue Sep 29, 2023 · 0 comments

Comments

@anjok
Copy link

anjok commented Sep 29, 2023

I had some issues with the EEPROM store and wanted to try the dummy store to double.check. Unfortunately it didn't compile. Here's what I did to get it to run.

stellarmate@astroberry:~/astro/OpenAstroTracker-Firmware $ git diff src/EPROMStore.cpp 
diff --git a/src/EPROMStore.cpp b/src/EPROMStore.cpp
index 37c5c22..52f6f49 100644
--- a/src/EPROMStore.cpp
+++ b/src/EPROMStore.cpp
@@ -1,9 +1,10 @@
 #include "inc/Globals.hpp"
+#include "../Configuration.hpp"
+#if USE_DUMMY_EEPROM == false
 PUSH_NO_WARNINGS
 #include <EEPROM.h>
 POP_NO_WARNINGS
-
-#include "../Configuration.hpp"
+#endif
 #include "Utility.hpp"
 #include "EPROMStore.hpp"
 
@@ -17,13 +18,15 @@ const float SteppingStorageNormalized = 25600.0;
 
 #if USE_DUMMY_EEPROM == true
 
-static uint8_t dummyEepromStorage[EEPROMStore::STORE_SIZE];
+static uint8_t *dummyEepromStorage;
 
 // Initialize the EEPROM object for ESP boards, setting aside storage
 void EEPROMStore::initialize()
 {
-    LOG(DEBUG_EEPROM, "[EEPROM]: Dummy: Startup with %d bytes", EEPROMStore::STORE_SIZE);
-    memset(dummyEepromStorage, 0, sizeof(dummyEepromStorage));
+    size_t size = EEPROMStore::STORE_SIZE;
+    dummyEepromStorage = (uint8_t *)malloc(size);
+    LOG(DEBUG_EEPROM, "[EEPROM]: Dummy: Startup with %d bytes", size);
+    memset(dummyEepromStorage, 0, size);
 
     displayContents();  // Will always be empty at restart
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant