meshtastic/docs/development/firmware/oled-guide.mdx

39 lines
1.5 KiB
Plaintext
Raw Normal View History

2022-08-25 15:57:00 -07:00
---
2022-11-04 10:06:45 -07:00
id: oled-guide
2022-11-03 17:10:08 -07:00
title: OLED Localization Guide
sidebar_label: OLED Localization
2022-08-25 15:57:00 -07:00
---
2023-01-19 05:01:57 -08:00
1. Create an extended ASCII custom font. Use a glyph editor to create a new font file. The easiest way is to use the online [glyph editor](https://rawgit.com/ThingPulse/esp8266-oled-ssd1306/master/resources/glyphEditor.html) from the OLED library. ([glyph editor source code](https://github.com/ThingPulse/esp8266-oled-ssd1306/tree/master/resources))
1. Copy and paste the existing font.
2. Modify it according desired codepage and save the new font file in `graphics/font` folder.
Please note that the used font file format differs from common Adafruit GFX.
2022-11-07 20:53:52 -08:00
2. Update the `customFontTableLookup` function in `Screen.h`
2023-01-19 05:01:57 -08:00
1. To map the double-byte UTF-8 code to the corresponding extended ASCII character of the desired codepage update the `customFontTableLookup` function in the `Screen.h` file.
2023-06-09 17:16:03 -07:00
2. Modify the `switch (last)` statement: use left byte from UTF-8 code in the `case` label to map character's right byte to its extended ASCII code by specifying an offset.
2022-11-07 20:53:52 -08:00
3. Define language and font in `Screen.cpp`
2023-01-19 05:01:57 -08:00
```c
#ifdef OLED_{LANG_NAME}
#include "fonts/OLEDDisplayFonts{LANG_NAME}.h"
#endif
...
#ifdef OLED_{LANG_NAME}
#define FONT_SMALL ArialMT_Plain_10_{LANG_NAME}
#else
#define FONT_SMALL ArialMT_Plain_10
#endif
```
2022-11-07 20:53:52 -08:00
4. Define language in `variant/*/platformio.ini`
2023-01-19 05:01:57 -08:00
```text
build_flags =
${esp32_base.build_flags}
-D xxxxx
-D OLED_{LANG_NAME}
-I variants/xxxxx
```