Hello,
I'm working with a display that accepts char messages like this:
uint8_t xpos = 0;
uint8_t ypos = 1;
char[8] theMessage = "";
uint16_t value = 1000;
//****** Convert value to Char
ltoa (value,theMessage,10);
DOG.string(xpos, ypos, font_16x32nums, theMessage);
DOG.string(xpos, 11, font_16x32nums, "unit");
Now the problem is when i print out something the lines of the display look like this
**********
999 unit
1 unit
**********
this looks very bad, i would have to be the resprective digits fixed like:
**********
999 unit
10 unit
1 unit
**********
for this i created function
if(value <100){
ypos = 1;
}
if (value <10){
ypos = 2;
}
which works, but sadly this thing is font dependend. The positions for a new characters are different for each display font ( 8x8, 8x6, 8x16, 16x16) and are line depending. So this function is needed to be individual for each value print.
Is there any way to do this in a neutral way like you can do with float?
if i convert a float to a string, its lenght is fixed by setting the lenght:
float test = 3.141;
float test2 = 13.141;
char theMessage[8];
dtostrf(test, 5,3, theMessage); //char will be 3.141
dtostrf(test, 5,2, theMessage); //char will be 13.14
but sadly ITOA does not provide this...
Any work around?