Roughing some transition work
This commit is contained in:
@@ -7,6 +7,17 @@ This is due to a few aims:
|
|||||||
2. Allows external events to change the state
|
2. Allows external events to change the state
|
||||||
3. Means state can be read/write over BLE or other external control interfaces
|
3. Means state can be read/write over BLE or other external control interfaces
|
||||||
|
|
||||||
|
## Transitions
|
||||||
|
|
||||||
|
When changing the view to a new view it can be preferable to transition using an animation.
|
||||||
|
The tooling provides for left, right and down animations at this point.
|
||||||
|
The use of these gives a notion of "direction" when navigating the menu.
|
||||||
|
|
||||||
|
```
|
||||||
|
<TODO>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## TODO notes
|
## TODO notes
|
||||||
|
|
||||||
On settings menu exit:
|
On settings menu exit:
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ 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
|
// 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 {
|
||||||
@@ -112,15 +112,34 @@ void guiRenderLoop(void) {
|
|||||||
case OperatingMode::ThermalRunaway:
|
case OperatingMode::ThermalRunaway:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
// Render done, draw it out
|
|
||||||
OLED::refresh();
|
|
||||||
// Update state holders
|
// Update state holders
|
||||||
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) {
|
||||||
|
OLED::refresh();
|
||||||
|
OLED::useSecondaryFramebuffer(true);
|
||||||
|
return; // Exit early to avoid refresh with new framebuffer
|
||||||
|
}
|
||||||
|
} else if (context.transitionMode != TransitionAnimation::None) {
|
||||||
|
// We haven't changed mode but transition is set, so we are at the other side of a transition
|
||||||
|
// We now want to transition from old contents (main buffer) to new contents (secondary buffer)
|
||||||
|
switch (context.transitionMode) {
|
||||||
|
case TransitionAnimation::Down:
|
||||||
|
break;
|
||||||
|
case TransitionAnimation::Left:
|
||||||
|
break;
|
||||||
|
case TransitionAnimation::Right:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
OLED::useSecondaryFramebuffer(false);
|
||||||
|
context.transitionMode = TransitionAnimation::None; // Clear transition flag
|
||||||
}
|
}
|
||||||
|
// Render done, draw it out
|
||||||
|
OLED::refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
OperatingMode handle_post_init_state() {
|
OperatingMode handle_post_init_state() {
|
||||||
|
|||||||
@@ -41,10 +41,14 @@ enum class OperatingMode {
|
|||||||
ThermalRunaway, // Thermal Runaway warning state.
|
ThermalRunaway, // Thermal Runaway warning state.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class TransitionAnimation { None = 0, Right, Left, Down };
|
||||||
|
|
||||||
// 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 {
|
||||||
TickType_t viewEnterTime; // Set to ticks when this view state was first entered
|
TickType_t viewEnterTime; // Set to ticks when this view state was first entered
|
||||||
OperatingMode previousMode;
|
OperatingMode previousMode;
|
||||||
|
TransitionAnimation transitionMode;
|
||||||
|
// Below is scratch state, this is retained over re-draws but blown away on state change
|
||||||
struct scratch {
|
struct scratch {
|
||||||
uint16_t state1; // 16 bit state scratch
|
uint16_t state1; // 16 bit state scratch
|
||||||
uint16_t state2; // 16 bit state scratch
|
uint16_t state2; // 16 bit state scratch
|
||||||
@@ -61,6 +65,7 @@ OperatingMode gui_SolderingSleepingMode(const ButtonState buttons, guiContext *c
|
|||||||
OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt); // Main mode for hot pointy tool
|
OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt); // Main mode for hot pointy tool
|
||||||
OperatingMode gui_solderingTempAdjust(const ButtonState buttons, guiContext *cxt); // For adjusting the setpoint temperature of the iron
|
OperatingMode gui_solderingTempAdjust(const ButtonState buttons, guiContext *cxt); // For adjusting the setpoint temperature of the iron
|
||||||
OperatingMode drawHomeScreen(const ButtonState buttons, guiContext *cxt); // IDLE / Home screen
|
OperatingMode drawHomeScreen(const ButtonState buttons, guiContext *cxt); // IDLE / Home screen
|
||||||
|
OperatingMode gui_SettingsMenu(const ButtonState buttons, guiContext *cxt); //
|
||||||
|
|
||||||
OperatingMode gui_solderingProfileMode(const ButtonState buttons, guiContext *cxt); // Profile mode for hot likely-not-so-pointy tool
|
OperatingMode gui_solderingProfileMode(const ButtonState buttons, guiContext *cxt); // Profile mode for hot likely-not-so-pointy tool
|
||||||
OperatingMode performCJCC(const ButtonState buttons, guiContext *cxt); // Used to calibrate the Cold Junction offset
|
OperatingMode performCJCC(const ButtonState buttons, guiContext *cxt); // Used to calibrate the Cold Junction offset
|
||||||
|
|||||||
8
source/Core/Threads/OperatingModes/SettingsMenu.cpp
Normal file
8
source/Core/Threads/OperatingModes/SettingsMenu.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include "OperatingModes.h"
|
||||||
|
OperatingMode gui_SettingsMenu(const ButtonState buttons, guiContext *cxt) {
|
||||||
|
// Render out the current settings menu
|
||||||
|
// State 1 -> Root menu
|
||||||
|
// State 2 -> Sub entry
|
||||||
|
|
||||||
|
return OperatingMode::SettingsMenu;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user