diff --git a/workspace/ts100/src/Interrupt.c b/workspace/ts100/src/Interrupt.c index 772ffb98..145777c9 100644 --- a/workspace/ts100/src/Interrupt.c +++ b/workspace/ts100/src/Interrupt.c @@ -24,76 +24,91 @@ uint32_t getLastButtonPress() { uint8_t getButtons() { //We want to check the times for the lat buttons & also the rawKeys state //If a key has just gone down, rawKeys & KEY ==1 + //This is effectively just a big switch statement to handle a small delay on triggering to stop bounce, and also handle key repeat uint8_t out = 0; - if (millis() - AkeyChange > 50) { - if (LongKeys & BUT_A) { - if (rawKeys & BUT_A) { - if (millis() - AkeyChange > 800) { - out |= BUT_A; - AkeyChange = millis(); + //Special handling case for two keys down at once + //This is here to allow for people who do not manage to get both keys down within 50ms of each other. + if ((rawKeys & (BUT_A | BUT_B)) == (BUT_A | BUT_B)) { + //both keys are probably down + if (millis() - AkeyChange > 50) + if (millis() - BkeyChange > 50) { + out = (BUT_A | BUT_B); + AkeyChange = millis(); + BkeyChange = millis(); + rawKeys=0; + } + LongKeys = 0; + } else { + if (millis() - AkeyChange > 80) { + if (LongKeys & BUT_A) { + if (rawKeys & BUT_A) { + if (millis() - AkeyChange > 800) { + out |= BUT_A; + AkeyChange = millis(); + LongKeys &= ~BUT_A; + + LongKeys |= (BUT_A << 2); + } + } else { LongKeys &= ~BUT_A; + LongKeys &= ~(BUT_A << 2); + } - LongKeys |= (BUT_A << 2); + } else if (LongKeys & (BUT_A << 2)) { + if (rawKeys & BUT_A) { + if (millis() - AkeyChange > 100) { + out |= BUT_A; + AkeyChange = millis(); + } + } else { + LongKeys &= ~BUT_A; + LongKeys &= ~(BUT_A << 2); } } else { - LongKeys &= ~BUT_A; - LongKeys &= ~(BUT_A << 2); - } - - } else if (LongKeys & (BUT_A << 2)) { - if (rawKeys & BUT_A) { - if (millis() - AkeyChange > 100) { + if (rawKeys & BUT_A) { + //The key is down out |= BUT_A; - AkeyChange = millis(); + LongKeys |= BUT_A; + } else { + //The key has been lifted + LongKeys &= ~BUT_A; + LongKeys &= ~(BUT_A << 2); } - } else { - LongKeys &= ~BUT_A; - LongKeys &= ~(BUT_A << 2); - } - } else { - if (rawKeys & BUT_A) { - //The key is down - out |= BUT_A; - LongKeys |= BUT_A; - } else { - //The key has been lifted - LongKeys &= ~BUT_A; - LongKeys &= ~(BUT_A << 2); } } - } - if (millis() - BkeyChange > 50) { - if (LongKeys & BUT_B) { - if (rawKeys & BUT_B) { - if (millis() - BkeyChange > 800) { - out |= BUT_B; - BkeyChange = millis(); - LongKeys |= (BUT_B << 2); + if (millis() - BkeyChange > 80) { + if (LongKeys & BUT_B) { + if (rawKeys & BUT_B) { + if (millis() - BkeyChange > 800) { + out |= BUT_B; + BkeyChange = millis(); + LongKeys |= (BUT_B << 2); + LongKeys &= ~BUT_B; + } + } else { LongKeys &= ~BUT_B; + LongKeys &= ~(BUT_B << 2); + } + } else if (LongKeys & (BUT_B << 2)) { + if (rawKeys & BUT_B) { + if (millis() - BkeyChange > 100) { + out |= BUT_B; + BkeyChange = millis(); + } + } else { + LongKeys &= ~BUT_B; + LongKeys &= ~(BUT_B << 2); } } else { - LongKeys &= ~BUT_B; - LongKeys &= ~(BUT_B << 2); - } - } else if (LongKeys & (BUT_B << 2)) { - if (rawKeys & BUT_B) { - if (millis() - BkeyChange > 100) { + if (rawKeys & BUT_B) { + //The key is down out |= BUT_B; - BkeyChange = millis(); + LongKeys |= BUT_B; + } else { + //The key has been lifted + LongKeys &= ~BUT_B; + LongKeys &= ~(BUT_B << 2); } - } else { - LongKeys &= ~BUT_B; - LongKeys &= ~(BUT_B << 2); - } - } else { - if (rawKeys & BUT_B) { - //The key is down - out |= BUT_B; - LongKeys |= BUT_B; - } else { - //The key has been lifted - LongKeys &= ~BUT_B; - LongKeys &= ~(BUT_B << 2); } } } diff --git a/workspace/ts100/src/Modes.c b/workspace/ts100/src/Modes.c index 2768d2ae..a11c2b72 100644 --- a/workspace/ts100/src/Modes.c +++ b/workspace/ts100/src/Modes.c @@ -417,7 +417,13 @@ void DrawUI() { static uint16_t lastSolderingDrawnTemp2 = 0; static uint8_t settingsLongTestScrollPos = 0; uint16_t temp = readIronTemp(0, 0, 0xFFFF); - + if (millis() - getLastMovement() > (5 * 60 * 1000) + && (millis() - getLastButtonPress() > (5 * 60 * 1000))) { + //OLED off + Oled_DisplayOff(); + } else { + Oled_DisplayOn(); + } switch (operatingMode) { case STARTUP: //We are chilling in the idle mode @@ -719,7 +725,8 @@ void DrawUI() { Clear_Screen(); OLED_DrawString(CoolingPromptString, 5); temp = readIronTemp(0, 1, 0xFFFF); //force temp re-reading - if (temp < 500 || ((millis() % 1000) > 500)) + if (temp < 500 || ((millis() % 1000) > 500) + || (!systemSettings.coolingTempBlink)) drawTemp(temp, 5, systemSettings.temperatureRounding); break; @@ -728,7 +735,7 @@ void DrawUI() { break; case THERMOMETER: temp = readIronTemp(0, 1, 0xFFFF); //Force a reading as heater is off - OLED_DrawString("TEMP ", 5);//extra one to it clears the leftover 'L' from IDLE + OLED_DrawString("Temp ", 5);//extra one to it clears the leftover 'L' from IDLE drawTemp(temp, 5, 0); break; case DCINDISP: { diff --git a/workspace/ts100/src/Oled.c b/workspace/ts100/src/Oled.c index 0ddf102f..c667523c 100644 --- a/workspace/ts100/src/Oled.c +++ b/workspace/ts100/src/Oled.c @@ -46,24 +46,30 @@ u8 OLED_Setup_Array[46] = { /**/ 0x80, 0XA6,/*Normal display*/ 0x80, 0xAF /*Dispaly on*/ }; - +uint8_t OLEDOnOffState = 0;//Used to lock out so we dont send it too often /* Function: Oled_DisplayOn Description:Turn on the Oled display */ void Oled_DisplayOn(void) { - u8 data[6] = { 0x80, 0X8D, 0x80, 0X14, 0x80, 0XAF }; + if (OLEDOnOffState != 1) { + u8 data[6] = { 0x80, 0X8D, 0x80, 0X14, 0x80, 0XAF }; - I2C_PageWrite(data, 6, DEVICEADDR_OLED); + I2C_PageWrite(data, 6, DEVICEADDR_OLED); + OLEDOnOffState = 1; + } } /* Function: Oled_DisplayOff Description:Turn off the Oled display */ void Oled_DisplayOff(void) { - u8 data[6] = { 0x80, 0X8D, 0x80, 0X10, 0x80, 0XAE }; + if (OLEDOnOffState != 2) { + u8 data[6] = { 0x80, 0X8D, 0x80, 0X10, 0x80, 0XAE }; - I2C_PageWrite(data, 6, DEVICEADDR_OLED); + I2C_PageWrite(data, 6, DEVICEADDR_OLED); + OLEDOnOffState = 2; + } } /* @@ -89,9 +95,9 @@ const u8* Data_Command(u8 length, const u8* data) { } //This causes us to write out the buffered screen data to the display void OLED_Sync() { - Set_ShowPos(0,0); + Set_ShowPos(0, 0); Data_Command(96, displayBuffer); - Set_ShowPos(0,1); + Set_ShowPos(0, 1); Data_Command(96, displayBuffer + 96); } diff --git a/workspace/ts100/src/Strings.c b/workspace/ts100/src/Strings.c index c015d2b2..da130a03 100644 --- a/workspace/ts100/src/Strings.c +++ b/workspace/ts100/src/Strings.c @@ -26,12 +26,12 @@ const char* SettingsLongNames[14] = const char* TempCalStatus[3] = { "Cal Temp", "Cal OK ", "Cal Fail" }; //All fixed 8 chars const char* UVLOWarningString = "Low Volt"; //Fixed width 8 chars -const char* CoolingPromptString = "COOL "; //Fixed width 5 chars +const char* CoolingPromptString = "Cool "; //Fixed width 5 chars const char SettingTrueChar = 'T'; const char SettingFalseChar = 'F'; const char SettingFastChar = 'F'; -const char SettingMediumChar = 'F'; -const char SettingSlowChar = 'F'; +const char SettingMediumChar = 'M'; +const char SettingSlowChar = 'S'; const char SettingRightChar = 'R'; const char SettingLeftChar = 'L'; const char SettingAutoChar = 'A'; @@ -63,8 +63,8 @@ const char* CoolingPromptString = "COOL ";//Fixed width 5 chars const char SettingTrueChar = 'T'; const char SettingFalseChar = 'F'; const char SettingFastChar = 'F'; -const char SettingMediumChar = 'F'; -const char SettingSlowChar = 'F'; +const char SettingMediumChar = 'M'; +const char SettingSlowChar = 'S'; const char SettingRightChar = 'R'; const char SettingLeftChar = 'L'; const char SettingAutoChar = 'A';