Dirk- / NanoBLEFlashPrefs

Substitute for the missing EEPROM storage on Arduino Nano 33 BLE and BLE Sense.
GNU General Public License v2.0
16 stars 1 forks source link

Saving float array to flash #2

Closed rom-bek closed 2 years ago

rom-bek commented 2 years ago

Hi Dirk,

thank you for sharing your library, it work's fine! Is it also possible to save float arrays into structure (and values to flash) as defined here?

  // Preferences structure. Arbitrary, but must not exeed 1019 words (4076 byte)
  typedef struct flashStruct {
      float aaa;
          float bbb;
      float ccc[10];
          float ddd[20];
  } flashPrefs;
  ...

I tryed it, but writePrefs-operation is not successful, nano BLE is still hanging in the while loop. ;-)

  ...
  myFlashVariables.writePrefs(&flashVars, sizeof(flashVars));
  Serial.print("Writing data (" + String(sizeof(flashVars)) + " bytes) to flash ... ");
  while (!myFlashVariables.operationCompleted()) {
  }
  Serial.println("done.");
  ...

Thank you and best regards Roman

Dirk- commented 2 years ago

This should work. Did you delete the old prefs when you changed the structure? Maybe that is causing the problem.

rom-bek commented 2 years ago

Yes,

the reason was that the old prefs structure has not been deleted before I expanded it with float arrays. I didn' notice the corresponding uncommented section (myFlashPrefs.deletePrefs()) in your example file!

Thank you very much for your fast response! Roman