Add showing the tip temp on idle (#226)
This shows the tip temp on the simple home screen if the temp is > 50C. This removes the tip temp warning for all users, as now everyone can see the tip temp. #187
This commit is contained in:
@@ -29,14 +29,14 @@ public:
|
|||||||
OLED(FRToSI2C* i2cHandle); // Initialize Driver and store I2C pointer
|
OLED(FRToSI2C* i2cHandle); // Initialize Driver and store I2C pointer
|
||||||
void initialize(); // Startup the I2C coms (brings screen out of reset etc)
|
void initialize(); // Startup the I2C coms (brings screen out of reset etc)
|
||||||
void refresh(); // Draw the buffer out to the LCD using the DMA Channel
|
void refresh(); // Draw the buffer out to the LCD using the DMA Channel
|
||||||
void drawChar(char c, char preCursorCommand = '\0');// Draw a character to a specific location
|
void drawChar(char c, char preCursorCommand = '\0'); // Draw a character to a specific location
|
||||||
void displayOnOff(bool on); // Turn the screen on or not
|
void displayOnOff(bool on); // Turn the screen on or not
|
||||||
void setRotation(bool leftHanded); // Set the rotation for the screen
|
void setRotation(bool leftHanded); // Set the rotation for the screen
|
||||||
bool getRotation(); // Get the current rotation of the LCD
|
bool getRotation(); // Get the current rotation of the LCD
|
||||||
void print(const char* string); // Draw a string to the current location, with current font
|
void print(const char* string); // Draw a string to the current location, with current font
|
||||||
void setCursor(int16_t x, int16_t y); // Set the cursor location by pixels
|
void setCursor(int16_t x, int16_t y); // Set the cursor location by pixels
|
||||||
void setCharCursor(int16_t x, int16_t y); //Set cursor location by chars in current font
|
void setCharCursor(int16_t x, int16_t y); //Set cursor location by chars in current font
|
||||||
void setFont(uint8_t fontNumber);// (Future) Set the font that is being used
|
void setFont(uint8_t fontNumber); // (Future) Set the font that is being used
|
||||||
void drawImage(const uint8_t* buffer, uint8_t x, uint8_t width);
|
void drawImage(const uint8_t* buffer, uint8_t x, uint8_t width);
|
||||||
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
|
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
|
||||||
void printNumber(uint16_t number, uint8_t places);
|
void printNumber(uint16_t number, uint8_t places);
|
||||||
@@ -47,13 +47,15 @@ public:
|
|||||||
void drawSymbol(uint8_t symbolID);//Used for drawing symbols of a predictable width
|
void drawSymbol(uint8_t symbolID);//Used for drawing symbols of a predictable width
|
||||||
void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||||
const uint8_t* ptr);
|
const uint8_t* ptr);
|
||||||
|
void fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||||
|
const uint8_t value);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//Draw a buffer to the screen buffer
|
//Draw a buffer to the screen buffer
|
||||||
|
|
||||||
FRToSI2C* i2c; //i2c Pointer
|
FRToSI2C* i2c; //i2c Pointer
|
||||||
const uint8_t* currentFont; // Pointer to the current font used for rendering to the buffer
|
const uint8_t* currentFont; // Pointer to the current font used for rendering to the buffer
|
||||||
uint8_t screenBuffer[12 + 96 + 96 + 10]; // The data buffer
|
uint8_t screenBuffer[14 + 96 + 96 + 10]; // The data buffer
|
||||||
uint8_t* firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
uint8_t* firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
||||||
uint8_t* secondStripPtr; //Pointers to the strips
|
uint8_t* secondStripPtr; //Pointers to the strips
|
||||||
bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
|
bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ OLED::OLED(FRToSI2C* i2cHandle) {
|
|||||||
currentFont = FONT_12;
|
currentFont = FONT_12;
|
||||||
fontWidth = 12;
|
fontWidth = 12;
|
||||||
inLeftHandedMode = false;
|
inLeftHandedMode = false;
|
||||||
firstStripPtr = &screenBuffer[13];
|
firstStripPtr = &screenBuffer[15];
|
||||||
secondStripPtr = &screenBuffer[13 + 96];
|
secondStripPtr = &screenBuffer[15 + 96];
|
||||||
fontHeight = 16;
|
fontHeight = 16;
|
||||||
fontWidth = 12;
|
fontWidth = 12;
|
||||||
displayOffset = 0;
|
displayOffset = 0;
|
||||||
@@ -77,17 +77,17 @@ void OLED::refresh() {
|
|||||||
screenBuffer[3] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide
|
screenBuffer[3] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide
|
||||||
screenBuffer[4] = 0x80;
|
screenBuffer[4] = 0x80;
|
||||||
screenBuffer[5] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide)
|
screenBuffer[5] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide)
|
||||||
|
screenBuffer[6] = 0x80; /*Set COM Scan direction*/
|
||||||
screenBuffer[6] = 0x80; //Set pages to rollover after 2
|
screenBuffer[7] = inLeftHandedMode ? 0xC8 : 0xC0;
|
||||||
screenBuffer[7] = 0x22;
|
screenBuffer[8] = 0x80; //Set pages to rollover after 2
|
||||||
screenBuffer[8] = 0x80;
|
screenBuffer[9] = 0x22;
|
||||||
screenBuffer[9] = 0x00; //start page 0
|
|
||||||
screenBuffer[10] = 0x80;
|
screenBuffer[10] = 0x80;
|
||||||
screenBuffer[11] = 0x01;
|
screenBuffer[11] = 0x00; //start page 0
|
||||||
|
screenBuffer[12] = 0x80;
|
||||||
screenBuffer[12] = 0x40; //start of data marker
|
screenBuffer[13] = 0x01;
|
||||||
|
screenBuffer[14] = 0x40; //start of data marker
|
||||||
i2c->Transmit( DEVICEADDR_OLED, screenBuffer, 12 + 96 * 2 + 1);
|
|
||||||
|
i2c->Transmit( DEVICEADDR_OLED, screenBuffer, 12 + 96 * 2 + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,3 +308,35 @@ void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void OLED::fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||||
|
const uint8_t value) {
|
||||||
|
// Splat this from x->x+wide in two strides
|
||||||
|
if (x <= -wide)
|
||||||
|
return; //cutoffleft
|
||||||
|
if (x > 96)
|
||||||
|
return; //cutoff right
|
||||||
|
|
||||||
|
uint8_t visibleStart = 0;
|
||||||
|
uint8_t visibleEnd = wide;
|
||||||
|
|
||||||
|
// trimming to draw partials
|
||||||
|
if (x < 0) {
|
||||||
|
visibleStart -= x; //subtract negative value == add absolute value
|
||||||
|
}
|
||||||
|
if (x + wide > 96) {
|
||||||
|
visibleEnd = 96 - x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y == 0) {
|
||||||
|
//Splat first line of data
|
||||||
|
for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) {
|
||||||
|
firstStripPtr[xx + x] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (y == 8 || height == 16) {
|
||||||
|
// Splat the second line
|
||||||
|
for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) {
|
||||||
|
secondStripPtr[x + xx] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -665,8 +665,10 @@ void startGUITask(void const *argument) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t animationStep = 0;
|
uint8_t animationStep = 0;
|
||||||
|
|
||||||
uint8_t tempWarningState = 0;
|
uint8_t tempWarningState = 0;
|
||||||
bool buttonLockout = false;
|
bool buttonLockout = false;
|
||||||
|
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
switch (systemSettings.OrientationMode) {
|
switch (systemSettings.OrientationMode) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -710,12 +712,14 @@ void startGUITask(void const *argument) {
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ButtonState buttons = getButtonState();
|
ButtonState buttons = getButtonState();
|
||||||
|
|
||||||
if (tempWarningState == 2)
|
if (tempWarningState == 2)
|
||||||
buttons = BUTTON_F_SHORT;
|
buttons = BUTTON_F_SHORT;
|
||||||
if (buttons != BUTTON_NONE && buttonLockout)
|
if (buttons != BUTTON_NONE && buttonLockout)
|
||||||
buttons = BUTTON_NONE;
|
buttons = BUTTON_NONE;
|
||||||
else
|
else
|
||||||
buttonLockout = false;
|
buttonLockout = false;
|
||||||
|
|
||||||
switch (buttons) {
|
switch (buttons) {
|
||||||
case BUTTON_NONE:
|
case BUTTON_NONE:
|
||||||
// Do nothing
|
// Do nothing
|
||||||
@@ -748,7 +752,7 @@ void startGUITask(void const *argument) {
|
|||||||
lcd.setFont(0);
|
lcd.setFont(0);
|
||||||
lcd.displayOnOff(true); // turn lcd on
|
lcd.displayOnOff(true); // turn lcd on
|
||||||
gui_solderingMode(); // enter soldering mode
|
gui_solderingMode(); // enter soldering mode
|
||||||
tempWarningState = 0; // make sure warning can show
|
|
||||||
break;
|
break;
|
||||||
case BUTTON_B_SHORT:
|
case BUTTON_B_SHORT:
|
||||||
lcd.setFont(0);
|
lcd.setFont(0);
|
||||||
@@ -782,17 +786,7 @@ void startGUITask(void const *argument) {
|
|||||||
|
|
||||||
if (tipTemp > 600)
|
if (tipTemp > 600)
|
||||||
tipTemp = 0;
|
tipTemp = 0;
|
||||||
if (tipTemp > 50) {
|
|
||||||
if (tempWarningState == 0) {
|
|
||||||
currentlyActiveTemperatureTarget = 0; // ensure tip is off
|
|
||||||
lcd.displayOnOff(true); // force LCD on
|
|
||||||
if (gui_showTipTempWarning() == 1) {
|
|
||||||
tempWarningState = 2; // we can re-enter the warning
|
|
||||||
} else
|
|
||||||
tempWarningState = 1;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
tempWarningState = 0;
|
|
||||||
// Clear the lcd buffer
|
// Clear the lcd buffer
|
||||||
lcd.clearScreen();
|
lcd.clearScreen();
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
@@ -825,10 +819,26 @@ void startGUITask(void const *argument) {
|
|||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
gui_drawBatteryIcon();
|
gui_drawBatteryIcon();
|
||||||
} else {
|
} else {
|
||||||
lcd.drawArea(0, 0, 84, 16, idleScreenBGF); // Needs to be flipped
|
lcd.drawArea(0, 0, 84, 16, idleScreenBGF); // Needs to be flipped so button ends up on right side of screen
|
||||||
lcd.setCursor(84, 0);
|
lcd.setCursor(84, 0);
|
||||||
gui_drawBatteryIcon();
|
gui_drawBatteryIcon();
|
||||||
}
|
}
|
||||||
|
if (tipTemp > 50) {
|
||||||
|
//draw temp over the start soldering button
|
||||||
|
//Location changes on screen rotation
|
||||||
|
if (lcd.getRotation()) {
|
||||||
|
// in right handed mode we want to draw over the first part
|
||||||
|
lcd.fillArea(55, 0, 41, 16, 0); //clear the area for the temp
|
||||||
|
lcd.setCursor(56, 0);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
lcd.fillArea(0, 0, 41, 16, 0); //clear the area
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
}
|
||||||
|
//draw in the temp
|
||||||
|
lcd.setFont(0); //big font
|
||||||
|
gui_drawTipTemp(); // draw in the temp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd.refresh();
|
lcd.refresh();
|
||||||
|
|||||||
Reference in New Issue
Block a user