1
0
forked from me/IronOS

Moved to use EXTI to read button status

Temperature sensor appears to work (may need calibration work still)
This commit is contained in:
Ben V. Brown
2016-09-20 23:11:36 +10:00
parent 98ca6784a0
commit 52e92feae7
20 changed files with 321 additions and 2035 deletions

View File

@@ -7,18 +7,18 @@
#include "Modes.h"
//This does the required processing and state changes
void ProcessUI() {
uint8_t Buttons = Get_gKey(); //read the buttons status
uint8_t Buttons = getButtons(); //read the buttons status
if (millis() - LastButtonPushTime < 50)
if (millis() - getLastButtonPress() < 100)
Buttons = 0;
//rough prevention for debouncing and allocates settling time
//OLED_DrawThreeNumber(Buttons, 0);
switch (operatingMode) {
case STARTUP:
if (Buttons & KEY_A) {
if (Buttons & BUT_A) {
//A key pressed so we are moving to soldering mode
operatingMode = SOLDERING;
} else if (Buttons & KEY_B) {
} else if (Buttons & BUT_B) {
//B Button was pressed so we are moving to the Settings menu
operatingMode = SETTINGS;
}
@@ -26,42 +26,41 @@ void ProcessUI() {
break;
case SOLDERING:
//We need to check the buttons if we need to jump out
if (Buttons & KEY_A) {
if (Buttons & BUT_A) {
//A key pressed so we are moving to temp set
operatingMode = TEMP_ADJ;
} else if (Buttons & KEY_B) {
} else if (Buttons & BUT_B) {
//B Button was pressed so we are moving back to idle
operatingMode = STARTUP;
} else {
//We need to check the timer for movement in case we need to goto idle
if (millis() - LastMovementTime > (systemSettings.SleepTime * 60000)
&& millis() - LastMovementTime
> (systemSettings.SleepTime * 60000)) {
operatingMode = SLEEP; //Goto Sleep Mode
return;
}
if (systemSettings.movementEnabled)
if (millis() - getLastMovement()
> (systemSettings.SleepTime * 60000)) {
operatingMode = SLEEP; //Goto Sleep Mode
return;
}
//If no buttons pushed we need to read the current temperatures
// and then setup the drive signal time for the iron
}
break;
case TEMP_ADJ:
if (Buttons & KEY_A) {
if (Buttons & BUT_A) {
//A key pressed so we are moving down in temp
} else if (Buttons & KEY_B) {
} else if (Buttons & BUT_B) {
//B key pressed so we are moving up in temp
} else {
//we check the timeout for how long the buttons have not been pushed
//if idle for > 3 seconds then we return to soldering
if (millis() - LastButtonPushTime > 3000)
if (millis() - getLastButtonPress() > 3000)
operatingMode = SOLDERING;
}
break;
case SETTINGS:
//Settings is the mode with the most logic
//Here we are in the menu so we need to increment through the sub menus / increase the value
if (Buttons & KEY_A) {
if (Buttons & BUT_A) {
//A key iterates through the menu
if (settingsPage == 2) {
//Roll off the end
@@ -70,7 +69,7 @@ void ProcessUI() {
//TODO Save settings
} else
++settingsPage; //move to the next option
} else if (Buttons & KEY_B) {
} else if (Buttons & BUT_B) {
//B changes the value selected
switch (settingsPage) {
case UVLO:
@@ -97,6 +96,17 @@ void ProcessUI() {
break;
case SLEEP:
//The iron is sleeping at a lower temperature due to lack of movement
if (Buttons & BUT_A) {
//A Button was pressed so we are moving back to soldering
operatingMode = SOLDERING;
} else if (Buttons & BUT_B) {
//B Button was pressed so we are moving back to soldering
operatingMode = SOLDERING;
} else if (systemSettings.movementEnabled)
if (millis() - getLastMovement() > 100) {
operatingMode = SOLDERING; //Goto active mode again
return;
}
break;
default:
@@ -109,30 +119,35 @@ void DrawUI() {
case STARTUP:
//We are chilling in the idle mode
//Check if movement in the last 5 minutes , if not sleep OLED
if (millis() - LastMovementTime > (5 * 60 * 1000)) {
if (millis() - getLastMovement() > (5 * 60 * 1000)) {
//OLED off
Oled_DisplayOff();
} else {
Oled_DisplayOn();
OLED_DrawString("IDLE ", 0); //write the word IDLE
OLED_DrawString("IDLE ", 6); //write the word IDLE
}
break;
case SOLDERING:
//The user is soldering
//We draw in the current system temp and an indicator if the iron is heating or not
//First lets draw the current tip temp
//OLED_DrawString("SOLD ", 6);
OLED_DrawThreeNumber(readIronTemp(0), 0);
break;
case TEMP_ADJ:
//We are prompting the user to change the temp so we draw the current setpoint temp
//With the nifty arrows
OLED_DrawString("TEMP ", 6);
break;
case SETTINGS:
//We are prompting the user the setting name
OLED_DrawString("SETT ", 6);
break;
case SLEEP:
//The iron is in sleep temp mode
//Draw in temp and sleep
OLED_DrawString("SLEP ", 6);
break;
default:
break;