русификация дисплеев: фикс конвертера CP1251, перевод в simple_*/ui-tiny, OLED_RU для ST7789LCD
Build and deploy Docs site to GitHub Pages / github-pages (push) Canceled after 0s
PR Build Check / build (Heltec_v3_companion_radio_ble) (push) Canceled after 0s
PR Build Check / build (Heltec_v3_repeater) (push) Canceled after 0s
PR Build Check / build (Heltec_v3_room_server) (push) Canceled after 0s
PR Build Check / build (LilyGo_Tlora_C6_repeater_) (push) Canceled after 0s
PR Build Check / build (PicoW_repeater) (push) Canceled after 0s
PR Build Check / build (RAK_4631_companion_radio_ble) (push) Canceled after 0s
PR Build Check / build (RAK_4631_companion_radio_ethernet) (push) Canceled after 0s
PR Build Check / build (RAK_4631_repeater) (push) Canceled after 0s
PR Build Check / build (RAK_4631_repeater_ethernet) (push) Canceled after 0s
PR Build Check / build (RAK_4631_room_server) (push) Canceled after 0s
PR Build Check / build (RAK_4631_room_server_ethernet) (push) Canceled after 0s
PR Build Check / build (Tbeam_SX1276_repeater) (push) Canceled after 0s
PR Build Check / build (wio-e5-mini_repeater) (push) Canceled after 0s
PR Build Check / build (wio_wm1110_repeater) (push) Canceled after 0s
Run Unit Tests / test (push) Canceled after 0s
Build and deploy Docs site to GitHub Pages / github-pages (push) Canceled after 0s
PR Build Check / build (Heltec_v3_companion_radio_ble) (push) Canceled after 0s
PR Build Check / build (Heltec_v3_repeater) (push) Canceled after 0s
PR Build Check / build (Heltec_v3_room_server) (push) Canceled after 0s
PR Build Check / build (LilyGo_Tlora_C6_repeater_) (push) Canceled after 0s
PR Build Check / build (PicoW_repeater) (push) Canceled after 0s
PR Build Check / build (RAK_4631_companion_radio_ble) (push) Canceled after 0s
PR Build Check / build (RAK_4631_companion_radio_ethernet) (push) Canceled after 0s
PR Build Check / build (RAK_4631_repeater) (push) Canceled after 0s
PR Build Check / build (RAK_4631_repeater_ethernet) (push) Canceled after 0s
PR Build Check / build (RAK_4631_room_server) (push) Canceled after 0s
PR Build Check / build (RAK_4631_room_server_ethernet) (push) Canceled after 0s
PR Build Check / build (Tbeam_SX1276_repeater) (push) Canceled after 0s
PR Build Check / build (wio-e5-mini_repeater) (push) Canceled after 0s
PR Build Check / build (wio_wm1110_repeater) (push) Canceled after 0s
Run Unit Tests / test (push) Canceled after 0s
This commit is contained in:
@@ -154,13 +154,13 @@ public:
|
||||
char tmp[80];
|
||||
|
||||
if (_page == HomePage::FIRST) {
|
||||
// // node name
|
||||
// display.setTextSize(1);
|
||||
// display.setColor(DisplayDriver::GREEN);
|
||||
// char filtered_name[sizeof(_node_prefs->node_name)];
|
||||
// display.translateUTF8ToBlocks(filtered_name, _node_prefs->node_name, sizeof(filtered_name));
|
||||
// display.setCursor(0, 0);
|
||||
// display.print(filtered_name);
|
||||
// node name
|
||||
display.setTextSize(1);
|
||||
display.setColor(UIColor::primary_txt);
|
||||
char filtered_name[sizeof(_node_prefs->node_name)];
|
||||
display.translateUTF8ToBlocks(filtered_name, _node_prefs->node_name, sizeof(filtered_name));
|
||||
display.setCursor(0, 0);
|
||||
display.print(filtered_name);
|
||||
|
||||
|
||||
display.setColor(UIColor::primary_txt);
|
||||
|
||||
@@ -95,7 +95,9 @@ void UITask::renderCurrScreen() {
|
||||
_display->setCursor(0, 0);
|
||||
_display->setTextSize(1);
|
||||
_display->setColor(UIColor::primary_txt);
|
||||
_display->print(_node_prefs->node_name);
|
||||
char filtered_name[sizeof(_node_prefs->node_name)];
|
||||
_display->translateUTF8ToBlocks(filtered_name, _node_prefs->node_name, sizeof(filtered_name));
|
||||
_display->print(filtered_name);
|
||||
|
||||
// freq / sf
|
||||
_display->setCursor(0, 20);
|
||||
|
||||
@@ -77,7 +77,9 @@ void UITask::renderCurrScreen() {
|
||||
_display->setCursor(0, 0);
|
||||
_display->setTextSize(1);
|
||||
_display->setColor(UIColor::primary_txt);
|
||||
_display->print(_node_prefs->node_name);
|
||||
char filtered_name[sizeof(_node_prefs->node_name)];
|
||||
_display->translateUTF8ToBlocks(filtered_name, _node_prefs->node_name, sizeof(filtered_name));
|
||||
_display->print(filtered_name);
|
||||
|
||||
// freq / sf
|
||||
_display->setCursor(0, 20);
|
||||
|
||||
@@ -77,7 +77,9 @@ void UITask::renderCurrScreen() {
|
||||
_display->setCursor(0, 0);
|
||||
_display->setTextSize(1);
|
||||
_display->setColor(UIColor::primary_txt);
|
||||
_display->print(_node_prefs->node_name);
|
||||
char filtered_name[sizeof(_node_prefs->node_name)];
|
||||
_display->translateUTF8ToBlocks(filtered_name, _node_prefs->node_name, sizeof(filtered_name));
|
||||
_display->print(filtered_name);
|
||||
|
||||
// freq / sf
|
||||
_display->setCursor(0, 20);
|
||||
|
||||
@@ -59,6 +59,9 @@ public:
|
||||
char cc = 0;
|
||||
#endif
|
||||
for (size_t i = 0; src[i] != 0 && j < dest_size - 1; i++) {
|
||||
#ifdef OLED_RU
|
||||
cc = 0; // сброс на каждом символе: иначе нераспознанный код повторит предыдущую букву
|
||||
#endif
|
||||
unsigned char c = (unsigned char)src[i];
|
||||
if (c >= 32 && c <= 126) {
|
||||
#ifdef OLED_RU
|
||||
@@ -109,7 +112,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cc > 0) {
|
||||
if (cc != 0) {
|
||||
dest[j++] = cc;
|
||||
} else {
|
||||
dest[j++] = '\xAE'; // CP1251 smile emoji replace
|
||||
|
||||
@@ -67,11 +67,14 @@ void SH1106Display::startFrame(ColorVal bkg)
|
||||
display.clearDisplay(); // TODO: apply 'bkg'
|
||||
_color = SH110X_WHITE;
|
||||
#ifdef OLED_RU
|
||||
// glcdfont6x8 несёт карту CP1251, поэтому CP437 не нужен (он действует
|
||||
// только для встроенного шрифта Adafruit)
|
||||
display.setFont(&glcdfont6x8);
|
||||
#else
|
||||
display.cp437(true); // встроенный шрифт: полный Code Page 437 (нужен для █ 0xDB)
|
||||
#endif
|
||||
display.setTextColor(_color);
|
||||
display.setTextSize(1);
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
setTextSize(1); // через свой override, чтобы _size не разъезжался
|
||||
#ifdef OLED_RU
|
||||
display.setCursor(0, 7);
|
||||
#endif
|
||||
|
||||
@@ -62,11 +62,14 @@ void SSD1306Display::startFrame(ColorVal bkg) {
|
||||
display.clearDisplay(); // TODO: apply 'bkg'
|
||||
_color = SSD1306_WHITE;
|
||||
#ifdef OLED_RU
|
||||
// glcdfont6x8 несёт карту CP1251, поэтому CP437 не нужен (он действует
|
||||
// только для встроенного шрифта Adafruit)
|
||||
display.setFont(&glcdfont6x8);
|
||||
#else
|
||||
display.cp437(true); // встроенный шрифт: полный Code Page 437 (нужен для █ 0xDB)
|
||||
#endif
|
||||
display.setTextColor(_color);
|
||||
display.setTextSize(1);
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
setTextSize(1); // через свой override, чтобы _size не разъезжался
|
||||
#ifdef OLED_RU
|
||||
display.setCursor(0, 7);
|
||||
#endif
|
||||
|
||||
@@ -627,14 +627,19 @@ void ST7735Display::clear() {
|
||||
void ST7735Display::startFrame(ColorVal bkg) {
|
||||
sprite->fillScreen(bkg);
|
||||
sprite->setTextColor(curr_color = UIColor::primary_txt);
|
||||
sprite->setFreeFont();
|
||||
#ifdef OLED_RU
|
||||
#ifdef OLED_RU
|
||||
// Шрифт ставим один раз: setFreeFont() пересчитывает метрики glyph_ab/glyph_bb
|
||||
// по всем 224 глифам, а шрифт между кадрами не меняется
|
||||
if (!_ru_font) {
|
||||
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);
|
||||
_ru_font = true;
|
||||
}
|
||||
#else
|
||||
sprite->setFreeFont();
|
||||
sprite->setAttribute(CP437_SWITCH, true); // встроенный шрифт: полный CP437
|
||||
#endif
|
||||
sprite->setAttribute(UTF8_SWITCH, false); // байты приходят уже в CP1251/ASCII
|
||||
setTextSize(1); // This one affects size of Please wait... message
|
||||
#ifdef OLED_RU
|
||||
sprite->setCursor(0, 7);
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,7 @@ class ST7735Display : public DisplayDriver {
|
||||
RefCountedDigitalPin* _peripher_power;
|
||||
#ifdef OLED_RU
|
||||
uint8_t _size;
|
||||
bool _ru_font;
|
||||
#endif
|
||||
|
||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||
@@ -23,6 +24,7 @@ public:
|
||||
_isOn = false;
|
||||
#ifdef OLED_RU
|
||||
_size = 1;
|
||||
_ru_font = false;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
@@ -33,6 +35,7 @@ public:
|
||||
_isOn = false;
|
||||
#ifdef OLED_RU
|
||||
_size = 1;
|
||||
_ru_font = false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include "ST7789LCDDisplay.h"
|
||||
#ifdef OLED_RU
|
||||
#include "glcdfont6x8.h"
|
||||
#endif
|
||||
|
||||
#ifndef PIN_TFT_MISO
|
||||
#define PIN_TFT_MISO -1
|
||||
@@ -56,7 +59,9 @@ bool ST7789LCDDisplay::begin() {
|
||||
display.fillScreen(ST77XX_BLACK);
|
||||
display.setTextColor(ST77XX_WHITE);
|
||||
display.setTextSize(2 * DISPLAY_SCALE_X);
|
||||
#ifndef OLED_RU
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
#endif
|
||||
|
||||
_isOn = true;
|
||||
}
|
||||
@@ -92,12 +97,23 @@ void ST7789LCDDisplay::clear() {
|
||||
void ST7789LCDDisplay::startFrame(ColorVal bkg) {
|
||||
display.fillScreen(bkg);
|
||||
display.setTextColor(_color = UIColor::primary_txt);
|
||||
display.setTextSize(1 * DISPLAY_SCALE_X); // This one affects size of Please wait... message
|
||||
#ifdef OLED_RU
|
||||
// glcdfont6x8 несёт карту CP1251; CP437 действует только для встроенного шрифта
|
||||
if (!_ru_font) {
|
||||
display.setFont(&glcdfont6x8);
|
||||
_ru_font = true;
|
||||
}
|
||||
#else
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
#endif
|
||||
setTextSize(1); // This one affects size of Please wait... message
|
||||
}
|
||||
|
||||
void ST7789LCDDisplay::setTextSize(int sz) {
|
||||
display.setTextSize(sz * DISPLAY_SCALE_X);
|
||||
#ifdef OLED_RU
|
||||
_size = sz;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ST7789LCDDisplay::setColor(ColorVal c) {
|
||||
@@ -105,7 +121,14 @@ void ST7789LCDDisplay::setColor(ColorVal c) {
|
||||
}
|
||||
|
||||
void ST7789LCDDisplay::setCursor(int x, int y) {
|
||||
#ifdef OLED_RU
|
||||
// Кастомный шрифт Adafruit рисуется от базовой линии: глиф поднят над ней
|
||||
// на 7 * фактический размер (setTextSize выше округляет sz * DISPLAY_SCALE_X)
|
||||
int px_size = (int)(_size * DISPLAY_SCALE_X);
|
||||
display.setCursor(x * DISPLAY_SCALE_X, y * DISPLAY_SCALE_Y + 7 * px_size);
|
||||
#else
|
||||
display.setCursor(x * DISPLAY_SCALE_X, y * DISPLAY_SCALE_Y);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ST7789LCDDisplay::print(const char* str) {
|
||||
|
||||
@@ -15,6 +15,10 @@ class ST7789LCDDisplay : public DisplayDriver {
|
||||
bool _isOn;
|
||||
uint16_t _color;
|
||||
RefCountedDigitalPin* _peripher_power;
|
||||
#ifdef OLED_RU
|
||||
uint8_t _size;
|
||||
bool _ru_font;
|
||||
#endif
|
||||
|
||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||
public:
|
||||
@@ -24,6 +28,10 @@ public:
|
||||
_peripher_power(peripher_power)
|
||||
{
|
||||
_isOn = false;
|
||||
#ifdef OLED_RU
|
||||
_size = 1;
|
||||
_ru_font = false;
|
||||
#endif
|
||||
}
|
||||
#elif defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT) || defined(HELTEC_V4_R8_TFT)
|
||||
ST7789LCDDisplay(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
|
||||
@@ -32,6 +40,10 @@ public:
|
||||
_peripher_power(peripher_power)
|
||||
{
|
||||
_isOn = false;
|
||||
#ifdef OLED_RU
|
||||
_size = 1;
|
||||
_ru_font = false;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
ST7789LCDDisplay(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
|
||||
@@ -39,6 +51,10 @@ public:
|
||||
_peripher_power(peripher_power)
|
||||
{
|
||||
_isOn = false;
|
||||
#ifdef OLED_RU
|
||||
_size = 1;
|
||||
_ru_font = false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
bool begin();
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Adafruit GFX font font size: 6x8
|
||||
// Кодировка карты глифов — CP1251 (0xC0-0xFF: А-Я, а-я; 0xA5/0xA8/0xAA/0xAF/0xB2/0xB8/0xBA/0xBF: Ґ/Ё/Є/Ї/і/ё/є/ї).
|
||||
#pragma once
|
||||
|
||||
const uint8_t glcdfont6x8Bitmaps[] PROGMEM = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 32
|
||||
|
||||
Reference in New Issue
Block a user