1
0
forked from me/IronOS

Fixes for some animations not running

Dont bail on animations if keypress is still held
This commit is contained in:
Ben V. Brown
2023-07-22 17:01:28 +10:00
parent bf00e1bc58
commit 86fed6bfbe
4 changed files with 58 additions and 55 deletions

View File

@@ -262,7 +262,8 @@ void OLED::maskScrollIndicatorOnOLED() {
* If forward is true, this displays a forward navigation to the second framebuffer contents. * If forward is true, this displays a forward navigation to the second framebuffer contents.
* Otherwise a rewinding navigation animation is shown to the second framebuffer contents. * Otherwise a rewinding navigation animation is shown to the second framebuffer contents.
*/ */
void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) { void OLED::transitionSecondaryFramebuffer(const bool forwardNavigation, const TickType_t viewEnterTime) {
bool buttonsReleased = getButtonState() == BUTTON_NONE;
uint8_t *stripBackPointers[4]; uint8_t *stripBackPointers[4];
stripBackPointers[0] = &secondFrameBuffer[FRAMEBUFFER_START + 0]; stripBackPointers[0] = &secondFrameBuffer[FRAMEBUFFER_START + 0];
stripBackPointers[1] = &secondFrameBuffer[FRAMEBUFFER_START + OLED_WIDTH]; stripBackPointers[1] = &secondFrameBuffer[FRAMEBUFFER_START + OLED_WIDTH];
@@ -317,7 +318,8 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
refresh(); // Now refresh to write out the contents to the new page refresh(); // Now refresh to write out the contents to the new page
vTaskDelayUntil(&startDraw, TICKS_100MS / 7); vTaskDelayUntil(&startDraw, TICKS_100MS / 7);
if (getButtonState() != BUTTON_NONE) { buttonsReleased |= getButtonState() == BUTTON_NONE;
if (getButtonState() != BUTTON_NONE && buttonsReleased) {
memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START); memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START);
refresh(); // Now refresh to write out the contents to the new page refresh(); // Now refresh to write out the contents to the new page
return; return;
@@ -340,8 +342,9 @@ void OLED::useSecondaryFramebuffer(bool useSecondary) {
* *
* **This function blocks until the transition has completed or user presses button** * **This function blocks until the transition has completed or user presses button**
*/ */
void OLED::transitionScrollDown() { void OLED::transitionScrollDown(const TickType_t viewEnterTime) {
TickType_t startDraw = xTaskGetTickCount(); TickType_t startDraw = xTaskGetTickCount();
bool buttonsReleased = getButtonState() == BUTTON_NONE;
for (uint8_t heightPos = 0; heightPos < OLED_HEIGHT; heightPos++) { for (uint8_t heightPos = 0; heightPos < OLED_HEIGHT; heightPos++) {
// For each line, we shuffle all bits up a row // For each line, we shuffle all bits up a row
@@ -378,7 +381,8 @@ void OLED::transitionScrollDown() {
secondFrameBuffer[secondStripPos] >>= 1; secondFrameBuffer[secondStripPos] >>= 1;
#endif /* OLED_128x32 */ #endif /* OLED_128x32 */
} }
if (getButtonState() != BUTTON_NONE) { buttonsReleased |= getButtonState() == BUTTON_NONE;
if (getButtonState() != BUTTON_NONE && buttonsReleased) {
// Exit early, but have to transition whole buffer // Exit early, but have to transition whole buffer
memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START); memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START);
refresh(); // Now refresh to write out the contents to the new page refresh(); // Now refresh to write out the contents to the new page

View File

@@ -46,9 +46,9 @@ extern "C" {
#define OLED_GRAM_START_FLIP 0 #define OLED_GRAM_START_FLIP 0
#define OLED_GRAM_END_FLIP 0x7F #define OLED_GRAM_END_FLIP 0x7F
#define OLED_VCOM_LAYOUT 0x12 #define OLED_VCOM_LAYOUT 0x12
#define OLED_SEGMENT_MAP_REVERSED #define OLED_SEGMENT_MAP_REVERSED
#define OLED_DIVIDER 0xD3 #define OLED_DIVIDER 0xD3
#else #else
@@ -59,14 +59,14 @@ extern "C" {
#define OLED_GRAM_START_FLIP 0 #define OLED_GRAM_START_FLIP 0
#define OLED_GRAM_END_FLIP 95 #define OLED_GRAM_END_FLIP 95
#define OLED_VCOM_LAYOUT 0x02 #define OLED_VCOM_LAYOUT 0x02
#define OLED_SEGMENT_MAP 0xA0 #define OLED_SEGMENT_MAP 0xA0
#define OLED_DIVIDER 0xD5 #define OLED_DIVIDER 0xD5
#endif /* OLED_128x32 */ #endif /* OLED_128x32 */
#define OLED_ON 0xAF #define OLED_ON 0xAF
#define OLED_OFF 0xAE #define OLED_OFF 0xAE
#define FRAMEBUFFER_START 17 #define FRAMEBUFFER_START 17
@@ -78,7 +78,10 @@ enum class FontStyle {
class OLED { class OLED {
public: public:
enum DisplayState : bool { OFF = false, ON = true }; enum DisplayState : bool {
OFF = false,
ON = true
};
static void initialize(); // Startup the I2C coms (brings screen out of reset etc) static void initialize(); // Startup the I2C coms (brings screen out of reset etc)
static bool isInitDone(); static bool isInitDone();
@@ -117,10 +120,10 @@ public:
static void setInverseDisplay(bool inverted); static void setInverseDisplay(bool inverted);
static int16_t getCursorX() { return cursor_x; } static int16_t getCursorX() { return cursor_x; }
// Draw a string to the current location, with selected font; optionally - with MAX length only // Draw a string to the current location, with selected font; optionally - with MAX length only
static void print(const char *string, FontStyle fontStyle, uint8_t length = 255); static void print(const char *string, FontStyle fontStyle, uint8_t length = 255);
static void printWholeScreen(const char *string); static void printWholeScreen(const char *string);
// Print *F or *C - in font style of Small, Large (by default) or Extra based on input arg // Print *F or *C - in font style of Small, Large (by default) or Extra based on input arg
static void printSymbolDeg(FontStyle fontStyle = FontStyle::LARGE); static void printSymbolDeg(FontStyle fontStyle = FontStyle::LARGE);
// Set the cursor location by pixels // Set the cursor location by pixels
static void setCursor(int16_t x, int16_t y) { static void setCursor(int16_t x, int16_t y) {
cursor_x = x; cursor_x = x;
@@ -146,9 +149,9 @@ public:
static void drawHeatSymbol(uint8_t state); static void drawHeatSymbol(uint8_t state);
static void drawScrollIndicator(uint8_t p, uint8_t h); // Draws a scrolling position indicator static void drawScrollIndicator(uint8_t p, uint8_t h); // Draws a scrolling position indicator
static void maskScrollIndicatorOnOLED(); static void maskScrollIndicatorOnOLED();
static void transitionSecondaryFramebuffer(bool forwardNavigation); static void transitionSecondaryFramebuffer(const bool forwardNavigation, const TickType_t viewEnterTime);
static void useSecondaryFramebuffer(bool useSecondary); static void useSecondaryFramebuffer(bool useSecondary);
static void transitionScrollDown(); static void transitionScrollDown(const TickType_t viewEnterTime);
private: private:
static bool checkDisplayBufferChecksum() { static bool checkDisplayBufferChecksum() {

View File

@@ -116,8 +116,10 @@ OperatingMode guiHandleDraw(void) {
newMode = handle_post_init_state(); newMode = handle_post_init_state();
break; break;
case OperatingMode::Hibernating: case OperatingMode::Hibernating:
newMode = OperatingMode::HomeScreen;
break; break;
case OperatingMode::ThermalRunaway: case OperatingMode::ThermalRunaway:
newMode = OperatingMode::HomeScreen;
break; break;
}; };
return newMode; return newMode;
@@ -142,13 +144,13 @@ void guiRenderLoop(void) {
// Now dispatch the transition // Now dispatch the transition
switch (context.transitionMode) { switch (context.transitionMode) {
case TransitionAnimation::Down: case TransitionAnimation::Down:
OLED::transitionScrollDown(); OLED::transitionScrollDown(context.viewEnterTime);
break; break;
case TransitionAnimation::Left: case TransitionAnimation::Left:
OLED::transitionSecondaryFramebuffer(false); OLED::transitionSecondaryFramebuffer(false, context.viewEnterTime);
break; break;
case TransitionAnimation::Right: case TransitionAnimation::Right:
OLED::transitionSecondaryFramebuffer(true); OLED::transitionSecondaryFramebuffer(true, context.viewEnterTime);
break; break;
case TransitionAnimation::None: case TransitionAnimation::None:
default: default:

View File

@@ -29,6 +29,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt)
cxt->scratch_state.state2 = 0; cxt->scratch_state.state2 = 0;
break; break;
case BUTTON_BOTH: case BUTTON_BOTH:
/*Fall through*/
case BUTTON_B_LONG: case BUTTON_B_LONG:
cxt->transitionMode = TransitionAnimation::Right; cxt->transitionMode = TransitionAnimation::Right;
return OperatingMode::HomeScreen; return OperatingMode::HomeScreen;
@@ -39,13 +40,12 @@ 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; 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) {
// Lock buttons // Lock buttons
if (warnUser(translatedString(Tr->LockingKeysString), buttons)) { if (warnUser(translatedString(Tr->LockingKeysString), buttons)) {
cxt->scratch_state.state1 = 1; cxt->scratch_state.state1 = 1;
} }
@@ -54,7 +54,6 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt)
default: default:
break; break;
} }
}
return OperatingMode::Soldering; return OperatingMode::Soldering;
} }
OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) { OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) {
@@ -73,36 +72,6 @@ OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) {
* --> Long hold double button to toggle key lock * --> Long hold double button to toggle key lock
*/ */
// First check for button locking & dispatch buttons
OperatingMode newMode = handleSolderingButtons(buttons, cxt);
if (newMode != OperatingMode::Soldering) {
return newMode;
}
// Check if we should bail due to undervoltage for example
if (checkExitSoldering()) {
setBuzzer(false);
cxt->transitionMode = TransitionAnimation::Right;
return OperatingMode::HomeScreen;
}
#ifdef NO_SLEEP_MODE
if (shouldShutdown()) {
// shutdown
currentTempTargetDegC = 0;
return OperatingMode::HomeScreen;
}
#endif
if (shouldBeSleeping()) {
return OperatingMode::Sleeping;
}
if (heaterThermalRunaway) {
currentTempTargetDegC = 0; // heater control off
heaterThermalRunaway = false;
return OperatingMode::ThermalRunaway;
}
// Update the setpoints for the temperature // Update the setpoints for the temperature
if (cxt->scratch_state.state2) { if (cxt->scratch_state.state2) {
if (getSettingValue(SettingsOptions::TemperatureInF)) { if (getSettingValue(SettingsOptions::TemperatureInF)) {
@@ -178,5 +147,30 @@ 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 // Check if we should bail due to undervoltage for example
if (checkExitSoldering()) {
setBuzzer(false);
cxt->transitionMode = TransitionAnimation::Right;
return OperatingMode::HomeScreen;
}
#ifdef NO_SLEEP_MODE
if (shouldShutdown()) {
// shutdown
currentTempTargetDegC = 0;
cxt->transitionMode = TransitionAnimation::Right;
return OperatingMode::HomeScreen;
}
#endif
if (shouldBeSleeping()) {
return OperatingMode::Sleeping;
}
if (heaterThermalRunaway) {
currentTempTargetDegC = 0; // heater control off
heaterThermalRunaway = false;
cxt->transitionMode = TransitionAnimation::Right;
return OperatingMode::ThermalRunaway;
}
return handleSolderingButtons(buttons, cxt);
} }