Hi, I want ask community for solution of my problem. I have saved values as HEX in EEPROM, but I didnt find way, how to get it as HEX, everytime was translated as DEC. Please, kan you kick me, where I do mistake? Thanx.
If I fill manually to line "for (byte k = 0; k < strlen_P(buf); k++) {`" - buf as direct HEX i.e. DD, AD, DF, A9, then it did working. So, main problem I have, that script read from EEPROM and interpret saved HEX code as DEC.
All data is saved to EEPROM as bytes, it is how you interpret them that makes them decimal, hex, binary etc
Are you asking how to save data to EEPROM as a string (lowercase s) that represents the data as hex and then read the string back and convert it to decimal ?
In the EEPROM I have next content, F7B9EFCBCEBEC9DECECEBEC9D9A8CEF7.....
And I want read by byte, as F7 - B9 - EF - CB - CE - BE.....
But, I didnt find way, how to get it as HEX format. Reading return DEC format as 247 - 185 - 239 - 203...
I mean, the problem is, how to read as HEX, because when I put straight HEX symbol, like F7, then it did continue as I wanted.
I have saved shortcuts to PROGMEM adress, const char DD[] PROGMEM = "ADVANCING";
const char DE[] PROGMEM = "AUTOMATIC";
const char DF[] PROGMEM = "BACKWARD";
const char EA[] PROGMEM = "BEFORE";"
And I want by reading from EEPROM sequence, which saved text in PROGMEM, will be send to display, I want make a sentences from five bytes - address. F7 - first word, B9 - second word, ....
I specifying what I think would be the solution for me.
[code] EEPROM.get(dis + 1, data);
for (byte k = 0; k < strlen_P((data)); k++) {
char myChar = pgm_read_byte_near((data) + k);
Serial.print(myChar);
} [/code ]
Here script read "data" from eeprom as decimal, so result is bad, if I will read here as hexa, it will be working perfect, if I did put instead variable "data" - direct symbols "F9" - then it did continue as I want.
Or, how to achieve, that output which I did read from eeprom, will be HEX and not DEC as I get now.
I did write shortcuts to EEPROM, because I have only 1kB SRAM, and have not space for OLED RAM.
The reason is to move data from sram to eeprom, due to small ram size.
If you have any idea, how to save to eeprom as decimal, I will glad, when you explain me.
I did saved to EEPROM by external editor, content I did explain in communication above.
CRC and another about is ok. If I will read directly from each addressess and then print as HEXC, it is everything correct. But as I wrote, I don't know how to get as HEX and then put to strlen_P function. If use serial.print (blbla, HEX) it did display same values as I have saved in eeprom.
@MiroSmet : That is the point you obviously don't understand. In the end everything you store - whether eprom, sram or flash is stored as a binary pattern. The difference is in the end who you interpret it when printing it e.g. with Serial.print.