Display refresh an display color working

This commit is contained in:
norbert-walter 2022-02-16 22:06:36 +01:00
parent ae65a13775
commit 27a00e9913
6 changed files with 187 additions and 95 deletions

View File

@ -2,6 +2,7 @@
#include "OBP60Hardware.h" #include "OBP60Hardware.h"
#include "OBP60ExtensionPort.h" #include "OBP60ExtensionPort.h"
// Please dont forget to declarate the fonts in OBP60ExtensionPort.h
#include "Ubuntu_Bold8pt7b.h" #include "Ubuntu_Bold8pt7b.h"
#include "Ubuntu_Bold20pt7b.h" #include "Ubuntu_Bold20pt7b.h"
#include "Ubuntu_Bold32pt7b.h" #include "Ubuntu_Bold32pt7b.h"

View File

@ -8,10 +8,13 @@
#include <GxIO/GxIO_SPI/GxIO_SPI.h> // GxEPD lip for SPI display communikation #include <GxIO/GxIO_SPI/GxIO_SPI.h> // GxEPD lip for SPI display communikation
#include <GxIO/GxIO.h> // GxEPD lip for SPI #include <GxIO/GxIO.h> // GxEPD lip for SPI
// Extension port
void MCP23017Init(); void MCP23017Init();
// SPI pin definitions for E-Ink display // E-Ink display
extern GxEPD_Class display; extern GxEPD_Class display; // E-Ink display functions
// Fonts declarations for display
extern const GFXfont Ubuntu_Bold8pt7b; extern const GFXfont Ubuntu_Bold8pt7b;
extern const GFXfont Ubuntu_Bold20pt7b; extern const GFXfont Ubuntu_Bold20pt7b;
extern const GFXfont Ubuntu_Bold32pt7b; extern const GFXfont Ubuntu_Bold32pt7b;
@ -19,17 +22,17 @@ extern const GFXfont DSEG7Classic_BoldItalic16pt7b;
extern const GFXfont DSEG7Classic_BoldItalic42pt7b; extern const GFXfont DSEG7Classic_BoldItalic42pt7b;
extern const GFXfont DSEG7Classic_BoldItalic60pt7b; extern const GFXfont DSEG7Classic_BoldItalic60pt7b;
void setPortPin(uint pin, bool value); // Gloabl functions
void setPortPin(uint pin, bool value); // Set port pin for extension port
void togglePortPin(uint pin); void togglePortPin(uint pin); // Toggle extension port pin
void blinkingFlashLED(); void blinkingFlashLED(); // Blinking function for LED on extension port
void setBlinkingLED(bool on); // Set blinking LED active
void buzzer(uint frequency, uint duration); void buzzer(uint frequency, uint duration); // Buzzer function
void setBuzzerPower(uint power); void setBuzzerPower(uint power); // Set buzzer power
void underVoltageDetection(); void underVoltageDetection(); // Function for 12V undervoltage detection
void setBlinkingLED(bool on);
#endif #endif

View File

