From 26c7d0f2cbc6190b828c10f0ba50220d48065df8 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 5 Jan 2022 20:41:38 +1100 Subject: [PATCH 1/8] Clean up soldering temp adjust button handling --- source/Core/Src/Settings.cpp | 2 +- source/Core/Threads/GUIThread.cpp | 24 +++++++----------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/source/Core/Src/Settings.cpp b/source/Core/Src/Settings.cpp index 8beb8c9c..e09501c3 100644 --- a/source/Core/Src/Settings.cpp +++ b/source/Core/Src/Settings.cpp @@ -29,7 +29,7 @@ typedef struct { uint16_t versionMarker; uint16_t length; // Length of valid bytes following uint16_t settingsValues[SettingsOptionsLength]; - // used to make this nicely "good enough" aligned to 32 butes to make driver code trivial + // used to make this nicely "good enough" aligned to 32 bytes to make driver code trivial uint32_t padding; } systemSettingsType; diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 1359fe57..054940bc 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -202,36 +202,23 @@ static void gui_solderingTempAdjust() { break; case BUTTON_B_LONG: if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) { - if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) { - delta = getSettingValue(SettingsOptions::TempChangeLongStep); - } else - delta = -getSettingValue(SettingsOptions::TempChangeLongStep); - + delta = -getSettingValue(SettingsOptions::TempChangeLongStep); autoRepeatTimer = xTaskGetTickCount(); autoRepeatAcceleration += PRESS_ACCEL_STEP; } break; case BUTTON_B_SHORT: - if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) { - delta = getSettingValue(SettingsOptions::TempChangeShortStep); - } else - delta = -getSettingValue(SettingsOptions::TempChangeShortStep); + delta = -getSettingValue(SettingsOptions::TempChangeShortStep); break; case BUTTON_F_LONG: if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) { - if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) { - delta = -getSettingValue(SettingsOptions::TempChangeLongStep); - } else - delta = getSettingValue(SettingsOptions::TempChangeLongStep); + delta = getSettingValue(SettingsOptions::TempChangeLongStep); autoRepeatTimer = xTaskGetTickCount(); autoRepeatAcceleration += PRESS_ACCEL_STEP; } break; case BUTTON_F_SHORT: - if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) { - delta = -getSettingValue(SettingsOptions::TempChangeShortStep); - } else - delta = getSettingValue(SettingsOptions::TempChangeShortStep); + delta = getSettingValue(SettingsOptions::TempChangeShortStep); break; default: break; @@ -239,6 +226,9 @@ static void gui_solderingTempAdjust() { if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) < PRESS_ACCEL_INTERVAL_MIN) { autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN; } + if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) { + delta = -delta; + } // constrain between 10-450 C uint16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp); newTemp += delta; From 827308f6911f063b5bde5f50101f7275c13c5d05 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 5 Jan 2022 21:00:14 +1100 Subject: [PATCH 2/8] Add some rounding --- source/Core/Threads/GUIThread.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 054940bc..face0ad1 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -226,12 +226,18 @@ static void gui_solderingTempAdjust() { if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) < PRESS_ACCEL_INTERVAL_MIN) { autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN; } + // If buttons are flipped; flip the delta if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) { delta = -delta; } - // constrain between 10-450 C - uint16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp); + + // constrain between the set temp limits, i.e. 10-450 C + int16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp); newTemp += delta; + // Round to nearest increment of delta + delta = abs(delta); + newTemp = (newTemp / delta) * delta; + if (getSettingValue(SettingsOptions::TemperatureInF)) { if (newTemp > MAX_TEMP_F) newTemp = MAX_TEMP_F; @@ -243,7 +249,7 @@ static void gui_solderingTempAdjust() { if (newTemp < MIN_TEMP_C) newTemp = MIN_TEMP_C; } - setSettingValue(SettingsOptions::SolderingTemp, newTemp); + setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp); if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2)) return; // exit if user just doesn't press anything for a bit From 52f0d5242aa1bd0b751fe5e65bf1635dc0d75144 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 5 Jan 2022 21:04:33 +1100 Subject: [PATCH 3/8] Update GUIThread.cpp --- source/Core/Threads/GUIThread.cpp | 38 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index face0ad1..fe82e8cc 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -230,27 +230,27 @@ static void gui_solderingTempAdjust() { if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) { delta = -delta; } + if (delta != 0) { + // constrain between the set temp limits, i.e. 10-450 C + int16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp); + newTemp += delta; + // Round to nearest increment of delta + delta = abs(delta); + newTemp = (newTemp / delta) * delta; - // constrain between the set temp limits, i.e. 10-450 C - int16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp); - newTemp += delta; - // Round to nearest increment of delta - delta = abs(delta); - newTemp = (newTemp / delta) * delta; - - if (getSettingValue(SettingsOptions::TemperatureInF)) { - if (newTemp > MAX_TEMP_F) - newTemp = MAX_TEMP_F; - if (newTemp < MIN_TEMP_F) - newTemp = MIN_TEMP_F; - } else { - if (newTemp > MAX_TEMP_C) - newTemp = MAX_TEMP_C; - if (newTemp < MIN_TEMP_C) - newTemp = MIN_TEMP_C; + if (getSettingValue(SettingsOptions::TemperatureInF)) { + if (newTemp > MAX_TEMP_F) + newTemp = MAX_TEMP_F; + if (newTemp < MIN_TEMP_F) + newTemp = MIN_TEMP_F; + } else { + if (newTemp > MAX_TEMP_C) + newTemp = MAX_TEMP_C; + if (newTemp < MIN_TEMP_C) + newTemp = MIN_TEMP_C; + } + setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp); } - setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp); - if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2)) return; // exit if user just doesn't press anything for a bit From 761bafad831d30e43a390d7005772483db1a0312 Mon Sep 17 00:00:00 2001 From: discip <53649486+discip@users.noreply.github.com> Date: Thu, 6 Jan 2022 02:13:38 +0100 Subject: [PATCH 4/8] fixed detailed view for lefties --- source/Core/Threads/GUIThread.cpp | 125 ++++++++++++++++++++++++++---- 1 file changed, 109 insertions(+), 16 deletions(-) diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 1359fe57..232be976 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -508,7 +508,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) { case BUTTON_B_LONG: case BUTTON_F_SHORT: case BUTTON_B_SHORT: - // Do nothing and display a lock warming + // Do nothing and display a lock warning warnUser(translatedString(Tr->WarningKeysLockedString), TICKS_SECOND / 2); break; default: @@ -552,7 +552,15 @@ static void gui_solderingMode(uint8_t jumpToSleep) { } } // else we update the screen information - OLED::setCursor(0, 0); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(50, 0); + } else { + OLED::setCursor(-1, 0); + } OLED::clearScreen(); // Draw in the screen details if (getSettingValue(SettingsOptions::DetailedSoldering)) { @@ -560,23 +568,55 @@ static void gui_solderingMode(uint8_t jumpToSleep) { #ifndef NO_SLEEP_MODE if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) { - OLED::setCursor(47, 0); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(32, 0); + } else { + OLED::setCursor(47, 0); + } display_countdown(getSleepTimeout()); } #endif if (boostModeOn) { - OLED::setCursor(54, 8); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(38, 8); + } else { + OLED::setCursor(55, 8); + } OLED::print(SymbolPlus, FontStyle::SMALL); } - OLED::setCursor(67, 0); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(0, 0); + } else { + OLED::setCursor(67, 0); + } OLED::printNumber(x10WattHistory.average() / 10, 2, FontStyle::SMALL); OLED::print(SymbolDot, FontStyle::SMALL); OLED::printNumber(x10WattHistory.average() % 10, 1, FontStyle::SMALL); OLED::print(SymbolWatts, FontStyle::SMALL); - OLED::setCursor(67, 8); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(0, 8); + } else { + OLED::setCursor(67, 8); + } printVoltage(); OLED::print(SymbolVolts, FontStyle::SMALL); } else { @@ -910,28 +950,83 @@ void startGUITask(void const *argument) { } // Clear the lcd buffer OLED::clearScreen(); - OLED::setCursor(0, 0); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(50, 0); + } else { + OLED::setCursor(-1, 0); + } if (getSettingValue(SettingsOptions::DetailedIDLE)) { if (isTipDisconnected()) { - OLED::drawArea(0, 0, 41, 16, disconnectedTipIcon); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + // in right handed mode we want to draw over the first part + OLED::drawArea(55, 0, 41, 16, disconnectedTipIconFlip); + } else { + OLED::drawArea(0, 0, 41, 16, disconnectedTipIcon); + } +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(-1, 0); + } else { + OLED::setCursor(42, 0); + } + uint32_t Vlt = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0); + OLED::printNumber(Vlt / 10, 2, FontStyle::LARGE); + OLED::print(SymbolDot, FontStyle::LARGE); + OLED::printNumber(Vlt % 10, 1, FontStyle::LARGE); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(48, 8); + } else { + OLED::setCursor(91, 8); + } + OLED::print(SymbolVolts, FontStyle::SMALL); } else { if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300))) // Blink temp if setting enable and temp < 55° // 1000 tick/sec // OFF 300ms ON 700ms - gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp - OLED::setCursor(73, 0); // top right + gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(6, 0); + } else { + OLED::setCursor(73, 0); // top right + } OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL); // draw set temp if (getSettingValue(SettingsOptions::TemperatureInF)) OLED::print(SymbolDegF, FontStyle::SMALL); else OLED::print(SymbolDegC, FontStyle::SMALL); +#ifdef OLED_FLIP + if (!OLED::getRotation()) { +#else + if (OLED::getRotation()) { +#endif + OLED::setCursor(0, 8); + } else { + OLED::setCursor(67, 8); // bottom right + } + printVoltage(); // draw voltage then symbol (v) + OLED::print(SymbolVolts, FontStyle::SMALL); } - OLED::setCursor(67, 8); // bottom right - printVoltage(); // draw voltage then symbol (v) - OLED::print(SymbolVolts, FontStyle::SMALL); - } else { #ifdef OLED_FLIP if (!OLED::getRotation()) { @@ -967,7 +1062,6 @@ void startGUITask(void const *argument) { // in right handed mode we want to draw over the first part OLED::fillArea(55, 0, 41, 16, 0); // clear the area for the temp OLED::setCursor(56, 0); - } else { OLED::fillArea(0, 0, 41, 16, 0); // clear the area OLED::setCursor(0, 0); @@ -987,7 +1081,6 @@ void startGUITask(void const *argument) { #endif // in right handed mode we want to draw over the first part OLED::drawArea(55, 0, 41, 16, disconnectedTipIconFlip); - } else { OLED::drawArea(0, 0, 41, 16, disconnectedTipIcon); } From d7b759c534f899412b9e50e1e04c38deb0749abb Mon Sep 17 00:00:00 2001 From: discip <53649486+discip@users.noreply.github.com> Date: Thu, 6 Jan 2022 02:30:45 +0100 Subject: [PATCH 5/8] fixed detailed view for lefties --- source/Core/Threads/GUIThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 232be976..413fdc45 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -689,9 +689,9 @@ static void gui_solderingMode(uint8_t jumpToSleep) { } else { setStatusLED(LED_HEATING); } - // If we have tripped thermal runaway, turn off header and show warning + // If we have tripped thermal runaway, turn off heater and show warning if (heaterThermalRunaway) { - currentTempTargetDegC = 0; // heaater control off + currentTempTargetDegC = 0; // heater control off // TODO WARNING warnUser(translatedString(Tr->WarningThermalRunaway), 10 * TICKS_SECOND); From ca6ff84ddb3e73630b13249a14ac27cadf0eeeb9 Mon Sep 17 00:00:00 2001 From: discip <53649486+discip@users.noreply.github.com> Date: Thu, 6 Jan 2022 03:22:54 +0100 Subject: [PATCH 6/8] Update translation_DE.json --- Translations/translation_DE.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Translations/translation_DE.json b/Translations/translation_DE.json index a3487a86..770ac3fc 100644 --- a/Translations/translation_DE.json +++ b/Translations/translation_DE.json @@ -194,7 +194,7 @@ }, "LanguageSwitch": { "text2": ["Sprache:", " DE Deutsch"], - "desc": "" + "desc": "Sprache der Firmware ändern" }, "Brightness": { "text2": ["Bildschirm-", "kontrast"], From 2505e30f86aab9cef9fe02b5d7cf30b80263a49f Mon Sep 17 00:00:00 2001 From: ysard Date: Thu, 6 Jan 2022 04:45:44 +0100 Subject: [PATCH 7/8] sh_ts100_linux.sh: Fix 'Device or resource busy' errors due to rmdir without umounting --- Flashing/flash_ts100_linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flashing/flash_ts100_linux.sh b/Flashing/flash_ts100_linux.sh index 7c8aac06..5f3328bb 100755 --- a/Flashing/flash_ts100_linux.sh +++ b/Flashing/flash_ts100_linux.sh @@ -69,7 +69,7 @@ mount_ts100() { } umount_ts100() { - if ! mountpoint "$DIR_TMP" > /dev/null && sudo umount "$DIR_TMP"; then + if ! (mountpoint "$DIR_TMP" > /dev/null && sudo umount "$DIR_TMP"); then echo "Failed to unmount $DIR_TMP" exit 1 fi From 1ddd15306daea63885e240542c588d941f51b07d Mon Sep 17 00:00:00 2001 From: ysard Date: Thu, 6 Jan 2022 04:54:40 +0100 Subject: [PATCH 8/8] update flash_ts100_linux.sh * Add a clean method to check if the flash is done correctly or not. * Note that this partially reverts 48b9097 due to the bash shell use instead of legacy sh shell (this is for the use of colors in the check report) --- Flashing/flash_ts100_linux.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Flashing/flash_ts100_linux.sh b/Flashing/flash_ts100_linux.sh index 5f3328bb..dbd65a77 100755 --- a/Flashing/flash_ts100_linux.sh +++ b/Flashing/flash_ts100_linux.sh @@ -1,7 +1,9 @@ -#!/bin/sh +#!/bin/bash # TS100 Flasher for Linux by Alex Wigen (https://github.com/awigen) +# Jan 2021 - Update by Ysard (https://github.com/ysard) DIR_TMP="/tmp/ts100" +HEX_FIRMWARE="$DIR_TMP/ts100.hex" usage() { echo @@ -76,6 +78,21 @@ umount_ts100() { rmdir "$DIR_TMP" } +check_flash() { + RDY_FIRMWARE="${HEX_FIRMWARE%.*}.rdy" + ERR_FIRMWARE="${HEX_FIRMWARE%.*}.err" + if [ -f "$RDY_FIRMWARE" ]; then + echo -e "\e[92mFlash is done\e[0m" + echo "Disconnect the USB and power up the iron. You're good to go." + elif [ -f "$ERR_FIRMWARE" ]; then + echo -e "\e[91mFlash error; Please retry!\e[0m" + else + echo -e "\e[91mUNKNOWN error\e[0m" + echo "Flash result: " + ls "$DIR_TMP"/ts100* + fi +} + cleanup() { enable_gautomount if [ -d "$DIR_TMP" ]; then @@ -109,7 +126,7 @@ echo "Found TS100 config disk device on $DEVICE" mount_ts100 echo "Mounted config disk drive, flashing..." -cp -v "$1" "$DIR_TMP/ts100.hex" +cp -v "$1" "$HEX_FIRMWARE" sync echo "Waiting for TS100 to flash" @@ -119,6 +136,5 @@ echo "Remounting config disk drive" umount_ts100 wait_for_ts100 mount_ts100 +check_flash -echo "Flash result: " -ls "$DIR_TMP"/ts100*