From 64dbd7d32ec175207e43a62c8249331b19c4764c Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 7 Oct 2017 11:52:52 +1100 Subject: [PATCH] Tidy up fonts ready for translations --- workspace/TS100/inc/Settings.h | 3 +- workspace/TS100/inc/Translation.h | 24 ++- workspace/TS100/src/OLED.cpp | 42 ++--- workspace/TS100/src/Settings.cpp | 5 +- workspace/TS100/src/Translation.c | 257 +++--------------------------- workspace/TS100/src/gui.cpp | 100 ++++++------ workspace/TS100/src/main.cpp | 40 +++-- workspace/ts100/inc/Font.h | 15 +- 8 files changed, 148 insertions(+), 338 deletions(-) diff --git a/workspace/TS100/inc/Settings.h b/workspace/TS100/inc/Settings.h index b881b4f8..cfe6a55e 100644 --- a/workspace/TS100/inc/Settings.h +++ b/workspace/TS100/inc/Settings.h @@ -11,7 +11,7 @@ #define SETTINGS_H_ #include #include "stm32f1xx_hal.h" -#define SETTINGSVERSION 0x10 /*Change this if you change the struct below to prevent people getting out of sync*/ +#define SETTINGSVERSION 0x11 /*Change this if you change the struct below to prevent people getting out of sync*/ /* * This struct must be a multiple of 2 bytes as it is saved / restored from flash in uint16_t chunks @@ -21,7 +21,6 @@ typedef struct { uint16_t SleepTemp; //temp to drop to in sleep uint8_t SleepTime; //minutes timeout to sleep uint8_t cutoutSetting; // The voltage we cut out at for under voltage - uint8_t powerDisplay; //Toggle to swap the arrows with a power readout instead uint8_t OrientationMode; //If true we want to invert the display for lefties uint8_t sensitivity; //Sensitivity of accelerometer (5 bits) uint8_t autoStartMode; //Should the unit automatically jump straight into soldering mode when power is applied diff --git a/workspace/TS100/inc/Translation.h b/workspace/TS100/inc/Translation.h index da67fd1c..d0ed1b36 100644 --- a/workspace/TS100/inc/Translation.h +++ b/workspace/TS100/inc/Translation.h @@ -8,8 +8,8 @@ #ifndef TRANSLATION_H_ #define TRANSLATION_H_ -extern const char* SettingsLongNames[14]; -extern const char* SettingsShortNames[14]; +extern const char* SettingsLongNames[15]; +extern const char* SettingsShortNames[15]; extern const char* SettingsCalibrationWarning; extern const char* UVLOWarningString; extern const char* SleepingSimpleString; @@ -19,13 +19,21 @@ extern const char* WarningAdvancedString; extern const char SettingTrueChar; extern const char SettingFalseChar; -extern const char SettingSleepChar; -extern const char SettingFastChar; -extern const char SettingMediumChar; -extern const char SettingSlowChar; extern const char SettingRightChar; extern const char SettingLeftChar; extern const char SettingAutoChar; -extern const char SettingTempCChar; -extern const char SettingTempFChar; + +#define LANG_EN +#define LANG + +#ifndef LANG +#define LANG_EN +#define LANG +#endif + +#ifndef LANG +#error NO LANGUAGE DEFINED +#endif + + #endif /* TRANSLATION_H_ */ diff --git a/workspace/TS100/src/OLED.cpp b/workspace/TS100/src/OLED.cpp index 7ce06ee0..4c84a7ba 100644 --- a/workspace/TS100/src/OLED.cpp +++ b/workspace/TS100/src/OLED.cpp @@ -7,6 +7,7 @@ #include #include +#include "Translation.h" /*Setup params for the OLED screen*/ /*http://www.displayfuture.com/Display/datasheet/controller/SSD1307.pdf*/ /*All commands are prefixed with 0x80*/ @@ -53,7 +54,7 @@ OLED::OLED(I2C_HandleTypeDef* i2cHandle) { fontWidth = 12; displayOffset = 0; displayOnOffState = true; - fontTableLength=sizeof(FONT_12); + fontTableLength = sizeof(FONT_12); } @@ -72,14 +73,14 @@ void OLED::refresh() { screenBuffer[0] = 0x80; screenBuffer[1] = 0x21; screenBuffer[2] = 0x80; - screenBuffer[3] = inLeftHandedMode ? 0 : 32;//display is shifted by 32 in left handed mode as driver ram is 128 wide + screenBuffer[3] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide screenBuffer[4] = 0x80; - screenBuffer[5] = inLeftHandedMode ? 95 : 0x7F;//End address of the ram segment we are writing to (96 wide) + screenBuffer[5] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide) screenBuffer[6] = 0x80; //Set pages to rollover after 2 screenBuffer[7] = 0x22; screenBuffer[8] = 0x80; - screenBuffer[9] = 0x00;//start page 0 + screenBuffer[9] = 0x00; //start page 0 screenBuffer[10] = 0x80; screenBuffer[11] = 0x01; @@ -94,38 +95,39 @@ void OLED::drawChar(char c, char PrecursorCommand) { if (c < ' ') return; //We are left with - uint8_t* charPointer; + uint8_t* charPointer = 0; //Fonts are offset to start at the space char. /* * UTF font handling is done using the two input chars * Precursor is the command char that is used to select the table * */ - uint16_t index = 0; + if (PrecursorCommand == 0) - index = (c - ' '); + charPointer = ((uint8_t*) currentFont) + ((fontWidth * (fontHeight / 8)) * (c - ' ')); else { //This is for extended range //We decode the precursor command to find the offset - //Latin stats at 96 c -= 0x80; +#ifdef INCLUDE_FONT_LATIN if (PrecursorCommand == 0xC3) - index = (128) + (c); + charPointer = ((uint8_t*) FONT_12_LATIN) + ((fontWidth * (fontHeight / 8)) * (32 + c)); else if (PrecursorCommand == 0xC2) - index = (96) + (c); - else if (PrecursorCommand == 0xD0) - index = (192) + (c); + charPointer = ((uint8_t*) FONT_12_LATIN) + ((fontWidth * (fontHeight / 8)) * (c)); +#endif +#ifdef INCLUDE_FONT_CYRILLIC + if (PrecursorCommand == 0xD0) + charPointer = ((uint8_t*) FONT_12_Cyrillic) + ((fontWidth * (fontHeight / 8)) * (c)); else if (PrecursorCommand == 0xD1) - index = (256) + (c); - else - return; + charPointer = ((uint8_t*) FONT_12_Cyrillic) + ((fontWidth * (fontHeight / 8)) * (64 + c)); +#endif + } - charPointer = ((uint8_t*) currentFont) + ((fontWidth * (fontHeight / 8)) * index); - if ((charPointer - currentFont) > fontTableLength) - return; - if (cursor_x >= 0 && cursor_x < 96) - drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer); + + if (charPointer) + if (cursor_x >= 0 && cursor_x < 96) + drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer); cursor_x += fontWidth; } diff --git a/workspace/TS100/src/Settings.cpp b/workspace/TS100/src/Settings.cpp index 2a0d26aa..27b527f2 100644 --- a/workspace/TS100/src/Settings.cpp +++ b/workspace/TS100/src/Settings.cpp @@ -79,12 +79,11 @@ void resetSettings() { systemSettings.version = SETTINGSVERSION; //Store the version number to allow for easier upgrades systemSettings.advancedScreens = 0; //Do we show detailed screens? systemSettings.OrientationMode = 2; //Default to automatic - systemSettings.sensitivity = 8; //Default high sensitivity + systemSettings.sensitivity = 7; //Default high sensitivity systemSettings.voltageDiv = 117; //Default divider from schematic - systemSettings.ShutdownTime = 15; //How many minutes until the unit turns itself off + systemSettings.ShutdownTime = 10; //How many minutes until the unit turns itself off systemSettings.boostModeEnabled = 1; //Default to safe, with no boost mode systemSettings.BoostTemp = 420; //default to 400C - systemSettings.powerDisplay = 0; //default to power display being off systemSettings.autoStartMode = 0; //Auto start off for safety systemSettings.coolingTempBlink = 0; //Blink the temperature on the cooling screen when its > 50C systemSettings.CalibrationOffset = 10; diff --git a/workspace/TS100/src/Translation.c b/workspace/TS100/src/Translation.c index ca85c2b7..be91fa7a 100644 --- a/workspace/TS100/src/Translation.c +++ b/workspace/TS100/src/Translation.c @@ -6,36 +6,25 @@ */ #include "Translation.h" -#define LANG_EN -#define LANG - -#ifndef LANG -#define LANG_EN -#define LANG -#endif - -#ifndef LANG -#error NO LANGUAGE DEFINED -#endif #ifdef LANG_EN -const char* SettingsLongNames[14] = { +const char* SettingsLongNames[15] = { /*These are all the help text for all the settings.*/ /*No requirements on spacing or length*/ -"Power source. Sets cutoff voltage. ", // - "Sleep Temperature ", // - "Sleep Timeout ", // - "Shutdown Timeout ", // - "Motion Sensitivity <0.Off 1.least sensitive 9.most sensitive>", // - "Temperature Unit ", // - "Display detailed information in a smaller font.", // - "Display Orientation ", // - "Enable front key enters boost mode 450C mode when soldering", // - "Temperature when in \"boost\" mode", // - "Automatically starts the iron into soldering on power up. T=Soldering, S= Sleep mode,F=Off", // - "Blink the temperature on the cooling screen while the tip is still hot.", // - "Calibrate tip offset.", // - "Reset all settings", // - "VIN Calibration. Buttons adjust, long press to exit", // +"Power source. Sets cutoff voltage. ", //Power Source + "Sleep Temperature ", //Sleep Temp + "Sleep Timeout ", //Sleep Timeout + "Shutdown Timeout ", //Shutdown Time + "Motion Sensitivity <0.Off 1.least sensitive 9.most sensitive>", //Motion Sensitivity + "Temperature Unit ", //Temp Unit + "Display detailed information in a smaller font.", //Detailed Information + "Display Orientation ", //Orientation + "Enable front key enters boost mode 450C mode when soldering", //Boost enable + "Temperature when in \"boost\" mode", //Boost Temp + "Automatically starts the iron into soldering on power up. T=Soldering, S= Sleep mode,F=Off", //Auto start + "Blink the temperature on the cooling screen while the tip is still hot.", //Cooling Blink + "Calibrate tip offset.", //Calibrate Tip + "Reset all settings", //Reset Settings + "VIN Calibration. Buttons adjust, long press to exit", //VIN Cal }; const char* SettingsCalibrationWarning = "Please ensure the tip is at room temperature before continuing!"; @@ -45,220 +34,14 @@ const char* SleepingAdvancedString = "Sleeping..."; // <=17 chars const char* WarningSimpleString = "HOT!"; //Must be <= 4 chars const char* WarningAdvancedString = "WARNING! TIP HOT!"; -const char SettingTrueChar = 'V'; -const char SettingFalseChar = 'F'; -const char SettingSleepChar = 'S'; -const char SettingFastChar = 'R'; -const char SettingMediumChar = 'M'; -const char SettingSlowChar = 'L'; -const char SettingRightChar = 'D'; -const char SettingLeftChar = 'I'; -const char SettingAutoChar = 'A'; -const char SettingTempCChar = 'C'; -const char SettingTempFChar = 'F'; -#endif - -#ifdef LANG_ES -const char* SettingsLongNames[14] = { - /*These are all the help text for all the settings.*/ - /*All must start with 6 spaces so they come on screen nicely.*/ - "Fuente de energía. Ajusta el límite inferior de voltaje. ", // - "Temperatura en reposo. ",// - "Tiempo hasta activar reposo. ",// - "Tiempo hasta apagado. ",// - "Sensibilidad del movimiento. <0=Apagado 1=El menos sensible 9=El más sensible>",// - "Display detailed information in a smaller font.",// - "Orientación de la pantalla ",// - "Activar el botón \"Boost\" en modo soldadura.",// - "Temperatura en modo \"Boost\". ",// - "Iniciar modo soldadura en el encendido. ",// - "Parpadea la temperatura en el enfriamiento si la punta sigue caliente.",// - "Calibrate tip offset.",// - "Reset all settings",// -}; -const char* SettingsCalibrationWarning = "Please ensure the tip is at room temperature before continuing!"; -const char* UVLOWarningString = "LOW VOLT"; //Fixed width 8 chars -const char SettingTrueChar = 'V'; -const char SettingFalseChar = 'F'; -const char SettingSleepChar = 'S'; -const char SettingFastChar = 'R'; -const char SettingMediumChar = 'M'; -const char SettingSlowChar = 'L'; -const char SettingRightChar = 'D'; -const char SettingLeftChar = 'I'; -const char SettingAutoChar = 'A'; -const char SettingTempCChar = 'C'; -const char SettingTempFChar = 'F'; -#endif - -#ifdef LANG_DE -const char* SettingsLongNames[14] = { - /*These are all the help text for all the settings.*/ - /*All must start with 6 spaces so they come on screen nicely.*/ - "Stromversorgung. Setzt Abschaltspannung ", - "Ruhetemperatur ", - "Ruhemodus nach ", - "Abschaltzeit ", - "Bewegungsempfindlichkeit <0=Aus 1=Minimal 9=Maximal>", - "Display detailed information in a smaller font.", // - "Anzeigerichtung ", - "Fronttaste für Temperaturboost einschalten", - "Temperatur im \"boost\"-Modus ", - "Automatischer Start beim Einschalten. ", - "Temperatur blinkt beim Abkühlen, solange noch heiß.", - "Calibrate tip offset.",//s - "Reset all settings",}; -}; -const char* UVLOWarningString = "V gering"; //Fixed width 8 chars -const char* CoolingPromptString = "Kalt ";//Fixed width 5 chars -const char SettingTrueChar = 'J'; -const char SettingFalseChar = 'N'; -const char SettingSleepChar = 'R'; -const char SettingFastChar = 'S'; -const char SettingMediumChar = 'M'; -const char SettingSlowChar = 'L'; -const char SettingRightChar = 'R'; -const char SettingLeftChar = 'L'; -const char SettingAutoChar = 'A'; -const char SettingTempCChar = 'C'; -const char SettingTempFChar = 'F'; -#endif - -#ifdef LANG_FR -const char* SettingsLongNames[14] = { - /*These are all the help text for all the settings.*/ - /*All must start with 6 spaces so they come on screen nicely.*/ - "Type d\'alimentation. Regle la tension de coupure. ", - "Temperature en veille. ", - "Temps avant mise en veille. ", - "Temps avant extinction. ", - "Sensibilitee du capteur de mouvement. <0=Inactif 1=Peu sensible 9=Tres sensible>", - "Display detailed information in a smaller font.", // - "Orientation de l\'affichage. ", - "Active le mode \"Boost\" 450C sur le bouton de devant pendant la soudure.", - "Temperature du mode \"Boost\". ", - "Demarre automatiquement la soudure a l\'allumage. ", - "Fait clignotter la temperature pendant la phase de refroidissement quand la panne est chaude.", - "Calibrate tip offset.",//s - "Reset all settings",}; -}; -const char* SettingsCalibrationWarning = "Please ensure the tip is at room temperature before continuing!"; - -const char* UVLOWarningString = "Batt Bas"; //Fixed width 8 chars -const char* CoolingPromptString = "Etein";//Fixed width 5 chars -const char SettingTrueChar = 'A'; -const char SettingFalseChar = 'D'; -const char SettingSleepChar = 'V'; -const char SettingFastChar = 'R'; -const char SettingMediumChar = 'M'; -const char SettingSlowChar = 'L'; -const char SettingRightChar = 'D'; -const char SettingLeftChar = 'G'; -const char SettingAutoChar = 'A'; -const char SettingTempCChar = 'C'; -const char SettingTempFChar = 'F'; -#endif - -#ifdef LANG_IT -const char* SettingsLongNames[14] = { - /*These are all the help text for all the settings.*/ - "Sorgente di alimentazione. Imposta il limite inferiore di tensione. ", - "Temperatura modalità riposo ", - "Timeout per passaggio a modalità riposo ", - "Timeout spegnimento ", - "Sensibilità al movimento <0=Spento 1=Sensibilità minima 9=Sensibilità massima>", - "Display detailed information in a smaller font.", // - "Orientamento del display ", - "Il tasto anteriore abilita modalità \"boost\" fino a 450C durante la saldatura", - "Temperatura in modalità \"boost\" ", - "Avvia automaticamente il saldatore quando viene alimentato. ", - "Durante lo spegnimento la temperatura lampeggia sul display finché la punta è calda.", - "Calibrate tip offset.",//s - "Reset all settings",}; -}; -const char* SettingsCalibrationWarning = "Please ensure the tip is at room temperature before continuing!"; - -const char* UVLOWarningString = "LOW VOLT"; //Fixed width 8 chars -const char* CoolingPromptString = "Cool";//Fixed width 5 chars -const char SettingTrueChar = 'S'; -const char SettingFalseChar = 'N'; -const char SettingSleepChar = 'R'; -const char SettingFastChar = 'V'; -const char SettingMediumChar = 'M'; -const char SettingSlowChar = 'L'; -const char SettingRightChar = 'D'; -const char SettingLeftChar = 'S'; -const char SettingAutoChar = 'A'; -const char SettingTempCChar = 'C'; -const char SettingTempFChar = 'F'; -#endif - -#ifdef LANG_SE -const char* SettingsLongNames[14] = { - /*These are all the help text for all the settings.*/ - "Stromforsorjning. Satt avstagningsvolt. ", - "Vilolage Temperatur ", - "Vilolage Timeout ", - "Avstagningstimeout ", - "Rorelsekanslighet <0=Av 1=Minsta kanslighet 9=Hogsta kanslighet>", - "Display detailed information in a smaller font.", // - "Skarmorientation ", - "Aktivera boost-lage med framre knappen ", - "Temperatur i \"boostlage\" ", - "Startar i lodningslage direkt ", - "Blinka temperaturen medans jarnet fortfarande ar varmt. ", - "Calibrate tip offset.",//s - "Reset all settings",}; -}; -const char* SettingsCalibrationWarning = "Please ensure the tip is at room temperature before continuing!"; - -const char* UVLOWarningString = "Lag Volt"; //Fixed width 8 chars -const char* CoolingPromptString = "Sval ";//Fixed width 5 chars -const char SettingTrueChar = 'P'; -const char SettingFalseChar = 'A'; -const char SettingSleepChar = 'V'; -const char SettingFastChar = 'S'; -const char SettingMediumChar = 'M'; -const char SettingSlowChar = 'L'; -const char SettingRightChar = 'H'; -const char SettingLeftChar = 'V'; -const char SettingAutoChar = 'A'; -const char SettingTempCChar = 'C'; -const char SettingTempFChar = 'F'; -#endif - -#ifdef LANG_RU -const char* SettingsLongNames[14] = { -//These are all the help text for all the settings./ - "Источник питания. Установка напряжения отключения. ", "Температура Сна <С>", - "Переход в режим Сна <Минуты>", "Переходит в режим ожидания <Минуты>", - "Акселерометр <0. Выкл. 1. мин. чувствительный 9. макс. чувствительный>", - "Display detailed information in a smaller font.",// - "Ориентация Дисплея ", - "Активация кнопки A для Турбо режима до 450С при пайке ", "Установка температуры для Турбо режима", - "Изменяет стрелки на дисплей питания при пайке", - "Автоматический запуск паяльника при включении питания. T=Нагрев, S=Режим Сна,F=Выкл.", - "Мигает температура на экране охлаждения, пока жало остается горячим.", "Calibrate tip offset.",//s - "Reset all settings",}; - -const char* SettingsCalibrationWarning = "Please ensure the tip is at room temperature before continuing!"; - -const char* UVLOWarningString = "Low Volt"; //Fixed width 8 chars -const char* CoolingPromptString = "Выкл. ";//Fixed width 5 chars const char SettingTrueChar = 'T'; const char SettingFalseChar = 'F'; -const char SettingSleepChar = 'S'; -const char SettingFastChar = 'F'; -const char SettingMediumChar = 'M'; -const char SettingSlowChar = 'S'; const char SettingRightChar = 'R'; const char SettingLeftChar = 'L'; const char SettingAutoChar = 'A'; -const char SettingTempCChar = 'C'; -const char SettingTempFChar = 'F'; - #endif -const char* SettingsShortNames[14] = { /**/ + +const char* SettingsShortNames[15] = { /**/ "PWRSC ", // Power Source (DC or batt) "STMP ", // Sleep Temperature "STME ", // Sleep Timeout @@ -272,5 +55,5 @@ const char* SettingsShortNames[14] = { /**/ "ASTART ", // Automatic Start mode "CLBLNK ", // Cooldown blink "TMP CAL?", // Temperature calibration enter menu - "RESET? " // Settings reset command - }; + "RESET? ", // Settings reset command + "CAL VIN?", }; diff --git a/workspace/TS100/src/gui.cpp b/workspace/TS100/src/gui.cpp index 9b56898f..0947210b 100644 --- a/workspace/TS100/src/gui.cpp +++ b/workspace/TS100/src/gui.cpp @@ -84,8 +84,8 @@ static void settings_displaySleepTemp(void) { } static void settings_setSleepTime(void) { ++systemSettings.SleepTime; //Go up 1 minute at a time - if (systemSettings.SleepTime > 16) - systemSettings.SleepTime = 1; //can't set time over 30 mins + if (systemSettings.SleepTime >= 16) + systemSettings.SleepTime = 1; //can't set time over 10 mins //Remember that ^ is the time of no movement } static void settings_displaySleepTime(void) { @@ -135,9 +135,9 @@ static void settings_setAdvancedScreens(void) { static void settings_displayAdvancedScreens(void) { lcd.print(SettingsShortNames[6]); if (systemSettings.advancedScreens) - lcd.drawChar('T'); + lcd.drawChar(SettingTrueChar); else - lcd.drawChar('F'); + lcd.drawChar(SettingFalseChar); } static void settings_setDisplayRotation(void) { systemSettings.OrientationMode++; @@ -147,13 +147,13 @@ static void settings_displayDisplayRotation(void) { lcd.print(SettingsShortNames[7]); switch (systemSettings.OrientationMode) { case 0: - lcd.drawChar('R'); + lcd.drawChar(SettingRightChar); break; case 1: - lcd.drawChar('L'); + lcd.drawChar(SettingLeftChar); break; case 2: - lcd.drawChar('A'); + lcd.drawChar(SettingAutoChar); break; } @@ -164,9 +164,9 @@ static void settings_setBoostModeEnabled(void) { static void settings_displayBoostModeEnabled(void) { lcd.print(SettingsShortNames[8]); if (systemSettings.boostModeEnabled) - lcd.drawChar('T'); + lcd.drawChar(SettingTrueChar); else - lcd.drawChar('F'); + lcd.drawChar(SettingFalseChar); } static void settings_setBoostTemp(void) { systemSettings.BoostTemp += 10; //Go up 10C at a time @@ -185,10 +185,10 @@ static void settings_displayAutomaticStartMode(void) { lcd.print(SettingsShortNames[10]); switch (systemSettings.autoStartMode) { case 0: - lcd.drawChar('F'); + lcd.drawChar(SettingFalseChar); break; case 1: - lcd.drawChar('T'); + lcd.drawChar(SettingTrueChar); break; } } @@ -198,9 +198,9 @@ static void settings_setCoolingBlinkEnabled(void) { static void settings_displayCoolingBlinkEnabled(void) { lcd.print(SettingsShortNames[11]); if (systemSettings.coolingTempBlink) - lcd.drawChar('T'); + lcd.drawChar(SettingTrueChar); else - lcd.drawChar('F'); + lcd.drawChar(SettingFalseChar); } static void settings_setResetSettings(void) { settingsResetRequest = !settingsResetRequest; @@ -208,22 +208,22 @@ static void settings_setResetSettings(void) { static void settings_displayResetSettings(void) { lcd.print(SettingsShortNames[13]); if (settingsResetRequest) - lcd.drawChar('T'); + lcd.drawChar(SettingTrueChar); else - lcd.drawChar('F'); + lcd.drawChar(SettingFalseChar); } static void settings_setCalibrate(void) { //Calibrate the offset //We split off here to confirm with the user - uint8_t maxOffset = strlen(SettingsCalibrationWarning); + uint8_t maxOffset = strlen(SettingsCalibrationWarning) + 5; uint32_t descriptionStart = HAL_GetTick(); lcd.setFont(0); lcd.clearScreen(); lcd.setCursor(0, 0); for (;;) { - int16_t descriptionOffset = ((HAL_GetTick() - descriptionStart) / 150) % maxOffset; + int16_t descriptionOffset = (((HAL_GetTick() - descriptionStart) / 150) % maxOffset); lcd.setCursor(12 * (7 - descriptionOffset), 0); lcd.print(SettingsCalibrationWarning); ButtonState buttons = getButtonState(); @@ -273,45 +273,45 @@ static void settings_displayCalibrate(void) { static void settings_setCalibrateVIN(void) { //Jump to the voltage calibration subscreen - lcd.setFont(0); - lcd.clearScreen(); + lcd.setFont(0); + lcd.clearScreen(); + lcd.setCursor(0, 0); + for (;;) { lcd.setCursor(0, 0); - for (;;) { - lcd.setCursor(0, 0); - lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv)/10,2); - lcd.print("."); - lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv)%10,1); - lcd.print("V"); + lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); + lcd.print("."); + lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); + lcd.print("V"); - ButtonState buttons = getButtonState(); - switch (buttons) { - case BUTTON_F_SHORT: - systemSettings.voltageDiv++; - break; - case BUTTON_B_SHORT: - systemSettings.voltageDiv--; - break; - case BUTTON_BOTH: - case BUTTON_F_LONG: - case BUTTON_B_LONG: - saveSettings(); - return; - break; - case BUTTON_NONE: - break; - } - lcd.refresh(); - osDelay(50); - if(systemSettings.voltageDiv<90) - systemSettings.voltageDiv=90; - else if (systemSettings.voltageDiv>130) - systemSettings.voltageDiv=130; - //Cap to sensible values + ButtonState buttons = getButtonState(); + switch (buttons) { + case BUTTON_F_SHORT: + systemSettings.voltageDiv++; + break; + case BUTTON_B_SHORT: + systemSettings.voltageDiv--; + break; + case BUTTON_BOTH: + case BUTTON_F_LONG: + case BUTTON_B_LONG: + saveSettings(); + return; + break; + case BUTTON_NONE: + break; } + lcd.refresh(); + osDelay(50); + if (systemSettings.voltageDiv < 90) + systemSettings.voltageDiv = 90; + else if (systemSettings.voltageDiv > 130) + systemSettings.voltageDiv = 130; + //Cap to sensible values + } } static void settings_displayCalibrateVIN(void) { lcd.clearScreen(); lcd.setCursor(0, 0); - lcd.print("CAL VIN?"); + lcd.print(SettingsShortNames[14]); } diff --git a/workspace/TS100/src/main.cpp b/workspace/TS100/src/main.cpp index a0191a22..99f688ed 100644 --- a/workspace/TS100/src/main.cpp +++ b/workspace/TS100/src/main.cpp @@ -71,8 +71,7 @@ int main(void) { while (1) { } } -void GUIDelay() -{ +void GUIDelay() { osDelay(50); } ButtonState getButtonState() { @@ -211,7 +210,7 @@ static void gui_drawBatteryIcon() { cellV = 9; lcd.drawBattery(cellV + 1); } else - lcd.drawChar(' '); //print a blank spot if there is no battery symbol + lcd.drawSymbol(16); //Draw the DC Logo } static void gui_solderingTempAdjust() { @@ -302,11 +301,11 @@ static void gui_settingsMenu() { } else { //Draw description //draw string starting from descriptionOffset - int16_t maxOffset = strlen(settingsMenu[currentScreen].description); + int16_t maxOffset = strlen(settingsMenu[currentScreen].description)+5; if (descriptionStart == 0) descriptionStart = HAL_GetTick(); - int16_t descriptionOffset = ((HAL_GetTick() - descriptionStart) / 150) % maxOffset; + int16_t descriptionOffset = (((HAL_GetTick() - descriptionStart) / 150) % maxOffset); //^ Rolling offset based on time lcd.setCursor(12 * (7 - descriptionOffset), 0); lcd.print(settingsMenu[currentScreen].description); @@ -372,7 +371,10 @@ static void gui_showTipTempWarning() { } } else { lcd.setFont(0); - lcd.print(WarningSimpleString); + lcd.drawArea(0, 0, 24, 16, WarningBlock24); + lcd.setCursor(24, 0); + //lcd.print(WarningSimpleString); + lcd.print(" "); if (systemSettings.temperatureInF) { lcd.printNumber(tipMeasurementToF(getTipRawTemp(0)), 3); lcd.drawSymbol(0); @@ -433,10 +435,11 @@ static int gui_SolderingSleepingMode() { else lcd.print("C"); - lcd.print(" VIN:"); + lcd.print(" |"); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); lcd.drawChar('.'); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); + lcd.drawChar('V'); } else { lcd.setFont(0); lcd.print(SleepingSimpleString); @@ -446,13 +449,14 @@ static int gui_SolderingSleepingMode() { else lcd.drawSymbol(1); } - if (lastMovementTime) - if (((uint32_t) (HAL_GetTick() - lastMovementTime)) - > (uint32_t) (systemSettings.ShutdownTime * 60 * 1000)) { - //shutdown - currentlyActiveTemperatureTarget = 0; - return 1; //we want to exit soldering mode - } + if (systemSettings.ShutdownTime)//only allow shutdown exit if time > 0 + if (lastMovementTime) + if (((uint32_t) (HAL_GetTick() - lastMovementTime)) + > (uint32_t) (systemSettings.ShutdownTime * 60 * 1000)) { + //shutdown + currentlyActiveTemperatureTarget = 0; + return 1; //we want to exit soldering mode + } lcd.refresh(); GUIDelay(); HAL_IWDG_Refresh(&hiwdg); @@ -596,8 +600,9 @@ static void gui_solderingMode() { lcd.refresh(); if (systemSettings.sensitivity) if (HAL_GetTick() - lastMovementTime > sleepThres && HAL_GetTick() - lastButtonTime > sleepThres) { - if (gui_SolderingSleepingMode()) + if (gui_SolderingSleepingMode()) { return; //If the function returns non-0 then exit + } } GUIDelay(); HAL_IWDG_Refresh(&hiwdg); @@ -672,6 +677,8 @@ void startGUITask(void const * argument) { lcd.print(__DATE__); //print the compile date lcd.refresh(); waitForButtonPress(); + lcd.setFont(0); //reset font + } break; case BUTTON_F_LONG: @@ -709,6 +716,7 @@ void startGUITask(void const * argument) { if (tipTemp > 50) { if (tempWarningState == 0) { currentlyActiveTemperatureTarget = 0; //ensure tip is off + lcd.displayOnOff(true); //force LCD on gui_showTipTempWarning(); tempWarningState = 1; } @@ -869,7 +877,7 @@ void startMOVTask(void const * argument) { } - osDelay(20);//Slow down update rate + osDelay(20); //Slow down update rate } } diff --git a/workspace/ts100/inc/Font.h b/workspace/ts100/inc/Font.h index 61cb7416..909d6f52 100644 --- a/workspace/ts100/inc/Font.h +++ b/workspace/ts100/inc/Font.h @@ -114,7 +114,8 @@ const uint8_t FONT_12[]={ 0x00,0x00,0x03,0x03,0x03,0x07,0x7E,0xFC,0xC0,0x80,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3F,0x1F,0x01,0x00,0x00,0x00,//} 0x00,0x10,0x18,0x0C,0x04,0x0C,0x18,0x10,0x18,0x0C,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 0x00,0x00,0x80,0xC0,0x60,0x30,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x0F,0x0F,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0F,0x0F,0x00,//Up triangle - +}; +const uint8_t FONT_12_LATIN[] = { /*Start extended Latin range*/ //V96 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//A0 (blank) @@ -219,6 +220,8 @@ const uint8_t FONT_12[]={ 0x00,0x00,0x03,0xFF,0xFF,0x1B,0x18,0x18,0xF8,0xF0,0x00,0x00,0x00,0x00,0x30,0x3F,0x3F,0x36,0x06,0x06,0x07,0x03,0x00,0x00,//FE//254 0x00,0x00,0x60,0xEC,0x8C,0x00,0x00,0x8C,0xEC,0x60,0x00,0x00,0x00,0x00,0x00,0x81,0xE7,0x7E,0x1E,0x07,0x01,0x00,0x00,0x00,//FF//255 //V192 +}; +const uint8_t FONT_12_Cyrillic[] = { /* Cyrillic Glyphs */ 0x00,0xFC,0xFC,0x8D,0x8F,0x8E,0x8C,0x8C,0x8C,0x0C,0x0C,0x00,0x00,0x3F,0x3F,0x31,0x31,0x31,0x31,0x31,0x31,0x30,0x30,0x00, // Ѐ d0 80 0x00,0xFE,0xFE,0xC7,0xC7,0xC6,0xC6,0xC7,0xC7,0x06,0x06,0x00,0x00,0x3F,0x3F,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00, // Ё d0 81 @@ -342,7 +345,9 @@ const uint8_t ExtraFontChars[] = { 0x00,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x00,0x00,0x38,0x3A,0x39,0x38,0x3A,0x39,0x38,0x3A,0x39,0x10,0x10, // heating 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x10,0x10, // cooling - + //width = 12 + //height = 16 + 0x00,0x60,0xE0,0xFE,0xE0,0xE0,0xE0,0xE0,0xFE,0xE0,0x60,0x00,0x00,0x00,0x00,0x01,0x03,0xFF,0xFF,0x03,0x01,0x00,0x00,0x00, /* @@ -411,6 +416,12 @@ const uint8_t FontSymbols[] = { 0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x04,0x06,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x06,0x04,//UP block 0x00,0x20,0x60,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0x60,0x20,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x03,0x01,0x00,0x00,0x00,//Down block }; +const uint8_t WarningBlock24[] = { + //width = 24 + //height = 16 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x30,0x0C,0x02,0xF1,0xF1,0xF1,0x02,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0xC0,0xB0,0x8C,0x83,0x80,0x80,0x80,0x80,0xB3,0xB3,0xB3,0x80,0x80,0x80,0x80,0x83,0x8C,0xB0,0xC0,0x00,0x00, +}; const uint8_t idleScreenBG[] = { //width = 84