Generate per-language translation sources (#806)

This generates dedicates Translation.cpp files for translation language
and derives all language-specific data from them.

The Makefile is extended to also take care of generating these source
files.
This allows reuse of nearly all object files between builds of different
languages for the same model and regenerating the translation sources if
necessary.
This speeds up the release builds and the normal write-compile-cycle
considerably.
It also eliminates miscompilations when manually building different
languages.
This commit is contained in:
Thomas Weißschuh
2021-02-02 09:44:34 +01:00
committed by GitHub
parent 5e372310cd
commit 15e51f9faa
36 changed files with 108 additions and 266 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# coding=utf-8
from __future__ import print_function
import argparse
import json
import os
import io
@@ -10,8 +11,7 @@ import fontTables
import re
import subprocess
TRANSLATION_CPP = "Translation.cpp"
UNIT_H = "unit.h"
HERE = os.path.dirname(__file__)
try:
to_unicode = unicode
@@ -19,6 +19,10 @@ except NameError:
to_unicode = str
def log(message):
print(message, file=sys.stdout)
# Loading a single JSON file
def loadJson(fileName, skipFirstLine):
with io.open(fileName, mode="r", encoding="utf-8") as f:
@@ -30,48 +34,33 @@ def loadJson(fileName, skipFirstLine):
return obj
# Reading all language translations into a dictionary by langCode
def readTranslations(jsonDir):
langDict = {}
UnitDict = {}
def readTranslation(jsonDir, langCode):
fileName = 'translation_{}.json'.format(langCode)
# Read all translation files from the input dir
for fileName in os.listdir(jsonDir):
fileWithPath = os.path.join(jsonDir, fileName)
fileWithPath = os.path.join(jsonDir, fileName)
lf = fileName.lower()
try:
lang = loadJson(fileWithPath, False)
except json.decoder.JSONDecodeError as e:
log("Failed to decode " + fileName)
log(str(e))
sys.exit(2)
# Read only translation_XX.json
if lf.startswith("translation_") and lf.endswith(".json"):
try:
lang = loadJson(fileWithPath, False)
except json.decoder.JSONDecodeError as e:
print("Failed to decode " + lf)
print(str(e))
sys.exit(2)
# Extract lang code from file name
langCode = fileName[12:-5].upper()
# ...and the one specified in the JSON file...
try:
langCodeFromJson = lang["languageCode"]
except KeyError:
langCodeFromJson = "(missing)"
# Extract lang code from file name
langCode = fileName[12:-5].upper()
# ...and the one specified in the JSON file...
try:
langCodeFromJson = lang["languageCode"]
except KeyError:
langCodeFromJson = "(missing)"
# ...cause they should be the same!
if langCode != langCodeFromJson:
raise ValueError(
"Invalid languageCode " + langCodeFromJson + " in file " + fileName
)
try:
TempUnitF_FromJson = lang["tempUnitFahrenheit"]
except KeyError:
TempUnitF_FromJson = True # Default to true.
# ...cause they should be the same!
if langCode != langCodeFromJson:
raise ValueError(
"Invalid languageCode " + langCodeFromJson + " in file " + fileName
)
langDict[langCode] = lang
UnitDict[langCode] = TempUnitF_FromJson
return langDict, UnitDict
return lang
def writeStart(f):
@@ -85,26 +74,6 @@ def writeStart(f):
)
def writeStartUnit(f):
f.write(
to_unicode(
"""// WARNING: THIS FILE WAS AUTO GENERATED BY make_translation.py. PLEASE DO NOT EDIT.
/**
* °F Fahrenheit Support
* You will find the default Fahrenheit configuration in the translation_xx.json
* If tempUnitFahrenheit is set to:
* true - you can switch in menu settings to Fahrenheit or Celsius.
* false - you see only Celsius. All settings are then is in Celsius only.
*/
#ifndef _UNIT_H
#define _UNIT_H\n
"""
)
)
def escapeC(s):
return s.replace('"', '\\"')
@@ -220,9 +189,9 @@ def getFontMapAndTable(textList):
symbolMap[sym] = "\\x%0.2X" % index
index = index + 1
if len(textList) > (253 - len(forcedFirstSymbols)):
print("Error, too many used symbols for this version")
log("Error, too many used symbols for this version")
exit(1)
print("Generating fonts for {} symbols".format(len(textList)))
log("Generating fonts for {} symbols".format(len(textList)))
for sym in textList:
if sym not in symbolMap:
@@ -235,12 +204,12 @@ def getFontMapAndTable(textList):
fontSmallTable = fontTables.getSmallFontMap()
for sym in forcedFirstSymbols:
if sym not in fontTable:
print("Missing Large font element for {}".format(sym))
log("Missing Large font element for {}".format(sym))
exit(1)
fontLine = fontTable[sym]
fontTableStrings.append(fontLine + "//{} -> {}".format(symbolMap[sym], sym))
if sym not in fontSmallTable:
print("Missing Small font element for {}".format(sym))
log("Missing Small font element for {}".format(sym))
exit(1)
fontLine = fontSmallTable[sym]
fontSmallTableStrings.append(
@@ -249,13 +218,13 @@ def getFontMapAndTable(textList):
for sym in textList:
if sym not in fontTable:
print("Missing Large font element for {}".format(sym))
log("Missing Large font element for {}".format(sym))
exit(1)
if sym not in forcedFirstSymbols:
fontLine = fontTable[sym]
fontTableStrings.append(fontLine + "//{} -> {}".format(symbolMap[sym], sym))
if sym not in fontSmallTable:
print("Missing Small font element for {}".format(sym))
log("Missing Small font element for {}".format(sym))
exit(1)
fontLine = fontSmallTable[sym]
fontSmallTableStrings.append(
@@ -279,21 +248,20 @@ def convStr(symbolConversionTable, text):
outputString = ""
for c in text.replace("\\r", "").replace("\\n", "\n"):
if c not in symbolConversionTable:
print("Missing font definition for {}".format(c))
log("Missing font definition for {}".format(c))
else:
outputString = outputString + symbolConversionTable[c]
return outputString
def writeLanguage(languageCode, defs, f):
print("Generating block for " + languageCode)
lang = langDict[languageCode]
def writeLanguage(lang, defs, f):
languageCode = lang['languageCode']
log("Generating block for " + languageCode)
# Iterate over all of the text to build up the symbols & counts
textList = getLetterCounts(defs, lang)
# From the letter counts, need to make a symbol translator & write out the font
(fontTableText, symbolConversionTable) = getFontMapAndTable(textList)
f.write(to_unicode("\n#ifdef LANG_" + languageCode + "\n"))
f.write(fontTableText)
try:
langName = lang["languageLocalName"]
@@ -486,29 +454,13 @@ def writeLanguage(languageCode, defs, f):
)
f.write(to_unicode("};\n\n"))
# ----- Block end
f.write(to_unicode("#endif\n"))
f.write("const bool HasFahrenheit = " + (
"true" if lang.get('tempUnitFahrenheit', True) else "false") +
";\n")
def writeUnit(languageCode, defs, f, UnitCodes):
print("Generating unit block for " + languageCode)
lang = langDict[languageCode]
unit = UnitDict[UnitCodes]
try:
langName = lang["languageLocalName"]
except KeyError:
langName = languageCode
f.write(to_unicode(" #ifdef LANG_" + languageCode + "\n"))
if unit:
f.write(to_unicode(" #define ENABLED_FAHRENHEIT_SUPPORT" + "\n"))
else:
f.write(to_unicode(" //#define ENABLED_FAHRENHEIT_SUPPORT" + "\n"))
# ----- Block end
f.write(to_unicode(" #endif /* ---- " + langName + " ---- */\n"))
def readVersion():
def readVersion(jsonDir):
with open(os.path.relpath(jsonDir + "/../source/version.h"), "r") as version_file:
try:
for line in version_file:
@@ -535,37 +487,6 @@ def readVersion():
return version
def read_opts():
"""Reading input parameters
First parameter = json directory
Second parameter = translation directory
Third paramter = unit directory
"""
if len(sys.argv) > 1:
jsonDir = sys.argv[1]
else:
jsonDir = "."
if len(sys.argv) > 2:
outFileTranslationCPP = sys.argv[2]
else:
outDir = os.path.relpath(jsonDir + "/../source/Core/Gen")
if not os.path.exists(outDir):
os.makedirs(outDir)
outFileTranslationCPP = os.path.join(outDir, TRANSLATION_CPP)
if len(sys.argv) > 3:
outFileUnitH = sys.argv[3]
else:
outDir = os.path.relpath(jsonDir + "/../source/Core/Inc")
outFileUnitH = os.path.join(outDir, UNIT_H)
if len(sys.argv) > 4:
raise Exception("Too many parameters!")
return jsonDir, outFileTranslationCPP, outFileUnitH
def orderOutput(langDict):
# These languages go first
mandatoryOrder = ["EN"]
@@ -581,41 +502,33 @@ def orderOutput(langDict):
return mandatoryOrder
def writeTarget(outFileTranslationCPP, outFileUnitH, defs, langCodes, UnitCodes):
# Start writing the file
with io.open(outFileTranslationCPP, "w", encoding="utf-8", newline="\n") as f:
writeStart(f)
for langCode in langCodes:
writeLanguage(langCode, defs, f)
with io.open(outFileUnitH, "w", encoding="utf-8", newline="\n") as f:
writeStartUnit(f)
for langCode, UnitCode in zip(langCodes, UnitCodes):
writeUnit(langCode, defs, f, UnitCode)
f.write(to_unicode("\n#endif /* _UNIT_H */\n"))
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')
return parser.parse_args()
if __name__ == "__main__":
try:
jsonDir, outFileTranslationCPP, outFileUnitH = read_opts()
except:
print("usage: make_translation.py {json dir} {cpp dir}")
sys.exit(1)
jsonDir = HERE
args = parseArgs()
try:
buildVersion = readVersion()
buildVersion = readVersion(jsonDir)
except:
print("error: could not get/extract build version")
log("error: could not get/extract build version")
sys.exit(1)
print("Build version: " + buildVersion)
print("Making " + outFileTranslationCPP + " from " + jsonDir)
print("Making " + outFileUnitH + " from " + jsonDir)
log("Build version: " + buildVersion)
log("Making " + args.languageCode + " from " + jsonDir)
langDict, UnitDict = readTranslations(jsonDir)
lang = readTranslation(jsonDir, args.languageCode)
defs = loadJson(os.path.join(jsonDir, "translations_def.js"), True)
langCodes = orderOutput(langDict)
UnitCodes = orderOutput(UnitDict)
writeTarget(outFileTranslationCPP, outFileUnitH, defs, langCodes, UnitCodes)
out = args.output
writeStart(out)
writeLanguage(lang, defs, out)
print("Done")
log("Done")

View File

@@ -53,9 +53,7 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC) {
}
uint32_t TipThermoModel::convertTipRawADCToDegC(uint16_t rawADC) { return convertuVToDegC(convertTipRawADCTouV(rawADC)); }
#ifdef ENABLED_FAHRENHEIT_SUPPORT
uint32_t TipThermoModel::convertTipRawADCToDegF(uint16_t rawADC) { return convertuVToDegF(convertTipRawADCTouV(rawADC)); }
#endif
// Table that is designed to be walked to find the best sample for the lookup
@@ -196,7 +194,6 @@ uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
return 0;
}
#ifdef ENABLED_FAHRENHEIT_SUPPORT
uint32_t TipThermoModel::convertuVToDegF(uint32_t tipuVDelta) { return convertCtoF(convertuVToDegC(tipuVDelta)); }
uint32_t TipThermoModel::convertCtoF(uint32_t degC) {
@@ -211,7 +208,6 @@ uint32_t TipThermoModel::convertFtoC(uint32_t degF) {
}
return ((degF - 32) * 5) / 9;
}
#endif
uint32_t TipThermoModel::getTipInC(bool sampleNow) {
int32_t currentTipTempInC = TipThermoModel::convertTipRawADCToDegC(getTipRawTemp(sampleNow));
@@ -224,13 +220,12 @@ uint32_t TipThermoModel::getTipInC(bool sampleNow) {
return 0;
return currentTipTempInC;
}
#ifdef ENABLED_FAHRENHEIT_SUPPORT
uint32_t TipThermoModel::getTipInF(bool sampleNow) {
uint32_t currentTipTempInF = getTipInC(sampleNow);
currentTipTempInF = convertCtoF(currentTipTempInF);
return currentTipTempInF;
}
#endif
uint32_t TipThermoModel::getTipMaxInC() {
uint32_t maximumTipTemp = TipThermoModel::convertTipRawADCToDegC(0x7FFF - (21 * 5)); // back off approx 5 deg c from ADC max

View File

@@ -9,34 +9,25 @@
#define SRC_TIPTHERMOMODEL_H_
#include "BSP.h"
#include "stdint.h"
#include "unit.h"
class TipThermoModel {
public:
// These are the main two functions
static uint32_t getTipInC(bool sampleNow = false);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
static uint32_t getTipInF(bool sampleNow = false);
#endif
// Calculates the maximum temperature can can be read by the ADC range
static uint32_t getTipMaxInC();
static uint32_t convertTipRawADCToDegC(uint16_t rawADC);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
static uint32_t convertTipRawADCToDegF(uint16_t rawADC);
#endif
// Returns the uV of the tip reading before the op-amp compensating for pullups
static uint32_t convertTipRawADCTouV(uint16_t rawADC);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
static uint32_t convertCtoF(uint32_t degC);
static uint32_t convertFtoC(uint32_t degF);
#endif
private:
static uint32_t convertuVToDegC(uint32_t tipuVDelta);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
static uint32_t convertuVToDegF(uint32_t tipuVDelta);
#endif
};
#endif /* SRC_TIPTHERMOMODEL_H_ */

View File

@@ -10,7 +10,6 @@
#include "FreeRTOS.h"
#include "cmsis_os.h"
#include "unit.h"
#ifdef __cplusplus
extern "C" {

View File

@@ -9,9 +9,8 @@
#ifndef SETTINGS_H_
#define SETTINGS_H_
#include "unit.h"
#include <stdint.h>
#define SETTINGSVERSION (0x24)
#define SETTINGSVERSION (0x25)
/*Change this if you change the struct below to prevent people getting \
out of sync*/
@@ -37,9 +36,7 @@ typedef struct {
// down screen until its <50C
uint8_t detailedIDLE : 1; // Detailed idle screen
uint8_t detailedSoldering : 1; // Detailed soldering screens
#ifdef ENABLED_FAHRENHEIT_SUPPORT
uint8_t temperatureInF : 1; // Should the temp be in F or C (true is F)
#endif
uint8_t descriptionScrollSpeed : 1; // Description scroll speed
uint8_t lockingMode : 2; // Store the locking mode
uint8_t KeepAwakePulse; // Keep Awake pulse power in 0.1 watts (10 = 1Watt)

View File

@@ -8,9 +8,9 @@
#ifndef TRANSLATION_H_
#define TRANSLATION_H_
#include "stdint.h"
#include "unit.h"
extern const uint8_t USER_FONT_12[];
extern const uint8_t USER_FONT_6x8[];
extern const bool HasFahrenheit;
extern const char *SettingsShortNames[29][2];
extern const char *SettingsDescriptions[29];
@@ -70,9 +70,7 @@ extern const char *SymbolMinus;
extern const char *SymbolSpace;
extern const char *SymbolDot;
extern const char *SymbolDegC;
#ifdef ENABLED_FAHRENHEIT_SUPPORT
extern const char *SymbolDegF;
#endif
extern const char *SymbolMinutes;
extern const char *SymbolSeconds;
extern const char *SymbolWatts;

View File

@@ -67,9 +67,7 @@ void resetSettings() {
systemSettings.autoStartMode = AUTO_START_MODE; // Auto start off for safety
systemSettings.lockingMode = LOCKING_MODE; // Disable locking for safety
systemSettings.coolingTempBlink = COOLING_TEMP_BLINK; // Blink the temperature on the cooling screen when its > 50C
#ifdef ENABLED_FAHRENHEIT_SUPPORT
systemSettings.temperatureInF = TEMPERATURE_INF; // default to 0
#endif
systemSettings.descriptionScrollSpeed = DESCRIPTION_SCROLL_SPEED; // default to slow
systemSettings.CalibrationOffset = CALIBRATION_OFFSET; // the adc offset in uV
systemSettings.powerLimit = POWER_LIMIT; // 30 watts default limit

View File

@@ -13,7 +13,6 @@
#include "cmsis_os.h"
#include "main.hpp"
#include "string.h"
#include "unit.h"
void gui_Menu(const menuitem *menu);
@@ -33,10 +32,8 @@ static bool settings_setShutdownTime(void);
static void settings_displayShutdownTime(void);
static bool settings_setSensitivity(void);
static void settings_displaySensitivity(void);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
static bool settings_setTempF(void);
static void settings_displayTempF(void);
#endif
static bool settings_setAdvancedSolderingScreens(void);
static void settings_displayAdvancedSolderingScreens(void);
static bool settings_setAdvancedIDLEScreens(void);
@@ -168,9 +165,7 @@ const menuitem UIMenu[] = {
* Cooldown blink
* Reverse Temp change buttons + -
*/
#ifdef ENABLED_FAHRENHEIT_SUPPORT
{(const char *)SettingsDescriptions[5], settings_setTempF, settings_displayTempF}, /* Temperature units*/
#endif
{(const char *)SettingsDescriptions[5], settings_setTempF, settings_displayTempF}, /* Temperature units, this has to be the first element in the array to work with the logic in settings_enterUIMenu() */
{(const char *)SettingsDescriptions[7], settings_setDisplayRotation, settings_displayDisplayRotation}, /*Display Rotation*/
{(const char *)SettingsDescriptions[10], settings_setCoolingBlinkEnabled, settings_displayCoolingBlinkEnabled}, /*Cooling blink warning*/
{(const char *)SettingsDescriptions[15], settings_setScrollSpeed, settings_displayScrollSpeed}, /*Scroll Speed for descriptions*/
@@ -341,15 +336,12 @@ static void settings_displayQCInputV(void) {
#endif
static bool settings_setSleepTemp(void) {
// If in C, 10 deg, if in F 20 deg
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) {
systemSettings.SleepTemp += 20;
if (systemSettings.SleepTemp > 580)
systemSettings.SleepTemp = 60;
return systemSettings.SleepTemp == 580;
} else
#endif
{
} else {
systemSettings.SleepTemp += 10;
if (systemSettings.SleepTemp > 300)
systemSettings.SleepTemp = 10;
@@ -405,7 +397,6 @@ static void settings_displayShutdownTime(void) {
OLED::print(SymbolMinutes);
}
}
#ifdef ENABLED_FAHRENHEIT_SUPPORT
static bool settings_setTempF(void) {
systemSettings.temperatureInF = !systemSettings.temperatureInF;
if (systemSettings.temperatureInF) {
@@ -436,7 +427,6 @@ static void settings_displayTempF(void) {
OLED::print((systemSettings.temperatureInF) ? SymbolDegF : SymbolDegC);
}
#endif
static bool settings_setSensitivity(void) {
systemSettings.sensitivity++;
@@ -540,7 +530,6 @@ static void settings_displayDisplayRotation(void) {
}
static bool settings_setBoostTemp(void) {
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) {
if (systemSettings.BoostTemp == 0) {
systemSettings.BoostTemp = 480; // loop back at 480
@@ -552,9 +541,7 @@ static bool settings_setBoostTemp(void) {
systemSettings.BoostTemp = 0; // jump to off
}
return systemSettings.BoostTemp == 840;
} else
#endif
{
} else {
if (systemSettings.BoostTemp == 0) {
systemSettings.BoostTemp = 250; // loop back at 250
} else {
@@ -907,7 +894,7 @@ static bool settings_enterPowerMenu(void) {
}
static void settings_displayUIMenu(void) { displayMenu(2); }
static bool settings_enterUIMenu(void) {
gui_Menu(UIMenu);
gui_Menu(HasFahrenheit ? UIMenu : UIMenu + 1);
return false;
}
static void settings_displayAdvancedMenu(void) { displayMenu(3); }

View File

@@ -18,7 +18,6 @@ extern "C" {
#include "main.hpp"
#include "stdlib.h"
#include "string.h"
#include "unit.h"
#include <MMA8652FC.hpp>
#include <gui.hpp>
#include <history.hpp>
@@ -69,11 +68,9 @@ void GUIDelay() {
void gui_drawTipTemp(bool symbol) {
// Draw tip temp handling unit conversion & tolerance near setpoint
uint32_t Temp = 0;
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) {
Temp = TipThermoModel::getTipInF();
} else
#endif
{
Temp = TipThermoModel::getTipInC();
}
@@ -82,19 +79,15 @@ void gui_drawTipTemp(bool symbol) {
if (symbol) {
if (OLED::getFont() == 0) {
// Big font, can draw nice symbols
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF)
OLED::drawSymbol(0);
else
#endif
OLED::drawSymbol(1);
} else {
// Otherwise fall back to chars
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF)
OLED::print(SymbolDegF);
else
#endif
OLED::print(SymbolDegC);
}
}
@@ -252,15 +245,12 @@ static void gui_solderingTempAdjust() {
autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
}
// constrain between 10-450 C
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) {
if (systemSettings.SolderingTemp > 850)
systemSettings.SolderingTemp = 850;
if (systemSettings.SolderingTemp < 60)
systemSettings.SolderingTemp = 60;
} else
#endif
{
} else {
if (systemSettings.SolderingTemp > 450)
systemSettings.SolderingTemp = 450;
if (systemSettings.SolderingTemp < 10)
@@ -282,11 +272,9 @@ static void gui_solderingTempAdjust() {
OLED::print(SymbolSpace);
OLED::printNumber(systemSettings.SolderingTemp, 3);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF)
OLED::drawSymbol(0);
else
#endif
{
OLED::drawSymbol(1);
}
@@ -330,22 +318,16 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
if (checkVoltageForExit())
return 1; // return non-zero on error
#endif
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) {
currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(systemSettings.SleepTemp, systemSettings.SolderingTemp));
} else
#endif
{
} else {
currentTempTargetDegC = stayOff ? 0 : min(systemSettings.SleepTemp, systemSettings.SolderingTemp);
}
// draw the lcd
uint16_t tipTemp;
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF)
tipTemp = TipThermoModel::getTipInF();
else
#endif
{
else {
tipTemp = TipThermoModel::getTipInC();
}
@@ -357,12 +339,9 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
OLED::setCursor(0, 8);
OLED::print(SleepingTipAdvancedString);
OLED::printNumber(tipTemp, 3);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF)
OLED::print(SymbolDegF);
else
#endif
{
else {
OLED::print(SymbolDegC);
}
@@ -373,12 +352,9 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
OLED::setFont(0);
OLED::print(SleepingSimpleString);
OLED::printNumber(tipTemp, 3);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF)
OLED::drawSymbol(0);
else
#endif
{
else {
OLED::drawSymbol(1);
}
}
@@ -613,21 +589,15 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
// Update the setpoints for the temperature
if (boostModeOn) {
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF)
currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.BoostTemp);
else
#endif
{
else {
currentTempTargetDegC = (systemSettings.BoostTemp);
}
} else {
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF)
currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.SolderingTemp);
else
#endif
{
else {
currentTempTargetDegC = (systemSettings.SolderingTemp);
}
}

View File

@@ -2,10 +2,9 @@
ifndef model
model:=TS100
endif
OUTPUT_EXE=$(model)_$(lang)
ifndef lang
lang:= EN
endif
ALL_LANGUAGES=BG CS DA DE EN ES FI FR HR HU IT LT NL NL_BE NO PL PT RU SK SL SR_CYRL SR_LATN SV TR UK
# Enumerate all of the include directories
APP_INC_DIR = ./Core/Inc
@@ -104,7 +103,6 @@ INCLUDES = -I$(APP_INC_DIR) \
$(DEVICE_INCLUDES)
TRANSLATION_FILES=$(wildcard ../../Translations/translation_*.json)
GENERATED_TRANSLATION_SOURCE=Core/Gen/Translation.cpp
SOURCE := $(shell find $(SOURCE_THREADS_DIR) -type f -name '*.c') \
$(shell find $(SOURCE_CORE_DIR) -type f -name '*.c') \
$(shell find $(SOURCE_DRIVERS_DIR) -type f -name '*.c') \
@@ -114,8 +112,7 @@ SOURCE_CPP := $(shell find $(SOURCE_THREADS_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_CORE_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_DRIVERS_DIR) -type f -name '*.cpp') \
$(shell find $(DEVICE_BSP_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp') \
$(GENERATED_TRANSLATION_SOURCE)
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
# output folder
HEXFILE_DIR=Hexfile
@@ -126,7 +123,7 @@ OUTPUT_DIR=Objects/$(model)
OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
# global defines ---------------------------------------------------------------
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U
# Without debug code
DEBUG=
@@ -169,8 +166,6 @@ endif
LINKER_FLAGS= -Wl,--gc-sections \
-Wl,--wrap=malloc \
-Wl,--wrap=free \
-o$(OUT_HEXFILE).elf \
-Wl,-Map=$(OUT_HEXFILE).map \
-lm \
-Wl,--undefined=vTaskSwitchContext \
-Wl,--undefined=pxCurrentTCB \
@@ -275,49 +270,55 @@ OBJS_S = $(S_SRCS:.S=.o)
OUT_OBJS=$(addprefix $(OUTPUT_DIR)/,$(OBJS))
OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
all: $(OUT_HEXFILE).hex $(OUT_HEXFILE).bin
default : firmware-EN
firmware-%: $(HEXFILE_DIR)/$(model)_%.hex $(HEXFILE_DIR)/$(model)_%.bin
@true
ALL_FIRMWARE_TARGETS=$(addprefix firmware-,$(ALL_LANGUAGES))
all: $(ALL_FIRMWARE_TARGETS)
#
# The rule to create the target directory
#
# Create hexfile
%.hex : %.elf
$(OBJCOPY) $^ -O ihex $@
%.hex : %.elf Makefile
$(OBJCOPY) $< -O ihex $@
%.bin : %.elf
$(SIZE) --format=berkeley $^
$(OBJCOPY) $^ -O binary $@
%.bin : %.elf Makefile
$(SIZE) --format=berkeley $<
$(OBJCOPY) $< -O binary $@
$(OUT_HEXFILE).elf : $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) Makefile $(LDSCRIPT)
$(HEXFILE_DIR)/$(model)_%.elf : $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUTPUT_DIR)/Core/Gen/Translation.%.o Makefile $(LDSCRIPT)
@test -d $(@D) || mkdir -p $(@D)
@echo Linking $(OUTPUT_EXE).elf
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(LIBS) $(LINKER_FLAGS)
@echo Linking $@
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUTPUT_DIR)/Core/Gen/Translation.$*.o $(LIBS) $(LINKER_FLAGS) -o$@ -Wl,-Map=$@.map
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile $(APP_INC_DIR)/unit.h
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
@test -d $(@D) || mkdir -p $(@D)
@echo Compiling ${<}
@$(CC) -c $(CFLAGS) $< -o $@
$(OUT_OBJS_CPP): $(OUTPUT_DIR)/%.o : %.cpp Makefile $(APP_INC_DIR)/unit.h
$(OUTPUT_DIR)/%.o : %.cpp Makefile
@test -d $(@D) || mkdir -p $(@D)
@echo Compiling ${<}
@$(CPP) -c $(CXXFLAGS) $< -o $@
$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.S Makefile
@test -d $(@D) || mkdir -p $(@D)
@echo 'Building file: $<'
@$(AS) -c $(AFLAGS) $< -o $@
$(APP_INC_DIR)/unit.h $(GENERATED_TRANSLATION_SOURCE): $(TRANSLATION_FILES) Makefile ../Translations/make_translation.py
@echo 'Building translations'
@cd ../Translations && python3 make_translation.py
Core/Gen/Translation.%.cpp: ../Translations/translation_%.json Makefile ../Translations/make_translation.py ../Translations/translations_commons.js
@test -d $(@D) || mkdir -p $(@D)
@echo 'Generating translations for language $*'
@python3 ../Translations/make_translation.py -o $(PWD)/$@ $*
clean :
rm -f $(GENERATED_TRANSLATION_SOURCE) $(SOURCE_CORE_DIR)/Translation.cpp
rm -Rf $(SOURCE_CORE_DIR)/Translation.cpp Core/Gen
rm -Rf $(OUTPUT_DIR_BASE)
rm -Rf $(HEXFILE_DIR)
@@ -328,7 +329,8 @@ style:
done
@echo "Done"
.PHONY: style
.PHONY: style all clean default
.SECONDARY:
# pull in dependency info for *existing* .o files
-include $(OUT_OBJS:.o=.d)

View File

@@ -123,16 +123,8 @@ if [ ${#BUILD_LANGUAGES[@]} -gt 0 ] && [ ${#BUILD_MODELS[@]} -gt 0 ]; then
checkLastCommand
for model in "${BUILD_MODELS[@]}"; do
for lang in "${BUILD_LANGUAGES[@]}"; do
echo "Building firmware for $model in $lang"
make -j lang="$lang" model="$model" >/dev/null
checkLastCommand
echo "Cleanup Temp files for $model in $lang"
rm -rf Objects/*/Core/ >/dev/null
checkLastCommand
done
echo "Cleanup model change"
rm -rf Objects/ >/dev/null
echo "Building firmware for $model in ${BUILD_LANGUAGES[@]}"
make -j$(nproc) model="$model" "${BUILD_LANGUAGES[@]/#/firmware-}" >/dev/null
checkLastCommand
done
else