Updating cutoff voltage to DC/3.5V*cell count
Working on progress for: #29 #30
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
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 readIronTemp(uint16_t calibration_temp, uint8_t read,
|
||||
uint16_t setPointTemp); //read the iron temp in C X10
|
||||
uint16_t readDCVoltage(uint16_t divFactor);/*Get the system voltage X10*/
|
||||
int16_t readTipTemp();
|
||||
int readSensorTemp(void);
|
||||
#endif /* ANALOG_H_ */
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "PID.h"
|
||||
#include "Settings.h"
|
||||
#include "Analog.h"
|
||||
#include <string.h>
|
||||
enum {
|
||||
STARTUP, //we are sitting on the prompt to push a button
|
||||
SOLDERING, //Normal operating mode
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define SETTINGS_H_
|
||||
#include <stdint.h>
|
||||
#include "stm32f10x_flash.h"
|
||||
#define SETTINGSVERSION 12 /*Change this if you change the struct below to prevent people getting out of sync*/
|
||||
#define SETTINGSVERSION 13 /*Change this if you change the struct below to prevent people getting out of sync*/
|
||||
//Display Speeds
|
||||
#define DISPLAYMODE_FAST (0x00)
|
||||
#define DISPLAYMODE_MEDIUM (0x01)
|
||||
@@ -29,7 +29,7 @@ struct {
|
||||
uint32_t SleepTemp; //temp to drop to in sleep
|
||||
uint8_t version; //Used to track if a reset is needed on firmware upgrade
|
||||
uint8_t SleepTime; //minutes timeout to sleep
|
||||
uint8_t cutoutVoltage:5; //The voltage we cut out at for under voltage
|
||||
uint8_t cutoutSetting:5; //(3 bits) The voltage we cut out at for under voltage
|
||||
uint8_t displayTempInF:1; //If we need to convert the C reading to F
|
||||
uint8_t flipDisplay:1; //If true we want to invert the display for lefties
|
||||
uint8_t sensitivity:6; //Sensitivity of accelerometer (5 bits)
|
||||
@@ -44,5 +44,6 @@ struct {
|
||||
|
||||
void saveSettings();
|
||||
void restoreSettings();
|
||||
uint8_t lookupVoltageLevel(uint8_t level);
|
||||
void resetSettings();
|
||||
#endif /* SETTINGS_H_ */
|
||||
|
||||
@@ -34,14 +34,12 @@ void setup() {
|
||||
I2C_Configuration(); //Start the I2C hardware
|
||||
GPIO_Init_OLED(); //Init the GPIO ports for the OLED
|
||||
restoreSettings(); //Load settings
|
||||
|
||||
StartUp_Accelerometer(systemSettings.sensitivity); //start the accelerometer
|
||||
|
||||
StartUp_Accelerometer(systemSettings.sensitivity); //Start the accelerometer
|
||||
setupPID(); //Init the PID values
|
||||
readIronTemp(systemSettings.tempCalibration, 0,0); //load the default calibration value
|
||||
Init_Oled(systemSettings.flipDisplay); //Init the OLED display
|
||||
|
||||
OLED_DrawString("VER 1.13", 8); //Version Number
|
||||
OLED_DrawString("VER 1.14", 8); //Version Number
|
||||
delayMs(500); //Pause to show version number
|
||||
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
* Author: Ralim <ralim@ralimtek.com>
|
||||
*/
|
||||
#include "Modes.h"
|
||||
const char *SettingsLongNames[] = { " Undervoltage Cutout <V>",
|
||||
const char *SettingsLongNames[] = {
|
||||
" Power source. Sets cutoff voltage. <DC 10V> <S 3.5V per cell>",
|
||||
" Sleep Temperature <C>", " Sleep Timeout <Minutes>",
|
||||
" Shutdown Timeout <Minutes>",
|
||||
" Motion Sensitivity <0.Off 1.least sensitive 9.most sensitive>",
|
||||
@@ -14,8 +15,6 @@ const char *SettingsLongNames[] = { " Undervoltage Cutout <V>",
|
||||
" Flip Display for Left Hand",
|
||||
" Enable front key boost 450C mode when soldering",
|
||||
" Temperature when in boost mode" };
|
||||
const uint8_t SettingsLongNamesLengths[] = { 29, 27, 29, 32, 67, 22, 33, 37, 32,
|
||||
53, 36 };
|
||||
uint8_t StatusFlags = 0;
|
||||
uint32_t temporaryTempStorage = 0;
|
||||
//This does the required processing and state changes
|
||||
@@ -95,7 +94,7 @@ void ProcessUI() {
|
||||
}
|
||||
}
|
||||
uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //get X10 voltage
|
||||
if ((voltage / 10) < systemSettings.cutoutVoltage) {
|
||||
if ((voltage) < lookupVoltageLevel(systemSettings.cutoutSetting)) {
|
||||
operatingMode = UVLOWARN;
|
||||
lastModeChange = millis();
|
||||
}
|
||||
@@ -147,9 +146,8 @@ void ProcessUI() {
|
||||
switch (settingsPage) {
|
||||
case UVCO:
|
||||
//we are incrementing the cutout voltage
|
||||
systemSettings.cutoutVoltage += 1; //Go up 1V at a jump
|
||||
if (systemSettings.cutoutVoltage > 24)
|
||||
systemSettings.cutoutVoltage = 10;
|
||||
systemSettings.cutoutSetting += 1; //Go up 1V at a jump
|
||||
systemSettings.cutoutSetting %= 5; //wrap 0->4
|
||||
break;
|
||||
case SLEEP_TEMP:
|
||||
systemSettings.SleepTemp += 100; //Go up 10C at a time
|
||||
@@ -455,7 +453,7 @@ void DrawUI() {
|
||||
StatusFlags = 4;
|
||||
//If the user has idled for > 3 seconds, show the long name for the selected setting instead
|
||||
//draw from settingsLongTestScrollPos through to end of screen
|
||||
uint8_t lengthLeft = SettingsLongNamesLengths[settingsPage]
|
||||
uint8_t lengthLeft = strlen(SettingsLongNames[settingsPage])
|
||||
- settingsLongTestScrollPos;
|
||||
if (lengthLeft < 1)
|
||||
settingsLongTestScrollPos = 0;
|
||||
@@ -476,9 +474,16 @@ void DrawUI() {
|
||||
settingsLongTestScrollPos = 0;
|
||||
switch (settingsPage) {
|
||||
case UVCO:
|
||||
OLED_DrawString("UVCO ", 5);
|
||||
OLED_DrawTwoNumber(systemSettings.cutoutVoltage, 5);
|
||||
OLED_DrawChar('V', 7);
|
||||
OLED_DrawString("PWRSC ", 6);
|
||||
if (systemSettings.cutoutSetting == 0) {
|
||||
//DC
|
||||
OLED_DrawChar('D', 6);
|
||||
OLED_DrawChar('C', 7);
|
||||
} else {
|
||||
//S count
|
||||
OLED_DrawChar('2' + systemSettings.cutoutSetting, 6);
|
||||
OLED_DrawChar('S', 7);
|
||||
}
|
||||
break;
|
||||
case SLEEP_TEMP:
|
||||
OLED_DrawString("STMP ", 5);
|
||||
|
||||
@@ -38,23 +38,36 @@ void restoreSettings() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Lookup function for cutoff setting -> X10 voltage
|
||||
/*
|
||||
* 0=DC
|
||||
* 1=3S
|
||||
* 2=4S
|
||||
* 3=5S
|
||||
* 4=6S
|
||||
*/
|
||||
uint8_t lookupVoltageLevel(uint8_t level) {
|
||||
if (level == 0)
|
||||
return 100; //10V since iron does not function below this
|
||||
else
|
||||
return (level * 35) + (35 * 2);
|
||||
}
|
||||
void resetSettings() {
|
||||
|
||||
systemSettings.SleepTemp = 1500; //Temperature the iron sleeps at - default 150.0 C
|
||||
systemSettings.SleepTime = 1; //How many minutes we wait until going to sleep - default 1 min
|
||||
systemSettings.SolderingTemp = 3200; //Default soldering temp is 320.0 C
|
||||
systemSettings.cutoutVoltage = 10; //10V is the minium cutout voltage as the unit V measurement is unstable below 9.5V
|
||||
systemSettings.version = SETTINGSVERSION; //Store the version number to allow for easier upgrades
|
||||
systemSettings.displayTempInF =0; //default to C
|
||||
systemSettings.flipDisplay=0; //Default to right handed mode
|
||||
systemSettings.sensitivity=6; //Default high sensitivity
|
||||
systemSettings.tempCalibration=239; //Default to their calibration value
|
||||
systemSettings.voltageDiv=144; //Default divider from schematic
|
||||
systemSettings.ShutdownTime=30; //How many minutes until the unit turns itself off
|
||||
systemSettings.displayUpdateSpeed=1; //How fast the LCD updates
|
||||
systemSettings.temperatureRounding=0; //How the temperature is rounded off
|
||||
systemSettings.boostModeEnabled=0; //Default to safe, with no boost mode
|
||||
systemSettings.BoostTemp=4000; //default to 400C
|
||||
systemSettings.SleepTemp = 1500;//Temperature the iron sleeps at - default 150.0 C
|
||||
systemSettings.SleepTime = 1;//How many minutes we wait until going to sleep - default 1 min
|
||||
systemSettings.SolderingTemp = 3200; //Default soldering temp is 320.0 C
|
||||
systemSettings.cutoutSetting = 0; //default to no cut-off voltage
|
||||
systemSettings.version = SETTINGSVERSION;//Store the version number to allow for easier upgrades
|
||||
systemSettings.displayTempInF = 0; //default to C
|
||||
systemSettings.flipDisplay = 0; //Default to right handed mode
|
||||
systemSettings.sensitivity = 6; //Default high sensitivity
|
||||
systemSettings.tempCalibration = 239; //Default to their calibration value
|
||||
systemSettings.voltageDiv = 144; //Default divider from schematic
|
||||
systemSettings.ShutdownTime = 30;//How many minutes until the unit turns itself off
|
||||
systemSettings.displayUpdateSpeed = 1; //How fast the LCD updates
|
||||
systemSettings.temperatureRounding = 0; //How the temperature is rounded off
|
||||
systemSettings.boostModeEnabled = 0;//Default to safe, with no boost mode
|
||||
systemSettings.BoostTemp = 4000; //default to 400C
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user