mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Roughly functioning menu system
Has some functionality issues Still need settings saving & movement detection
This commit is contained in:
@@ -19,7 +19,10 @@ extern volatile uint32_t gHeat_cnt;
|
|||||||
inline void setIronTimer(uint32_t time) {
|
inline void setIronTimer(uint32_t time) {
|
||||||
gHeat_cnt = time;
|
gHeat_cnt = time;
|
||||||
}
|
}
|
||||||
|
inline uint32_t getIronTimer()
|
||||||
|
{
|
||||||
|
return gHeat_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
#define LOW 0
|
#define LOW 0
|
||||||
#define HIGH 1
|
#define HIGH 1
|
||||||
|
|||||||
@@ -42,8 +42,11 @@ inline uint32_t millis() {
|
|||||||
inline uint32_t getLastButtonPress() {
|
inline uint32_t getLastButtonPress() {
|
||||||
return lastKeyPress;
|
return lastKeyPress;
|
||||||
}
|
}
|
||||||
inline uint32_t getLastMovement(){
|
inline uint32_t resetLastButtonPress() {
|
||||||
return lastMovement;
|
lastKeyPress = millis();
|
||||||
|
}
|
||||||
|
inline uint32_t getLastMovement() {
|
||||||
|
return lastMovement;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint16_t getButtons() {
|
inline uint16_t getButtons() {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ int main(void) {
|
|||||||
Clear_Screen(); //clear the display buffer to black
|
Clear_Screen(); //clear the display buffer to black
|
||||||
systemSettings.SleepTemp = 1000;
|
systemSettings.SleepTemp = 1000;
|
||||||
systemSettings.SleepTime = 1;
|
systemSettings.SleepTime = 1;
|
||||||
systemSettings.SolderingTemp = 1500;
|
systemSettings.SolderingTemp = 1200;
|
||||||
readIronTemp(239); //load the default calibration value
|
readIronTemp(239); //load the default calibration value
|
||||||
setupPID(); //init the PID values
|
setupPID(); //init the PID values
|
||||||
//OLED_DrawString("TEST012",7);
|
//OLED_DrawString("TEST012",7);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
void ProcessUI() {
|
void ProcessUI() {
|
||||||
uint8_t Buttons = getButtons(); //read the buttons status
|
uint8_t Buttons = getButtons(); //read the buttons status
|
||||||
|
|
||||||
if (millis() - getLastButtonPress() < 100)
|
if (millis() - getLastButtonPress() < 150)
|
||||||
Buttons = 0;
|
Buttons = 0;
|
||||||
//rough prevention for debouncing and allocates settling time
|
//rough prevention for debouncing and allocates settling time
|
||||||
//OLED_DrawThreeNumber(Buttons, 0);
|
//OLED_DrawThreeNumber(Buttons, 0);
|
||||||
@@ -18,9 +18,11 @@ void ProcessUI() {
|
|||||||
if (Buttons & BUT_A) {
|
if (Buttons & BUT_A) {
|
||||||
//A key pressed so we are moving to soldering mode
|
//A key pressed so we are moving to soldering mode
|
||||||
operatingMode = SOLDERING;
|
operatingMode = SOLDERING;
|
||||||
|
resetLastButtonPress();
|
||||||
} else if (Buttons & BUT_B) {
|
} else if (Buttons & BUT_B) {
|
||||||
//B Button was pressed so we are moving to the Settings menu
|
//B Button was pressed so we are moving to the Settings menu
|
||||||
operatingMode = SETTINGS;
|
operatingMode = SETTINGS;
|
||||||
|
resetLastButtonPress();
|
||||||
}
|
}
|
||||||
//Nothing else to check here
|
//Nothing else to check here
|
||||||
break;
|
break;
|
||||||
@@ -29,9 +31,11 @@ void ProcessUI() {
|
|||||||
if (Buttons & BUT_A) {
|
if (Buttons & BUT_A) {
|
||||||
//A key pressed so we are moving to temp set
|
//A key pressed so we are moving to temp set
|
||||||
operatingMode = TEMP_ADJ;
|
operatingMode = TEMP_ADJ;
|
||||||
|
resetLastButtonPress();
|
||||||
} else if (Buttons & BUT_B) {
|
} else if (Buttons & BUT_B) {
|
||||||
//B Button was pressed so we are moving back to idle
|
//B Button was pressed so we are moving back to idle
|
||||||
operatingMode = STARTUP;
|
operatingMode = STARTUP;
|
||||||
|
resetLastButtonPress();
|
||||||
} else {
|
} else {
|
||||||
//We need to check the timer for movement in case we need to goto idle
|
//We need to check the timer for movement in case we need to goto idle
|
||||||
if (systemSettings.movementEnabled)
|
if (systemSettings.movementEnabled)
|
||||||
@@ -54,9 +58,14 @@ void ProcessUI() {
|
|||||||
case TEMP_ADJ:
|
case TEMP_ADJ:
|
||||||
if (Buttons & BUT_A) {
|
if (Buttons & BUT_A) {
|
||||||
//A key pressed so we are moving down in temp
|
//A key pressed so we are moving down in temp
|
||||||
|
resetLastButtonPress();
|
||||||
|
if (systemSettings.SolderingTemp > 1000)
|
||||||
|
systemSettings.SolderingTemp -= 100;
|
||||||
} else if (Buttons & BUT_B) {
|
} else if (Buttons & BUT_B) {
|
||||||
//B key pressed so we are moving up in temp
|
//B key pressed so we are moving up in temp
|
||||||
|
resetLastButtonPress();
|
||||||
|
if (systemSettings.SolderingTemp < 4500)
|
||||||
|
systemSettings.SolderingTemp += 100;
|
||||||
} else {
|
} else {
|
||||||
//we check the timeout for how long the buttons have not been pushed
|
//we check the timeout for how long the buttons have not been pushed
|
||||||
//if idle for > 3 seconds then we return to soldering
|
//if idle for > 3 seconds then we return to soldering
|
||||||
@@ -67,7 +76,11 @@ void ProcessUI() {
|
|||||||
case SETTINGS:
|
case SETTINGS:
|
||||||
//Settings is the mode with the most logic
|
//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
|
//Here we are in the menu so we need to increment through the sub menus / increase the value
|
||||||
|
if (millis() - getLastButtonPress() < 300)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Buttons & BUT_A) {
|
if (Buttons & BUT_A) {
|
||||||
|
resetLastButtonPress();
|
||||||
//A key iterates through the menu
|
//A key iterates through the menu
|
||||||
if (settingsPage == 2) {
|
if (settingsPage == 2) {
|
||||||
//Roll off the end
|
//Roll off the end
|
||||||
@@ -77,18 +90,21 @@ void ProcessUI() {
|
|||||||
} else
|
} else
|
||||||
++settingsPage; //move to the next option
|
++settingsPage; //move to the next option
|
||||||
} else if (Buttons & BUT_B) {
|
} else if (Buttons & BUT_B) {
|
||||||
|
resetLastButtonPress();
|
||||||
//B changes the value selected
|
//B changes the value selected
|
||||||
switch (settingsPage) {
|
switch (settingsPage) {
|
||||||
case UVLO:
|
case UVLO:
|
||||||
//we are incrementing the cutout voltage
|
//we are incrementing the cutout voltage
|
||||||
systemSettings.cutoutVoltage += 5; //Go up 0.5V at a jump
|
systemSettings.cutoutVoltage += 1; //Go up 1V at a jump
|
||||||
if (systemSettings.cutoutVoltage < 90)
|
if (systemSettings.cutoutVoltage > 24)
|
||||||
systemSettings.cutoutVoltage = 90; //cant set UVLO below 9V
|
systemSettings.cutoutVoltage = 9;
|
||||||
|
else if (systemSettings.cutoutVoltage < 9)
|
||||||
|
systemSettings.cutoutVoltage = 9; //cant set UVLO below 9V
|
||||||
break;
|
break;
|
||||||
case SLEEP_TEMP:
|
case SLEEP_TEMP:
|
||||||
systemSettings.SleepTemp += 10; //Go up 10c at a time
|
systemSettings.SleepTemp += 100; //Go up 10c at a time
|
||||||
if (systemSettings.SleepTemp > 300)
|
if (systemSettings.SleepTemp > 3000)
|
||||||
systemSettings.SleepTemp = 100; //cant sleep higher than 300
|
systemSettings.SleepTemp = 1000;//cant sleep higher than 300
|
||||||
break;
|
break;
|
||||||
case SLEEP_TIME:
|
case SLEEP_TIME:
|
||||||
++systemSettings.SleepTime; //Go up 1 minute at a time
|
++systemSettings.SleepTime; //Go up 1 minute at a time
|
||||||
@@ -137,25 +153,58 @@ void DrawUI() {
|
|||||||
Oled_DisplayOff();
|
Oled_DisplayOff();
|
||||||
} else {
|
} else {
|
||||||
Oled_DisplayOn();
|
Oled_DisplayOn();
|
||||||
OLED_DrawString("IDLE ", 6); //write the word IDLE
|
OLED_DrawString("IDLE ", 7); //write the word IDLE
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SOLDERING:
|
case SOLDERING:
|
||||||
//The user is soldering
|
//The user is soldering
|
||||||
//We draw in the current system temp and an indicator if the iron is heating or not
|
if (systemSettings.SolderingTemp < readIronTemp(0)) {
|
||||||
//First lets draw the current tip temp
|
OLED_DrawChar('C', 14 * 4);
|
||||||
//OLED_DrawString("SOLD ", 6);
|
} else {
|
||||||
OLED_DrawThreeNumber(readIronTemp(0)/10, 0);
|
if (systemSettings.SolderingTemp - readIronTemp(0) < 20) {
|
||||||
|
OLED_DrawChar(' ', 14 * 4);
|
||||||
|
} else { //we are heating
|
||||||
|
OLED_DrawChar('H', 14 * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
OLED_DrawThreeNumber(readIronTemp(0) / 10, 0);
|
||||||
|
OLED_DrawChar('C', 14 * 3);
|
||||||
|
OLED_DrawChar(' ', 14 * 4);
|
||||||
|
OLED_DrawChar(' ', 14 * 5);
|
||||||
break;
|
break;
|
||||||
case TEMP_ADJ:
|
case TEMP_ADJ:
|
||||||
//We are prompting the user to change the temp so we draw the current setpoint temp
|
//We are prompting the user to change the temp so we draw the current setpoint temp
|
||||||
//With the nifty arrows
|
//With the nifty arrows
|
||||||
OLED_DrawString("TEMP ", 6);
|
OLED_DrawChar(' ', 0);
|
||||||
|
OLED_DrawThreeNumber(systemSettings.SolderingTemp / 10, 14 * 1);
|
||||||
|
OLED_DrawChar(' ', 14 * 4);
|
||||||
|
OLED_DrawChar(' ', 14 * 5);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SETTINGS:
|
case SETTINGS:
|
||||||
//We are prompting the user the setting name
|
//We are prompting the user the setting name
|
||||||
OLED_DrawString("SETT ", 6);
|
|
||||||
|
switch (settingsPage) {
|
||||||
|
case UVLO:
|
||||||
|
OLED_DrawString("UVLO", 4);
|
||||||
|
OLED_DrawTwoNumber(systemSettings.cutoutVoltage, 14 * 4);
|
||||||
|
//OLED_DrawChar('V', 14 * 5);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SLEEP_TEMP:
|
||||||
|
OLED_DrawString("STMP", 4);
|
||||||
|
OLED_DrawThreeNumber(systemSettings.SleepTemp / 10, 14 * 4);
|
||||||
|
//OLED_DrawChar('V', 14 * 5);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SLEEP_TIME:
|
||||||
|
OLED_DrawString("STME ", 5);
|
||||||
|
OLED_DrawTwoNumber(systemSettings.SleepTime, 14 * 5);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SLEEP:
|
case SLEEP:
|
||||||
//The iron is in sleep temp mode
|
//The iron is in sleep temp mode
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ void OLED_DrawChar(char c, uint8_t x) {
|
|||||||
* Draw a 2 digit number to the display
|
* Draw a 2 digit number to the display
|
||||||
* */
|
* */
|
||||||
void OLED_DrawTwoNumber(uint8_t in, uint8_t x) {
|
void OLED_DrawTwoNumber(uint8_t in, uint8_t x) {
|
||||||
OLED_DrawChar(in / 10, x);
|
OLED_DrawChar((in / 10)%10, x);
|
||||||
OLED_DrawChar(in % 10, x + 14);
|
OLED_DrawChar(in % 10, x + 14);
|
||||||
}
|
}
|
||||||
void OLED_DrawThreeNumber(uint16_t in, uint8_t x) {
|
void OLED_DrawThreeNumber(uint16_t in, uint8_t x) {
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ int32_t computePID(uint16_t setpoint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupPID(void) {
|
void setupPID(void) {
|
||||||
pidSettings.kp = 15;
|
pidSettings.kp = 18;
|
||||||
pidSettings.ki = 2;
|
pidSettings.ki = 3;
|
||||||
pidSettings.kd = 1;
|
pidSettings.kd = 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user