gettextbound for float variable? GFX lib.

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
analographi
 
Posts: 101
Joined: Sat Oct 14, 2006 8:15 am

gettextbound for float variable? GFX lib.

Post by analographi »

Hi

I'm using a EPD (2.7" from Adafruit). But I think it is about the GFX Library.

I have variable "Temperature" which comes as a float value

From the GFX Library I use:

Code: Select all

    display.setCursor(20 -  display.getTextBounds(String(Temperature)) / 2 , 20);
    display.print(Temperature, 1);



With that I want to center the value on the EPD Display

It's completely off. Like by 50 pixels or so.

But, if I do:

Code: Select all

int TemperatureInt = Temperature;
    display.setCursor(20 -  display.getTextBounds(String(TemperatureInt)) / 2 , 20);
    display.print(TemperatureInt, 0);


It's spot on in the center.

So it seems to be a problem with the float variable.

Do I use it wrong, or is it a limitation in the library?

Thank you for your time.

I use the GFX version 1.8.5. Why so old?
See other post:
Because I tried 1.10.12 and the EPD display only prints in red, not black. Also the examples of Adafruit for the EPD do that. My EPD Lib is 4.4.2

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”