From 233b98aa0594cb2240a7d61da99e13587d95a73a Mon Sep 17 00:00:00 2001 From: Bodmer Date: Fri, 23 Apr 2021 16:51:18 +0100 Subject: [PATCH] Implement UTF8 switch #1108 --- TFT_eSPI.cpp | 15 +++++++-------- TFT_eSPI.h | 2 +- library.json | 2 +- library.properties | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index 048e966..1164b51 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -3730,14 +3730,14 @@ uint8_t TFT_eSPI::getAttribute(uint8_t attr_id) { ** Function name: decodeUTF8 ** Description: Serial UTF-8 decoder with fall-back to extended ASCII *************************************************************************************x*/ -#define DECODE_UTF8 // Test only, comment out to stop decoding uint16_t TFT_eSPI::decodeUTF8(uint8_t c) { -#ifdef DECODE_UTF8 + if (!_utf8) return c; + // 7 bit Unicode Code Point if ((c & 0x80) == 0x00) { decoderState = 0; - return (uint16_t)c; + return c; } if (decoderState == 0) { @@ -3754,7 +3754,7 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t c) return 0; } // 21 bit Unicode Code Point not supported so fall-back to extended ASCII - // if ((c & 0xF8) == 0xF0) return (uint16_t)c; + // if ((c & 0xF8) == 0xF0) return c; } else { if (decoderState == 2) { @@ -3770,9 +3770,8 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t c) } decoderState = 0; -#endif - return (uint16_t)c; // fall-back to extended ASCII + return c; // fall-back to extended ASCII } @@ -3785,7 +3784,8 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining) uint16_t c = buf[(*index)++]; //Serial.print("Byte from string = 0x"); Serial.println(c, HEX); -#ifdef DECODE_UTF8 + if (!_utf8) return c; + // 7 bit Unicode if ((c & 0x80) == 0x00) return c; @@ -3801,7 +3801,6 @@ uint16_t TFT_eSPI::decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining) // 21 bit Unicode not supported so fall-back to extended ASCII // if ((c & 0xF8) == 0xF0) return c; -#endif return c; // fall-back to extended ASCII } diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 30f69d6..55df84a 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.3.65" +#define TFT_ESPI_VERSION "2.3.66" // Bit level feature flags // Bit 0 set: viewport capability diff --git a/library.json b/library.json index b425e41..6cd8b14 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.3.65", + "version": "2.3.66", "keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, 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 6651639..3e16fc0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.3.65 +version=2.3.66 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32