From 34db06ab9ce67dd77867f6fd9a3b04ce48e0a35b Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Thu, 1 Aug 2024 05:00:26 +0200 Subject: [PATCH 01/11] Update Soldering.cpp allow to use remaining state1 for timer --- source/Core/Threads/UI/logic/Soldering.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index 93be884194..27dbc8993a 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -7,7 +7,7 @@ // State 3 = buzzer timer OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) { - if (cxt->scratch_state.state1 >= 2) { + if (cxt->scratch_state.state1 & (2|3)) { // Buttons are currently locked switch (buttons) { case BUTTON_F_LONG: @@ -16,17 +16,21 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) } break; case BUTTON_BOTH_LONG: - if (cxt->scratch_state.state1 == 3) { + if ((cxt->scratch_state.state1 & (2|3)) == 3) { // Unlocking if (warnUser(translatedString(Tr->UnlockingKeysString), buttons)) { - cxt->scratch_state.state1 = 1; + // cxt->scratch_state.state1 &= ~3; + // cxt->scratch_state.state1 |= 1; + cxt->scratch_state.state1 &= ~2; } } else { warnUser(translatedString(Tr->WarningKeysLockedString), buttons); } break; case BUTTON_NONE: - cxt->scratch_state.state1 = 3; + //cxt->scratch_state.state1 &= ~2; + //cxt->scratch_state.state1 |= 3; + cxt->scratch_state.state1 |= 3; break; default: // Do nothing and display a lock warning warnUser(translatedString(Tr->WarningKeysLockedString), buttons); @@ -38,7 +42,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) switch (buttons) { case BUTTON_NONE: cxt->scratch_state.state2 = 0; - cxt->scratch_state.state1 = 0; + cxt->scratch_state.state1 &= ~1; break; case BUTTON_BOTH: /*Fall through*/ @@ -58,9 +62,9 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) case BUTTON_BOTH_LONG: if (getSettingValue(SettingsOptions::LockingMode)) { // Lock buttons - if (cxt->scratch_state.state1 == 0) { + if ((cxt->scratch_state.state1 & 1) == 0) { if (warnUser(translatedString(Tr->LockingKeysString), buttons)) { - cxt->scratch_state.state1 = 2; + cxt->scratch_state.state1 |= 2; } } else { // FIXME should be WarningKeysUnlockedString From c0ba6eb30d1acfd9ad44920ee61b7f4cfdeb71e0 Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Thu, 1 Aug 2024 05:29:53 +0200 Subject: [PATCH 02/11] Update Soldering.cpp revert last commit --- source/Core/Threads/UI/logic/Soldering.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index 27dbc8993a..93be884194 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -7,7 +7,7 @@ // State 3 = buzzer timer OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) { - if (cxt->scratch_state.state1 & (2|3)) { + if (cxt->scratch_state.state1 >= 2) { // Buttons are currently locked switch (buttons) { case BUTTON_F_LONG: @@ -16,21 +16,17 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) } break; case BUTTON_BOTH_LONG: - if ((cxt->scratch_state.state1 & (2|3)) == 3) { + if (cxt->scratch_state.state1 == 3) { // Unlocking if (warnUser(translatedString(Tr->UnlockingKeysString), buttons)) { - // cxt->scratch_state.state1 &= ~3; - // cxt->scratch_state.state1 |= 1; - cxt->scratch_state.state1 &= ~2; + cxt->scratch_state.state1 = 1; } } else { warnUser(translatedString(Tr->WarningKeysLockedString), buttons); } break; case BUTTON_NONE: - //cxt->scratch_state.state1 &= ~2; - //cxt->scratch_state.state1 |= 3; - cxt->scratch_state.state1 |= 3; + cxt->scratch_state.state1 = 3; break; default: // Do nothing and display a lock warning warnUser(translatedString(Tr->WarningKeysLockedString), buttons); @@ -42,7 +38,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) switch (buttons) { case BUTTON_NONE: cxt->scratch_state.state2 = 0; - cxt->scratch_state.state1 &= ~1; + cxt->scratch_state.state1 = 0; break; case BUTTON_BOTH: /*Fall through*/ @@ -62,9 +58,9 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) case BUTTON_BOTH_LONG: if (getSettingValue(SettingsOptions::LockingMode)) { // Lock buttons - if ((cxt->scratch_state.state1 & 1) == 0) { + if (cxt->scratch_state.state1 == 0) { if (warnUser(translatedString(Tr->LockingKeysString), buttons)) { - cxt->scratch_state.state1 |= 2; + cxt->scratch_state.state1 = 2; } } else { // FIXME should be WarningKeysUnlockedString From ae55d5c3de4a7503d700f4e53f5072f42ce7547d Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Thu, 1 Aug 2024 05:41:07 +0200 Subject: [PATCH 03/11] Update Soldering.cpp show the locked warning for half a second --- source/Core/Threads/UI/logic/Soldering.cpp | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index 93be884194..35875471ac 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -9,12 +9,16 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) { if (cxt->scratch_state.state1 >= 2) { // Buttons are currently locked - switch (buttons) { - case BUTTON_F_LONG: - if (getSettingValue(SettingsOptions::BoostTemp) && (getSettingValue(SettingsOptions::LockingMode) == lockingMode_t::BOOST)) { - cxt->scratch_state.state2 = 1; + if (cxt->scratch_state.state1 > 3) { + // show locked until timer is up + if ((cxt->scratch_state.state1 >> 2) < xTaskGetTickCount()) { + cxt->scratch_state.state1 &= 3; + } else { + warnUser(translatedString(Tr->WarningKeysLockedString), buttons); + return OperatingMode::Soldering; } - break; + } + switch (buttons) { case BUTTON_BOTH_LONG: if (cxt->scratch_state.state1 == 3) { // Unlocking @@ -28,7 +32,14 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) case BUTTON_NONE: cxt->scratch_state.state1 = 3; break; - default: // Do nothing and display a lock warning + case BUTTON_F_LONG: + if (getSettingValue(SettingsOptions::BoostTemp) && (getSettingValue(SettingsOptions::LockingMode) == lockingMode_t::BOOST)) { + cxt->scratch_state.state2 = 1; + break; + } + /*Fall through*/ + default: // Set timer for and display a lock warning + cxt->scratch_state.state1 |= (xTaskGetTickCount() + TICKS_SECOND / 2) << 2; warnUser(translatedString(Tr->WarningKeysLockedString), buttons); break; } From ea2deb0e129323649b66712ef2045f3c8458a648 Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Thu, 1 Aug 2024 05:56:09 +0200 Subject: [PATCH 04/11] Update Soldering.cpp change locked warning display time to 1 second --- source/Core/Threads/UI/logic/Soldering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index 35875471ac..f4ff487e0c 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -39,7 +39,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) } /*Fall through*/ default: // Set timer for and display a lock warning - cxt->scratch_state.state1 |= (xTaskGetTickCount() + TICKS_SECOND / 2) << 2; + cxt->scratch_state.state1 |= (xTaskGetTickCount() + TICKS_SECOND) << 2; warnUser(translatedString(Tr->WarningKeysLockedString), buttons); break; } From 3d43354ea1ab748217686fda9e7adfc0257721f7 Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Thu, 1 Aug 2024 08:39:14 +0200 Subject: [PATCH 05/11] Update Soldering.cpp fix timer logic --- source/Core/Threads/UI/logic/Soldering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index f4ff487e0c..35e5e9794c 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -11,7 +11,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) // Buttons are currently locked if (cxt->scratch_state.state1 > 3) { // show locked until timer is up - if ((cxt->scratch_state.state1 >> 2) < xTaskGetTickCount()) { + if ((uint16_t)(xTaskGetTickCount() << 2) - (cxt->scratch_state.state1 & ~3) > TICKS_SECOND) { cxt->scratch_state.state1 &= 3; } else { warnUser(translatedString(Tr->WarningKeysLockedString), buttons); From 697b0c795d01098a526de40020fb320c82db02bb Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Thu, 1 Aug 2024 08:54:26 +0200 Subject: [PATCH 06/11] Update Soldering.cpp fix another logic error --- source/Core/Threads/UI/logic/Soldering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index 35e5e9794c..e7559e7353 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -11,7 +11,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) // Buttons are currently locked if (cxt->scratch_state.state1 > 3) { // show locked until timer is up - if ((uint16_t)(xTaskGetTickCount() << 2) - (cxt->scratch_state.state1 & ~3) > TICKS_SECOND) { + if ((uint16_t)(xTaskGetTickCount() << 2) - (cxt->scratch_state.state1 & ~3) > TICKS_SECOND << 2) { cxt->scratch_state.state1 &= 3; } else { warnUser(translatedString(Tr->WarningKeysLockedString), buttons); From c002f45c7ea649c8b73642420bd721b710820649 Mon Sep 17 00:00:00 2001 From: discip <53649486+discip@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:46:20 +0200 Subject: [PATCH 07/11] making the LOCKED / UNLOCKED stay for a second --- source/Core/Threads/UI/logic/Soldering.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index e7559e7353..53d44d1cf7 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -26,7 +26,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) cxt->scratch_state.state1 = 1; } } else { - warnUser(translatedString(Tr->WarningKeysLockedString), buttons); + vTaskDelay(TICKS_SECOND); } break; case BUTTON_NONE: @@ -76,6 +76,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) } else { // FIXME should be WarningKeysUnlockedString warnUser(translatedString(Tr->UnlockingKeysString), buttons); + vTaskDelay(TICKS_SECOND); } } break; From cae14dee6ae309b9a3e971aa6497f68874780732 Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:44:15 +0200 Subject: [PATCH 08/11] Update OperatingModes.h add state7 for locked timer ticks --- source/Core/Threads/UI/logic/OperatingModes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/Core/Threads/UI/logic/OperatingModes.h b/source/Core/Threads/UI/logic/OperatingModes.h index 5387f64a6e..a2c08a7d5f 100644 --- a/source/Core/Threads/UI/logic/OperatingModes.h +++ b/source/Core/Threads/UI/logic/OperatingModes.h @@ -62,6 +62,7 @@ struct guiContext { uint32_t state4; // 32 bit state scratch uint16_t state5; // 16 bit state scratch uint16_t state6; // 16 bit state scratch + uint32_t state7; // 32 bit state scratch } scratch_state; }; From dfbf45a1c480abe30847be3fb0915d360707943d Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:54:33 +0200 Subject: [PATCH 09/11] Update Soldering.cpp fix timed locked warning based on review comments with additional state7 field. --- source/Core/Threads/UI/logic/Soldering.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index 53d44d1cf7..35a7398ab3 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -9,10 +9,10 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) { if (cxt->scratch_state.state1 >= 2) { // Buttons are currently locked - if (cxt->scratch_state.state1 > 3) { + if (cxt->scratch_state.state7 != 0) { // show locked until timer is up - if ((uint16_t)(xTaskGetTickCount() << 2) - (cxt->scratch_state.state1 & ~3) > TICKS_SECOND << 2) { - cxt->scratch_state.state1 &= 3; + if (xTaskGetTickCount() >= cxt->scratch_state.state7) { + cxt->scratch_state.state7 = 0; } else { warnUser(translatedString(Tr->WarningKeysLockedString), buttons); return OperatingMode::Soldering; @@ -26,7 +26,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) cxt->scratch_state.state1 = 1; } } else { - vTaskDelay(TICKS_SECOND); + warnUser(translatedString(Tr->WarningKeysLockedString), buttons); } break; case BUTTON_NONE: @@ -39,7 +39,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) } /*Fall through*/ default: // Set timer for and display a lock warning - cxt->scratch_state.state1 |= (xTaskGetTickCount() + TICKS_SECOND) << 2; + cxt->scratch_state.state7 = xTaskGetTickCount() + TICKS_SECOND; warnUser(translatedString(Tr->WarningKeysLockedString), buttons); break; } @@ -76,7 +76,6 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) } else { // FIXME should be WarningKeysUnlockedString warnUser(translatedString(Tr->UnlockingKeysString), buttons); - vTaskDelay(TICKS_SECOND); } } break; From d8b7c73b8ea092201d8a452aec75fc0f33b10555 Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Sun, 11 Aug 2024 00:38:22 +0200 Subject: [PATCH 10/11] Update Soldering.cpp allow unlock during locked warning --- source/Core/Threads/UI/logic/Soldering.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index 35a7398ab3..a23034416a 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -9,6 +9,18 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) { if (cxt->scratch_state.state1 >= 2) { // Buttons are currently locked + if (buttons == BUTTON_BOTH_LONG) { + if (cxt->scratch_state.state1 == 3) { + // Unlocking + if (warnUser(translatedString(Tr->UnlockingKeysString), buttons)) { + cxt->scratch_state.state1 = 1; + cxt->scratch_state.state7 = 0; + } + } else { + warnUser(translatedString(Tr->WarningKeysLockedString), buttons); + } + return OperatingMode::Soldering; + } if (cxt->scratch_state.state7 != 0) { // show locked until timer is up if (xTaskGetTickCount() >= cxt->scratch_state.state7) { @@ -19,16 +31,6 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) } } switch (buttons) { - case BUTTON_BOTH_LONG: - if (cxt->scratch_state.state1 == 3) { - // Unlocking - if (warnUser(translatedString(Tr->UnlockingKeysString), buttons)) { - cxt->scratch_state.state1 = 1; - } - } else { - warnUser(translatedString(Tr->WarningKeysLockedString), buttons); - } - break; case BUTTON_NONE: cxt->scratch_state.state1 = 3; break; From 42d7f8d4c5065060d90a7cc4b40adbf949b86cc8 Mon Sep 17 00:00:00 2001 From: neon12345 <784389+neon12345@users.noreply.github.com> Date: Tue, 13 Aug 2024 18:18:39 +0200 Subject: [PATCH 11/11] Update Soldering.cpp use the LockingKeysString message for state 2 --- source/Core/Threads/UI/logic/Soldering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index a23034416a..50508025f4 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -17,7 +17,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) cxt->scratch_state.state7 = 0; } } else { - warnUser(translatedString(Tr->WarningKeysLockedString), buttons); + warnUser(translatedString(Tr->LockingKeysString), buttons); } return OperatingMode::Soldering; }