1
0
forked from me/IronOS

Adding in lower sleep times

#46
Adding in smaller times for sleep
This commit is contained in:
Ben V. Brown
2017-08-09 10:28:51 +10:00
parent 9969c66520
commit c3d672c0dd
4 changed files with 27 additions and 13 deletions

View File

@@ -44,7 +44,7 @@ void StartUp_Accelerometer(uint8_t sensitivity) {
I2C_RegisterWrite( CTRL_REG2, 0x40); // Reset all registers to POR values
delayMs(2); // ~1ms delay
I2C_RegisterWrite(FF_MT_CFG_REG, 0x78); // Enable motion detection for X and Y axis, latch enabled
uint8_t sens = 9 * 6 + 3;
uint8_t sens = 9 * 6 + 5;
sens -= 6 * sensitivity;
I2C_RegisterWrite(FF_MT_THS_REG, 0x80 | sens); // Set threshold

View File

@@ -74,15 +74,20 @@ void ProcessUI() {
StatusFlags = 0;
}
//We need to check the timer for movement in case we need to goto idle
if (systemSettings.sensitivity)
if (millis() - getLastMovement()
> (systemSettings.SleepTime * 60000)) {
if (millis() - getLastButtonPress()
> (systemSettings.SleepTime * 60000)) {
if (systemSettings.sensitivity) {
uint32_t timeout = 0;
if (systemSettings.SleepTime < 6)
timeout = 1000 * 10 * systemSettings.SleepTime;
else
timeout = 60 * 1000 * (systemSettings.SleepTime - 5);
if (millis() - getLastMovement() > (timeout)) {
if (millis() - getLastButtonPress() > (timeout)) {
operatingMode = SLEEP;
return;
}
}
}
uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //get X10 voltage
if ((voltage) < lookupVoltageLevel(systemSettings.cutoutSetting)) {
operatingMode = UVLOWARN;
@@ -170,7 +175,7 @@ void ProcessUI() {
break;
case SLEEP_TIME:
++systemSettings.SleepTime; //Go up 1 minute at a time
if (systemSettings.SleepTime > 30)
if (systemSettings.SleepTime > 16)
systemSettings.SleepTime = 1;//can't set time over 30 mins
//Remember that ^ is the time of no movement
break;
@@ -219,7 +224,7 @@ void ProcessUI() {
break;
case AUTOSTART:
systemSettings.autoStart++;
systemSettings.autoStart %=3;
systemSettings.autoStart %= 3;
break;
case COOLINGBLINK:
systemSettings.coolingTempBlink =
@@ -566,8 +571,17 @@ void DrawUI() {
OLED_DrawThreeNumber(systemSettings.SleepTemp / 10, 5);
break;
case SLEEP_TIME:
OLED_DrawString(SettingsShortNames[SLEEP_TIME], 6);
OLED_DrawTwoNumber(systemSettings.SleepTime, 6);
Clear_Screen();
OLED_DrawString(SettingsShortNames[SLEEP_TIME], 5);
//Draw in the timescale
if (systemSettings.SleepTime < 6) {
OLED_DrawChar('S', 7);
OLED_DrawTwoNumber(systemSettings.SleepTime * 10, 5);
} else {
OLED_DrawChar('M', 7);
OLED_DrawTwoNumber(systemSettings.SleepTime - 5, 5);
}
break;
case SHUTDOWN_TIME:
OLED_DrawString(SettingsShortNames[SHUTDOWN_TIME], 6);

View File

@@ -58,7 +58,7 @@ uint8_t lookupVoltageLevel(uint8_t level) {
void resetSettings() {
systemSettings.SleepTemp = 1500;//Temperature the iron sleeps at - default 150.0 C
systemSettings.SleepTime = 1;//How many minutes we wait until going to sleep - default 1 min
systemSettings.SleepTime = 6;//How many seconds/minutes we wait until going to sleep - default 1 min
systemSettings.SolderingTemp = 3200; //Default soldering temp is 320.0 C
systemSettings.cutoutSetting = 0; //default to no cut-off voltage
systemSettings.version = SETTINGSVERSION;//Store the version number to allow for easier upgrades

View File

@@ -30,7 +30,6 @@ 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';
@@ -64,6 +63,7 @@ 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';
@@ -74,6 +74,6 @@ const char SettingTempCChar = 'C';
const char SettingTempFChar = 'F';
#endif
const char* SettingsShortNames[14] = { "PWRSC ", "STMP ", "SLTME ", "SHTME ",
const char* SettingsShortNames[14] = { "PWRSC ", "STMP ", "STME ", "SHTME ",
"MSENSE ", "TMPUNT ", "TMPRND ", "TMPSPD ", "DSPROT ", "BOOST ",
"BTMP ", "PWRDSP ", "ASTART ", "CLBLNK " };