From 56f31b02aaa4f22c5fade20a3e5e605776eb7c5c Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 26 Jul 2017 09:18:07 +1000 Subject: [PATCH] pre-work for power display --- workspace/ts100/.cproject | 5 +++-- workspace/ts100/src/Modes.c | 26 ++++++++++++++++---------- workspace/ts100/src/Oled.c | 11 ++++++++--- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/workspace/ts100/.cproject b/workspace/ts100/.cproject index f4bbcc93..3d0feb76 100644 --- a/workspace/ts100/.cproject +++ b/workspace/ts100/.cproject @@ -28,7 +28,7 @@ diff --git a/workspace/ts100/src/Modes.c b/workspace/ts100/src/Modes.c index 52acdfa7..6b6ebac6 100644 --- a/workspace/ts100/src/Modes.c +++ b/workspace/ts100/src/Modes.c @@ -463,17 +463,23 @@ void DrawUI() { OLED_DrawChar('C', 3); } //Optionally draw the arrows, or draw the power instead - OLED_BlankSlot(6 * 12 + 16, 24 - 16);//blank out the tail after the arrows - if (getIronTimer() == 0 - && (temp / 10) > (systemSettings.SolderingTemp / 10)) { - //Cooling - OLED_DrawSymbol(6, 5); + if (systemSettings.powerDisplay) { + //We want to draw in a neat little bar graph of power being pushed to the tip + Oled_DrawArea(6 * 12, 0, 12, 8, 0); } else { - if (getIronTimer() < 1500) { - //Maintaining - OLED_DrawSymbol(6, 7); - } else { //we are heating - OLED_DrawSymbol(6, 6); + //Draw in the arrows if the user has the power display turned off + OLED_BlankSlot(6 * 12 + 16, 24 - 16);//blank out the tail after the arrows + if (getIronTimer() == 0 + && (temp / 10) > (systemSettings.SolderingTemp / 10)) { + //Cooling + OLED_DrawSymbol(6, 5); + } else { + if (getIronTimer() < 1500) { + //Maintaining + OLED_DrawSymbol(6, 7); + } else { //we are heating + OLED_DrawSymbol(6, 6); + } } } diff --git a/workspace/ts100/src/Oled.c b/workspace/ts100/src/Oled.c index abbb7c01..fb1d98d5 100644 --- a/workspace/ts100/src/Oled.c +++ b/workspace/ts100/src/Oled.c @@ -77,14 +77,19 @@ void Oled_DisplayFlip() { Input: number of bytes to write, array to write Output: */ -const u8* Data_Command(u8 length,const 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 tx_data[0] = 0x40; length++; for (i = 1; i < length; i++) //Loop through the array of data - tx_data[i] = *data++; + { + if (data == 0) + tx_data[i] = 0; + else + tx_data[i] = *data++; + } I2C_PageWrite(tx_data, length, DEVICEADDR_OLED); //write out the buffer return data; } @@ -107,7 +112,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 *******************************************************************************/ -const u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high,const u8* ptr) { +const u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, const u8* ptr) { u8 m, n, y; n = y0 + high;