@ -4,7 +4,22 @@
#include <Arduino.h> #include <Arduino.h>
#include "qrcode.h" #include "qrcode.h"
void qrWiFi(String ssid, String passwd, bool refreshmode){ void qrWiFi(String ssid, String passwd, String displaycolor){
// Set display color
int textcolor = GxEPD_BLACK;
int pixelcolor = GxEPD_BLACK;
int bgcolor = GxEPD_WHITE;
if(displaycolor == "Normal"){
textcolor = GxEPD_BLACK;
pixelcolor = GxEPD_BLACK;
bgcolor = GxEPD_WHITE;
}
else{
textcolor = GxEPD_WHITE;
pixelcolor = GxEPD_WHITE;
bgcolor = GxEPD_BLACK;
}
// Set start point and pixel size // Set start point and pixel size
int16_t box_x = 100; // X offset int16_t box_x = 100; // X offset
int16_t box_y = 30; // Y offset int16_t box_y = 30; // Y offset
@ -24,9 +39,9 @@ void qrWiFi(String ssid, String passwd, bool refreshmode){
// Each horizontal module // Each horizontal module
for (uint8_t x = 0; x < qrcode.size; x++) { for (uint8_t x = 0; x < qrcode.size; x++) {
if(qrcode_getModule(&qrcode, x, y)){ if(qrcode_getModule(&qrcode, x, y)){
display.fillRect(box_x, box_y, box_s, box_s, GxEPD_BLACK); display.fillRect(box_x, box_y, box_s, box_s, pixelcolor);
} else { } else {
display.fillRect(box_x, box_y, box_s, box_s, GxEPD_WHITE); display.fillRect(box_x, box_y, box_s, box_s, bgcolor);
} }
box_x = box_x + box_s; box_x = box_x + box_s;
} }
@ -34,15 +49,10 @@ void qrWiFi(String ssid, String passwd, bool refreshmode){
box_x = init_x; box_x = init_x;
} }
display.setFont(&Ubuntu_Bold32pt7b); display.setFont(&Ubuntu_Bold32pt7b);
display.setTextColor(GxEPD_BLACK); display.setTextColor(textcolor);
display.setCursor(140, 285); display.setCursor(140, 285);
display.print("WiFi"); display.print("WiFi");
if(refreshmode == true){
display.update(); // Full update (slow)
}
else{
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast) display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
} }
}
#endif #endif

View File

