From c07b621daf6ca58c5eedb8dadff3f15d28b29660 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 16 Mar 2021 21:24:22 +1100 Subject: [PATCH] Rough pass --- Translations/make_translation.py | 16 +++++++++++++--- source/Core/Drivers/OLED.cpp | 15 ++++++++------- source/build.sh | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Translations/make_translation.py b/Translations/make_translation.py index cefc7ba2..fe6aaebc 100755 --- a/Translations/make_translation.py +++ b/Translations/make_translation.py @@ -247,14 +247,24 @@ def getFontMapAndTable(textList): totalSymbolCount = len(set(textList) | set(forcedFirstSymbols)) # \x00 is for NULL termination and \x01 is for newline, so the maximum # number of symbols allowed with 8 bits is `256 - 2`. - if totalSymbolCount > (256 - 2): + if totalSymbolCount > ((0xEE * 0x0F) - 2): log(f"Error, too many used symbols for this version (total {totalSymbolCount})") - exit(1) + sys.exit(1) log("Generating fonts for {} symbols".format(totalSymbolCount)) for sym in textList: if sym not in symbolMap: - symbolMap[sym] = "\\x%0.2X" % index + page = int(index / 0xEF) + if page == 0: + symbolMap[sym] = "\\x%0.2X" % index + else: + # Into extended range + # Leader is 0xFz where z is the page number + # Following char is the remainder + leader = page + 0xF0 + value = (index % 0xEF) + 1 + symbolMap[sym] = "\\x%0.2X" % leader + "\\x%0.2X" % value + index = index + 1 # Get the font table fontTableStrings = [] diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 9bd49e13..062e09cb 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -236,14 +236,15 @@ void OLED::setRotation(bool leftHanded) { // print a string to the current cursor location void OLED::print(const char *str) { - uint16_t cache = 0; + uint16_t page = 0; while (str[0]) { - if (str[0] >= 0xF0) { - cache = static_cast(str[0] & 0x0F) << 8; - } else if (cache != 0) { - cache |= str[0]; - drawChar(cache); - cache = 0; + if (static_cast(str[0]) >= 0xF0) { + page = static_cast(str[0]&0x0F); + } else if (page != 0) { + page*=0xEF; + page +=static_cast(str[0])-1; + drawChar(page); + page = 0; } else { drawChar(str[0]); } diff --git a/source/build.sh b/source/build.sh index eaa2a1c2..27c4f974 100644 --- a/source/build.sh +++ b/source/build.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -x +set -e TRANSLATION_DIR="../Translations" TRANSLATION_SCRIPT="make_translation.py"