Hook some status colours to the LED

This commit is contained in:
Ben V. Brown
2021-05-03 22:00:24 +10:00
parent 5ea2908fa2
commit c20ed926cd
2 changed files with 19 additions and 7 deletions

View File

@@ -438,7 +438,7 @@ bool isTipDisconnected() {
void setStatusLED(const enum StatusLED state) { void setStatusLED(const enum StatusLED state) {
static enum StatusLED lastState = LED_UNKNOWN; static enum StatusLED lastState = LED_UNKNOWN;
if (lastState != state) { if (lastState != state || state == LED_HEATING) {
switch (state) { switch (state) {
case LED_UNKNOWN: case LED_UNKNOWN:
case LED_OFF: case LED_OFF:
@@ -447,8 +447,11 @@ void setStatusLED(const enum StatusLED state) {
case LED_STANDBY: case LED_STANDBY:
WS2812::led_set_color(0, 0, 0xFF, 0); //green WS2812::led_set_color(0, 0, 0xFF, 0); //green
break; break;
case LED_HEATING: case LED_HEATING: {
WS2812::led_set_color(0, 0, 0, 0xFF); //Blue WS2812::led_set_color(0, ((HAL_GetTick() / 10) % 192) + 64, 0,
0); //Red fade
}
break; break;
case LED_HOT: case LED_HOT:
WS2812::led_set_color(0, 0xFF, 0, 0); //red WS2812::led_set_color(0, 0xFF, 0, 0); //red

View File

@@ -679,6 +679,14 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
return; // If the function returns non-0 then exit return; // If the function returns non-0 then exit
} }
} }
//Update LED status
int error = currentTempTargetDegC - TipThermoModel::getTipInC();
if (error >= -10 && error <= 10) {
//converged
setStatusLED(LED_HOT);
} else {
setStatusLED(LED_HEATING);
}
// slow down ui update rate // slow down ui update rate
GUIDelay(); GUIDelay();
} }
@@ -918,7 +926,7 @@ void startGUITask(void const *argument __unused) {
if (tipTemp > 55) { if (tipTemp > 55) {
setStatusLED(LED_COOLING_STILL_HOT); setStatusLED(LED_COOLING_STILL_HOT);
} else { } else {
setStatusLED(LED_OFF); setStatusLED(LED_STANDBY);
} }
// Preemptively turn the display on. Turn it off if and only if // Preemptively turn the display on. Turn it off if and only if
// the tip temperature is below 50 degrees C *and* motion sleep // the tip temperature is below 50 degrees C *and* motion sleep
@@ -933,6 +941,7 @@ void startGUITask(void const *argument __unused) {
&& ((xTaskGetTickCount() - lastButtonTime) && ((xTaskGetTickCount() - lastButtonTime)
> BUTTON_INACTIVITY_TIME))) { > BUTTON_INACTIVITY_TIME))) {
OLED::setDisplayState(OLED::DisplayState::OFF); OLED::setDisplayState(OLED::DisplayState::OFF);
setStatusLED(LED_OFF);
} }
// Clear the lcd buffer // Clear the lcd buffer
OLED::clearScreen(); OLED::clearScreen();