@@ -16,5 +16,5 @@ extern volatile uint16_t ADC1ConvertedValue[2];
|
|||||||
|
|
||||||
uint16_t Get_ADC1Value(uint8_t i);
|
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 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_ */
|
#endif /* ANALOG_H_ */
|
||||||
|
|||||||
@@ -17,16 +17,17 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Analog.h"
|
#include "Analog.h"
|
||||||
enum {
|
enum {
|
||||||
STARTUP, //we are sitting on the prompt to push a button
|
STARTUP, //we are sitting on the prompt to push a button
|
||||||
SOLDERING,
|
SOLDERING, //Normal operating mode
|
||||||
TEMP_ADJ,
|
TEMP_ADJ, //Adjust the set temperature
|
||||||
SETTINGS,
|
SETTINGS, //Settings menu
|
||||||
SLEEP,
|
SLEEP, //Iron is snoozing due to lack of use
|
||||||
COOLING,
|
COOLING, //Iron is cooling down -> Warning screen
|
||||||
UVLOWARN,
|
UVLOWARN, //Unit tripped low voltage
|
||||||
THERMOMETER,
|
THERMOMETER, //Read the tip temp
|
||||||
DCINDISP,
|
DCINDISP, //Disp the input voltage && Cal the DCin voltage divider
|
||||||
TEMPCAL,
|
TEMPCAL, //Cal tip temp offset
|
||||||
|
|
||||||
} operatingMode;
|
} operatingMode;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#define SETTINGS_H_
|
#define SETTINGS_H_
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "stm32f10x_flash.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 SETTINGSOPTIONSCOUNT 6 /*Number of settings in the settings menu*/
|
||||||
#define MOTION_HIGH (0x00)
|
#define MOTION_HIGH (0x00)
|
||||||
#define MOTION_MED (0x10)
|
#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 flipDisplay:1; //If true we want to invert the display for lefties
|
||||||
uint8_t sensitivity:7; //Sensitivity of accelerometer
|
uint8_t sensitivity:7; //Sensitivity of accelerometer
|
||||||
uint16_t tempCalibration; //Temperature calibration value
|
uint16_t tempCalibration; //Temperature calibration value
|
||||||
|
uint16_t voltageDiv; //Voltage divisor factor
|
||||||
} systemSettings;
|
} systemSettings;
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
//Reads the dc input and returns it as X10 voltage (ie 236 = 23.6V)
|
//Reads the dc input and returns it as X10 voltage (ie 236 = 23.6V)
|
||||||
//Seems unstable below 9.5V input
|
//Seems unstable below 9.5V input
|
||||||
uint16_t readDCVoltage() {
|
uint16_t readDCVoltage(uint16_t divFactor) {
|
||||||
uint16_t reading = 0;
|
uint16_t reading = 0;
|
||||||
for (u8 i = 0; i < 10; i++) {
|
for (u8 i = 0; i < 10; i++) {
|
||||||
reading += ADC_GetConversionValue(ADC2);
|
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
|
return reading; //return the read voltage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void setup() {
|
|||||||
readIronTemp(systemSettings.tempCalibration, 0,0); //load the default calibration value
|
readIronTemp(systemSettings.tempCalibration, 0,0); //load the default calibration value
|
||||||
Init_Oled(systemSettings.flipDisplay); //Init the OLED display
|
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
|
delayMs(800); //Pause to show version number
|
||||||
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
|
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Author: Ralim <ralim@ralimtek.com>
|
* Author: Ralim <ralim@ralimtek.com>
|
||||||
*/
|
*/
|
||||||
#include "Modes.h"
|
#include "Modes.h"
|
||||||
uint8_t tempCalStatus = 0;
|
uint8_t CalStatus = 0;
|
||||||
//This does the required processing and state changes
|
//This does the required processing and state changes
|
||||||
void ProcessUI() {
|
void ProcessUI() {
|
||||||
uint8_t Buttons = getButtons(); //read the buttons status
|
uint8_t Buttons = getButtons(); //read the buttons status
|
||||||
@@ -51,7 +51,7 @@ void ProcessUI() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint16_t voltage = readDCVoltage(); //get X10 voltage
|
uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //get X10 voltage
|
||||||
if ((voltage / 10) < systemSettings.cutoutVoltage) {
|
if ((voltage / 10) < systemSettings.cutoutVoltage) {
|
||||||
operatingMode = UVLOWARN;
|
operatingMode = UVLOWARN;
|
||||||
lastModeChange = millis();
|
lastModeChange = millis();
|
||||||
@@ -180,9 +180,10 @@ void ProcessUI() {
|
|||||||
|
|
||||||
if (Buttons == BUT_A) {
|
if (Buttons == BUT_A) {
|
||||||
//Single button press, cycle over to the DC display
|
//Single button press, cycle over to the DC display
|
||||||
|
CalStatus = 0;
|
||||||
operatingMode = DCINDISP;
|
operatingMode = DCINDISP;
|
||||||
} else if (Buttons == BUT_B) {
|
} else if (Buttons == BUT_B) {
|
||||||
tempCalStatus = 0;
|
CalStatus = 0;
|
||||||
operatingMode = TEMPCAL;
|
operatingMode = TEMPCAL;
|
||||||
} else if (Buttons == (BUT_A | BUT_B)) {
|
} else if (Buttons == (BUT_A | BUT_B)) {
|
||||||
//If the user is holding both button, exit the screen
|
//If the user is holding both button, exit the screen
|
||||||
@@ -193,13 +194,37 @@ void ProcessUI() {
|
|||||||
break;
|
break;
|
||||||
case DCINDISP: {
|
case DCINDISP: {
|
||||||
//This lets the user check the input voltage
|
//This lets the user check the input voltage
|
||||||
|
if (CalStatus == 0) {
|
||||||
if (Buttons == BUT_A) {
|
if (Buttons == BUT_A) {
|
||||||
//Single button press, cycle over to the temp display
|
//Single button press, cycle over to the temp display
|
||||||
operatingMode = THERMOMETER;
|
operatingMode = THERMOMETER;
|
||||||
} else if (Buttons == (BUT_A | BUT_B)) {
|
} else if (Buttons == BUT_B) {
|
||||||
//If the user is holding both button, exit the screen
|
//dc cal mode
|
||||||
operatingMode = STARTUP;
|
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;
|
operatingMode = THERMOMETER;
|
||||||
} else if (Buttons == BUT_A) {
|
} else if (Buttons == BUT_A) {
|
||||||
//Try and calibrate
|
//Try and calibrate
|
||||||
if (tempCalStatus == 0) {
|
if (CalStatus == 0) {
|
||||||
if ((readTipTemp() < 300) && (readSensorTemp() < 300)) {
|
if ((readTipTemp() < 300) && (readSensorTemp() < 300)) {
|
||||||
tempCalStatus = 1;
|
CalStatus = 1;
|
||||||
systemSettings.tempCalibration = readTipTemp();
|
systemSettings.tempCalibration = readTipTemp();
|
||||||
saveSettings();
|
saveSettings();
|
||||||
} else {
|
} else {
|
||||||
tempCalStatus = 2;
|
CalStatus = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Buttons == (BUT_A | BUT_B)) {
|
} else if (Buttons == (BUT_A | BUT_B)) {
|
||||||
@@ -237,7 +262,7 @@ void drawTemp(uint16_t temp, uint8_t x) {
|
|||||||
if (systemSettings.displayTempInF)
|
if (systemSettings.displayTempInF)
|
||||||
temp = (temp * 9 + 1600) / 5;/*Convert to F -> T*(9/5)+32*/
|
temp = (temp * 9 + 1600) / 5;/*Convert to F -> T*(9/5)+32*/
|
||||||
if (temp % 10 > 5)
|
if (temp % 10 > 5)
|
||||||
temp += 10;//round up
|
temp += 10; //round up
|
||||||
OLED_DrawThreeNumber(temp / 10, x);
|
OLED_DrawThreeNumber(temp / 10, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,26 +395,30 @@ void DrawUI() {
|
|||||||
drawTemp(temp, 5);
|
drawTemp(temp, 5);
|
||||||
break;
|
break;
|
||||||
case DCINDISP: {
|
case DCINDISP: {
|
||||||
uint16_t voltage = readDCVoltage(); //get X10 voltage
|
uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //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);
|
|
||||||
|
|
||||||
|
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;
|
break;
|
||||||
case TEMPCAL: {
|
case TEMPCAL: {
|
||||||
|
|
||||||
if (tempCalStatus == 0) {
|
if (CalStatus == 0) {
|
||||||
OLED_DrawString("CAL TEMP", 8);
|
OLED_DrawString("CAL TEMP", 8);
|
||||||
} else if (tempCalStatus == 1) {
|
} else if (CalStatus == 1) {
|
||||||
OLED_DrawString("CAL OK ", 8);
|
OLED_DrawString("CAL OK ", 8);
|
||||||
} else if (tempCalStatus == 2) {
|
} else if (CalStatus == 2) {
|
||||||
OLED_DrawString("CAL FAIL", 8);
|
OLED_DrawString("CAL FAIL", 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,6 @@ void resetSettings() {
|
|||||||
systemSettings.flipDisplay=0; //Default to right handed mode
|
systemSettings.flipDisplay=0; //Default to right handed mode
|
||||||
systemSettings.sensitivity=0x00; //Default high sensitivity
|
systemSettings.sensitivity=0x00; //Default high sensitivity
|
||||||
systemSettings.tempCalibration=239; //Default to their calibration value
|
systemSettings.tempCalibration=239; //Default to their calibration value
|
||||||
|
systemSettings.voltageDiv=144; //Default divider from schematic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user