From 82a5ed042da274d62484445ddac4011e2b552979 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 27 Sep 2017 11:29:16 +1000 Subject: [PATCH] Add new font glyphs, fix sceen rotation on soldering mode. --- workspace/TS100/inc/hardware.h | 1 + workspace/TS100/src/hardware.c | 4 ++ workspace/TS100/src/main.cpp | 95 +++++++++++++++++++++++++--------- workspace/ts100/inc/Font.h | 35 ++++++------- 4 files changed, 92 insertions(+), 43 deletions(-) diff --git a/workspace/TS100/inc/hardware.h b/workspace/TS100/inc/hardware.h index 3ee860f3..7cc9e5ee 100644 --- a/workspace/TS100/inc/hardware.h +++ b/workspace/TS100/inc/hardware.h @@ -42,6 +42,7 @@ uint16_t getHandleTemperature(); uint16_t getTipRawTemp(uint8_t instant); uint16_t getInputVoltageX10(); uint16_t getTipInstantTemperature(); +uint8_t getTipPWM(); void setTipPWM(uint8_t pulse); uint16_t ctoTipMeasurement(uint16_t temp); uint16_t tipMeasurementToC(uint16_t raw); diff --git a/workspace/TS100/src/hardware.c b/workspace/TS100/src/hardware.c index e504eac0..ad695777 100644 --- a/workspace/TS100/src/hardware.c +++ b/workspace/TS100/src/hardware.c @@ -83,6 +83,10 @@ uint16_t getInputVoltageX10() { //Ideal term is 57.69.... 58 is quite close return getADC(1) / 58; } +uint8_t getTipPWM() +{ + return htim2.Instance->CCR4; +} void setTipPWM(uint8_t pulse) { PWMSafetyTimer = 100; //This is decremented in the handler for PWM so that the tip pwm is disabled if the PID task is not scheduled often enough. if (pulse > 100) diff --git a/workspace/TS100/src/main.cpp b/workspace/TS100/src/main.cpp index 8016c494..61e328a8 100644 --- a/workspace/TS100/src/main.cpp +++ b/workspace/TS100/src/main.cpp @@ -447,31 +447,78 @@ static void gui_solderingMode() { waitForButtonPress(); return; } else { - lcd.printNumber(tipMeasurementToC(tipTemp), 3); - lcd.drawSymbol(1); - if (boostModeOn) - lcd.drawSymbol(2); - //6 gap - lcd.drawChar(' '); - //7 battery - 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 = getInputVoltageX10() / 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 - if (cellV > 9) - cellV = 9; - lcd.drawBattery(cellV + 1); - } - //8 ^V indicators + //We switch the layout direction depending on the orientation of the lcd. + if (lcd.getRotation()) { + // battery + 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 = getInputVoltageX10() / 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 + if (cellV > 9) + cellV = 9; + lcd.drawBattery(cellV + 1); + } else + lcd.drawChar(' '); //print a blank spot if there is no battery symbol + lcd.drawChar(' '); // Space out gap between battery <-> temp + + lcd.printNumber(tipMeasurementToC(tipTemp), 3); //Draw current tip temp + lcd.drawSymbol(1); //deg C + + //We draw boost arrow if boosting, or else gap temp <-> heat indicator + if (boostModeOn) + lcd.drawSymbol(2); + else + lcd.drawChar(' '); + + // Draw heating/cooling symbols + //If tip PWM > 25% then we are 'heating' + if (getTipPWM() > 25) + lcd.drawSymbol(14); + else + lcd.drawSymbol(15); + } else { + + // Draw heating/cooling symbols + //If tip PWM > 25% then we are 'heating' + if (getTipPWM() > 25) + lcd.drawSymbol(14); + else + lcd.drawSymbol(15); + //We draw boost arrow if boosting, or else gap temp <-> heat indicator + if (boostModeOn) + lcd.drawSymbol(2); + else + lcd.drawChar(' '); + + lcd.printNumber(tipMeasurementToC(tipTemp), 3); //Draw current tip temp + lcd.drawSymbol(1); //deg C + + lcd.drawChar(' '); // Space out gap between battery <-> temp + + 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 = getInputVoltageX10() / 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 + if (cellV > 9) + cellV = 9; + lcd.drawBattery(cellV + 1); + } else + lcd.drawChar(' '); //print a blank spot if there is no battery symbol + } } - // Draw heating/cooling symbols //Update the setpoints for the temperature if (boostModeOn) @@ -548,7 +595,7 @@ void startGUITask(void const * argument) { //Do nothing break; case BUTTON_BOTH: - //pressing both is ignored for now + //Not used yet break; //Long presses are ignored for now case BUTTON_B_LONG: diff --git a/workspace/ts100/inc/Font.h b/workspace/ts100/inc/Font.h index 21bba601..6f48af5d 100644 --- a/workspace/ts100/inc/Font.h +++ b/workspace/ts100/inc/Font.h @@ -217,30 +217,27 @@ const uint8_t FONT_12[]={ }; const uint8_t ExtraFontChars[] = { - 0x00,0x0C,0x12,0x12,0x0C,0x00,0xF8,0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x01,0x01,0x01,0x00,0x00,//Degrees F - 0x00,0x0C,0x12,0x12,0x0C,0xE0,0x10,0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x08,0x08,0x08,0x08,0x00,// Degrees C - 0x00,0x00,0x00,0x10,0x18,0x1C,0xFE,0x1C,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,//UP arrow - 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,0x18,0x24,0x24,0x18,0xC0,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x02,0x02,0x02,0x00,0x00,0x00,// Degrees F + 0x00,0x18,0x24,0x24,0x18,0x80,0x40,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x10,0x10,0x10,0x00,0x00,// Degrees C + 0x00,0x00,0x20,0x30,0x38,0xFC,0xFE,0xFC,0x38,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x00,0x00,0x00,0x00,// UP arrow - 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,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x3F,0x00,/*Battery Empty*/ + 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x50,0x50,0x50,0x50,0x50,0x50,0x40,0x3F,0x00,/*Battery 1*/ + 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x58,0x58,0x58,0x58,0x58,0x58,0x40,0x3F,0x00,/*Battery 2*/ + 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5C,0x5C,0x5C,0x5C,0x5C,0x5C,0x40,0x3F,0x00,/*Battery 3*/ + 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5E,0x5E,0x5E,0x5E,0x5E,0x5E,0x40,0x3F,0x00,/*Battery 4*/ + 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00,/*Battery 5*/ + 0x00,0xF0,0x08,0x8E,0x82,0x82,0x82,0x82,0x8E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00,/*Battery 6*/ + 0x00,0xF0,0x08,0xCE,0xC2,0xC2,0xC2,0xC2,0xCE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00,/*Battery 7*/ + 0x00,0xF0,0x08,0xEE,0xE2,0xE2,0xE2,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00,/*Battery 8*/ + 0x00,0xF0,0x08,0xEE,0xE2,0xF2,0xF2,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00,/*Battery 9*/ + 0x00,0xF0,0x08,0xEE,0xE2,0xFA,0xFA,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00,/*Battery 10*/ - 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,0x38,0xC4,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x00,0x00,0x38,0x3A,0x39,0x38,0x3A,0x39,0x38,0x3A,0x39,0x10,0x10, // heating + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x10,0x10, // cooling - 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*/ /* 0x00,0x00,0x00,0x80,0x80,0xFE,0xFF,0x83,0x87,0x06,0x00,0x00,0x00,0x00,0x30,0x70,0x60,0x7F,0x3F,0x00,0x00,0x00,0x00,0x00,//Function? 0x00,0x70,0xFA,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xFF,0xFE,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,//a_