diff --git a/src/helpers/ui/DisplayDriver.h b/src/helpers/ui/DisplayDriver.h index 6c1e3fc7..0dbe3b47 100644 --- a/src/helpers/ui/DisplayDriver.h +++ b/src/helpers/ui/DisplayDriver.h @@ -54,60 +54,67 @@ public: // convert UTF-8 characters to displayable block characters for compatibility virtual void translateUTF8ToBlocks(char* dest, const char* src, size_t dest_size) { size_t j = 0; -#ifdef OLED_RU - char last_char = 0; - char cc = 0; -#endif + #ifdef OLED_RU + char last_char = 0; + char cc = 0; + #endif for (size_t i = 0; src[i] != 0 && j < dest_size - 1; i++) { unsigned char c = (unsigned char)src[i]; if (c >= 32 && c <= 126) { -#ifdef OLED_RU + #ifdef OLED_RU last_char = 0; dest[j++] = c; // ASCII printable - } else if (last_char == 0 && (c == 0xD0 || c == 0xD1 || c == 0xD2)) { // Cyrillic UTF-8 start byte for 2 bytes sequence + } else if (c == 0xC2 || c == 0xC3 || c == 0xD0 || c == 0xD1 || c == 0xD2) { // Cyrillic UTF-8 convert last_char = c; - } else if (last_char > 0) { // Cyrillic UTF-8 next byte - cc = 0; // Translated charcode - switch (last_char) { - // map UTF-8 cyrillic chars to it CP-1251 ASCII codes - case 0xD0: { - if (c == 132) - cc = (170); // Є - if (c == 134) - cc = (178); // І - if (c == 135) - cc = (175); // Ї - if (c == 129) - cc = (168); // Ё - if (c > 143 && c < 192) - cc = (c + 48); - break; + c = src[++i]; // Get next char + + if (c != 0) { // Not end of a string + switch (last_char) { + case 0xC3: { + cc = (c | 0xC0); + break; + } + // map UTF-8 cyrillic cars to it Windows-1251 (CP-1251) ASCII codes + case 0xD0: { + if (c == 132) + cc = (170); // Є + if (c == 134) + cc = (178); // І + if (c == 135) + cc = (175); // Ї + if (c == 129) + cc = (168); // Ё + if (c > 143 && c < 192) + cc = (c + 48); + break; + } + case 0xD1: { + if (c == 148) + cc = (186); // є + if (c == 150) + cc = (179); // і + if (c == 151) + cc = (191); // ї + if (c == 145) + cc = (184); // ё + if (c > 127 && c < 144) + cc = (c + 112); + break; + } + case 0xD2: { + if (c == 144) + cc = (165); // Ґ + if (c == 145) + cc = (180); // ґ + break; + } } - case 0xD1: { - if (c == 148) - cc = (186); // є - if (c == 150) - cc = (179); // і - if (c == 151) - cc = (191); // ї - if (c == 145) - cc = (184); // ё - if (c > 127 && c < 144) - cc = (c + 112); - break; - } - case 0xD2: { - if (c == 144) - cc = (165); // Ґ - if (c == 145) - cc = (180); // ґ - break; - } - } - if (cc > 0) { - dest[j++] = cc; - } - last_char = 0; + if (cc > 0) { + dest[j++] = cc; + } else { + dest[j++] = '\xAE'; // CP1251 smile emoji replace + } + } } else if (c >= 0x80) { last_char = 0; dest[j++] = '\xAE'; // CP1251 smile emoji replace @@ -162,4 +169,4 @@ public: } virtual void endFrame() = 0; -}; \ No newline at end of file +}; diff --git a/src/helpers/ui/SSD1306Display.cpp b/src/helpers/ui/SSD1306Display.cpp index faede378..4c3b302c 100644 --- a/src/helpers/ui/SSD1306Display.cpp +++ b/src/helpers/ui/SSD1306Display.cpp @@ -117,4 +117,4 @@ uint16_t SSD1306Display::getTextWidth(const char* str) { void SSD1306Display::endFrame() { display.display(); -} \ No newline at end of file +} diff --git a/src/helpers/ui/ST7735Display.cpp b/src/helpers/ui/ST7735Display.cpp index 344f5b1d..14c4bb84 100644 --- a/src/helpers/ui/ST7735Display.cpp +++ b/src/helpers/ui/ST7735Display.cpp @@ -1,4 +1,7 @@ #include "ST7735Display.h" +#ifdef OLED_RU + #include "glcdfont6x8.h" +#endif //#include @@ -418,14 +421,14 @@ bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) { #endif // Color scheme -ColorVal UIColor::window_bkg = ST77XX_WHITE; +ColorVal UIColor::window_bkg = ST77XX_BLACK; ColorVal UIColor::title_bkg = ST77XX_BLUE; ColorVal UIColor::title_txt = ST77XX_WHITE; -ColorVal UIColor::primary_txt = ST77XX_BLACK; +ColorVal UIColor::primary_txt = ST77XX_WHITE; ColorVal UIColor::secondary_txt = (18 << 11) | (36 << 5) | 18; // mid-gray ColorVal UIColor::warning_txt = ST77XX_ORANGE; ColorVal UIColor::popup_bkg = ST77XX_CYAN; -ColorVal UIColor::popup_txt = ST77XX_BLACK; +ColorVal UIColor::popup_txt = ST77XX_WHITE; ColorVal UIColor::corp_blue = 0x001A; bool ST7735Display::begin() { @@ -542,12 +545,23 @@ void ST7735Display::startFrame(ColorVal bkg) { sprite->fillScreen(bkg); sprite->setTextColor(curr_color = UIColor::primary_txt); sprite->setFreeFont(); + #ifdef OLED_RU + sprite->setFreeFont(&glcdfont6x8); + #endif sprite->setTextSize(1); // This one affects size of Please wait... message //sprite->cp437(true); // Use full 256 char 'Code Page 437' font + sprite->setAttribute(CP437_SWITCH, true); + sprite->setAttribute(UTF8_SWITCH, false); + #ifdef OLED_RU + sprite->setCursor(0, 7); + #endif } void ST7735Display::setTextSize(int sz) { sprite->setTextSize(sz); + #ifdef OLED_RU + _size = sz; + #endif } void ST7735Display::setColor(ColorVal c) { @@ -556,7 +570,11 @@ void ST7735Display::setColor(ColorVal c) { } void ST7735Display::setCursor(int x, int y) { - sprite->setCursor(x*SCALE_X, y*SCALE_Y); + #ifdef OLED_RU + sprite->setCursor(x*SCALE_X, y*SCALE_Y + (_size * 7)); + #else + sprite->setCursor(x*SCALE_X, y*SCALE_Y); + #endif } void ST7735Display::print(const char* str) { diff --git a/src/helpers/ui/ST7735Display.h b/src/helpers/ui/ST7735Display.h index 6e289b21..368849bc 100644 --- a/src/helpers/ui/ST7735Display.h +++ b/src/helpers/ui/ST7735Display.h @@ -9,6 +9,9 @@ class ST7735Display : public DisplayDriver { bool _isOn; RefCountedDigitalPin* _peripher_power; +#ifdef OLED_RU + uint8_t _size; +#endif bool i2c_probe(TwoWire& wire, uint8_t addr); public: diff --git a/variants/heltec_t096/platformio.ini b/variants/heltec_t096/platformio.ini index 02e88328..333677f3 100644 --- a/variants/heltec_t096/platformio.ini +++ b/variants/heltec_t096/platformio.ini @@ -10,6 +10,7 @@ build_flags = ${nrf52_base.build_flags} -I src/helpers/ui -D HELTEC_T096 -D NRF52_POWER_MANAGEMENT + -D OLED_RU=1 -D P_LORA_DIO_1=21 -D P_LORA_NSS=5 -D P_LORA_RESET=16 diff --git a/variants/heltec_v3/platformio.ini b/variants/heltec_v3/platformio.ini index 65e636eb..b4c6cb9e 100644 --- a/variants/heltec_v3/platformio.ini +++ b/variants/heltec_v3/platformio.ini @@ -6,6 +6,7 @@ build_flags = ${sensor_base.build_flags} -I variants/heltec_v3 -D HELTEC_LORA_V3 + -D OLED_RU=1 -D ESP32_CPU_FREQ=80 -D P_LORA_DIO_1=14 -D P_LORA_NSS=8 diff --git a/variants/heltec_v4/platformio.ini b/variants/heltec_v4/platformio.ini index e7711a8a..f67a61ba 100644 --- a/variants/heltec_v4/platformio.ini +++ b/variants/heltec_v4/platformio.ini @@ -6,8 +6,8 @@ build_flags = ${sensor_base.build_flags} -I variants/heltec_v4 -D HELTEC_LORA_V4 - -D USE_SX1262 -D OLED_RU=1 + -D USE_SX1262 -D ESP32_CPU_FREQ=80 -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper @@ -188,7 +188,6 @@ build_flags = -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 -D DISPLAY_CLASS=SSD1306Display - -D OLED_RU=1 -D ENABLE_USB_INTERFACE ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 @@ -213,7 +212,6 @@ build_flags = -D AUTO_SHUTDOWN_MILLIVOLTS=3400 -D BLE_DEBUG_LOGGING=1 -D OFFLINE_QUEUE_SIZE=256 - -D OLED_RU=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${heltec_v4_oled.build_src_filter} diff --git a/variants/promicro/platformio.ini b/variants/promicro/platformio.ini index 90cb475f..4660c06b 100644 --- a/variants/promicro/platformio.ini +++ b/variants/promicro/platformio.ini @@ -5,6 +5,7 @@ build_flags = ${nrf52_base.build_flags} -I variants/promicro -D PROMICRO -D USE_SX1262 + -D OLED_RU=1 -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22