Skip to content

Commit

Permalink
OLED Cyrillic Support for v1.3 (#1640)
Browse files Browse the repository at this point in the history
* Extended ASCII codes and cyrillic support

(cherry picked from commit e977840)

* Fixed `ё`, `Ё` letters

(cherry picked from commit 2f4a2cc)

* Fixed `customFontTableLookup` execution flow

(cherry picked from commit 377f909)

* [OLED] Specifying the language by defining it in `platformio.ini`

(cherry picked from commit ddd8132)

* [OLED] localization guide

(cherry picked from commit a3267c8)

* [OLED] Cyrillic support

Localization guide has been moved to https://github.com/meshtastic/Meshtastic/tree/master/docs/developers/Firmware

https://meshtastic.org/docs/developers/Firmware/oled-l10n-guide

Co-authored-by: Thomas Göttgens <[email protected]>
Co-authored-by: Ben Meadors <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2022
1 parent 285ba96 commit cb3010b
Show file tree
Hide file tree
Showing 5 changed files with 475 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mesh/http/WiFiAPClient.h"
#endif

#ifdef OLED_RU
#include "fonts/OLEDDisplayFontsRU.h"
#endif

using namespace meshtastic; /** @todo remove */

extern bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct);
Expand Down Expand Up @@ -100,7 +104,11 @@ static uint16_t displayWidth, displayHeight;
#define FONT_MEDIUM ArialMT_Plain_24
#define FONT_LARGE ArialMT_Plain_24
#else
#ifdef OLED_RU
#define FONT_SMALL ArialMT_Plain_10_RU
#else
#define FONT_SMALL ArialMT_Plain_10
#endif
#define FONT_MEDIUM ArialMT_Plain_16
#define FONT_LARGE ArialMT_Plain_24
#endif
Expand Down
17 changes: 15 additions & 2 deletions src/graphics/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class Screen : public concurrency::OSThread
uint8_t last = LASTCHAR; // get last char
LASTCHAR = ch;

switch (last) { // conversion depnding on first UTF8-character
switch (last) { // conversion depending on first UTF8-character
case 0xC2: {
SKIPREST = false;
return (uint8_t)ch;
Expand All @@ -221,10 +221,23 @@ class Screen : public concurrency::OSThread
SKIPREST = false;
return (uint8_t)(ch | 0xC0);
}
// map UTF-8 cyrillic chars to it Windows-1251 (CP-1251) ASCII codes
// note: in this case we must use compatible font - provided ArialMT_Plain_10/16/24 by 'ThingPulse/esp8266-oled-ssd1306' library
// have empty chars for non-latin ASCII symbols
case 0xD0: {
SKIPREST = false;
if (ch == 129) return (uint8_t)(168); // Ё
if (ch > 143 && ch < 192) return (uint8_t)(ch + 48);
}
case 0xD1: {
SKIPREST = false;
if (ch == 145) return (uint8_t)(184); // ё
if (ch > 127 && ch < 144) return (uint8_t)(ch + 112);
}
}

// We want to strip out prefix chars for two-byte char formats
if (ch == 0xC2 || ch == 0xC3 || ch == 0x82)
if (ch == 0xC2 || ch == 0xC3 || ch == 0x82 || ch == 0xD0 || ch == 0xD1)
return (uint8_t)0;

// If we already returned an unconvertable-character symbol for this unconvertable-character sequence, return NULs for the
Expand Down
Loading

0 comments on commit cb3010b

Please sign in to comment.