From 9969c66520caf79da0afdd4ccafda3d4f5ab8bbb Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 9 Aug 2017 10:07:34 +1000 Subject: [PATCH] Add ability to start into sleep --- workspace/ts100/inc/Settings.h | 4 ++-- workspace/ts100/inc/Strings.h | 1 + workspace/ts100/src/Main.c | 9 +++++---- workspace/ts100/src/Modes.c | 7 ++++++- workspace/ts100/src/Strings.c | 8 +++++--- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/workspace/ts100/inc/Settings.h b/workspace/ts100/inc/Settings.h index 7b392b0e..5d5695d5 100644 --- a/workspace/ts100/inc/Settings.h +++ b/workspace/ts100/inc/Settings.h @@ -12,7 +12,7 @@ #include #include "stm32f10x_flash.h" #include "Oled.h" -#define SETTINGSVERSION 16 /*Change this if you change the struct below to prevent people getting out of sync*/ +#define SETTINGSVERSION 17 /*Change this if you change the struct below to prevent people getting out of sync*/ //Display Speeds #define DISPLAYMODE_FAST (0x00) #define DISPLAYMODE_MEDIUM (0x01) @@ -35,7 +35,7 @@ typedef struct { uint8_t displayTempInF:1; //If we need to convert the C reading to F uint8_t OrientationMode:2; //If true we want to invert the display for lefties uint8_t sensitivity:5; //Sensitivity of accelerometer (5 bits) - uint8_t autoStart:1; //Should the unit automatically jump straight into soldering mode when power is applied + uint8_t autoStart:2; //Should the unit automatically jump straight into soldering mode when power is applied uint8_t ShutdownTime:6; //Time until unit shuts down if left alone uint8_t displayUpdateSpeed:2; //How fast the display updates / temp showing mode uint8_t temperatureRounding:2; //Rounding mode for the temperature diff --git a/workspace/ts100/inc/Strings.h b/workspace/ts100/inc/Strings.h index 62147794..ef22ad39 100644 --- a/workspace/ts100/inc/Strings.h +++ b/workspace/ts100/inc/Strings.h @@ -19,6 +19,7 @@ extern const char* UVLOWarningString; //Fixed width 8 chars extern const char* CoolingPromptString; //Fixed width 5 chars extern const char SettingTrueChar; extern const char SettingFalseChar; +extern const char SettingSleepChar; extern const char SettingFastChar; extern const char SettingMediumChar; extern const char SettingSlowChar; diff --git a/workspace/ts100/src/Main.c b/workspace/ts100/src/Main.c index cbaf3776..81943559 100644 --- a/workspace/ts100/src/Main.c +++ b/workspace/ts100/src/Main.c @@ -14,13 +14,15 @@ void setup(); int main(void) { setup();/*Setup the system*/ - if (systemSettings.autoStart) + if (systemSettings.autoStart == 1) operatingMode = SOLDERING; + else if (systemSettings.autoStart == 2) + operatingMode = SLEEP; while (1) { Clear_Watchdog(); //reset the Watch dog timer ProcessUI(); DrawUI(); - OLED_Sync();//Write out the screen buffer + OLED_Sync(); //Write out the screen buffer delayMs(15); //Slow the system down waiting for the iron. if (systemSettings.OrientationMode == 2) { @@ -28,8 +30,7 @@ int main(void) { if (RotationChangedFlag) { OLED_SetOrientation(!getOrientation()); RotationChangedFlag = 0; - } - else if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == Bit_RESET) { + } else if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == Bit_RESET) { OLED_SetOrientation(!getOrientation()); RotationChangedFlag = 0; //^ This is a workaround for the IRQ being set off before we have the handler setup and enabled. diff --git a/workspace/ts100/src/Modes.c b/workspace/ts100/src/Modes.c index a11c2b72..472814dc 100644 --- a/workspace/ts100/src/Modes.c +++ b/workspace/ts100/src/Modes.c @@ -218,7 +218,8 @@ void ProcessUI() { systemSettings.powerDisplay = !systemSettings.powerDisplay; break; case AUTOSTART: - systemSettings.autoStart = !systemSettings.autoStart; + systemSettings.autoStart++; + systemSettings.autoStart %=3; break; case COOLINGBLINK: systemSettings.coolingTempBlink = @@ -660,6 +661,7 @@ void DrawUI() { case 0: OLED_DrawChar(SettingFalseChar, 7); break; + } break; case AUTOSTART: @@ -671,6 +673,9 @@ void DrawUI() { case 0: OLED_DrawChar(SettingFalseChar, 7); break; + case 2: + OLED_DrawChar(SettingSleepChar, 7); + break; } break; case COOLINGBLINK: diff --git a/workspace/ts100/src/Strings.c b/workspace/ts100/src/Strings.c index da130a03..45449198 100644 --- a/workspace/ts100/src/Strings.c +++ b/workspace/ts100/src/Strings.c @@ -18,10 +18,10 @@ const char* SettingsLongNames[14] = " Temperature Unit", " Temperature Rounding Amount", " Temperature Display Update Rate", " Display Orientation ", - " Enable front key boost 450C mode when soldering", - " Temperature when in boost mode", + " Enable front key enters boost mode 450C mode when soldering", + " Temperature when in \"boost\" mode", " Changes the arrows to a power display when soldering", - " Automatically starts the iron into soldering on power up.", + " Automatically starts the iron into soldering on power up.T=Soldering, S= Sleep mode,F=Off", " Blink the temperature on the cooling screen while the tip is still hot." }; const char* TempCalStatus[3] = { "Cal Temp", "Cal OK ", "Cal Fail" }; //All fixed 8 chars @@ -29,6 +29,8 @@ const char* UVLOWarningString = "Low Volt"; //Fixed width 8 chars const char* CoolingPromptString = "Cool "; //Fixed width 5 chars const char SettingTrueChar = 'T'; const char SettingFalseChar = 'F'; +const char SettingSleepChar = 'S'; + const char SettingFastChar = 'F'; const char SettingMediumChar = 'M'; const char SettingSlowChar = 'S';