How to split huge float to 8bit bytes?
Then write/read it to EERPOM
Thank you, how EEPROM is splitting it?
Why care? A float is 4 bytes stored in sequence at the address specified.
I want to write a parser to do the same splitting for GPS coordinates.
That's the code from EEPROM:
template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
const byte* p = (const byte*)(const void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
EEPROM.write(ee++, *p++);
return i;
}
template <class T> int EEPROM_readAnything(int ee, T& value)
{
byte* p = (byte*)(void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
}
Hot does it know the size when reading - it can be a short string as "Hello world" or it can be "really long string ..."
From example it says char[10], probably unlimited string is not supported.
Are you saying 4 bytes is enough to split any float value?
kapelan:
Are you saying 4 bytes is enough to split any float value?
A float is 4 bytes.