lexus2k / lcdgfx

Driver for LCD displays running on Arduino/Avr/ESP32/Linux (including Rasperry) platforms
MIT License
377 stars 52 forks source link

displaying floating point numbers #42

Closed leobg closed 3 years ago

leobg commented 3 years ago

Ask any question, you have, regarding the library Appology for the newbie question, I am struggling to find way to display floating point number with lcdfgx, for example on serial you could do Serial.println(1.23456, 2) to get "1.23" displayed. I couldn't find anything in the demos I could use either. Any help will be greatly appreciated!

leobg commented 3 years ago

I should probably add I am trying to use this library with a DisplaySSD1306_128x64_I2C

krukhlis commented 3 years ago

I should probably add I am trying to use this library with a DisplaySSD1306_128x64_I2C

It doesn't metter which library you gonna use. Approach is the same -- first you convert using regular functions your numbers to String( here you specify formatting like rounding, number of digits after . , etc). And then you print this string using your graphics library of choice.

leobg commented 3 years ago

I should probably add I am trying to use this library with a DisplaySSD1306_128x64_I2C

It doesn't metter which library you gonna use. Approach is the same -- first you convert using regular functions your numbers to String( here you specify formatting like rounding, number of digits after . , etc). And then you print this string using your graphics library of choice.

Thanks @krukhlis, that's what I just actually ended up doing.