diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index e5562de..c864c49 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -5105,6 +5105,7 @@ int16_t TFT_eSPI::drawFloat(float floatNumber, uint8_t dp, int32_t poX, int32_t uint8_t ptr = 0; // Initialise pointer for array int8_t digits = 1; // Count the digits to avoid array overflow float rounding = 0.5; // Round up down delta + bool negative = false; if (dp > 7) dp = 7; // Limit the size of decimal portion @@ -5116,10 +5117,16 @@ int16_t TFT_eSPI::drawFloat(float floatNumber, uint8_t dp, int32_t poX, int32_t str[ptr] = 0; // Put a null in the array as a precaution digits = 0; // Set digits to 0 to compensate so pointer value can be used later floatNumber = -floatNumber; // Make positive + negative = true; } floatNumber += rounding; // Round up or down + if (dp == 0) { + if (negative) floatNumber = -floatNumber; + return drawNumber((long)floatNumber, poX, poY, font); + } + // For error put ... in string and return (all TFT_eSPI library fonts contain . character) if (floatNumber >= 2147483647) { strcpy(str, "..."); diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 30375c0..a7d894b 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.4.38" +#define TFT_ESPI_VERSION "2.4.39" // Bit level feature flags // Bit 0 set: viewport capability diff --git a/library.json b/library.json index dab10c3..cd13512 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.4.38", + "version": "2.4.39", "keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D", "description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32", "repository": diff --git a/library.properties b/library.properties index 2d0672c..c74ca83 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.4.38 +version=2.4.39 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32