From baa4979a9696f4055f3fbee1acf49bb64f3e6877 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 22 Jul 2017 12:20:36 +1000 Subject: [PATCH] V1.14 - Adds battery icon to cell selection Relivant to #29 and #30 --- BatteryIcon.bmp | Bin 0 -> 630 bytes workspace/ts100/inc/Font.h | 40 +++++++++++++++++++++++++++++++-- workspace/ts100/inc/Oled.h | 5 +++-- workspace/ts100/src/Modes.c | 33 +++++++++++++++++++-------- workspace/ts100/src/Oled.c | 12 +++++++--- workspace/ts100/src/Settings.c | 2 +- 6 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 BatteryIcon.bmp diff --git a/BatteryIcon.bmp b/BatteryIcon.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8a00f31afc80da3eb432a1d22cef22d61e34abea GIT binary patch literal 630 zcmZ?rEn{K;12Z700mM8&EC9re3=%++fx!VP59UA#pN&fY2?3y*7mJWJp|BykA?5%j z>M;ON5UvJd4u+C?WHms=gU1~8dXU@ky9cO-puebY4$w(J0CF7IdB|Ldd*D)N3 ", + " Power source. Sets cutoff voltage. ", " Sleep Temperature ", " Sleep Timeout ", " Shutdown Timeout ", " Motion Sensitivity <0.Off 1.least sensitive 9.most sensitive>", @@ -157,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: @@ -411,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 @@ -430,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); } } diff --git a/workspace/ts100/src/Oled.c b/workspace/ts100/src/Oled.c index c584a0d5..abbb7c01 100644 --- a/workspace/ts100/src/Oled.c +++ b/workspace/ts100/src/Oled.c @@ -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); diff --git a/workspace/ts100/src/Settings.c b/workspace/ts100/src/Settings.c index 38e7b008..d08bf121 100644 --- a/workspace/ts100/src/Settings.c +++ b/workspace/ts100/src/Settings.c @@ -50,7 +50,7 @@ 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); + return (level * 33) + (33 * 2); } void resetSettings() {