Compare commits

..

4 Commits

Author SHA1 Message Date
Ben V. Brown
baa4979a96 V1.14 - Adds battery icon to cell selection
Relivant to #29 and #30
2017-07-22 12:20:36 +10:00
Ben V. Brown
2a5f4e6d89 Updating cutoff voltage to DC/3.5V*cell count
Working on progress for:
#29 #30
2017-07-22 11:19:23 +10:00
Ben V. Brown
c50b33e142 Small font reference 2017-07-22 10:54:47 +10:00
Ben V. Brown
c8f49d173a Add key auto-repeat 2017-07-12 22:18:13 +10:00
12 changed files with 138 additions and 55 deletions

BIN
BatteryIcon.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

BIN
sa-720x300.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -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_ */

View File

@@ -9,7 +9,9 @@
#ifndef FONT_H_
#define FONT_H_
/*
* Remember screen is LSB at the top, MSB at the bottom of the strip!
*/
#define FONT_WIDTH 12 /*How many pixels wide the font is*/
const uint8_t FONT[]={
0x00,0xF0,0xFC,0x0E,0x82,0xC2,0x62,0x1E,0xFC,0xF0,0x00,0x00,
@@ -95,8 +97,42 @@ const uint8_t FONT[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0F,0x0F,0x0F,0x0F,0x00,0x00,0x00,0x00,/*.*/
};
};
const uint8_t extendedFont[] = {
0x00,0x00,0xF8,0x08,0x0E,0x02,0x02,0x0E,0x08,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x40,0x40,0x40,0x40,0x40,0x40,0x7F,0x00,0x00,/*Battery Empty*/
0x00,0x00,0xF8,0x08,0x0E,0x02,0x02,0x0E,0x08,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x60,0x60,0x60,0x60,0x60,0x60,0x7F,0x00,0x00,/*Battery 1*/
0x00,0x00,0xF8,0x08,0x0E,0x02,0x02,0x0E,0x08,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x70,0x70,0x70,0x70,0x70,0x70,0x7F,0x00,0x00,/*Battery 2*/
0x00,0x00,0xF8,0x08,0x0E,0x02,0x02,0x0E,0x08,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x78,0x78,0x78,0x78,0x78,0x78,0x7F,0x00,0x00,/*Battery 3*/
0x00,0x00,0xF8,0x08,0x0E,0x02,0x02,0x0E,0x08,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7F,0x00,0x00,/*Battery 4*/
0x00,0x00,0xF8,0x08,0x0E,0x02,0x02,0x0E,0x08,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x7E,0x7E,0x7E,0x7E,0x7E,0x7E,0x7F,0x00,0x00,/*Battery 5*/
0x00,0x00,0xF8,0x08,0x0E,0x02,0x02,0x0E,0x08,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x00,0x00,/*Battery 6*/
0x00,0x00,0xF8,0x88,0x8E,0x82,0x82,0x8E,0x88,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x00,0x00,/*Battery 7*/
0x00,0x00,0xF8,0xC8,0xCE,0xC2,0xC2,0xCE,0xC8,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x00,0x00,/*Battery 8*/
0x00,0x00,0xF8,0xE8,0xEE,0xE2,0xE2,0xEE,0xE8,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x00,0x00,/*Battery 9*/
0x00,0x00,0xF8,0xF8,0xFE,0xF2,0xF2,0xFE,0xF8,0xF8,0x00,0x00,
0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x00,0x00,/*Battery 10*/
};
const uint8_t Iron_Base[] ={
0x00,0x20,0x60,0x60,0x60,0x60,0x60,0x60,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,

View File

@@ -26,9 +26,9 @@ inline void resetLastButtonPress() {
}
inline void resetButtons() {
lastKeyPress = millis();
keyState = 0;
}
inline uint32_t getLastMovement() {
return lastMovement;
}
@@ -39,7 +39,10 @@ inline uint16_t getButtons() {
inline uint16_t getRawButtons() {
return rawKeys;
}
inline void restoreButtons()
{
keyState=getRawButtons();
}
/*IRQ prototypes*/
void NMI_Handler(void);

View File

@@ -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

View File

@@ -14,16 +14,17 @@
void Oled_DisplayOn(void);
void Oled_DisplayOff(void);
u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, u8* ptr);
const u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high,const u8* ptr);
void Set_ShowPos(u8 x, u8 y);
void Oled_DisplayFlip();
void GPIO_Init_OLED(void);
void Init_Oled(uint8_t leftHanded);
u8* Data_Command(u8 len, u8* ptr);
const u8* Data_Command(u8 len,const u8* ptr);
void Clear_Screen(void);//Clear the screen
/*Functions for writing to the screen*/
void OLED_DrawString(const char* string, const uint8_t length);
void OLED_DrawChar(char c, uint8_t x);
void OLED_DrawExtendedChar(uint8_t id, uint8_t x);
void OLED_DrawTwoNumber(uint8_t in, uint8_t x);
void OLED_BlankSlot(uint8_t xStart,uint8_t width);
void OLED_DrawThreeNumber(uint16_t in, uint8_t x);

