RobTillaart/FRAM_I2C

add readObject, writeObject APIs

WestfW opened this issue · 6 comments

You should steal implement the readObject and writeObject methods from Adafruits FRAM_I2C library, only implementing them properly with the multibyte read and write primitives you already have.
See https://forum.arduino.cc/t/re-fast-data-logging-using-fram/968962/25

Thanks for the issue, will look into this later this week.

@WestfW
Created a new branch - https://github.com/RobTillaart/FRAM_I2C/tree/develop

added two template functions:

  • uint16_t writeObject(uint16_t memaddr, T &obj) writes an object to memaddr (and following bytes). Returns memaddr + sizeof(obj) to get the next address to write to.
  • uint16_t readObject(uint16_t memaddr, T &obj) reads an object from memaddr and next bytes. Returns memaddr + sizeof(obj) to get the next address to read from.

Please verify

update:
Found an FRAM so I tested the new functions with 3 example sketches and all seems to work as intended.

(I don't actually have an FRAM to confirm with. Issues was submitted based on the forum conversation.)

Thanks, as my tests showed no problems I will merge later today.

Merged - 0.3.4