* refactor of Color mapping in UITasks / DisplayDrivers

* color displays now with a new light theme
This commit is contained in:
Scott Powell
2026-07-22 16:03:33 +10:00
parent 78240e9477
commit b8504e55c6
32 changed files with 313 additions and 285 deletions
+43 -24
View File
@@ -53,23 +53,24 @@ public:
int render(DisplayDriver& display) override {
// meshcore logo
display.setColor(DisplayDriver::BLUE);
display.setColor(UIColor::corp_blue);
int logoWidth = 128;
display.drawXbm((display.width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
// meshcore website
const char* website = "https://meshcore.io";
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
uint16_t websiteWidth = display.getTextWidth(website);
display.setCursor((display.width() - websiteWidth) / 2, 22);
display.print(website);
// version info
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
display.drawTextCentered(display.width()/2, 35, _version_info);
display.setColor(UIColor::secondary_txt);
display.setTextSize(1);
display.drawTextCentered(display.width()/2, 48, FIRMWARE_BUILD_DATE);
@@ -128,7 +129,7 @@ class HomeScreen : public UIScreen {
int iconHeight = 10;
int iconX = display.width() - iconWidth - 5; // Position the icon near the top-right corner
int iconY = 0;
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::title_txt);
// battery outline
display.drawRect(iconX, iconY, iconWidth, iconHeight);
@@ -143,7 +144,7 @@ class HomeScreen : public UIScreen {
// show muted icon if buzzer is muted
#ifdef PIN_BUZZER
if (_task->isBuzzerQuiet()) {
display.setColor(DisplayDriver::RED);
display.setColor(UIColor::warning_txt);
display.drawXbm(iconX - 9, iconY + 1, muted_icon, 8, 8);
}
#endif
@@ -188,34 +189,37 @@ public:
}
int render(DisplayDriver& display) override {
display.setColor(UIColor::title_bkg);
display.fillRect(0, 0, display.width(), 12);
char tmp[80];
// node name
display.setTextSize(1);
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::title_txt);
char filtered_name[sizeof(_node_prefs->node_name)];
display.translateUTF8ToBlocks(filtered_name, _node_prefs->node_name, sizeof(filtered_name));
display.setCursor(0, 0);
display.setCursor(0, 2);
display.print(filtered_name);
// battery voltage
renderBatteryIndicator(display, _task->getBattMilliVolts());
// curr page indicator
display.setColor(UIColor::title_bkg);
int y = 14;
int x = display.width() / 2 - 5 * (HomePage::Count-1);
for (uint8_t i = 0; i < HomePage::Count; i++, x += 10) {
if (i == _page) {
display.fillRect(x-1, y-1, 3, 3);
display.fillRect(x-1, y-1, 4, 4);
} else {
display.fillRect(x, y, 1, 1);
display.fillRect(x, y, 2, 2);
}
}
if (_page == HomePage::FIRST) {
display.setColor(DisplayDriver::YELLOW);
display.setColor(UIColor::primary_txt);
display.setTextSize(2);
sprintf(tmp, "MSG: %d", _task->getMsgCount());
display.drawTextCentered(display.width() / 2, 20, tmp);
display.drawTextCentered(display.width() / 2, 22, tmp);
#ifdef WIFI_SSID
IPAddress ip = WiFi.localIP();
@@ -224,19 +228,19 @@ public:
display.drawTextCentered(display.width() / 2, 54, tmp);
#endif
if (_task->hasConnection()) {
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::warning_txt);
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
} else if (the_mesh.getBLEPin() != 0) { // BT pin
display.setColor(DisplayDriver::RED);
display.setColor(UIColor::warning_txt);
display.setTextSize(2);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
display.drawTextCentered(display.width() / 2, 43, tmp);
}
} else if (_page == HomePage::RECENT) {
the_mesh.getRecentlyHeard(recent, UI_RECENT_LIST_SIZE);
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::primary_txt);
int y = 20;
for (int i = 0; i < UI_RECENT_LIST_SIZE; i++, y += 11) {
auto a = &recent[i];
@@ -260,7 +264,7 @@ public:
display.print(tmp);
}
} else if (_page == HomePage::RADIO) {
display.setColor(DisplayDriver::YELLOW);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
// freq / sf
display.setCursor(0, 20);
@@ -279,15 +283,17 @@ public:
sprintf(tmp, "Noise floor: %d", radio_driver.getNoiseFloor());
display.print(tmp);
} else if (_page == HomePage::BLUETOOTH) {
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::corp_blue);
display.drawXbm((display.width() - 32) / 2, 18,
_task->isSerialEnabled() ? bluetooth_on : bluetooth_off,
32, 32);
display.setColor(UIColor::secondary_txt);
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 64 - 11, "toggle: " PRESS_LABEL);
} else if (_page == HomePage::ADVERT) {
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::corp_blue);
display.drawXbm((display.width() - 32) / 2, 18, advert_icon, 32, 32);
display.setColor(UIColor::secondary_txt);
display.drawTextCentered(display.width() / 2, 64 - 11, "advert: " PRESS_LABEL);
#if ENV_INCLUDE_GPS == 1
} else if (_page == HomePage::GPS) {
@@ -305,24 +311,33 @@ public:
#else
strcpy(buf, gps_state ? "gps on" : "gps off");
#endif
display.setColor(UIColor::primary_txt);
display.drawTextLeftAlign(0, y, buf);
if (nmea == NULL) {
y = y + 12;
display.setColor(UIColor::secondary_txt);
display.drawTextLeftAlign(0, y, "Can't access GPS");
} else {
display.setColor(UIColor::primary_txt);
strcpy(buf, nmea->isValid()?"fix":"no fix");
display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 12;
display.setColor(UIColor::secondary_txt);
display.drawTextLeftAlign(0, y, "sat");
display.setColor(UIColor::primary_txt);
sprintf(buf, "%d", nmea->satellitesCount());
display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 12;
display.setColor(UIColor::secondary_txt);
display.drawTextLeftAlign(0, y, "pos");
display.setColor(UIColor::primary_txt);
sprintf(buf, "%.4f %.4f",
nmea->getLatitude()/1000000., nmea->getLongitude()/1000000.);
display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 12;
display.setColor(UIColor::secondary_txt);
display.drawTextLeftAlign(0, y, "alt");
display.setColor(UIColor::primary_txt);
sprintf(buf, "%.2f", nmea->getAltitude()/1000.);
display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 12;
@@ -390,7 +405,9 @@ public:
strcpy(name, "unk"); sprintf(buf, "");
}
display.setCursor(0, y);
display.setColor(UIColor::secondary_txt);
display.print(name);
display.setColor(UIColor::primary_txt);
display.setCursor(
display.width()-display.getTextWidth(buf)-1, y
);
@@ -401,11 +418,13 @@ public:
else sensors_scroll_offset = 0;
#endif
} else if (_page == HomePage::SHUTDOWN) {
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::corp_blue);
display.setTextSize(1);
if (_shutdown_init) {
display.setColor(UIColor::warning_txt);
display.drawTextCentered(display.width() / 2, 34, "hibernating...");
} else {
display.setColor(UIColor::secondary_txt);
display.drawXbm((display.width() - 32) / 2, 18, power_icon, 32, 32);
display.drawTextCentered(display.width() / 2, 64 - 11, "hibernate:" PRESS_LABEL);
}
@@ -498,7 +517,7 @@ public:
char tmp[16];
display.setCursor(0, 0);
display.setTextSize(1);
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::corp_blue);
sprintf(tmp, "Unread: %d", num_unread);
display.print(tmp);
@@ -518,13 +537,13 @@ public:
display.drawRect(0, 11, display.width(), 1); // horiz line
display.setCursor(0, 14);
display.setColor(DisplayDriver::YELLOW);
display.setColor(UIColor::secondary_txt);
char filtered_origin[sizeof(p->origin)];
display.translateUTF8ToBlocks(filtered_origin, p->origin, sizeof(filtered_origin));
display.print(filtered_origin);
display.setCursor(0, 25);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
char filtered_msg[sizeof(p->msg)];
display.translateUTF8ToBlocks(filtered_msg, p->msg, sizeof(filtered_msg));
display.printWordWrap(filtered_msg, display.width());
@@ -806,9 +825,9 @@ void UITask::loop() {
_display->setTextSize(1);
int y = _display->height() / 3;
int p = _display->height() / 32;
_display->setColor(DisplayDriver::DARK);
_display->setColor(UIColor::popup_bkg);
_display->fillRect(p, y, _display->width() - p*2, y);
_display->setColor(DisplayDriver::LIGHT); // draw box border
_display->setColor(UIColor::popup_txt); // draw box border
_display->drawRect(p, y, _display->width() - p*2, y);
_display->drawTextCentered(_display->width() / 2, y + p*3, _alert);
_next_refresh = _alert_expiry; // will need refresh when alert is dismissed
@@ -845,7 +864,7 @@ void UITask::loop() {
if (_display != NULL) {
_display->startFrame();
_display->setTextSize(2);
_display->setColor(DisplayDriver::RED);
_display->setColor(UIColor::warning_txt);
_display->drawTextCentered(_display->width() / 2, 20, "Low Battery.");
_display->drawTextCentered(_display->width() / 2, 40, "Shutting Down!");
_display->endFrame();
+13 -14
View File
@@ -167,7 +167,7 @@ void UITask::renderBatteryIndicator(uint16_t batteryMilliVolts) {
int iconHeight = 12;
int iconX = _display->width() - iconWidth - 5; // Position the icon near the top-right corner
int iconY = 0;
_display->setColor(DisplayDriver::GREEN);
_display->setColor(UIColor::primary_txt);
// battery outline
_display->drawRect(iconX, iconY, iconWidth, iconHeight);
@@ -188,7 +188,7 @@ void UITask::renderCurrScreen() {
_display->setTextSize(1.4);
uint16_t textWidth = _display->getTextWidth(_alert);
_display->setCursor((_display->width() - textWidth) / 2, 22);
_display->setColor(DisplayDriver::GREEN);
_display->setColor(UIColor::warning_txt);
_display->print(_alert);
_alert[0] = 0;
_need_refresh = true;
@@ -197,30 +197,29 @@ void UITask::renderCurrScreen() {
// render message preview
_display->setCursor(0, 0);
_display->setTextSize(1);
_display->setColor(DisplayDriver::GREEN);
_display->setColor(UIColor::primary_txt);
_display->print(_node_prefs->node_name);
_display->setCursor(0, 12);
_display->setColor(DisplayDriver::YELLOW);
_display->setColor(UIColor::secondary_txt);
_display->print(_origin);
_display->setCursor(0, 24);
_display->setColor(DisplayDriver::LIGHT);
_display->print(_msg);
_display->setCursor(_display->width() - 28, 9);
_display->setTextSize(2);
_display->setColor(DisplayDriver::ORANGE);
_display->setColor(UIColor::primary_txt);
sprintf(tmp, "%d", _msgcount);
_display->print(tmp);
_display->setColor(DisplayDriver::YELLOW); // last color will be kept on T114
_display->setColor(UIColor::secondary_txt); // last color will be kept on T114
} else if ((millis() - ui_started_at) < BOOT_SCREEN_MILLIS) { // boot screen
// meshcore logo
_display->setColor(DisplayDriver::BLUE);
_display->setColor(UIColor::corp_blue);
int logoWidth = 128;
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
// version info
_display->setColor(DisplayDriver::LIGHT);
_display->setColor(UIColor::primary_txt);
_display->setTextSize(1);
uint16_t textWidth = _display->getTextWidth(_version_info);
_display->setCursor((_display->width() - textWidth) / 2, 22);
@@ -229,7 +228,7 @@ void UITask::renderCurrScreen() {
// node name
_display->setCursor(0, 0);
_display->setTextSize(1);
_display->setColor(DisplayDriver::GREEN);
_display->setColor(UIColor::primary_txt);
_display->print(_node_prefs->node_name);
// battery voltage
@@ -237,7 +236,7 @@ void UITask::renderCurrScreen() {
// freq / sf
_display->setCursor(0, 20);
_display->setColor(DisplayDriver::YELLOW);
_display->setColor(UIColor::secondary_txt);
sprintf(tmp, "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
_display->print(tmp);
@@ -248,14 +247,14 @@ void UITask::renderCurrScreen() {
// BT pin
if (!_connected && the_mesh.getBLEPin() != 0) {
_display->setColor(DisplayDriver::RED);
_display->setColor(UIColor::warning_txt);
_display->setTextSize(2);
_display->setCursor(0, 43);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
_display->print(tmp);
_display->setColor(DisplayDriver::GREEN);
_display->setColor(UIColor::primary_txt);
} else {
_display->setColor(DisplayDriver::LIGHT);
_display->setColor(UIColor::primary_txt);
}
}
_need_refresh = false;
@@ -104,7 +104,7 @@ public:
if (_status[0] == 0) return;
display.setTextSize(1);
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::primary_txt);
// if (_needs_redraw) {
// _text_width = display.getTextWidth(_status);
+18 -13
View File
@@ -56,24 +56,24 @@ public:
int render(DisplayDriver& display) override {
if (millis() < version_after) {
// meshcore logo
display.setColor(DisplayDriver::BLUE);
display.setColor(UIColor::corp_blue);
int logoWidth = 72;
display.drawXbm(0, 0, meshcore_logo, 72, 36);
} else {
// meshcore website
const char* website = "meshcore.io";
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
uint16_t websiteWidth = display.getTextWidth(website);
display.setCursor((display.width() - websiteWidth) / 2, 9);
display.print(website);
// version info
display.setColor(DisplayDriver::LIGHT);
display.setTextSize(1);
display.drawTextCentered(display.width()/2, 18, _version_info);
display.setColor(UIColor::secondary_txt);
display.setTextSize(1);
display.drawTextCentered(display.width()/2, 27, FIRMWARE_BUILD_DATE);
}
@@ -163,7 +163,7 @@ public:
// display.print(filtered_name);
display.setColor(DisplayDriver::YELLOW);
display.setColor(UIColor::primary_txt);
display.setTextSize(2);
sprintf(tmp, "MSG: %d", _task->getMsgCount());
display.setCursor(0, 10);
@@ -180,19 +180,19 @@ public:
display.drawTextCentered(display.width() / 2, 54, tmp);
#endif
if (_task->hasConnection()) {
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::warning_txt);
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, display.height()-8, "< Connected >");
} else if (the_mesh.getBLEPin() != 0) { // BT pin
display.setColor(DisplayDriver::RED);
display.setColor(UIColor::warning_txt);
display.setTextSize(2);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
display.drawTextCentered(display.width() / 2, display.height()-8, tmp);
}
} else if (_page == HomePage::RECENT) {
the_mesh.getRecentlyHeard(recent, UI_RECENT_LIST_SIZE);
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::primary_txt);
int y = 8;
for (int i = 0; i < UI_RECENT_LIST_SIZE; i++, y += 11) {
auto a = &recent[i];
@@ -216,7 +216,7 @@ public:
display.print(tmp);
}
} else if (_page == HomePage::RADIO) {
display.setColor(DisplayDriver::YELLOW);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
// frequency and spreading factor
display.setCursor(0, 8);
@@ -238,14 +238,14 @@ public:
display.drawTextRightAlign(display.width(), 26, tmp);
} else if (_page == HomePage::BLUETOOTH) {
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::corp_blue);
display.drawXbm((display.width() - 32) / 2, 8,
_task->isSerialEnabled() ? bluetooth_on : bluetooth_off,
32, 32);
display.setTextSize(1);
// display.drawTextCentered(display.width() / 2, 40 - 11, "toggle: " PRESS_LABEL);
} else if (_page == HomePage::ADVERT) {
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::corp_blue);
display.drawXbm((display.width() - 32) / 2, 8, advert_icon, 32, 32);
// display.drawTextCentered(display.width() / 2, 40 - 11, "advert: " PRESS_LABEL);
#if ENV_INCLUDE_GPS == 1
@@ -264,9 +264,11 @@ public:
#else
strcpy(buf, gps_state ? "gps on" : "gps off");
#endif
display.setColor(UIColor::primary_txt);
display.drawTextLeftAlign(0, y, buf);
if (nmea == NULL) {
// y = y + 8;
display.setColor(UIColor::warning_txt);
display.drawTextLeftAlign(0, y, "Can't access GPS");
} else {
if (!gps_state || !nmea->isValid()) {
@@ -274,6 +276,7 @@ public:
} else {
sprintf(buf, "%d sat", nmea->satellitesCount());
}
display.setColor(UIColor::primary_txt);
display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 8;
sprintf(buf, "lat %.4f",
@@ -349,8 +352,10 @@ public:
r.skipData(type);
strcpy(name, "unk"); sprintf(buf, "");
}
display.setColor(UIColor::secondary_txt);
display.setCursor(0, y);
display.print(name);
display.setColor(UIColor::primary_txt);
display.setCursor(
display.width()-display.getTextWidth(buf)-1, y
);
@@ -361,7 +366,7 @@ public:
else sensors_scroll_offset = 0;
#endif
} else if (_page == HomePage::SHUTDOWN) {
display.setColor(DisplayDriver::GREEN);
display.setColor(UIColor::secondary_txt);
display.setTextSize(1);
if (_shutdown_init) {
display.drawTextCentered(display.width() / 2, 20, "hibernating...");
@@ -692,9 +697,9 @@ void UITask::loop() {
_display->setTextSize(1);
int y = _display->height() / 3;
int p = _display->height() / 32;
_display->setColor(DisplayDriver::DARK);
_display->setColor(UIColor::popup_bkg);
_display->fillRect(p, y, _display->width() - p*2, y);
_display->setColor(DisplayDriver::LIGHT); // draw box border
_display->setColor(UIColor::popup_txt); // draw box border
_display->drawRect(p, y, _display->width() - p*2, y);
_display->drawTextCentered(_display->width() / 2, y + p*3, _alert);
_next_refresh = _alert_expiry; // will need refresh when alert is dismissed
+5 -7
View File
@@ -57,18 +57,17 @@ void UITask::renderCurrScreen() {
char tmp[80];
if (millis() < _started_at + BOOT_SCREEN_MILLIS) { // boot screen
// meshcore logo
_display->setColor(DisplayDriver::BLUE);
_display->setColor(UIColor::corp_blue);
int logoWidth = 128;
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
// meshcore website
const char* website = "https://meshcore.io";
_display->setColor(DisplayDriver::LIGHT);
_display->setColor(UIColor::primary_txt);
_display->setTextSize(1);
_display->drawTextCentered(_display->width() / 2, 22, website);
// version info
_display->setColor(DisplayDriver::LIGHT);
_display->setTextSize(1);
_display->drawTextCentered(_display->width() / 2, 35, _version_info);
@@ -77,13 +76,13 @@ void UITask::renderCurrScreen() {
_display->drawTextCentered(_display->width() / 2, 48, node_type);
} else if (_powering_off_at > 0) {
// meshcore logo
_display->setColor(DisplayDriver::BLUE);
_display->setColor(UIColor::corp_blue);
int logoWidth = 128;
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
// meshcore website
const char* website = "https://meshcore.io";
_display->setColor(DisplayDriver::LIGHT);
_display->setColor(UIColor::primary_txt);
_display->setTextSize(1);
_display->drawTextCentered(_display->width()/ 2, 22, website);
@@ -95,12 +94,11 @@ void UITask::renderCurrScreen() {
} else {
_display->setCursor(0, 0);
_display->setTextSize(1);
_display->setColor(DisplayDriver::GREEN);
_display->setColor(UIColor::primary_txt);
_display->print(_node_prefs->node_name);
// freq / sf
_display->setCursor(0, 20);
_display->setColor(DisplayDriver::YELLOW);
sprintf(tmp, "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
_display->print(tmp);
+3 -5
View File
@@ -49,20 +49,19 @@ void UITask::renderCurrScreen() {
char tmp[80];
if (millis() < BOOT_SCREEN_MILLIS) { // boot screen
// meshcore logo
_display->setColor(DisplayDriver::BLUE);
_display->setColor(UIColor::corp_blue);
int logoWidth = 128;
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
// meshcore website
const char* website = "https://meshcore.io";
_display->setColor(DisplayDriver::LIGHT);
_display->setColor(UIColor::primary_txt);
_display->setTextSize(1);
uint16_t websiteWidth = _display->getTextWidth(website);
_display->setCursor((_display->width() - websiteWidth) / 2, 22);
_display->print(website);
// version info
_display->setColor(DisplayDriver::LIGHT);
_display->setTextSize(1);
uint16_t versionWidth = _display->getTextWidth(_version_info);
_display->setCursor((_display->width() - versionWidth) / 2, 35);
@@ -77,12 +76,11 @@ void UITask::renderCurrScreen() {
// node name
_display->setCursor(0, 0);
_display->setTextSize(1);
_display->setColor(DisplayDriver::GREEN);
_display->setColor(UIColor::primary_txt);
_display->print(_node_prefs->node_name);
// freq / sf
_display->setCursor(0, 20);
_display->setColor(DisplayDriver::YELLOW);
sprintf(tmp, "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
_display->print(tmp);
+3 -5
View File
@@ -49,20 +49,19 @@ void UITask::renderCurrScreen() {
char tmp[80];
if (millis() < BOOT_SCREEN_MILLIS) { // boot screen
// meshcore logo
_display->setColor(DisplayDriver::BLUE);
_display->setColor(UIColor::corp_blue);
int logoWidth = 128;
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
// meshcore website
const char* website = "https://meshcore.io";
_display->setColor(DisplayDriver::LIGHT);
_display->setColor(UIColor::primary_txt);
_display->setTextSize(1);
uint16_t websiteWidth = _display->getTextWidth(website);
_display->setCursor((_display->width() - websiteWidth) / 2, 22);
_display->print(website);
// version info
_display->setColor(DisplayDriver::LIGHT);
_display->setTextSize(1);
uint16_t versionWidth = _display->getTextWidth(_version_info);
_display->setCursor((_display->width() - versionWidth) / 2, 35);
@@ -77,12 +76,11 @@ void UITask::renderCurrScreen() {
// node name
_display->setCursor(0, 0);
_display->setTextSize(1);
_display->setColor(DisplayDriver::GREEN);
_display->setColor(UIColor::primary_txt);
_display->print(_node_prefs->node_name);
// freq / sf
_display->setCursor(0, 20);
_display->setColor(DisplayDriver::YELLOW);
sprintf(tmp, "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
_display->print(tmp);
+11 -3
View File
@@ -3,12 +3,20 @@
#include <stdint.h>
#include <string.h>
using ColorVal = uint16_t;
class UIColor {
public:
// color definitions (by element _type_)
static ColorVal window_bkg, title_bkg, title_txt, primary_txt, secondary_txt, warning_txt, popup_bkg, popup_txt, corp_blue;
};
class DisplayDriver {
int _w, _h;
protected:
DisplayDriver(int w, int h) { _w = w; _h = h; }
public:
enum Color { DARK=0, LIGHT, RED, GREEN, BLUE, YELLOW, ORANGE }; // on b/w screen, colors will be !=0 synonym of light
//enum Color { DARK=0, LIGHT, RED, GREEN, BLUE, YELLOW, ORANGE }; // on b/w screen, colors will be !=0 synonym of light
int width() const { return _w; }
int height() const { return _h; }
@@ -18,9 +26,9 @@ public:
virtual void turnOn() = 0;
virtual void turnOff() = 0;
virtual void clear() = 0;
virtual void startFrame(Color bkg = DARK) = 0;
virtual void startFrame(ColorVal bkg = UIColor::window_bkg) = 0;
virtual void setTextSize(int sz) = 0;
virtual void setColor(Color c) = 0;
virtual void setColor(ColorVal c) = 0;
virtual void setCursor(int x, int y) = 0;
virtual void print(const char* str) = 0;
virtual void printWordWrap(const char* str, int max_width) { print(str); } // fallback to basic print() if no override
+22 -8
View File
@@ -2,6 +2,17 @@
#include "../../MeshCore.h"
// Color scheme
ColorVal UIColor::window_bkg = WHITE;
ColorVal UIColor::title_bkg = BLACK;
ColorVal UIColor::title_txt = WHITE;
ColorVal UIColor::primary_txt = BLACK;
ColorVal UIColor::secondary_txt = BLACK;
ColorVal UIColor::warning_txt = BLACK;
ColorVal UIColor::popup_bkg = BLACK;
ColorVal UIColor::popup_txt = WHITE;
ColorVal UIColor::corp_blue = BLACK;
BaseDisplay* E213Display::detectEInk()
{
// Test 1: Logic of BUSY pin
@@ -108,16 +119,18 @@ void E213Display::clear() {
display->clear();
}
void E213Display::startFrame(Color bkg) {
void E213Display::startFrame(ColorVal bkg) {
display_crc.reset();
// Fill screen with white first to ensure clean background
display->fillRect(0, 0, width(), height(), WHITE);
if (bkg == LIGHT) {
if (bkg == 0) {
// Fill with black if light background requested (inverted for e-ink)
display->fillRect(0, 0, width(), height(), BLACK);
}
_color = UIColor::primary_txt;
display->setTextColor(_color);
}
void E213Display::setTextSize(int sz) {
@@ -126,9 +139,10 @@ void E213Display::setTextSize(int sz) {
display->setTextSize(sz);
}
void E213Display::setColor(Color c) {
display_crc.update<Color>(c);
// implemented in individual display methods
void E213Display::setColor(ColorVal c) {
_color = c;
display_crc.update<ColorVal>(c);
display->setTextColor(_color);
}
void E213Display::setCursor(int x, int y) {
@@ -147,7 +161,7 @@ void E213Display::fillRect(int x, int y, int w, int h) {
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display->fillRect(x, y, w, h, BLACK);
display->fillRect(x, y, w, h, _color);
}
void E213Display::drawRect(int x, int y, int w, int h) {
@@ -155,7 +169,7 @@ void E213Display::drawRect(int x, int y, int w, int h) {
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display->drawRect(x, y, w, h, BLACK);
display->drawRect(x, y, w, h, _color);
}
void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
@@ -179,7 +193,7 @@ void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
// If the bit is set, draw the pixel
if (bitSet) {
display->drawPixel(x + bx, y + by, BLACK);
display->drawPixel(x + bx, y + by, _color);
}
}
}
+3 -2
View File
@@ -16,6 +16,7 @@ class E213Display : public DisplayDriver {
RefCountedDigitalPin* _periph_power;
CRC32 display_crc;
uint32_t last_display_crc_value = 0;
uint16_t _color;
public:
E213Display(RefCountedDigitalPin* periph_power = NULL) : DisplayDriver(250, 122), _periph_power(periph_power) {}
@@ -30,9 +31,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char *str) override;
void fillRect(int x, int y, int w, int h) override;
+22 -8
View File
@@ -2,6 +2,17 @@
#include "../../MeshCore.h"
// Color scheme
ColorVal UIColor::window_bkg = WHITE;
ColorVal UIColor::title_bkg = BLACK;
ColorVal UIColor::title_txt = WHITE;
ColorVal UIColor::primary_txt = BLACK;
ColorVal UIColor::secondary_txt = BLACK;
ColorVal UIColor::warning_txt = BLACK;
ColorVal UIColor::popup_bkg = BLACK;
ColorVal UIColor::popup_txt = WHITE;
ColorVal UIColor::corp_blue = BLACK;
bool E290Display::begin() {
if (_init) return true;
@@ -62,15 +73,17 @@ void E290Display::clear() {
display.clear();
}
void E290Display::startFrame(Color bkg) {
void E290Display::startFrame(ColorVal bkg) {
display_crc.reset();
// Fill screen with white first to ensure clean background
display.fillRect(0, 0, width(), height(), WHITE);
if (bkg == LIGHT) {
if (bkg == 0) {
// Fill with black if light background requested (inverted for e-ink)
display.fillRect(0, 0, width(), height(), BLACK);
}
_color = UIColor::primary_txt;
display.setTextColor(_color);
}
void E290Display::setTextSize(int sz) {
@@ -79,9 +92,10 @@ void E290Display::setTextSize(int sz) {
display.setTextSize(sz);
}
void E290Display::setColor(Color c) {
display_crc.update<Color>(c);
// implemented in individual display methods
void E290Display::setColor(ColorVal c) {
_color = c;
display_crc.update<ColorVal>(c);
display.setTextColor(_color);
}
void E290Display::setCursor(int x, int y) {
@@ -100,7 +114,7 @@ void E290Display::fillRect(int x, int y, int w, int h) {
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display.fillRect(x, y, w, h, BLACK);
display.fillRect(x, y, w, h, _color);
}
void E290Display::drawRect(int x, int y, int w, int h) {
@@ -108,7 +122,7 @@ void E290Display::drawRect(int x, int y, int w, int h) {
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display.drawRect(x, y, w, h, BLACK);
display.drawRect(x, y, w, h, _color);
}
void E290Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
@@ -132,7 +146,7 @@ void E290Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
// If the bit is set, draw the pixel
if (bitSet) {
display.drawPixel(x + bx, y + by, BLACK);
display.drawPixel(x + bx, y + by, _color);
}
}
}
+3 -2
View File
@@ -16,6 +16,7 @@ class E290Display : public DisplayDriver {
RefCountedDigitalPin* _periph_power;
CRC32 display_crc;
uint32_t last_display_crc_value = 0;
uint16_t _color;
public:
E290Display(RefCountedDigitalPin* periph_power = NULL) : DisplayDriver(296, 128), _periph_power(periph_power) {}
@@ -26,9 +27,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char *str) override;
void fillRect(int x, int y, int w, int h) override;
+18 -11
View File
@@ -14,6 +14,18 @@
SPIClass SPI1 = SPIClass(FSPI);
#endif
// Color scheme
ColorVal UIColor::window_bkg = GxEPD_WHITE;
ColorVal UIColor::title_bkg = GxEPD_BLACK;
ColorVal UIColor::title_txt = GxEPD_WHITE;
ColorVal UIColor::primary_txt = GxEPD_BLACK;
ColorVal UIColor::secondary_txt = GxEPD_BLACK;
ColorVal UIColor::warning_txt = GxEPD_BLACK;
ColorVal UIColor::popup_bkg = GxEPD_BLACK;
ColorVal UIColor::popup_txt = GxEPD_WHITE;
ColorVal UIColor::corp_blue = GxEPD_BLACK;
bool GxEPDDisplay::begin() {
display.epd2.selectSPI(SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
#ifdef ESP32
@@ -61,9 +73,9 @@ void GxEPDDisplay::clear() {
display_crc.reset();
}
void GxEPDDisplay::startFrame(Color bkg) {
display.fillScreen(GxEPD_WHITE);
display.setTextColor(_curr_color = GxEPD_BLACK);
void GxEPDDisplay::startFrame(ColorVal bkg) {
display.fillScreen(bkg);
display.setTextColor(_curr_color = UIColor::primary_txt);
display_crc.reset();
}
@@ -85,14 +97,9 @@ void GxEPDDisplay::setTextSize(int sz) {
}
}
void GxEPDDisplay::setColor(Color c) {
display_crc.update<Color> (c);
// colours need to be inverted for epaper displays
if (c == DARK) {
display.setTextColor(_curr_color = GxEPD_WHITE);
} else {
display.setTextColor(_curr_color = GxEPD_BLACK);
}
void GxEPDDisplay::setColor(ColorVal c) {
display_crc.update<ColorVal> (c);
display.setTextColor(_curr_color = c);
}
void GxEPDDisplay::setCursor(int x, int y) {
+2 -2
View File
@@ -51,9 +51,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void fillRect(int x, int y, int w, int h) override;
+17 -31
View File
@@ -1,5 +1,16 @@
#include "LGFXDisplay.h"
// Color scheme
ColorVal UIColor::window_bkg = 0xFFFF;
ColorVal UIColor::title_bkg = 0x001F;
ColorVal UIColor::title_txt = 0xFFFF;
ColorVal UIColor::primary_txt = 0x0000;
ColorVal UIColor::secondary_txt = (18 << 11) | (36 << 5) | 18; // mid-gray
ColorVal UIColor::warning_txt = 0xFD20;
ColorVal UIColor::popup_bkg = 0x07FF; // CYAN
ColorVal UIColor::popup_txt = 0x0000;
ColorVal UIColor::corp_blue = 0x001A;
bool LGFXDisplay::begin() {
turnOn();
display->init();
@@ -35,45 +46,20 @@ void LGFXDisplay::clear() {
buffer.clearDisplay();
}
void LGFXDisplay::startFrame(Color bkg) {
void LGFXDisplay::startFrame(ColorVal bkg) {
// display->startWrite();
// display->getScanLine();
buffer.clearDisplay();
buffer.setTextColor(TFT_WHITE);
_color = bkg;
buffer.fillScreen(_color);
buffer.setTextColor(_color = UIColor::primary_txt);
}
void LGFXDisplay::setTextSize(int sz) {
buffer.setTextSize(sz);
}
void LGFXDisplay::setColor(Color c) {
// _color = (c != 0) ? ILI9342_WHITE : ILI9342_BLACK;
switch (c) {
case DARK:
_color = TFT_BLACK;
break;
case LIGHT:
_color = TFT_WHITE;
break;
case RED:
_color = TFT_RED;
break;
case GREEN:
_color = TFT_GREEN;
break;
case BLUE:
_color = TFT_BLUE;
break;
case YELLOW:
_color = TFT_YELLOW;
break;
case ORANGE:
_color = TFT_ORANGE;
break;
default:
_color = TFT_WHITE;
}
buffer.setTextColor(_color);
void LGFXDisplay::setColor(ColorVal c) {
buffer.setTextColor(_color = c);
}
void LGFXDisplay::setCursor(int x, int y) {
+2 -2
View File
@@ -25,9 +25,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void fillRect(int x, int y, int w, int h) override;
+16 -18
View File
@@ -96,18 +96,16 @@
#define NV3001B_TEXT_SIZE2_SCALE_Y 3
#endif
static uint16_t mapColor(DisplayDriver::Color c) {
switch (c) {
case DisplayDriver::DARK: return 0x0000;
case DisplayDriver::LIGHT: return 0xffff;
case DisplayDriver::RED: return 0xf800;
case DisplayDriver::GREEN: return 0x07e0;
case DisplayDriver::BLUE: return 0x001f;
case DisplayDriver::YELLOW: return 0xffe0;
case DisplayDriver::ORANGE: return 0xfd20;
default: return 0xffff;
}
}
// Color scheme
ColorVal UIColor::window_bkg = 0xFFFF;
ColorVal UIColor::title_bkg = 0x001F;
ColorVal UIColor::title_txt = 0xFFFF;
ColorVal UIColor::primary_txt = 0x0000;
ColorVal UIColor::secondary_txt = (18 << 11) | (36 << 5) | 18; // mid-gray
ColorVal UIColor::warning_txt = 0xFD20;
ColorVal UIColor::popup_bkg = 0x07FF; // CYAN
ColorVal UIColor::popup_txt = 0x0000;
ColorVal UIColor::corp_blue = 0x001A;
static int scaleX(int x) {
return (int)(x * DISPLAY_SCALE_X);
@@ -465,15 +463,15 @@ void NV3001BDisplay::turnOff() {
void NV3001BDisplay::clear() {
uint16_t saved = color;
color = 0x0000;
color = UIColor::window_bkg;
fillPhysicalRect(0, 0, NV3001B_SCREEN_WIDTH, NV3001B_SCREEN_HEIGHT);
color = saved;
}
void NV3001BDisplay::startFrame(Color bkg) {
color = mapColor(bkg);
void NV3001BDisplay::startFrame(ColorVal bkg) {
color = bkg;
fillPhysicalRect(0, 0, NV3001B_SCREEN_WIDTH, NV3001B_SCREEN_HEIGHT);
color = 0xffff;
color = UIColor::primary_txt;
text_size = 1;
cursor_x = 0;
cursor_y = 0;
@@ -483,8 +481,8 @@ void NV3001BDisplay::setTextSize(int sz) {
text_size = sz < 1 ? 1 : sz;
}
void NV3001BDisplay::setColor(Color c) {
color = mapColor(c);
void NV3001BDisplay::setColor(ColorVal c) {
color = c;
}
void NV3001BDisplay::setCursor(int x, int y) {
+2 -2
View File
@@ -55,9 +55,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void fillRect(int x, int y, int w, int h) override;
+2 -2
View File
@@ -11,9 +11,9 @@ public:
void turnOn() override { }
void turnOff() override { }
void clear() override { }
void startFrame(Color bkg = DARK) override { }
void startFrame(ColorVal bkg = UIColor::window_bkg) override { }
void setTextSize(int sz) override { }
void setColor(Color c) override { }
void setColor(ColorVal c) override { }
void setCursor(int x, int y) override { }
void print(const char* str) override { }
void fillRect(int x, int y, int w, int h) override { }
+15 -4
View File
@@ -9,6 +9,17 @@ bool SH1106Display::i2c_probe(TwoWire &wire, uint8_t addr)
return (error == 0);
}
// Color scheme
ColorVal UIColor::window_bkg = SH110X_BLACK;
ColorVal UIColor::title_bkg = SH110X_WHITE;
ColorVal UIColor::title_txt = SH110X_BLACK;
ColorVal UIColor::primary_txt = SH110X_WHITE;
ColorVal UIColor::secondary_txt = SH110X_WHITE;
ColorVal UIColor::warning_txt = SH110X_WHITE;
ColorVal UIColor::popup_bkg = SH110X_WHITE;
ColorVal UIColor::popup_txt = SH110X_BLACK;
ColorVal UIColor::corp_blue = SH110X_WHITE;
bool SH1106Display::begin()
{
// Wire must already be initialised by board.begin() before this is called.
@@ -35,7 +46,7 @@ void SH1106Display::clear()
display.display();
}
void SH1106Display::startFrame(Color bkg)
void SH1106Display::startFrame(ColorVal bkg)
{
display.clearDisplay(); // TODO: apply 'bkg'
_color = SH110X_WHITE;
@@ -49,9 +60,9 @@ void SH1106Display::setTextSize(int sz)
display.setTextSize(sz);
}
void SH1106Display::setColor(Color c)
void SH1106Display::setColor(ColorVal c)
{
_color = (c != 0) ? SH110X_WHITE : SH110X_BLACK;
_color = c;
display.setTextColor(_color);
}
@@ -77,7 +88,7 @@ void SH1106Display::drawRect(int x, int y, int w, int h)
void SH1106Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h)
{
display.drawBitmap(x, y, bits, w, h, SH110X_WHITE);
display.drawBitmap(x, y, bits, w, h, _color);
}
uint16_t SH1106Display::getTextWidth(const char *str)
+2 -2
View File
@@ -30,9 +30,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char *str) override;
void fillRect(int x, int y, int w, int h) override;
+15 -4
View File
@@ -6,6 +6,17 @@ bool SSD1306Display::i2c_probe(TwoWire& wire, uint8_t addr) {
return (error == 0);
}
// Color scheme
ColorVal UIColor::window_bkg = SSD1306_BLACK;
ColorVal UIColor::title_bkg = SSD1306_WHITE;
ColorVal UIColor::title_txt = SSD1306_BLACK;
ColorVal UIColor::primary_txt = SSD1306_WHITE;
ColorVal UIColor::secondary_txt = SSD1306_WHITE;
ColorVal UIColor::warning_txt = SSD1306_WHITE;
ColorVal UIColor::popup_bkg = SSD1306_WHITE;
ColorVal UIColor::popup_txt = SSD1306_BLACK;
ColorVal UIColor::corp_blue = SSD1306_WHITE;
bool SSD1306Display::begin() {
if (!_isOn) {
if (_peripher_power) _peripher_power->claim();
@@ -44,7 +55,7 @@ void SSD1306Display::clear() {
display.display();
}
void SSD1306Display::startFrame(Color bkg) {
void SSD1306Display::startFrame(ColorVal bkg) {
display.clearDisplay(); // TODO: apply 'bkg'
_color = SSD1306_WHITE;
display.setTextColor(_color);
@@ -56,8 +67,8 @@ void SSD1306Display::setTextSize(int sz) {
display.setTextSize(sz);
}
void SSD1306Display::setColor(Color c) {
_color = (c != 0) ? SSD1306_WHITE : SSD1306_BLACK;
void SSD1306Display::setColor(ColorVal c) {
_color = c;
display.setTextColor(_color);
}
@@ -78,7 +89,7 @@ void SSD1306Display::drawRect(int x, int y, int w, int h) {
}
void SSD1306Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
display.drawBitmap(x, y, bits, w, h, SSD1306_WHITE);
display.drawBitmap(x, y, bits, w, h, _color);
}
uint16_t SSD1306Display::getTextWidth(const char* str) {
+2 -2
View File
@@ -35,9 +35,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void fillRect(int x, int y, int w, int h) override;
+16 -30
View File
@@ -417,6 +417,17 @@ bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
#define PIN_TFT_LEDA_CTL_ACTIVE HIGH
#endif
// Color scheme
ColorVal UIColor::window_bkg = ST77XX_WHITE;
ColorVal UIColor::title_bkg = ST77XX_BLUE;
ColorVal UIColor::title_txt = ST77XX_WHITE;
ColorVal UIColor::primary_txt = ST77XX_BLACK;
ColorVal UIColor::secondary_txt = (18 << 11) | (36 << 5) | 18; // mid-gray
ColorVal UIColor::warning_txt = ST77XX_ORANGE;
ColorVal UIColor::popup_bkg = ST77XX_CYAN;
ColorVal UIColor::popup_txt = ST77XX_BLACK;
ColorVal UIColor::corp_blue = 0x001A;
bool ST7735Display::begin() {
if (!sprite) {
// alloc offscreen canvas
@@ -527,9 +538,9 @@ void ST7735Display::clear() {
sprite->fillScreen(ST77XX_BLACK);
}
void ST7735Display::startFrame(Color bkg) {
sprite->fillScreen(ST77XX_BLACK);
sprite->setTextColor(curr_color = ST77XX_WHITE);
void ST7735Display::startFrame(ColorVal bkg) {
sprite->fillScreen(bkg);
sprite->setTextColor(curr_color = UIColor::primary_txt);
sprite->setFreeFont();
sprite->setTextSize(1); // This one affects size of Please wait... message
//sprite->cp437(true); // Use full 256 char 'Code Page 437' font
@@ -539,33 +550,8 @@ void ST7735Display::setTextSize(int sz) {
sprite->setTextSize(sz);
}
void ST7735Display::setColor(Color c) {
switch (c) {
case DisplayDriver::DARK :
curr_color = ST77XX_BLACK;
break;
case DisplayDriver::LIGHT :
curr_color = ST77XX_WHITE;
break;
case DisplayDriver::RED :
curr_color = ST77XX_RED;
break;
case DisplayDriver::GREEN :
curr_color = ST77XX_GREEN;
break;
case DisplayDriver::BLUE :
curr_color = ST77XX_BLUE;
break;
case DisplayDriver::YELLOW :
curr_color = ST77XX_YELLOW;
break;
case DisplayDriver::ORANGE :
curr_color = ST77XX_ORANGE;
break;
default:
curr_color = ST77XX_WHITE;
break;
}
void ST7735Display::setColor(ColorVal c) {
curr_color = c;
sprite->setTextColor(curr_color);
}
+2 -2
View File
@@ -33,9 +33,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void fillRect(int x, int y, int w, int h) override;
+16 -35
View File
@@ -26,6 +26,17 @@
#define SCALE_Y DISPLAY_SCALE_Y
#endif
// Color scheme
ColorVal UIColor::window_bkg = ST77XX_WHITE;
ColorVal UIColor::title_bkg = ST77XX_BLUE;
ColorVal UIColor::title_txt = ST77XX_WHITE;
ColorVal UIColor::primary_txt = ST77XX_BLACK;
ColorVal UIColor::secondary_txt = (18 << 11) | (36 << 5) | 18; // mid-gray
ColorVal UIColor::warning_txt = ST77XX_ORANGE;
ColorVal UIColor::popup_bkg = ST77XX_CYAN;
ColorVal UIColor::popup_txt = ST77XX_BLACK;
ColorVal UIColor::corp_blue = 0x001A;
bool ST7789Display::begin() {
if(!_isOn) {
pinMode(PIN_TFT_VDD_CTL, OUTPUT);
@@ -90,9 +101,9 @@ void ST7789Display::clear() {
display.clear();
}
void ST7789Display::startFrame(Color bkg) {
display.clear();
_color = ST77XX_WHITE;
void ST7789Display::startFrame(ColorVal bkg) {
display.fillRect(0, 0, display.width(), display.height());
_color = UIColor::primary_txt;
display.setRGB(_color);
display.setFont(ArialMT_Plain_16);
}
@@ -110,38 +121,8 @@ void ST7789Display::setTextSize(int sz) {
}
}
void ST7789Display::setColor(Color c) {
switch (c) {
case DisplayDriver::DARK :
_color = ST77XX_BLACK;
display.setColor(OLEDDISPLAY_COLOR::BLACK);
break;
#if 0
case DisplayDriver::LIGHT :
_color = ST77XX_WHITE;
break;
case DisplayDriver::RED :
_color = ST77XX_RED;
break;
case DisplayDriver::GREEN :
_color = ST77XX_GREEN;
break;
case DisplayDriver::BLUE :
_color = ST77XX_BLUE;
break;
case DisplayDriver::YELLOW :
_color = ST77XX_YELLOW;
break;
case DisplayDriver::ORANGE :
_color = ST77XX_ORANGE;
break;
#endif
default:
_color = ST77XX_WHITE;
display.setColor(OLEDDISPLAY_COLOR::WHITE);
break;
}
display.setRGB(_color);
void ST7789Display::setColor(ColorVal c) {
display.setRGB(_color = c);
}
void ST7789Display::setCursor(int x, int y) {
+2 -2
View File
@@ -27,9 +27,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void printWordWrap(const char* str, int max_width) override;
+16 -31
View File
@@ -23,6 +23,17 @@ bool ST7789LCDDisplay::i2c_probe(TwoWire& wire, uint8_t addr) {
return true;
}
// Color scheme
ColorVal UIColor::window_bkg = ST77XX_WHITE;
ColorVal UIColor::title_bkg = ST77XX_BLUE;
ColorVal UIColor::title_txt = ST77XX_WHITE;
ColorVal UIColor::primary_txt = ST77XX_BLACK;
ColorVal UIColor::secondary_txt = (18 << 11) | (36 << 5) | 18; // mid-gray
ColorVal UIColor::warning_txt = ST77XX_ORANGE;
ColorVal UIColor::popup_bkg = ST77XX_CYAN;
ColorVal UIColor::popup_txt = ST77XX_BLACK;
ColorVal UIColor::corp_blue = 0x001A;
bool ST7789LCDDisplay::begin() {
if (!_isOn) {
if (_peripher_power) _peripher_power->claim();
@@ -78,9 +89,9 @@ void ST7789LCDDisplay::clear() {
display.fillScreen(ST77XX_BLACK);
}
void ST7789LCDDisplay::startFrame(Color bkg) {
display.fillScreen(ST77XX_BLACK);
display.setTextColor(ST77XX_WHITE);
void ST7789LCDDisplay::startFrame(ColorVal bkg) {
display.fillScreen(bkg);
display.setTextColor(_color = UIColor::primary_txt);
display.setTextSize(1 * DISPLAY_SCALE_X); // This one affects size of Please wait... message
display.cp437(true); // Use full 256 char 'Code Page 437' font
}
@@ -89,34 +100,8 @@ void ST7789LCDDisplay::setTextSize(int sz) {
display.setTextSize(sz * DISPLAY_SCALE_X);
}
void ST7789LCDDisplay::setColor(Color c) {
switch (c) {
case DisplayDriver::DARK :
_color = ST77XX_BLACK;
break;
case DisplayDriver::LIGHT :
_color = ST77XX_WHITE;
break;
case DisplayDriver::RED :
_color = ST77XX_RED;
break;
case DisplayDriver::GREEN :
_color = ST77XX_GREEN;
break;
case DisplayDriver::BLUE :
_color = ST77XX_BLUE;
break;
case DisplayDriver::YELLOW :
_color = ST77XX_YELLOW;
break;
case DisplayDriver::ORANGE :
_color = ST77XX_ORANGE;
break;
default:
_color = ST77XX_WHITE;
break;
}
display.setTextColor(_color);
void ST7789LCDDisplay::setColor(ColorVal c) {
display.setTextColor(_color = c);
}
void ST7789LCDDisplay::setCursor(int x, int y) {
+2 -2
View File
@@ -47,9 +47,9 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setColor(ColorVal c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void fillRect(int x, int y, int w, int h) override;
+12
View File
@@ -0,0 +1,12 @@
#include "U8g2Display.h"
// Color scheme
ColorVal UIColor::window_bkg = 0;
ColorVal UIColor::title_bkg = 1;
ColorVal UIColor::title_txt = 0;
ColorVal UIColor::primary_txt = 1;
ColorVal UIColor::secondary_txt = 1;
ColorVal UIColor::warning_txt = 1;
ColorVal UIColor::popup_bkg = 1;
ColorVal UIColor::popup_txt = 0;
ColorVal UIColor::corp_blue = 1;
+6 -10
View File
@@ -72,10 +72,10 @@ public:
_u8g2.sendBuffer();
}
void startFrame(Color bkg = DARK) override {
_u8g2.clearBuffer();
_drawColor = 1;
_u8g2.setDrawColor(1);
void startFrame(ColorVal bkg = UIColor::window_bkg) override {
_u8g2.clearBuffer(); // TODO: apply 'bkg' color
_drawColor = UIColor::primary_txt;
_u8g2.setDrawColor(_drawColor);
applyFont(1);
}
@@ -83,8 +83,8 @@ public:
applyFont(sz);
}
void setColor(Color c) override {
_drawColor = (c != DARK) ? 1 : 0;
void setColor(ColorVal c) override {
_drawColor = c;
_u8g2.setDrawColor(_drawColor);
}
@@ -94,22 +94,18 @@ public:
}
void print(const char* str) override {
_u8g2.setDrawColor(_drawColor);
_u8g2.drawStr(_cursorX, _cursorY, str);
}
void fillRect(int x, int y, int w, int h) override {
_u8g2.setDrawColor(_drawColor);
_u8g2.drawBox(x, y, w, h);
}
void drawRect(int x, int y, int w, int h) override {
_u8g2.setDrawColor(_drawColor);
_u8g2.drawFrame(x, y, w, h);
}
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override {
_u8g2.setDrawColor(1);
_u8g2.drawXBM(x, y, w, h, bits);
}
+1 -1
View File
@@ -23,7 +23,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<TechoCardBoard.cpp>
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<helpers/ui/U8g2Display.h>
+<helpers/ui/U8g2Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../variants/lilygo_techo_card>
lib_deps =