aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2017-05-18 23:58:35 +1000
committerBen V. Brown <[email protected]>2017-05-18 23:58:39 +1000
commit1522c419cf85804e12635033e416ec1fe2600cb8 (patch)
tree74f063b0584c44f36a97c21ce43d1ffa03500812
parentddedd9ad4fc60dbde4bdf5bbc13255a5e7dd799e (diff)
downloadIronOS-1.05.tar.gz
IronOS-1.05.zip
Add ability to calibrate input DC voltage reading, V1.05v1.05
Closes #5
-rw-r--r--workspace/ts100/inc/Analog.h2
-rw-r--r--workspace/ts100/inc/Modes.h21
-rw-r--r--workspace/ts100/inc/Settings.h3
-rw-r--r--workspace/ts100/src/Analog.c4
-rw-r--r--workspace/ts100/src/Main.c2
-rw-r--r--workspace/ts100/src/Modes.c83
-rw-r--r--workspace/ts100/src/Settings.c2
7 files changed, 74 insertions, 43 deletions
diff --git a/workspace/ts100/inc/Analog.h b/workspace/ts100/inc/Analog.h
index f36a0310..a81e6871 100644
--- a/workspace/ts100/inc/Analog.h
+++ b/workspace/ts100/inc/Analog.h
@@ -16,5 +16,5 @@ extern volatile uint16_t ADC1ConvertedValue[2];
uint16_t Get_ADC1Value(uint8_t i);
uint16_t readIronTemp(uint16_t calibration_temp, uint8_t read,uint16_t setPointTemp); //read the iron temp in C X10
-uint16_t readDCVoltage();/*Get the system voltage X10*/
+uint16_t readDCVoltage(uint16_t divFactor);/*Get the system voltage X10*/
#endif /* ANALOG_H_ */
diff --git a/workspace/ts100/inc/Modes.h b/workspace/ts100/inc/Modes.h
index 7c91d49d..1503c54f 100644
--- a/workspace/ts100/inc/Modes.h
+++ b/workspace/ts100/inc/Modes.h
@@ -17,16 +17,17 @@
#include "Settings.h"
#include "Analog.h"
enum {
- STARTUP, //we are sitting on the prompt to push a button
- SOLDERING,
- TEMP_ADJ,
- SETTINGS,
- SLEEP,
- COOLING,
- UVLOWARN,
- THERMOMETER,
- DCINDISP,
- TEMPCAL,
+ STARTUP, //we are sitting on the prompt to push a button
+ SOLDERING, //Normal operating mode
+ TEMP_ADJ, //Adjust the set temperature
+ SETTINGS, //Settings menu
+ SLEEP, //Iron is snoozing due to lack of use
+ COOLING, //Iron is cooling down -> Warning screen
+ UVLOWARN, //Unit tripped low voltage
+ THERMOMETER, //Read the tip temp
+ DCINDISP, //Disp the input voltage && Cal the DCin voltage divider
+ TEMPCAL, //Cal tip temp offset
+
} operatingMode;
enum {
diff --git a/workspace/ts100/inc/Settings.h b/workspace/ts100/inc/Settings.h
index 7c058223..16500bc8 100644
--- a/workspace/ts100/inc/Settings.h
+++ b/workspace/ts100/inc/Settings.h
@@ -11,7 +11,7 @@
#define SETTINGS_H_
#include <stdint.h>
#include "stm32f10x_flash.h"
-#define SETTINGSVERSION 0x03 /*Change this if you change the struct below to prevent people getting out of sync*/
+#define SETTINGSVERSION 0x04 /*Change this if you change the struct below to prevent people getting out of sync*/
#define SETTINGSOPTIONSCOUNT 6 /*Number of settings in the settings menu*/
#define MOTION_HIGH (0x00)
#define MOTION_MED (0x10)
@@ -30,6 +30,7 @@ struct {
uint8_t flipDisplay:1; //If true we want to invert the display for lefties
uint8_t sensitivity:7; //Sensitivity of accelerometer
uint16_t tempCalibration; //Temperature calibration value
+ uint16_t voltageDiv; //Voltage divisor factor
} systemSettings;
void saveSettings();
diff --git a/workspace/ts100/src/Analog.c b/workspace/ts100/src/Analog.c
index 4d071162..fcc99b51 100644
--- a/workspace/ts100/src/Analog.c
+++ b/workspace/ts100/src/Analog.c
@@ -10,12 +10,12 @@
//Reads the dc input and returns it as X10 voltage (ie 236 = 23.6V)
//Seems unstable below 9.5V input
-uint16_t readDCVoltage() {
+uint16_t readDCVoltage(uint16_t divFactor) {
uint16_t reading = 0;
for (u8 i = 0; i < 10; i++) {
reading += ADC_GetConversionValue(ADC2);
}
- reading /= 144; //take the average and convert to X10 voltage
+ reading /= divFactor; //take the average and convert to X10 voltage
return reading; //return the read voltage
}
diff --git a/workspace/ts100/src/Main.c b/workspace/ts100/src/Main.c
index 6f707f88..a28b9ca8 100644
--- a/workspace/ts100/src/Main.c
+++ b/workspace/ts100/src/Main.c
@@ -37,7 +37,7 @@ void setup() {
readIronTemp(systemSettings.tempCalibration, 0,0); //load the default calibration value
Init_Oled(systemSettings.flipDisplay); //Init the OLED display
- OLED_DrawString("VER 1.04", 8); //
+ OLED_DrawString("VER 1.05", 8); //
delayMs(800); //Pause to show version number
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
}
diff --git a/workspace/ts100/src/Modes.c b/workspace/ts100/src/Modes.c
index 4db834fb..bb5cc1f8 100644
--- a/workspace/ts100/src/Modes.c
+++ b/workspace/ts100/src/Modes.c
@@ -5,7 +5,7 @@
* Author: Ralim <[email protected]>
*/
#include "Modes.h"
-uint8_t tempCalStatus = 0;
+uint8_t CalStatus = 0;
//This does the required processing and state changes
void ProcessUI() {
uint8_t Buttons = getButtons(); //read the buttons status
@@ -51,7 +51,7 @@ void ProcessUI() {
return;
}
}
- uint16_t voltage = readDCVoltage(); //get X10 voltage
+ uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //get X10 voltage
if ((voltage / 10) < systemSettings.cutoutVoltage) {
operatingMode = UVLOWARN;
lastModeChange = millis();
@@ -180,9 +180,10 @@ void ProcessUI() {
if (Buttons == BUT_A) {
//Single button press, cycle over to the DC display
+ CalStatus = 0;
operatingMode = DCINDISP;
} else if (Buttons == BUT_B) {
- tempCalStatus = 0;
+ CalStatus = 0;
operatingMode = TEMPCAL;
} else if (Buttons == (BUT_A | BUT_B)) {
//If the user is holding both button, exit the screen
@@ -193,13 +194,37 @@ void ProcessUI() {
break;
case DCINDISP: {
//This lets the user check the input voltage
-
- if (Buttons == BUT_A) {
- //Single button press, cycle over to the temp display
- operatingMode = THERMOMETER;
- } else if (Buttons == (BUT_A | BUT_B)) {
- //If the user is holding both button, exit the screen
- operatingMode = STARTUP;
+ if (CalStatus == 0) {
+ if (Buttons == BUT_A) {
+ //Single button press, cycle over to the temp display
+ operatingMode = THERMOMETER;
+ } else if (Buttons == BUT_B) {
+ //dc cal mode
+ CalStatus = 1;
+ } else if (Buttons == (BUT_A | BUT_B)) {
+ //If the user is holding both button, exit the screen
+ operatingMode = STARTUP;
+ }
+ } else {
+ //User is calibrating the dc input
+ if (Buttons == BUT_A) {
+ if (!systemSettings.flipDisplay)
+ systemSettings.voltageDiv++;
+ else
+ systemSettings.voltageDiv--;
+ } else if (Buttons == BUT_B) {
+ if (!systemSettings.flipDisplay)
+ systemSettings.voltageDiv--;
+ else
+ systemSettings.voltageDiv++;
+ } else if (Buttons == (BUT_A | BUT_B)) {
+ CalStatus = 0;
+ saveSettings();
+ }
+ if (systemSettings.voltageDiv < 120)
+ systemSettings.voltageDiv = 160;
+ else if (systemSettings.voltageDiv > 160)
+ systemSettings.voltageDiv = 120;
}
}
@@ -210,13 +235,13 @@ void ProcessUI() {
operatingMode = THERMOMETER;
} else if (Buttons == BUT_A) {
//Try and calibrate
- if (tempCalStatus == 0) {
+ if (CalStatus == 0) {
if ((readTipTemp() < 300) && (readSensorTemp() < 300)) {
- tempCalStatus = 1;
+ CalStatus = 1;
systemSettings.tempCalibration = readTipTemp();
saveSettings();
} else {
- tempCalStatus = 2;
+ CalStatus = 2;
}
}
} else if (Buttons == (BUT_A | BUT_B)) {
@@ -237,7 +262,7 @@ void drawTemp(uint16_t temp, uint8_t x) {
if (systemSettings.displayTempInF)
temp = (temp * 9 + 1600) / 5;/*Convert to F -> T*(9/5)+32*/
if (temp % 10 > 5)
- temp += 10;//round up
+ temp += 10; //round up
OLED_DrawThreeNumber(temp / 10, x);
}
@@ -370,26 +395,30 @@ void DrawUI() {
drawTemp(temp, 5);
break;
case DCINDISP: {
- uint16_t voltage = readDCVoltage(); //get X10 voltage
- OLED_DrawString("IN", 2);
- OLED_DrawChar((voltage / 100) % 10, 2);
- voltage -= (voltage / 100) * 100;
- OLED_DrawChar((voltage / 10) % 10, 3);
- voltage -= (voltage / 10) * 10;
- OLED_DrawChar('.', 4);
- OLED_DrawChar(voltage % 10, 5);
- OLED_DrawChar('V', 6);
- OLED_DrawChar(' ', 7);
+ uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //get X10 voltage
+ if (CalStatus == 0 || ((millis() % 1000) > 500)) {
+ OLED_DrawString("IN", 2);
+ OLED_DrawChar((voltage / 100) % 10, 2);
+ voltage -= (voltage / 100) * 100;
+ OLED_DrawChar((voltage / 10) % 10, 3);
+ voltage -= (voltage / 10) * 10;
+ OLED_DrawChar('.', 4);
+ OLED_DrawChar(voltage % 10, 5);
+ OLED_DrawChar('V', 6);
+ OLED_DrawChar(' ', 7);
+ } else {
+ OLED_DrawString("IN ", 8);
+ }
}
break;
case TEMPCAL: {
- if (tempCalStatus == 0) {
+ if (CalStatus == 0) {
OLED_DrawString("CAL TEMP", 8);
- } else if (tempCalStatus == 1) {
+ } else if (CalStatus == 1) {
OLED_DrawString("CAL OK ", 8);
- } else if (tempCalStatus == 2) {
+ } else if (CalStatus == 2) {
OLED_DrawString("CAL FAIL", 8);
}
}
diff --git a/workspace/ts100/src/Settings.c b/workspace/ts100/src/Settings.c
index 0a88a3c6..174c9968 100644
--- a/workspace/ts100/src/Settings.c
+++ b/workspace/ts100/src/Settings.c
@@ -51,6 +51,6 @@ void resetSettings() {
systemSettings.flipDisplay=0; //Default to right handed mode
systemSettings.sensitivity=0x00; //Default high sensitivity
systemSettings.tempCalibration=239; //Default to their calibration value
-
+ systemSettings.voltageDiv=144; //Default divider from schematic
}