mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Starting GUI render refactor to be more immediate mode
Update TemperatureAdjust.cpp . Cleanup Soldering Sleep SolderingProfiles Soldering Rework Rough pass GUI Temp Adjust Cleanup old OperatingMode Debug Menu
This commit is contained in:
@@ -31,8 +31,123 @@ extern "C" {
|
||||
#include "pd.h"
|
||||
#endif
|
||||
// File local variables
|
||||
#define MOVEMENT_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
|
||||
#define BUTTON_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
|
||||
|
||||
extern bool heaterThermalRunaway;
|
||||
ButtonState buttonsAtDeviceBoot; // We record button state at startup, incase of jumping to debug modes
|
||||
|
||||
OperatingMode currentOperatingMode; // Current mode we are rendering
|
||||
guiContext context; // Context passed to functions to aid in state during render passes
|
||||
|
||||
void guiRenderLoop(void) {
|
||||
OLED::clearScreen(); // Clear ready for render pass
|
||||
// Read button state
|
||||
ButtonState buttons = getButtonState();
|
||||
// Enforce screen on if buttons pressed
|
||||
if (buttons != BUTTON_NONE) {
|
||||
OLED::setDisplayState(OLED::DisplayState::ON);
|
||||
} else {
|
||||
// Buttons are none; check if we can sleep display
|
||||
uint32_t tipTemp = TipThermoModel::getTipInC();
|
||||
if ((tipTemp < 50) && getSettingValue(SettingsOptions::Sensitivity)
|
||||
&& (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
|
||||
OLED::setDisplayState(OLED::DisplayState::OFF);
|
||||
setStatusLED(LED_OFF);
|
||||
} else {
|
||||
OLED::setDisplayState(OLED::DisplayState::ON);
|
||||
if (tipTemp > 55) {
|
||||
setStatusLED(LED_COOLING_STILL_HOT);
|
||||
} else {
|
||||
setStatusLED(LED_STANDBY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch button state to gui mode
|
||||
OperatingMode newMode = currentOperatingMode;
|
||||
switch (currentOperatingMode) {
|
||||
case OperatingMode::StartupWarnings:
|
||||
newMode = showWarnings(buttons, &context);
|
||||
break;
|
||||
case OperatingMode::UsbPDDebug:
|
||||
#ifdef HAS_POWER_DEBUG_MENU
|
||||
showPDDebug(buttons, &context);
|
||||
break;
|
||||
#else
|
||||
/*fallthrough*/
|
||||
#endif
|
||||
case OperatingMode::StartupLogo:
|
||||
BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR); // TODO needs refactor
|
||||
newMode = OperatingMode::StartupWarnings;
|
||||
break;
|
||||
default:
|
||||
/* Fallthrough */
|
||||
case OperatingMode::HomeScreen:
|
||||
newMode = drawHomeScreen(buttons, &context);
|
||||
break;
|
||||
case OperatingMode::Soldering:
|
||||
newMode = gui_solderingMode(buttons, &context);
|
||||
break;
|
||||
case OperatingMode::SolderingProfile:
|
||||
newMode = gui_solderingProfileMode(buttons, &context);
|
||||
break;
|
||||
case OperatingMode::Sleeping:
|
||||
newMode = gui_SolderingSleepingMode(buttons, &context);
|
||||
break;
|
||||
case OperatingMode::TemperatureAdjust:
|
||||
newMode = gui_solderingTempAdjust(buttons, &context);
|
||||
break;
|
||||
case OperatingMode::DebugMenuReadout:
|
||||
newMode = showDebugMenu(buttons, &context);
|
||||
break;
|
||||
case OperatingMode::CJCCalibration:
|
||||
newMode = performCJCC(buttons, &context);
|
||||
break;
|
||||
case OperatingMode::SettingsMenu:
|
||||
break;
|
||||
case OperatingMode::InitialisationDone:
|
||||
break;
|
||||
case OperatingMode::Hibernating:
|
||||
break;
|
||||
case OperatingMode::ThermalRunaway:
|
||||
break;
|
||||
};
|
||||
// Render done, draw it out
|
||||
OLED::refresh();
|
||||
// Update state holders
|
||||
if (newMode != currentOperatingMode) {
|
||||
context.viewEnterTime = xTaskGetTickCount();
|
||||
context.previousMode = currentOperatingMode;
|
||||
memset(&context.scratch_state, 0, sizeof(context.scratch_state));
|
||||
currentOperatingMode = newMode;
|
||||
}
|
||||
}
|
||||
|
||||
OperatingMode handle_post_init_state() {
|
||||
#ifdef HAS_POWER_DEBUG_MENU
|
||||
#ifdef DEBUG_POWER_MENU_BUTTON_B
|
||||
if (buttonsAtDeviceBoot == BUTTON_B_LONG || buttonsAtDeviceBoot == BUTTON_B_SHORT) {
|
||||
#else
|
||||
if (buttonsAtDeviceBoot == BUTTON_F_LONG || buttonsAtDeviceBoot == BUTTON_F_SHORT) {
|
||||
#endif
|
||||
return OperatingMode::UsbPDDebug;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (getSettingValue(SettingsOptions::CalibrateCJC) > 0) {
|
||||
return OperatingMode::CJCCalibration;
|
||||
}
|
||||
|
||||
if (getSettingValue(SettingsOptions::AutoStartMode) == 1) {
|
||||
// jump directly to the autostart mode
|
||||
return OperatingMode::Sleeping;
|
||||
}
|
||||
if (getSettingValue(SettingsOptions::AutoStartMode) == 2) {
|
||||
return OperatingMode::Hibernating;
|
||||
}
|
||||
|
||||
return OperatingMode::HomeScreen;
|
||||
}
|
||||
|
||||
/* StartGUITask function */
|
||||
void startGUITask(void const *argument) {
|
||||
@@ -48,41 +163,25 @@ void startGUITask(void const *argument) {
|
||||
getTipRawTemp(1); // reset filter
|
||||
|
||||
OLED::setRotation(getSettingValue(SettingsOptions::OrientationMode) & 1);
|
||||
// If the front button is held down, on supported devices, show PD debugging metrics
|
||||
#ifdef HAS_POWER_DEBUG_MENU
|
||||
#ifdef DEBUG_POWER_MENU_BUTTON_B
|
||||
if (getButtonB()) {
|
||||
#else
|
||||
if (getButtonA()) {
|
||||
#endif
|
||||
showPDDebug();
|
||||
}
|
||||
#endif
|
||||
buttonsAtDeviceBoot = getButtonState();
|
||||
|
||||
if (getSettingValue(SettingsOptions::CalibrateCJC) > 0) {
|
||||
performCJCC();
|
||||
// // If the boot logo is enabled with timeout and the autostart mode is enabled (but not set to sleep w/o heat), start heating during boot logo
|
||||
// if (getSettingValue(SettingsOptions::LOGOTime) > 0 && getSettingValue(SettingsOptions::LOGOTime) < 5 && getSettingValue(SettingsOptions::AutoStartMode) > 0
|
||||
// && getSettingValue(SettingsOptions::AutoStartMode) < 3) {
|
||||
// uint16_t sleepTempDegC;
|
||||
// if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||
// sleepTempDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::SleepTemp));
|
||||
// } else {
|
||||
// sleepTempDegC = getSettingValue(SettingsOptions::SleepTemp);
|
||||
// }
|
||||
// // Only heat to sleep temperature (but no higher than 75°C for safety)
|
||||
// currentTempTargetDegC = min(sleepTempDegC, 75);
|
||||
// }
|
||||
// TODO
|
||||
TickType_t startRender = xTaskGetTickCount();
|
||||
for (;;) {
|
||||
guiRenderLoop();
|
||||
resetWatchdog();
|
||||
vTaskDelayUntil(&startRender, TICKS_100MS / 2);
|
||||
}
|
||||
|
||||
// If the boot logo is enabled (but it times out) and the autostart mode is enabled (but not set to sleep w/o heat), start heating during boot logo
|
||||
if (getSettingValue(SettingsOptions::LOGOTime) > 0 && getSettingValue(SettingsOptions::LOGOTime) < 5 && getSettingValue(SettingsOptions::AutoStartMode) > 0
|
||||
&& getSettingValue(SettingsOptions::AutoStartMode) < 3) {
|
||||
uint16_t sleepTempDegC;
|
||||
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||
sleepTempDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::SleepTemp));
|
||||
} else {
|
||||
sleepTempDegC = getSettingValue(SettingsOptions::SleepTemp);
|
||||
}
|
||||
// Only heat to sleep temperature (but no higher than 75°C for safety)
|
||||
currentTempTargetDegC = min(sleepTempDegC, 75);
|
||||
}
|
||||
|
||||
showBootLogo();
|
||||
showWarnings();
|
||||
if (getSettingValue(SettingsOptions::AutoStartMode)) {
|
||||
// jump directly to the autostart mode
|
||||
gui_solderingMode(getSettingValue(SettingsOptions::AutoStartMode) - 1);
|
||||
buttonLockout = true;
|
||||
}
|
||||
|
||||
drawHomeScreen(buttonLockout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user