diff --git a/Translations/make_translation.py b/Translations/make_translation.py index 38171344..81290746 100755 --- a/Translations/make_translation.py +++ b/Translations/make_translation.py @@ -23,6 +23,7 @@ except NameError: @functools.lru_cache(maxsize=None) def cjkFont(): from bdflib import reader as bdfreader + with open(os.path.join(HERE, "wqy-bitmapsong/wenquanyi_9pt.bdf"), "rb") as f: return bdfreader.read_bdf(f) @@ -43,7 +44,7 @@ def loadJson(fileName, skipFirstLine): def readTranslation(jsonDir, langCode): - fileName = 'translation_{}.json'.format(langCode) + fileName = "translation_{}.json".format(langCode) fileWithPath = os.path.join(jsonDir, fileName) @@ -184,8 +185,10 @@ def getLetterCounts(defs, lang): symbolCounts.reverse() return symbolCounts + def getCJKGlyph(sym): from bdflib.model import Glyph + try: glyph: Glyph = cjkFont()[ord(sym)] except: @@ -213,6 +216,7 @@ def getCJKGlyph(sym): return True else: return False + # A glyph in the font table is divided into upper and lower parts, each by # 8px high. Each byte represents half if a column, with the LSB being the # top-most pixel. The data goes from the left-most to the right-most column @@ -228,6 +232,7 @@ def getCJKGlyph(sym): s += f"0x{b:02X}," return s + def getFontMapAndTable(textList): # the text list is sorted # allocate out these in their order as number codes @@ -244,7 +249,7 @@ def getFontMapAndTable(textList): # number of symbols allowed with 8 bits is `256 - 2`. if totalSymbolCount > (256 - 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: @@ -259,12 +264,12 @@ def getFontMapAndTable(textList): for sym in forcedFirstSymbols: if sym not in fontTable: log("Missing Large font element for {}".format(sym)) - exit(1) + sys.exit(1) fontLine = fontTable[sym] fontTableStrings.append(fontLine + "//{} -> {}".format(symbolMap[sym], sym)) if sym not in fontSmallTable: log("Missing Small font element for {}".format(sym)) - exit(1) + sys.exit(1) fontLine = fontSmallTable[sym] fontSmallTableStrings.append( fontLine + "//{} -> {}".format(symbolMap[sym], sym) @@ -276,7 +281,7 @@ def getFontMapAndTable(textList): fromFont = getCJKGlyph(sym) if fromFont is None: log("Missing Large font element for {}".format(sym)) - exit(1) + sys.exit(1) # We store the glyph back to the fontTable. fontTable[sym] = fromFont # We also put a "replacement character" in the small font table @@ -287,7 +292,7 @@ def getFontMapAndTable(textList): fontTableStrings.append(fontLine + "//{} -> {}".format(symbolMap[sym], sym)) if sym not in fontSmallTable: log("Missing Small font element for {}".format(sym)) - exit(1) + sys.exit(1) fontLine = fontSmallTable[sym] fontSmallTableStrings.append( fontLine + "//{} -> {}".format(symbolMap[sym], sym) @@ -317,7 +322,7 @@ def convStr(symbolConversionTable, text): def writeLanguage(lang, defs, f): - languageCode = lang['languageCode'] + languageCode = lang["languageCode"] log("Generating block for " + languageCode) # Iterate over all of the text to build up the symbols & counts textList = getLetterCounts(defs, lang) @@ -516,10 +521,11 @@ def writeLanguage(lang, defs, f): ) f.write(to_unicode("};\n\n")) - f.write("const bool HasFahrenheit = " + ( - "true" if lang.get('tempUnitFahrenheit', True) else "false") + - ";\n") - + f.write( + "const bool HasFahrenheit = " + + ("true" if lang.get("tempUnitFahrenheit", True) else "false") + + ";\n" + ) def readVersion(jsonDir): @@ -567,9 +573,9 @@ def orderOutput(langDict): def parseArgs(): parser = argparse.ArgumentParser() parser.add_argument( - '--output', '-o', - help='Target file', type=argparse.FileType('w'), required=True) - parser.add_argument('languageCode', help='Language to generate') + "--output", "-o", help="Target file", type=argparse.FileType("w"), required=True + ) + parser.add_argument("languageCode", help="Language to generate") return parser.parse_args() diff --git a/build.sh b/build.sh deleted file mode 100644 index 10f26c0d..00000000 --- a/build.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -docker-compose run --rm builder /bin/bash /build/ci/buildAll.sh \ No newline at end of file diff --git a/source/Core/BSP/Miniware/flash.c b/source/Core/BSP/Miniware/flash.c index d764df93..1d5469ee 100644 --- a/source/Core/BSP/Miniware/flash.c +++ b/source/Core/BSP/Miniware/flash.c @@ -30,7 +30,7 @@ uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) { // now we program it uint16_t *data = (uint16_t *)buffer; HAL_FLASH_Unlock(); - for (uint8_t i = 0; i < (length / 2); i++) { + for (uint16_t i = 0; i < (length / 2); i++) { resetWatchdog(); HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, (uint32_t)&settings_page[i], data[i]); } diff --git a/source/Core/BSP/Pine64/flash.c b/source/Core/BSP/Pine64/flash.c index 95aa4fe5..8c0ce3f5 100644 --- a/source/Core/BSP/Pine64/flash.c +++ b/source/Core/BSP/Pine64/flash.c @@ -26,7 +26,7 @@ uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) { fmc_page_erase((uint32_t)SETTINGS_START_PAGE); resetWatchdog(); uint16_t *data = (uint16_t *)buffer; - for (uint8_t i = 0; i < (length / 2); i++) { + for (uint16_t i = 0; i < (length / 2); i++) { fmc_halfword_program((uint32_t)SETTINGS_START_PAGE + (i * 2), data[i]); fmc_flag_clear(FMC_FLAG_END); fmc_flag_clear(FMC_FLAG_WPERR); diff --git a/source/Core/Drivers/FUSB302/policy_engine.cpp b/source/Core/Drivers/FUSB302/policy_engine.cpp index e8358f5b..2ab7f99a 100644 --- a/source/Core/Drivers/FUSB302/policy_engine.cpp +++ b/source/Core/Drivers/FUSB302/policy_engine.cpp @@ -213,7 +213,7 @@ PolicyEngine::policy_engine_state PolicyEngine::pe_sink_eval_cap() { * than the maximum possible) */ _pps_index = 8; /* Search for the first PPS APDO */ - for (int8_t i = 0; i < PD_NUMOBJ_GET(&tempMessage); i++) { + for (int i = 0; i < PD_NUMOBJ_GET(&tempMessage); i++) { if ((tempMessage.obj[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED && (tempMessage.obj[i] & PD_APDO_TYPE) == PD_APDO_TYPE_PPS) { _pps_index = i + 1; break; diff --git a/source/build.sh b/source/build.sh index e07e102f..f8d30751 100644 --- a/source/build.sh +++ b/source/build.sh @@ -1,5 +1,5 @@ #!/bin/bash - +set -e TRANSLATION_DIR="../Translations" TRANSLATION_SCRIPT="make_translation.py"