View File

@@ -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_ */

View File

@@ -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
}

View File

@@ -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.3V per cell>",
" Sleep Temperature <C>", " Sleep Timeout <Minutes>",
" Shutdown Timeout <Minutes>",
" Motion Sensitivity <0.Off 1.least sensitive 9.most sensitive>",
@@ -14,21 +15,20 @@ 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
void ProcessUI() {
uint8_t Buttons = getButtons(); //read the buttons status
static uint32_t lastModeChange = 0;
if (millis() - getLastButtonPress() < 30)
if (getRawButtons() && ((millis() - getLastButtonPress()) > 1000)) {
lastKeyPress = millis() - 600;
Buttons = getRawButtons();
} else if (millis() - getLastButtonPress() < 80) {
Buttons = 0;
else if (Buttons != 0) {
resetLastButtonPress();
} else if (Buttons != 0) {
resetButtons();
}
//rough prevention for de-bouncing and allocates settling time
switch (operatingMode) {
case STARTUP:
@@ -94,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();
}
@@ -146,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
@@ -158,7 +157,7 @@ void ProcessUI() {
case SLEEP_TIME:
++systemSettings.SleepTime; //Go up 1 minute at a time
if (systemSettings.SleepTime > 30)
systemSettings.SleepTime = 1;//cant set time over 30 mins
systemSettings.SleepTime = 1;//can't set time over 30 mins
//Remember that ^ is the time of no movement
break;
case SHUTDOWN_TIME:
@@ -412,12 +411,27 @@ void DrawUI() {
lastOLEDDrawTime = millis();
//Now draw symbols
if (StatusFlags == 8)
OLED_DrawChar('B', 3);
else
OLED_DrawChar(' ', 3);
OLED_DrawChar('B', 4);
else {
OLED_DrawChar(' ', 4);
}
//Draw in battery symbol if desired
if (systemSettings.cutoutSetting) {
//User is on a lithium battery
//we need to calculate which of the 10 levels they are on
uint8_t cellCount = systemSettings.cutoutSetting + 2;
uint16_t cellV = readDCVoltage(systemSettings.voltageDiv)
/ cellCount;
//Should give us approx cell voltage X10
//Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
if (cellV < 33)
cellV = 33;
cellV -= 33; //Should leave us a number of 0-9
OLED_DrawExtendedChar(cellV + 1, 5);
} else {
OLED_DrawChar(' ', 5);
}
OLED_BlankSlot(6 * 12 + 16, 24 - 16);//blank out the tail after the arrows
OLED_BlankSlot(4 * 12 + 16, 24 - 16);//blank out the tail after the temp
if (getIronTimer() == 0
&& (temp / 10) > (systemSettings.SolderingTemp / 10)) {
//Cooling
@@ -431,9 +445,9 @@ void DrawUI() {
}
}
if (systemSettings.displayTempInF) {
OLED_DrawSymbol(4, 1);
OLED_DrawChar('F', 3);
} else {
OLED_DrawSymbol(4, 0);
OLED_DrawChar('C', 3);
}
}
@@ -454,7 +468,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;
@@ -475,9 +489,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);

View File

@@ -77,7 +77,7 @@ void Oled_DisplayFlip() {
Input: number of bytes to write, array to write
Output:
*/
u8* Data_Command(u8 length, u8* data) {
const u8* Data_Command(u8 length,const u8* data) {
int i;
u8 tx_data[129];
//here are are inserting the data write command at the beginning
@@ -107,7 +107,7 @@ void Set_ShowPos(u8 x, u8 y) {
Inputs:(x,y) start point, (width,height) of enclosing rect, pointer to data
Output: pointer to the last byte written out
*******************************************************************************/
u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, u8* ptr) {
const u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high,const u8* ptr) {
u8 m, n, y;
n = y0 + high;
@@ -174,7 +174,7 @@ void Clear_Screen(void) {
/*
* Draws a string onto the screen starting at the left
*/
void OLED_DrawString(const char* string,const uint8_t length) {
void OLED_DrawString(const char* string, const uint8_t length) {
for (uint8_t i = 0; i < length; i++) {
OLED_DrawChar(string[i], i);
}
@@ -209,7 +209,13 @@ void OLED_DrawChar(char c, uint8_t x) {
Oled_DrawArea(x, 0, FONT_WIDTH, 16, (u8*) ptr);
}
void OLED_DrawExtendedChar(uint8_t id, uint8_t x) {
u8* ptr = (u8*) extendedFont;
ptr += (id) * (FONT_WIDTH * 2);
x *= FONT_WIDTH; //convert to a x coordinate
Oled_DrawArea(x, 0, FONT_WIDTH, 16, (u8*) ptr);
}
void OLED_BlankSlot(uint8_t xStart, uint8_t width) {
u8* ptr = (u8*) FONT;
ptr += (36) * (FONT_WIDTH * 2);

View File

@@ -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 * 33) + (33 * 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
}