@ -10,6 +10,7 @@ class PageOneValue : public Page{
// Get config data // Get config data
String lengthformat = config->getString(config->lengthFormat); String lengthformat = config->getString(config->lengthFormat);
bool simulation = config->getBool(config->useSimuData); bool simulation = config->getBool(config->useSimuData);
String displaycolor = config->getString(config->displaycolor);
bool holdvalues = config->getBool(config->holdvalues); bool holdvalues = config->getBool(config->holdvalues);
// Get boat values // Get boat values
@ -21,17 +22,30 @@ class PageOneValue : public Page{
// Logging boat values // Logging boat values
if (value == NULL) return; if (value == NULL) return;
LOG_DEBUG(GwLog::LOG,"drawing at PageOneValue, p=%s, v=%f", name1, value1); LOG_DEBUG(GwLog::LOG,"Drawing at PageOneValue, p=%s, v=%f", name1, value1);
// Draw page // Draw page
//*********************************************************** //***********************************************************
// Clear display // Clear display, set background color and text color
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen int textcolor = GxEPD_BLACK;
int pixelcolor = GxEPD_BLACK;
int bgcolor = GxEPD_WHITE;
if(displaycolor == "Normal"){
textcolor = GxEPD_BLACK;
pixelcolor = GxEPD_BLACK;
bgcolor = GxEPD_WHITE;
}
else{
textcolor = GxEPD_WHITE;
pixelcolor = GxEPD_WHITE;
bgcolor = GxEPD_BLACK;
}
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, bgcolor); // Draw white sreen
display.setTextColor(textcolor);
// Show name // Show name
display.setFont(&Ubuntu_Bold32pt7b); display.setFont(&Ubuntu_Bold32pt7b);
display.setTextColor(GxEPD_BLACK);
display.setCursor(20, 100); display.setCursor(20, 100);
display.print(name1); // Page name display.print(name1); // Page name
display.setFont(&Ubuntu_Bold20pt7b); display.setFont(&Ubuntu_Bold20pt7b);
@ -77,11 +91,8 @@ class PageOneValue : public Page{
// Key Layout // Key Layout
display.setFont(&Ubuntu_Bold8pt7b); display.setFont(&Ubuntu_Bold8pt7b);
display.setTextColor(GxEPD_BLACK); display.setCursor(115, 290);
display.setCursor(0, 290); display.print(" [ <<<<<< >>>>>> ]");
display.print(" [ < ]");
display.setCursor(290, 290);
display.print("[ > ]");
display.setCursor(343, 290); display.setCursor(343, 290);
display.print("[ILUM]"); display.print("[ILUM]");

View File

@ -324,6 +324,21 @@
"obp60":"true" "obp60":"true"
} }
}, },
{
"name": "displaycolor",
"label": "Display Color",
"type": "list",
"default": "Normal",
"description": "If display color inverse then is background black and all other white",
"list": [
"Normal",
"Inverse"
],
"category": "OBP60 Display",
"capabilities": {
"obp60":"true"
}
},
{ {
"name": "statusLine", "name": "statusLine",
"label": "Status Line", "label": "Status Line",

View File

@ -13,8 +13,8 @@
#include "OBP60ExtensionPort.h" // Functions lib for extension board #include "OBP60ExtensionPort.h" // Functions lib for extension board
#include "OBP60Keypad.h" // Functions for keypad #include "OBP60Keypad.h" // Functions for keypad
// True type character sets // True type character sets includes
// See OBP60ExtensionPort.h // See OBP60ExtensionPort.cpp
// Pictures // Pictures
//#include GxEPD_BitmapExamples // Example picture //#include GxEPD_BitmapExamples // Example picture
@ -258,27 +258,50 @@ void OBP60Task(GwApi *api){
} }
// Init E-Ink display // Init E-Ink display
display.init(); // Initialize and clear display
display.setTextColor(GxEPD_BLACK); // Set display color
display.setRotation(0); // Set display orientation (horizontal)
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
display.update(); // Full update (slow)
String displaymode = api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString(); String displaymode = api->getConfig()->getConfigItem(api->getConfig()->display,true)->asString();
if(String(displaymode) == "Logo + QR Code" || String(displaymode) == "Logo"){ String displaycolor = api->getConfig()->getConfigItem(api->getConfig()->displaycolor,true)->asString();
display.drawExampleBitmap(gImage_Logo_OBP_400x300_sw, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw start logo
// display.drawExampleBitmap(gImage_MFD_OBP60_400x300_sw, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw start logo
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
delay(SHOW_TIME); // Logo show time
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
if(String(displaymode) == "Logo + QR Code"){
String systemname = api->getConfig()->getConfigItem(api->getConfig()->systemName,true)->asString(); String systemname = api->getConfig()->getConfigItem(api->getConfig()->systemName,true)->asString();
String wifipass = api->getConfig()->getConfigItem(api->getConfig()->apPassword,true)->asString(); String wifipass = api->getConfig()->getConfigItem(api->getConfig()->apPassword,true)->asString();
bool refreshmode = api->getConfig()->getConfigItem(api->getConfig()->refresh,true)->asBoolean(); bool refreshmode = api->getConfig()->getConfigItem(api->getConfig()->refresh,true)->asBoolean();
qrWiFi(systemname, wifipass, refreshmode); // Show QR code for WiFi connection int textcolor = GxEPD_BLACK;
int pixelcolor = GxEPD_BLACK;
int bgcolor = GxEPD_WHITE;
display.init(); // Initialize and clear display
display.setRotation(0); // Set display orientation (horizontal)
if(displaycolor == "Normal"){
textcolor = GxEPD_BLACK;
pixelcolor = GxEPD_BLACK;
bgcolor = GxEPD_WHITE;
}
else{
textcolor = GxEPD_WHITE;
pixelcolor = GxEPD_WHITE;
bgcolor = GxEPD_BLACK;
}
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, bgcolor); // Draw white sreen
display.setTextColor(textcolor); // Set display color
display.update(); // Full update (slow)
if(String(displaymode) == "Logo + QR Code" || String(displaymode) == "Logo"){
display.drawBitmap(gImage_Logo_OBP_400x300_sw, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, pixelcolor); // Draw start logo
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
delay(SHOW_TIME); // Logo show time delay(SHOW_TIME); // Logo show time
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, bgcolor); // Draw white sreen
if(refreshmode == true){
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, bgcolor); // Draw white sreen
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Needs partial update before full update to refresh the frame buffer
display.update(); // Full update
}
else{
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Partial update (fast)
}
if(String(displaymode) == "Logo + QR Code"){
qrWiFi(systemname, wifipass, displaycolor); // Show QR code for WiFi connection
delay(SHOW_TIME); // Logo show time
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, bgcolor); // Draw white sreen
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Needs partial update before full update to refresh the frame buffer
display.update(); // Full update
} }
} }
@ -344,11 +367,14 @@ void OBP60Task(GwApi *api){
LOG_DEBUG(GwLog::LOG,"obp60task: start mainloop"); LOG_DEBUG(GwLog::LOG,"obp60task: start mainloop");
int pageNumber=0; int pageNumber=0;
int lastPage=pageNumber; int lastPage=pageNumber;
long starttime0 = millis(); // Mainloop
long starttime1 = millis(); // Full disolay refresh
while (true){ while (true){
delay(1000); if(millis() > starttime0 + 100){
starttime0 = millis();
//check if there is a keyboard message //check if there is a keyboard message
int keyboardMessage=0; int keyboardMessage=0;
if (xQueueReceive(allParameters.queue,&keyboardMessage,0)){ while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
LOG_DEBUG(GwLog::LOG,"new key from keyboard %d",keyboardMessage); LOG_DEBUG(GwLog::LOG,"new key from keyboard %d",keyboardMessage);
Page *currentPage=pages[pageNumber].page; Page *currentPage=pages[pageNumber].page;
@ -358,21 +384,46 @@ void OBP60Task(GwApi *api){
if (keyboardMessage > 0) if (keyboardMessage > 0)
{ {
// Decoding all key codes // Decoding all key codes
// #6 Backlight on if key controled
String backlight = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
if(String(backlight) == "Control by Key"){
if(keyboardMessage == 6){
LOG_DEBUG(GwLog::LOG,"Toggle Backlight LED");
togglePortPin(OBP_BACKLIGHT_LED);
}
}
// #9 Swipe right
if (keyboardMessage == 9) if (keyboardMessage == 9)
{ {
pageNumber++; pageNumber++;
if (pageNumber >= numPages) if (pageNumber >= numPages)
pageNumber = 0; pageNumber = 0;
} }
// #10 Swipe left
if (keyboardMessage == 10) if (keyboardMessage == 10)
{ {
pageNumber--; pageNumber--;
if (pageNumber < 0) if (pageNumber < 0)
pageNumber = numPages - 1; pageNumber = numPages - 1;
} }
// #9 or #10 Refresh display befor start a new page if reshresh is enabled
bool refreshmode = api->getConfig()->getConfigItem(api->getConfig()->refresh,true)->asBoolean();
if(refreshmode == true && (keyboardMessage == 9 || keyboardMessage == 10)){
display.fillRect(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_WHITE); // Draw white sreen
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, true); // Needs partial update before full update to refresh the frame buffer
display.update(); // Full update
}
} }
LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber); LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber);
} }
// Subtask E-Ink full refresh
if(millis() > starttime1 + FULL_REFRESH_TIME * 1000){
LOG_DEBUG(GwLog::DEBUG,"E-Ink full refresh");
display.update(); // Full update
starttime1 = millis();
}
//refresh data from api //refresh data from api
api->getBoatDataValues(boatValues.numValues,boatValues.allBoatValues); api->getBoatDataValues(boatValues.numValues,boatValues.allBoatValues);
api->getStatus(commonData.status); api->getStatus(commonData.status);
@ -402,6 +453,7 @@ void OBP60Task(GwApi *api){
} }
} }
}
vTaskDelete(NULL); vTaskDelete(NULL);
} }