diff options
author | Ben V. Brown <[email protected]> | 2017-05-29 11:07:38 +1000 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2017-05-29 11:07:45 +1000 |
commit | 7e1e81cc6ffdf8f42c5c79d99cb51d245e390d5c (patch) | |
tree | 1a2bff6a80f5a825161cad7cece6e43eccbf6fb5 /workspace/ts100/src/Modes.c | |
parent | a01cb7a4be570f50e129a42f727ba9e9e9d8a187 (diff) | |
download | IronOS-7e1e81cc6ffdf8f42c5c79d99cb51d245e390d5c.tar.gz IronOS-7e1e81cc6ffdf8f42c5c79d99cb51d245e390d5c.zip |
Adds automatic shutdownv1.07
Closes #7 .
Adds shutdown feature with settings entry
Diffstat (limited to 'workspace/ts100/src/Modes.c')
-rw-r--r-- | workspace/ts100/src/Modes.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/workspace/ts100/src/Modes.c b/workspace/ts100/src/Modes.c index db1c64f2..429423a7 100644 --- a/workspace/ts100/src/Modes.c +++ b/workspace/ts100/src/Modes.c @@ -116,6 +116,11 @@ void ProcessUI() { systemSettings.SleepTime = 1; //cant set time over 30 mins //Remember that ^ is the time of no movement break; + case SHUTDOWN_TIME: + ++systemSettings.ShutdownTime; + if (systemSettings.ShutdownTime > 60) + systemSettings.ShutdownTime = 0; //wrap to off + break; case MOTIONDETECT: systemSettings.movementEnabled = !systemSettings.movementEnabled; @@ -142,16 +147,29 @@ void ProcessUI() { if (Buttons & BUT_A) { //A Button was pressed so we are moving back to soldering operatingMode = SOLDERING; + Oled_DisplayOn(); return; } else if (Buttons & BUT_B) { //B Button was pressed so we are moving back to soldering operatingMode = SOLDERING; + Oled_DisplayOn(); return; } else if (systemSettings.movementEnabled) if (millis() - getLastMovement() < 1000) {//moved in the last second operatingMode = SOLDERING; //Goto active mode again + Oled_DisplayOn(); return; } + if (systemSettings.movementEnabled) { + //Check if we should shutdown + if ((millis() - getLastMovement() + > (systemSettings.ShutdownTime * 60000)) + || (millis() - getLastButtonPress() + > systemSettings.ShutdownTime * 60000)) { + operatingMode = COOLING; //shutdown the tip + Oled_DisplayOn(); + } + } //else if nothing has been pushed we need to compute the PID to keep the iron at the sleep temp int32_t newOutput = computePID(systemSettings.SleepTemp); setIronTimer(newOutput); @@ -333,9 +351,13 @@ void DrawUI() { OLED_DrawThreeNumber(systemSettings.SleepTemp / 10, 5); break; case SLEEP_TIME: - OLED_DrawString("STIME ", 6); + OLED_DrawString("SLTME ", 6); OLED_DrawTwoNumber(systemSettings.SleepTime, 6); break; + case SHUTDOWN_TIME: + OLED_DrawString("SHTME ", 6); + OLED_DrawTwoNumber(systemSettings.ShutdownTime, 6); + break; case MOTIONDETECT:/*Toggle the mode*/ if (systemSettings.movementEnabled) OLED_DrawString("MOTION T", 8); @@ -373,6 +395,7 @@ void DrawUI() { } break; + default: break; } @@ -382,6 +405,15 @@ void DrawUI() { //Draw in temp and sleep OLED_DrawString("SLP", 3); drawTemp(temp, 4); + + if (millis() - getLastMovement() > (10 * 60 * 1000) + && (millis() - getLastButtonPress() > (10 * 60 * 1000))) { + //OLED off + Oled_DisplayOff(); + } else { + Oled_DisplayOn(); + } + break; case COOLING: //We are warning the user the tip is cooling |