aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2017-05-29 11:07:38 +1000
committerBen V. Brown <[email protected]>2017-05-29 11:07:45 +1000
commit7e1e81cc6ffdf8f42c5c79d99cb51d245e390d5c (patch)
tree1a2bff6a80f5a825161cad7cece6e43eccbf6fb5
parenta01cb7a4be570f50e129a42f727ba9e9e9d8a187 (diff)
downloadIronOS-7e1e81cc6ffdf8f42c5c79d99cb51d245e390d5c.tar.gz
IronOS-7e1e81cc6ffdf8f42c5c79d99cb51d245e390d5c.zip
Adds automatic shutdownv1.07
Closes #7 . Adds shutdown feature with settings entry
-rw-r--r--README.md3
-rw-r--r--workspace/ts100/inc/Modes.h1
-rw-r--r--workspace/ts100/inc/Settings.h7
-rw-r--r--workspace/ts100/src/Main.c2
-rw-r--r--workspace/ts100/src/Modes.c34
-rw-r--r--workspace/ts100/src/Settings.c1
6 files changed, 42 insertions, 6 deletions
diff --git a/README.md b/README.md
index fd06bf66..bf21a558 100644
--- a/README.md
+++ b/README.md
@@ -51,8 +51,9 @@ The button near the tip cycles through the options, and the one near the usb cha
Note that settings are not saved until you exit the menu, and some settings such as screen flip do not apply until a power cycle is applied.
* UVCO -> Undervoltage cut out level, settable in 1V increments from 10-24V
-* STIME -> Sleep time, how long it takes before the unit goes to sleep
+* SLTME -> Sleep time, how long it takes before the unit goes to sleep
* STMP -> The temperature the unit drops to in sleep mode
+* SHTME -> Shutdown Time, how long the unit will wait after movement before shutting down completely
* MOTION -> Wether motion detection is enabled or not
* TMPUNIT -> Temperature unit, C or F
* FLPDSP -> Flip display for left handed users
diff --git a/workspace/ts100/inc/Modes.h b/workspace/ts100/inc/Modes.h
index 1503c54f..63478c7b 100644
--- a/workspace/ts100/inc/Modes.h
+++ b/workspace/ts100/inc/Modes.h
@@ -34,6 +34,7 @@ enum {
UVCO = 0,
SLEEP_TEMP,
SLEEP_TIME,
+ SHUTDOWN_TIME,
MOTIONDETECT,
MOTIONSENSITIVITY,
TEMPDISPLAY,
diff --git a/workspace/ts100/inc/Settings.h b/workspace/ts100/inc/Settings.h
index 16500bc8..53cf1eea 100644
--- a/workspace/ts100/inc/Settings.h
+++ b/workspace/ts100/inc/Settings.h
@@ -11,7 +11,7 @@
#define SETTINGS_H_
#include <stdint.h>
#include "stm32f10x_flash.h"
-#define SETTINGSVERSION 0x04 /*Change this if you change the struct below to prevent people getting out of sync*/
+#define SETTINGSVERSION 0x05 /*Change this if you change the struct below to prevent people getting out of sync*/
#define SETTINGSOPTIONSCOUNT 6 /*Number of settings in the settings menu*/
#define MOTION_HIGH (0x00)
#define MOTION_MED (0x10)
@@ -20,15 +20,16 @@
* This struct must be a multiple of 2 bytes as it is saved / restored from flash in uint16_t chunks
*/
struct {
- uint32_t SolderingTemp; //current setpoint for the iron
+ uint32_t SolderingTemp; //current set point for the iron
uint32_t SleepTemp; //temp to drop to in sleep
uint8_t version; //Used to track if a reset is needed on firmware upgrade
uint8_t SleepTime; //minutes timeout to sleep
- uint8_t cutoutVoltage:5; //The voltage we cutout at for undervoltage
+ uint8_t cutoutVoltage:5; //The voltage we cut out at for under voltage
uint8_t movementEnabled:1; //If movement is enabled
uint8_t displayTempInF:1; //If we need to convert the C reading to F
uint8_t flipDisplay:1; //If true we want to invert the display for lefties
uint8_t sensitivity:7; //Sensitivity of accelerometer
+ uint8_t ShutdownTime:7; //Time until unit shuts down if left alone
uint16_t tempCalibration; //Temperature calibration value
uint16_t voltageDiv; //Voltage divisor factor
} systemSettings;
diff --git a/workspace/ts100/src/Main.c b/workspace/ts100/src/Main.c
index 1768e0c5..39336017 100644
--- a/workspace/ts100/src/Main.c
+++ b/workspace/ts100/src/Main.c
@@ -37,7 +37,7 @@ void setup() {
readIronTemp(systemSettings.tempCalibration, 0,0); //load the default calibration value
Init_Oled(systemSettings.flipDisplay); //Init the OLED display
- OLED_DrawString("VER 1.06", 8); //
+ OLED_DrawString("VER 1.07", 8); //
delayMs(800); //Pause to show version number
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
}
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
diff --git a/workspace/ts100/src/Settings.c b/workspace/ts100/src/Settings.c
index 174c9968..e24601da 100644
--- a/workspace/ts100/src/Settings.c
+++ b/workspace/ts100/src/Settings.c
@@ -52,5 +52,6 @@ void resetSettings() {
systemSettings.sensitivity=0x00; //Default high sensitivity
systemSettings.tempCalibration=239; //Default to their calibration value
systemSettings.voltageDiv=144; //Default divider from schematic
+ systemSettings.ShutdownTime=30;
}