I have my age and I have a hard time absorbing knowledge. And quite a lot of things I don't understand yet. Forgive my questions, maybe simple for some people, but I never studied programming or electronics in school;)
But to the point. I found a library
https://github.com/khoih-prog/FlashStorage_STM32
And I would like to use it, I would like to read the position from gps and save it to the emulated eeprom memory.
For this example, I hard-coded the coordinates of three capital cities.
My question is. I have a Stm32F411 and I would like it to write data to my memory. What value should I enter for my STM32 in this field?
const int WRITTEN_SIGNATURE = 0xBEEFDEED; Suppose I would like 50% for the code and the other 50% for "eeprom".
The second question is how to correctly save these three state capitals to my eeprom virtual memory.
I used the example from put () but maybe just write () is enough ??
https://github.com/khoih-prog/FlashStor ... _write.ino
Ultimately, I would like to have 10 GPS points to be able to save and read them.
Thank you in advance for your help
My anti-code

Code: Select all
// Demonstrate how to use FlashStorage_STM32 with an API that is similar to the EEPROM library to Store and retrieve structured data.
#include <FlashStorage_STM32.h>
const int WRITTEN_SIGNATURE = 0xBEEFDEED;
float lat1 = 52,211233;
float lon1 = 4,532122;
float lat2 = 38,024321;
float lon2 = 23,443456;
float lat3 = 38,024321;
float lon3 = 23,443456;
// Create a structure that is big enough to contain a lat
// and a long. The "valid" variable is set to "true" once
// the structure is filled with actual data for the first time.
typedef struct
{
char lat[10];
char lon[10];
} Capitals;
void setup()
{
Serial.begin(115200);
while (!Serial);
delay(200);
// Check signature at address 0
int signature;
// Create a "Capitals" variable and call it "owner"
uint16_t storedAddress = 0;
Capitals owner;
EEPROM.get(storedAddress, signature);
// If the EEPROM is empty then no WRITTEN_SIGNATURE
if (signature != WRITTEN_SIGNATURE)
{
Serial.println("EEPROM is empty, writing WRITTEN_SIGNATURE and some example data:");
EEPROM.put(storedAddress, WRITTEN_SIGNATURE);
// ...in this case we ask for user data.
Serial.setTimeout(30000);
Serial.print("Insert your lat : ");
String lat = Serial.readStringUntil('\n');
Serial.println(lat);
Serial.print("Insert your long : ");
String long = Serial.readStringUntil('\n');
Serial.println(long);
// Fill the "owner" structure with the data entered by the user...
lat.toCharArray(owner.lat, 100);
long.toCharArray(owner.long, 100);
// ...and finally save everything into emulated-EEPROM
EEPROM.put(storedAddress + sizeof(signature), owner);
// Print a confirmation of the data inserted.
Serial.print("<< Your lat: "); Serial.print(owner.lat);
Serial.print(". Your long: "); Serial.print(owner.long);
Serial.println(" >> have been saved. Thank you!");
}
}
void loop()
{
// Do nothing...
}