Rough pass

This commit is contained in:
Ben V. Brown
2021-03-16 21:24:22 +11:00
parent 483581b3f2
commit c07b621daf
3 changed files with 22 additions and 11 deletions

View File

@@ -247,14 +247,24 @@ def getFontMapAndTable(textList):
totalSymbolCount = len(set(textList) | set(forcedFirstSymbols)) totalSymbolCount = len(set(textList) | set(forcedFirstSymbols))
# \x00 is for NULL termination and \x01 is for newline, so the maximum # \x00 is for NULL termination and \x01 is for newline, so the maximum
# number of symbols allowed with 8 bits is `256 - 2`. # 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})") log(f"Error, too many used symbols for this version (total {totalSymbolCount})")
exit(1) sys.exit(1)
log("Generating fonts for {} symbols".format(totalSymbolCount)) log("Generating fonts for {} symbols".format(totalSymbolCount))
for sym in textList: for sym in textList:
if sym not in symbolMap: 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 index = index + 1
# Get the font table # Get the font table
fontTableStrings = [] fontTableStrings = []

View File

@@ -236,14 +236,15 @@ void OLED::setRotation(bool leftHanded) {
// print a string to the current cursor location // print a string to the current cursor location
void OLED::print(const char *str) { void OLED::print(const char *str) {
uint16_t cache = 0; uint16_t page = 0;
while (str[0]) { while (str[0]) {
if (str[0] >= 0xF0) { if (static_cast<uint8_t>(str[0]) >= 0xF0) {
cache = static_cast<uint16_t>(str[0] & 0x0F) << 8; page = static_cast<uint16_t>(str[0]&0x0F);
} else if (cache != 0) { } else if (page != 0) {
cache |= str[0]; page*=0xEF;
drawChar(cache); page +=static_cast<uint8_t>(str[0])-1;
cache = 0; drawChar(page);
page = 0;
} else { } else {
drawChar(str[0]); drawChar(str[0]);
} }

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
set -x set -e
TRANSLATION_DIR="../Translations" TRANSLATION_DIR="../Translations"
TRANSLATION_SCRIPT="make_translation.py" TRANSLATION_SCRIPT="make_translation.py"