Transitions
Update SolderingProfile.cpp Hook in transistions
This commit is contained in:
@@ -18,7 +18,6 @@ extern "C" {
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "TipThermoModel.h"
|
#include "TipThermoModel.h"
|
||||||
#include "Translation.h"
|
#include "Translation.h"
|
||||||
#include "bflb_platform.h"
|
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "history.hpp"
|
#include "history.hpp"
|
||||||
@@ -40,31 +39,29 @@ OperatingMode currentOperatingMode = OperatingMode::InitialisationDone; // Curre
|
|||||||
guiContext context; // Context passed to functions to aid in state during render passes
|
guiContext context; // Context passed to functions to aid in state during render passes
|
||||||
|
|
||||||
OperatingMode handle_post_init_state();
|
OperatingMode handle_post_init_state();
|
||||||
|
OperatingMode guiHandleDraw(void) {
|
||||||
void guiRenderLoop(void) {
|
|
||||||
OLED::clearScreen(); // Clear ready for render pass
|
OLED::clearScreen(); // Clear ready for render pass
|
||||||
// Read button state
|
// Read button state
|
||||||
ButtonState buttons = getButtonState();
|
ButtonState buttons = getButtonState();
|
||||||
// Enforce screen on if buttons pressed, movement, hot tip etc
|
// Enforce screen on if buttons pressed, movement, hot tip etc
|
||||||
if (buttons != BUTTON_NONE) {
|
// if (buttons != BUTTON_NONE) {
|
||||||
OLED::setDisplayState(OLED::DisplayState::ON);
|
// OLED::setDisplayState(OLED::DisplayState::ON);
|
||||||
} else {
|
// } else {
|
||||||
// Buttons are none; check if we can sleep display
|
// // Buttons are none; check if we can sleep display
|
||||||
uint32_t tipTemp = TipThermoModel::getTipInC();
|
// uint32_t tipTemp = TipThermoModel::getTipInC();
|
||||||
if ((tipTemp < 50) && getSettingValue(SettingsOptions::Sensitivity)
|
// if ((tipTemp < 50) && getSettingValue(SettingsOptions::Sensitivity)
|
||||||
&& (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
|
// && (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
|
||||||
OLED::setDisplayState(OLED::DisplayState::OFF);
|
// OLED::setDisplayState(OLED::DisplayState::OFF);
|
||||||
setStatusLED(LED_OFF);
|
// setStatusLED(LED_OFF);
|
||||||
} else {
|
// } else {
|
||||||
OLED::setDisplayState(OLED::DisplayState::ON);
|
// OLED::setDisplayState(OLED::DisplayState::ON);
|
||||||
if (tipTemp > 55) {
|
// if (tipTemp > 55) {
|
||||||
setStatusLED(LED_COOLING_STILL_HOT);
|
// setStatusLED(LED_COOLING_STILL_HOT);
|
||||||
} else {
|
// } else {
|
||||||
setStatusLED(LED_STANDBY);
|
// setStatusLED(LED_STANDBY);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
MSG("Run GUI %d - %d\r\n", (int)currentOperatingMode, (int)buttons);
|
|
||||||
// Dispatch button state to gui mode
|
// Dispatch button state to gui mode
|
||||||
OperatingMode newMode = currentOperatingMode;
|
OperatingMode newMode = currentOperatingMode;
|
||||||
switch (currentOperatingMode) {
|
switch (currentOperatingMode) {
|
||||||
@@ -116,36 +113,43 @@ void guiRenderLoop(void) {
|
|||||||
case OperatingMode::ThermalRunaway:
|
case OperatingMode::ThermalRunaway:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
// Update state holders
|
return newMode;
|
||||||
|
}
|
||||||
|
void guiRenderLoop(void) {
|
||||||
|
OperatingMode newMode = guiHandleDraw(); // This does the screen drawing
|
||||||
|
|
||||||
|
// Post draw we handle any state transitions
|
||||||
|
|
||||||
if (newMode != currentOperatingMode) {
|
if (newMode != currentOperatingMode) {
|
||||||
context.viewEnterTime = xTaskGetTickCount();
|
context.viewEnterTime = xTaskGetTickCount();
|
||||||
context.previousMode = currentOperatingMode;
|
context.previousMode = currentOperatingMode;
|
||||||
memset(&context.scratch_state, 0, sizeof(context.scratch_state));
|
memset(&context.scratch_state, 0, sizeof(context.scratch_state));
|
||||||
currentOperatingMode = newMode;
|
currentOperatingMode = newMode;
|
||||||
// If the transition marker is set, we need to make the next draw occur to the secondary buffer so we have something to transition to
|
}
|
||||||
if (context.transitionMode != TransitionAnimation::None) {
|
// If the transition marker is set, we need to make the next draw occur to the secondary buffer so we have something to transition to
|
||||||
OLED::refresh();
|
if (context.transitionMode != TransitionAnimation::None) {
|
||||||
OLED::useSecondaryFramebuffer(true);
|
OLED::useSecondaryFramebuffer(true);
|
||||||
return; // Exit early to avoid refresh with new framebuffer
|
// Now we need to fill the secondary buffer with the _next_ frame to transistion to
|
||||||
}
|
guiHandleDraw();
|
||||||
} else if (context.transitionMode != TransitionAnimation::None) {
|
OLED::useSecondaryFramebuffer(false);
|
||||||
// We haven't changed mode but transition is set, so we are at the other side of a transition
|
// Now dispatch the transition
|
||||||
// We now want to transition from old contents (main buffer) to new contents (secondary buffer)
|
|
||||||
switch (context.transitionMode) {
|
switch (context.transitionMode) {
|
||||||
case TransitionAnimation::Down:
|
case TransitionAnimation::Down:
|
||||||
|
OLED::transitionScrollDown();
|
||||||
break;
|
break;
|
||||||
case TransitionAnimation::Left:
|
case TransitionAnimation::Left:
|
||||||
|
OLED::transitionSecondaryFramebuffer(false);
|
||||||
break;
|
break;
|
||||||
case TransitionAnimation::Right:
|
case TransitionAnimation::Right:
|
||||||
|
OLED::transitionSecondaryFramebuffer(true);
|
||||||
break;
|
break;
|
||||||
case TransitionAnimation::None:
|
case TransitionAnimation::None:
|
||||||
default:
|
default:
|
||||||
break; // Do nothing on unknown
|
break; // Do nothing on unknown
|
||||||
}
|
}
|
||||||
OLED::useSecondaryFramebuffer(false);
|
|
||||||
context.transitionMode = TransitionAnimation::None; // Clear transition flag
|
context.transitionMode = TransitionAnimation::None; // Clear transition flag
|
||||||
}
|
}
|
||||||
MSG("Post GUI %d - %d\r\n", (int)currentOperatingMode, (int)buttons);
|
|
||||||
// Render done, draw it out
|
// Render done, draw it out
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
}
|
}
|
||||||
@@ -211,6 +215,6 @@ void startGUITask(void const *argument) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
guiRenderLoop();
|
guiRenderLoop();
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
vTaskDelayUntil(&startRender, TICKS_100MS / 2); // Try and maintain 20fps ish update rate, way to fast but if we can its nice
|
vTaskDelayUntil(&startRender, TICKS_100MS * 4 / 10); // Try and maintain 20-25fps ish update rate, way to fast but if we can its nice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,9 +86,10 @@ OperatingMode showDebugMenu(const ButtonState buttons, guiContext *cxt) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttons == BUTTON_B_SHORT)
|
if (buttons == BUTTON_B_SHORT) {
|
||||||
|
cxt->transitionMode = TransitionAnimation::Up;
|
||||||
return OperatingMode::InitialisationDone;
|
return OperatingMode::InitialisationDone;
|
||||||
else if (buttons == BUTTON_F_SHORT) {
|
} else if (buttons == BUTTON_F_SHORT) {
|
||||||
cxt->scratch_state.state1++;
|
cxt->scratch_state.state1++;
|
||||||
#ifdef HALL_SENSOR
|
#ifdef HALL_SENSOR
|
||||||
cxt->scratch_state.state1 = cxt->scratch_state.state1 % 17;
|
cxt->scratch_state.state1 = cxt->scratch_state.state1 % 17;
|
||||||
|
|||||||
@@ -34,9 +34,11 @@ OperatingMode handleHomeButtons(const ButtonState buttons, guiContext *cxt) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BUTTON_B_LONG:
|
case BUTTON_B_LONG:
|
||||||
|
cxt->transitionMode = TransitionAnimation::Down;
|
||||||
return OperatingMode::DebugMenuReadout;
|
return OperatingMode::DebugMenuReadout;
|
||||||
break;
|
break;
|
||||||
case BUTTON_F_LONG:
|
case BUTTON_F_LONG:
|
||||||
|
cxt->transitionMode = TransitionAnimation::Left;
|
||||||
#ifdef PROFILE_SUPPORT
|
#ifdef PROFILE_SUPPORT
|
||||||
if (!isTipDisconnected()) {
|
if (!isTipDisconnected()) {
|
||||||
return OperatingMode::SolderingProfile;
|
return OperatingMode::SolderingProfile;
|
||||||
@@ -46,11 +48,13 @@ OperatingMode handleHomeButtons(const ButtonState buttons, guiContext *cxt) {
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case BUTTON_F_SHORT:
|
case BUTTON_F_SHORT:
|
||||||
|
cxt->transitionMode = TransitionAnimation::Left;
|
||||||
if (!isTipDisconnected()) {
|
if (!isTipDisconnected()) {
|
||||||
return OperatingMode::Soldering;
|
return OperatingMode::Soldering;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BUTTON_B_SHORT:
|
case BUTTON_B_SHORT:
|
||||||
|
cxt->transitionMode = TransitionAnimation::Right;
|
||||||
return OperatingMode::SettingsMenu;
|
return OperatingMode::SettingsMenu;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -41,7 +41,13 @@ enum class OperatingMode {
|
|||||||
ThermalRunaway, // Thermal Runaway warning state.
|
ThermalRunaway, // Thermal Runaway warning state.
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TransitionAnimation { None = 0, Right, Left, Down };
|
enum class TransitionAnimation {
|
||||||
|
None = 0,
|
||||||
|
Right = 1,
|
||||||
|
Left = 2,
|
||||||
|
Down = 3,
|
||||||
|
Up = 4,
|
||||||
|
};
|
||||||
|
|
||||||
// Generic context struct used for gui functions to be able to retain state
|
// Generic context struct used for gui functions to be able to retain state
|
||||||
struct guiContext {
|
struct guiContext {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "OperatingModes.h"
|
#include "OperatingModes.h"
|
||||||
#include "ScrollMessage.hpp"
|
#include "ScrollMessage.hpp"
|
||||||
#include "bflb_platform.h"
|
|
||||||
|
|
||||||
#define HELP_TEXT_TIMEOUT_TICKS (TICKS_SECOND * 3)
|
#define HELP_TEXT_TIMEOUT_TICKS (TICKS_SECOND * 3)
|
||||||
/*
|
/*
|
||||||
@@ -138,6 +137,7 @@ OperatingMode gui_SettingsMenu(const ButtonState buttons, guiContext *cxt) {
|
|||||||
currentMenu[currentScreen].incrementHandler();
|
currentMenu[currentScreen].incrementHandler();
|
||||||
} else {
|
} else {
|
||||||
(*subEntry) += 1;
|
(*subEntry) += 1;
|
||||||
|
cxt->transitionMode = TransitionAnimation::Right;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callIncrementHandler();
|
callIncrementHandler();
|
||||||
@@ -152,6 +152,7 @@ OperatingMode gui_SettingsMenu(const ButtonState buttons, guiContext *cxt) {
|
|||||||
// Scroll down
|
// Scroll down
|
||||||
if (currentScreen < (*currentMenuLength) - 1) {
|
if (currentScreen < (*currentMenuLength) - 1) {
|
||||||
// We can increment freely
|
// We can increment freely
|
||||||
|
cxt->transitionMode = TransitionAnimation::Down;
|
||||||
if (*subEntry == 0) {
|
if (*subEntry == 0) {
|
||||||
(*mainEntry) += 1;
|
(*mainEntry) += 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -161,11 +162,14 @@ OperatingMode gui_SettingsMenu(const ButtonState buttons, guiContext *cxt) {
|
|||||||
// We are at an end somewhere, increment as appropriate
|
// We are at an end somewhere, increment as appropriate
|
||||||
if (*subEntry == 0) {
|
if (*subEntry == 0) {
|
||||||
// This is end of the list
|
// This is end of the list
|
||||||
|
cxt->transitionMode = TransitionAnimation::Left;
|
||||||
return OperatingMode::HomeScreen;
|
return OperatingMode::HomeScreen;
|
||||||
} else {
|
} else {
|
||||||
(*subEntry) = 0;
|
(*subEntry) = 0;
|
||||||
(*mainEntry) += 1;
|
(*mainEntry) += 1;
|
||||||
}
|
}
|
||||||
|
// When we exit a list we want to animate to the left
|
||||||
|
cxt->transitionMode = TransitionAnimation::Left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt)
|
|||||||
break;
|
break;
|
||||||
case BUTTON_BOTH:
|
case BUTTON_BOTH:
|
||||||
case BUTTON_B_LONG:
|
case BUTTON_B_LONG:
|
||||||
|
cxt->transitionMode = TransitionAnimation::Right;
|
||||||
return OperatingMode::HomeScreen;
|
return OperatingMode::HomeScreen;
|
||||||
case BUTTON_F_LONG:
|
case BUTTON_F_LONG:
|
||||||
// if boost mode is enabled turn it on
|
// if boost mode is enabled turn it on
|
||||||
@@ -39,6 +40,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt)
|
|||||||
break;
|
break;
|
||||||
case BUTTON_F_SHORT:
|
case BUTTON_F_SHORT:
|
||||||
case BUTTON_B_SHORT: {
|
case BUTTON_B_SHORT: {
|
||||||
|
cxt->transitionMode = TransitionAnimation::Left;
|
||||||
return OperatingMode::TemperatureAdjust;
|
return OperatingMode::TemperatureAdjust;
|
||||||
case BUTTON_BOTH_LONG:
|
case BUTTON_BOTH_LONG:
|
||||||
if (getSettingValue(SettingsOptions::LockingMode) != 0) {
|
if (getSettingValue(SettingsOptions::LockingMode) != 0) {
|
||||||
@@ -80,6 +82,7 @@ OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) {
|
|||||||
// Check if we should bail due to undervoltage for example
|
// Check if we should bail due to undervoltage for example
|
||||||
if (checkExitSoldering()) {
|
if (checkExitSoldering()) {
|
||||||
setBuzzer(false);
|
setBuzzer(false);
|
||||||
|
cxt->transitionMode = TransitionAnimation::Right;
|
||||||
return OperatingMode::HomeScreen;
|
return OperatingMode::HomeScreen;
|
||||||
}
|
}
|
||||||
#ifdef NO_SLEEP_MODE
|
#ifdef NO_SLEEP_MODE
|
||||||
@@ -175,4 +178,5 @@ OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) {
|
|||||||
} else {
|
} else {
|
||||||
basicSolderingStatus(cxt->scratch_state.state2);
|
basicSolderingStatus(cxt->scratch_state.state2);
|
||||||
}
|
}
|
||||||
|
return OperatingMode::Soldering; // Stay put
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ OperatingMode gui_solderingProfileMode(const ButtonState buttons, guiContext *cx
|
|||||||
switch (buttons) {
|
switch (buttons) {
|
||||||
case BUTTON_BOTH:
|
case BUTTON_BOTH:
|
||||||
case BUTTON_B_LONG:
|
case BUTTON_B_LONG:
|
||||||
|
cxt->transitionMode = TransitionAnimation::Right;
|
||||||
return OperatingMode::HomeScreen; // exit on back long hold
|
return OperatingMode::HomeScreen; // exit on back long hold
|
||||||
case BUTTON_F_LONG:
|
case BUTTON_F_LONG:
|
||||||
case BUTTON_F_SHORT:
|
case BUTTON_F_SHORT:
|
||||||
@@ -207,4 +208,5 @@ OperatingMode gui_solderingProfileMode(const ButtonState buttons, guiContext *cx
|
|||||||
} else {
|
} else {
|
||||||
setStatusLED(LED_HOT);
|
setStatusLED(LED_HOT);
|
||||||
}
|
}
|
||||||
|
return OperatingMode::SolderingProfile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ OperatingMode gui_solderingTempAdjust(const ButtonState buttons, guiContext *cxt
|
|||||||
setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp);
|
setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp);
|
||||||
}
|
}
|
||||||
if (xTaskGetTickCount() - cxt->viewEnterTime > (TICKS_SECOND * 2)) {
|
if (xTaskGetTickCount() - cxt->viewEnterTime > (TICKS_SECOND * 2)) {
|
||||||
|
cxt->transitionMode = TransitionAnimation::Right;
|
||||||
return cxt->previousMode; // exit if user just doesn't press anything for a bit
|
return cxt->previousMode; // exit if user just doesn't press anything for a bit
|
||||||
}
|
}
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user