Hello! Thank you for your excellent library!
I slightly modified your example to highlight this strange behaviour:
sprintf( tmpString, "foo.a=%02d" , foo.a ); prints 26350 instead of 45
meanwhile
sprintf( tmpString, "foo.a=%02d" , uint8_t(foo.a) ); works well
=============================================
#include <EEPROM.h>
#include <EEWrap.h>
//Use the xxx_e types rather than the standard types like uint8_t
struct Foo{
uint8_e a;
int16_e b;
float_e c;
};
Foo foo EEMEM; //EEMEM tells the compiler that the object resides in the EEPROM
void setup(){
//Write to values stored in EEPROM
foo.a = 45;
foo.b = 12345;
foo.c = 3.1415;
//Print values from EEPROM
Serial.begin(9600);
Serial.println(foo.a);
Serial.println(foo.b);
Serial.println(foo.c);
char tmpString[20] = {0};
sprintf( tmpString, "foo.a=%02d" , foo.a );
Serial.println( tmpString ); // it prints " foo.a=26350 "
}
void loop() {}
Hello! Thank you for your excellent library!
I slightly modified your example to highlight this strange behaviour:
sprintf( tmpString, "foo.a=%02d" , foo.a ); prints 26350 instead of 45
meanwhile
sprintf( tmpString, "foo.a=%02d" , uint8_t(foo.a) ); works well
=============================================
#include <EEPROM.h>
#include <EEWrap.h>
//Use the xxx_e types rather than the standard types like uint8_t
struct Foo{
uint8_e a;
int16_e b;
float_e c;
};
Foo foo EEMEM; //EEMEM tells the compiler that the object resides in the EEPROM
void setup(){
//Write to values stored in EEPROM
foo.a = 45;
foo.b = 12345;
foo.c = 3.1415;
//Print values from EEPROM
Serial.begin(9600);
Serial.println(foo.a);
Serial.println(foo.b);
Serial.println(foo.c);
char tmpString[20] = {0};
sprintf( tmpString, "foo.a=%02d" , foo.a );
Serial.println( tmpString ); // it prints " foo.a=26350 "
}
void loop() {}