refactor(ui): upstream's UIColor palette in place of the DARK/LIGHT enum

- DisplayDriver takes ColorVal; each driver's .cpp defines the UIColor roles
  (window_bkg, primary_txt, ...) in its own values. ui-new draws in two:
  window_bkg and primary_txt. OLED and e-ink look as before (sim screens
  pixel-identical).
- E213, E290, LGFX, Null, ST7735, ST7789LCD, U8g2 taken whole from upstream
  (with them the rewritten ST7735 driver and the Heltec V4 R8 TFT display).
- SH1106, SSD1306, ST7789, EinkGfxDisplay and the sim drivers converted.
- ui-orig, ui-tiny, simple_* get upstream's colour roles; the repeater's UI
  taken from upstream (its power-off screen).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-15 14:42:04 +02:00
co-authored by Claude Opus 5.5
parent 83ba0161da
commit 8c20914689
69 changed files with 1062 additions and 530 deletions
+1 -1
View File
@@ -230,7 +230,7 @@ void setup() {
#endif
// Three dots mid-screen: no words, so no orientation (the settings aren't read yet).
const int dot = disp->width() >= 240 ? 6 : 3;
disp->setColor(DisplayDriver::LIGHT);
disp->setColor(UIColor::primary_txt);
for (int i = -1; i <= 1; i++)
disp->fillRect(disp->width() / 2 + i * 3 * dot - dot / 2, disp->height() / 2 - dot / 2, dot, dot);
disp->endFrame();
@@ -172,7 +172,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_login_kb) return kb().render(display);
AdminSession::State st = S().state();
@@ -31,7 +31,7 @@ public:
// cycles, Back saves) instead of a screen of its own with typed hints.
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Auto-advert");
int sel = 0, scroll = 0;
drawList(display, 1, sel, scroll, [&](int, int y, bool is_sel, int reserve) {
@@ -35,7 +35,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Battery curve");
const int mv = _task->getBattMilliVolts();
const bool custom = _prefs && battery::validCurve(_prefs->batt_curve_mv);
+3 -3
View File
@@ -84,7 +84,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_kb_row >= 0) {
return _kb->render(display);
@@ -103,7 +103,7 @@ public:
if (sent > 0) {
display.setCursor(display.width() - cw - 1, 0);
display.print(cbuf);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
int n = botcfg::rowCount(_tab);
@@ -138,7 +138,7 @@ public:
}
int mqr = info::listRow(display, y, r.label, shown, sel, reserve);
if (mqr > 0) mq_delay = mqr;
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
});
return 2000;
}
@@ -29,7 +29,7 @@ inline void draw(DisplayDriver& d, int x, int y, int w, const struct tm& t, uint
static const char* const INITIALS[] = { "M", "T", "W", "T", "F", "S", "S" };
const int lh = d.getLineHeight(), step = tight ? lh : lh + 2, cw = w / 7;
const int x0 = x + (w - 7 * cw) / 2;
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
for (int c = 0; c < 7; c++) d.drawTextCentered(x0 + c * cw + cw / 2, y, (tight ? INITIALS : NAMES)[c]);
info::rule(d, x0, y + (tight ? lh - 1 : lh + 1), 7 * cw);
const int top = y + (tight ? lh + 1 : step + 3), col0 = firstCol(t), n = daysIn(t.tm_year, t.tm_mon);
@@ -40,17 +40,17 @@ inline void draw(DisplayDriver& d, int x, int y, int w, const struct tm& t, uint
if (today && day == t.tm_mday) {
if (tight) d.fillSoftRect(cx, cy - 1, cw, lh);
else d.fillSoftRect(cx + 1, cy - 1, cw - 2, lh + 2);
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
d.drawTextCentered(cx + cw / 2, cy, buf);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
} else {
d.drawTextCentered(cx + cw / 2, cy, buf);
}
if (marked & (1UL << (day - 1))) { // under the number, in the gap below it
const int uw = d.getTextWidth(buf);
d.setColor(today && day == t.tm_mday ? DisplayDriver::DARK : DisplayDriver::LIGHT);
d.setColor(today && day == t.tm_mday ? UIColor::window_bkg : UIColor::primary_txt);
d.fillRect(cx + (cw - uw) / 2, cy + (tight ? lh - 2 : lh), uw, d.sepH());
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
}
}
}
@@ -111,7 +111,7 @@ public:
int render(DisplayDriver& display) {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_kb_active) return kb().render(display);
const int top = display.listStart();
@@ -124,7 +124,7 @@ public:
int y = top + i * step;
display.drawSelectionRow(0, y - 1, display.width(), step - 1, i == _type_sel);
display.drawTextEllipsized(2, y, display.width() - 4, TYPE_LABELS[i]);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
return 1000;
}
@@ -139,7 +139,7 @@ public:
display.drawSelectionRow(0, y - 1, display.width(), step - 1, sel);
int r = info::valueRow(display, y, "Topic", _topic[0] ? _topic : "(none)", sel, 0);
if (r > 0) mq_delay = r;
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
return (mq_delay > 0 && mq_delay < 1000) ? mq_delay : 1000;
}
@@ -157,7 +157,7 @@ public:
: info::valueRow(display, y, _hex_mode ? "Secret (hex)" : "Secret (phrase)",
_secret_text[0] ? _secret_text : "(none)", sel, 0);
if (r > 0) mq_delay = r;
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
return (mq_delay > 0 && mq_delay < 1000) ? mq_delay : 1000;
}
@@ -133,17 +133,17 @@ class ClockToolsScreen : public UIScreen {
for (int k = 0; buf[k]; k++) {
int cx = valx + k * cw;
if (k == char_idx) {
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
d.fillSoftRect(cx, y - 1, cw, d.getLineHeight() + 1);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
} else {
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
}
char one[2] = { buf[k], '\0' };
d.setCursor(cx, y);
d.print(one);
}
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
}
// ── Sub-renders ───────────────────────────────────────────────────────────
@@ -416,7 +416,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
switch (_view) {
case V_ALARM: return renderAlarm(display);
case V_TIMER: return renderTimer(display);
@@ -31,7 +31,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Compass");
const int cx = display.width() / 2;
@@ -26,7 +26,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
int item_h = display.lineStep();
int start_y = display.listStart();
int val_x = display.valCol();
@@ -43,7 +43,7 @@ public:
display.setCursor(val_x, y);
uint8_t f = _prefs->dashboard_fields[i];
display.print(telemetry::COMPACT[f < telemetry::COUNT ? f : telemetry::NONE]);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
return 500;
}
@@ -76,16 +76,16 @@ struct DigitEditor {
for (int k = 0; buf[k]; k++) {
int cx = x + k * cw;
if (k == char_idx) {
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
d.fillSoftRect(cx, y - 1, cw, d.getLineHeight() + 1);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
} else {
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
}
char one[2] = { buf[k], '\0' };
d.setCursor(cx, y);
d.print(one);
}
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
}
};
@@ -13,7 +13,7 @@ public:
int render(DisplayDriver& display) override {
display.setBrightness(4);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillRect(0, 0, display.width(), display.height());
return 1000;
}
@@ -134,9 +134,9 @@ struct FullscreenMsgView {
const int startY = header_h + 2;
const int visible = (display.height() - startY - lineH) / lineH;
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillRect(0, 0, display.width(), header_h);
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
display.drawTextEllipsized(2, 1, display.width() - 4, sender);
if (to_nick[0]) {
char trans_nick[32], to_label[36];
@@ -144,7 +144,7 @@ struct FullscreenMsgView {
snprintf(to_label, sizeof(to_label), "To: %s", trans_nick);
display.drawTextEllipsized(2, lineH + 3, display.width() - 4, to_label);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.translateUTF8ToBlocks(s_wrap_trans, body, sizeof(s_wrap_trans));
int lcount = wrapLines(display, s_wrap_trans, max_px, s_wrap_lines, 12);
+2 -2
View File
@@ -110,7 +110,7 @@ public:
int render(DisplayDriver& display) override {
buildItems();
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "GPIO");
bool any_live = false;
@@ -128,7 +128,7 @@ public:
} else { // indented: reads as GPIOn's sub-row
info::switchRow(display, y, " State", gpioModeOf(it.pin) == 3, sel, reserve);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
});
return any_live ? 500 : 2000; // faster refresh only while a row needs a live reading
}
+29 -29
View File
@@ -387,8 +387,8 @@ class HomeScreen : public UIScreen {
for (int i = 0; i < n; i++, y += step) {
const QRow& r = rows[i];
const bool sel = i == _quick_sel;
d.setColor(DisplayDriver::LIGHT);
if (sel) { d.fillSoftRect(m - 3, y - 1, W - 2 * m + 6, lh + 1); d.setColor(DisplayDriver::DARK); }
d.setColor(UIColor::primary_txt);
if (sel) { d.fillSoftRect(m - 3, y - 1, W - 2 * m + 6, lh + 1); d.setColor(UIColor::window_bkg); }
switch (r.kind) {
case Q_SWITCH: info::switchRow(d, y, r.label, r.n != 0, sel, reserve, m); break;
case Q_BAR: {
@@ -424,7 +424,7 @@ class HomeScreen : public UIScreen {
if (q > 0) mq = q;
}
}
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
}
return mq;
}
@@ -545,7 +545,7 @@ class HomeScreen : public UIScreen {
uint8_t mode = battery::mode(_node_prefs ? _node_prefs->batt_display_mode : 0);
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
const int lh = display.getLineHeight();
const int cw = display.getCharWidth();
@@ -726,7 +726,7 @@ public:
if (!init) return false;
// North marker — top-right, the same mini-icon as the full Trail map.
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
{
const int ns = miniIconScale(display);
miniIconDrawTop(display, ax + aw - ICON_MAP_NORTH.w * ns - 1, ay + 1, ICON_MAP_NORTH);
@@ -771,7 +771,7 @@ public:
// status line below instead (see statusDistanceKm() / render()), so this
// corner is free for it.
{
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
int ty = ay + ah - display.getLineHeight();
static const float M_PER_1E6 = 0.11132f; // metres per 1e-6° lat
float ppm = scale / M_PER_1E6; // pixels per metre
@@ -835,7 +835,7 @@ public:
const int rows_h = tall ? 4 * (lh + lh / 2) : 0;
const int ph = H - top - rows_h;
const int pw = tall ? W : wide ? (ph < W * 3 / 5 ? ph : W * 3 / 5) : W / 2; // map panel
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.drawSoftRect(0, top, pw, ph);
if (!drawMapPreview(d, 2, top + 2, pw - 4, ph - 4)) {
// An empty sheet: a sparse dot grid with the reason over it.
@@ -843,9 +843,9 @@ public:
for (int gx = 4; gx < pw - 2; gx += 6 * s) d.fillRect(gx, gy, s, s);
const char* why = "No fix";
const int tw = d.getTextWidth(why), tx = (pw - tw) / 2, ty = top + (ph - lh) / 2;
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
d.fillRect(tx - 2, ty - 1, tw + 4, lh + 2);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.setCursor(tx, ty);
d.print(why);
}
@@ -995,7 +995,7 @@ public:
const bool h12 = _node_prefs && _node_prefs->clock_12h;
const bool show_sec = !Features::IS_EINK && (!_node_prefs || !_node_prefs->clock_hide_seconds);
const int W = d.width(), H = d.height();
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.setTextSize(1);
const int lh = d.getLineHeight();
@@ -1066,7 +1066,7 @@ public:
// seconds (UITask::lockHintShown); e-ink keeps it up, it has no glance.
void drawLockPage(DisplayDriver& d) {
const int W = d.width(), H = d.height();
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.setTextSize(1);
const int lh = d.getLineHeight(), top = statusBarH(d) + 3;
const bool hint = Features::IS_EINK || _task->lockHintShown();
@@ -1145,9 +1145,9 @@ public:
if (!pill[0]) return;
const int pw = d.getTextWidth(pill) + 6;
d.fillSoftRect((W - pw) / 2, pill_y, pw, lh + 3);
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
d.drawTextCentered(W / 2, pill_y + 2, pill);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
}
// Under the lock clock on a tall or a 4.2" screen, between y and bottom: the month,
@@ -1195,7 +1195,7 @@ public:
const int mid_x = W / 2, mid_y = top + H / 2;
const bool roomy = H / 2 >= 7 * lh; // three lines and a chart a tile
StatusScreen* st = (StatusScreen*)_task->statusScreen();
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
info::vrule(d, mid_x, top, H);
info::rule(d, 0, mid_y, W);
// The tile's box, inside the rules.
@@ -1312,12 +1312,12 @@ public:
// Title bar displaying node name (except on lock screen), status icons and battery.
// Hidden on fullscreen pages (CLOCK).
if (_page != CLOCK) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
// The lock page has nothing on the left of the bar (its clock sits
// below it), so the status icons may use the whole row.
const int lock_reserve = _page == LOCK ? 0 : -1;
int rightEdge = renderBatteryIndicator(display, _task->getBattMilliVolts(), lock_reserve);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_page != LOCK) {
const int bar_ty = (statusBarH(display) - lh) / 2; // text centred in a tall bar (STATUS_ICON_SCALE)
@@ -1382,24 +1382,24 @@ public:
for (int i = 0; i < n; i++)
if (order[i] == _slide_from) { pill_x = x + pitch * i + (int)((pill_x - x - pitch * i) * slide + 0.5f); break; }
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillSoftRect(pill_x - pw / 2, dots_y - pg_half - pad, pw, pg_half * 2 + 1 + 2 * pad);
for (int i = 0; i < n; i++) {
const MiniIcon* ic = pageIcon(order[i]);
const int d2 = 2 * (x - pill_x < 0 ? pill_x - x : x - pill_x);
if (d2 <= pw - icon_w) display.setColor(DisplayDriver::DARK); // inside the pill
if (d2 <= pw - icon_w) display.setColor(UIColor::window_bkg); // inside the pill
else if (d2 < pw + icon_w) { x += pitch; continue; } // half under the gliding pill
else display.setColor(DisplayDriver::LIGHT);
else display.setColor(UIColor::primary_txt);
if (ic) miniIconDrawCenteredScaled(display, x, dots_y, *ic, s);
x += pitch;
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
if (_page == HomePage::CLOCK) {
uint32_t unix_ts = _rtc->getCurrentTime();
if (unix_ts < 1000000000UL) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
int mid_y = display.height() / 2 - step;
display.drawTextCentered(display.width() / 2, mid_y, "! No time sync");
@@ -1413,7 +1413,7 @@ public:
} else if (_page == HomePage::STATUS) {
drawStatusTiles(display, content_y);
} else if (isQuickPage(_page) && !(_page == HomePage::SHUTDOWN && _shutdown_init)) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
QRow rows[QUICK_MAX];
const int n = buildQuick(_page, rows);
@@ -1427,7 +1427,7 @@ public:
// landscape → 3×2, portrait → 2×3. The selected card is filled.
// No title — node name + battery (top bar) and the page-dots indicator above
// serve as the page identity.
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
const int cols = favCols(display);
@@ -1451,8 +1451,8 @@ public:
// Each slot a card: a soft frame round a pinned one, a dotted outline
// round a free one, filled while selected.
const int tx = cx + 1, ty = cy, tw = cell_w - 2, th = cell_h - 2;
display.setColor(DisplayDriver::LIGHT);
if (sel) { display.fillSoftRect(tx, ty, tw, th); display.setColor(DisplayDriver::DARK); }
display.setColor(UIColor::primary_txt);
if (sel) { display.fillSoftRect(tx, ty, tw, th); display.setColor(UIColor::window_bkg); }
else if (prefix) display.drawSoftRect(tx, ty, tw, th);
else {
const int t = display.sepH(); // dot size: 2px on a doubled panel
@@ -1533,7 +1533,7 @@ public:
// the newest message under the name, how long ago and how far along
// the bottom.
if (th >= 6 * line_h && display.width() >= 40 * display.getCharWidth()) {
display.setColor(sel ? DisplayDriver::DARK : DisplayDriver::LIGHT);
display.setColor(sel ? UIColor::window_bkg : UIColor::primary_txt);
const int by = ty + th - line_h - 3; // the bottom line
const uint32_t now = rtc_clock.getCurrentTime();
char buf[16];
@@ -1564,7 +1564,7 @@ public:
for (int k = 0; k < n; k++) display.drawTextEllipsized(tx + 3, my + k * line_h, tw - 6, lines[k]);
}
} else if (tall) {
display.setColor(sel ? DisplayDriver::DARK : DisplayDriver::LIGHT); // the badge leaves its own
display.setColor(sel ? UIColor::window_bkg : UIColor::primary_txt); // the badge leaves its own
const int s = miniIconScale(display), gap = line_h / 3;
int y = name_y + line_h + gap;
auto detail = [&](const MiniIcon& ic, const char* text) {
@@ -1590,7 +1590,7 @@ public:
} else {
display.drawTextCentered(tx + tw / 2, ty + (th - line_h) / 2, "+");
}
if (sel) display.setColor(DisplayDriver::LIGHT);
if (sel) display.setColor(UIColor::primary_txt);
}
// Persist any pruned slots once, outside the loop — a render pass can clear
// several gone tiles but only one flash write is needed. Self-healing: once
@@ -1598,7 +1598,7 @@ public:
if (fav_changed) the_mesh.savePrefs();
if (_tile_menu.active) _tile_menu.render(display);
} else if (_page == HomePage::SHUTDOWN) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, content_y + step, "hibernating..."); // the panel's Hibernate row
}
+7 -7
View File
@@ -148,9 +148,9 @@ inline void rose(DisplayDriver& d, int cx, int cy, int r, int deg) {
d.fillRect(cx - s / 2, cy + r - t, s, t); // S
d.fillRect(cx + r - t, cy - s / 2, t, s); // E
d.fillRect(cx - r, cy - s / 2, t, s); // W
d.setColor(DisplayDriver::DARK); // N, on a gap in the ring
d.setColor(UIColor::window_bkg); // N, on a gap in the ring
d.fillRect(cx - cw / 2 - 1, cy - r - lh / 2, cw + 2, lh);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.setCursor(cx - cw / 2, cy - r - lh / 2);
d.print("N");
if (deg >= 0) {
@@ -173,10 +173,10 @@ inline int chip(DisplayDriver& d, int x, int y, const char* t, bool filled = fal
const int w = chipW(d, t), h = d.getLineHeight() + 2;
if (filled) d.fillSoftRect(x, y, w, h);
else d.drawSoftRect(x, y, w, h);
if (filled) d.setColor(DisplayDriver::DARK);
if (filled) d.setColor(UIColor::window_bkg);
d.setCursor(x + 3, y + 1);
d.print(t);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
return x + w + 3;
}
@@ -203,7 +203,7 @@ inline int bigH(DisplayDriver& d) { return 2 * d.getLineHeight(); }
// the light bar).
inline int switchW(DisplayDriver& d) { return d.getTextWidth("Off"); }
inline void toggle(DisplayDriver& d, int x_right, int y, bool on, bool inv = false) {
d.setColor(inv ? DisplayDriver::DARK : DisplayDriver::LIGHT);
d.setColor(inv ? UIColor::window_bkg : UIColor::primary_txt);
d.drawTextRightAlign(x_right, y, on ? "On" : "Off");
}
@@ -323,9 +323,9 @@ inline void chart(DisplayDriver& d, int x, int y, int w, int h, const History<N>
const int ix = x + 2, iy = y + 2, iw = w - 4, ih = h - 4;
if (empty) { // nothing to draw yet: say so over the line
const int tw = d.getTextWidth("no data"), tx = x + (w - tw) / 2, ty = y + (h - lh) / 2;
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
d.fillRect(tx - 2, ty, tw + 4, lh);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.setCursor(tx, ty);
d.print("no data");
} else {
@@ -589,7 +589,7 @@ struct KeyboardWidget {
// Single UI font (misc-fixed 5x7) covers Latin/Greek/Cyrillic — the keyboard
// renders in it directly, no per-render font switching or headroom padding.
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
const int rows = gridRows();
const int cols = gridCols();
@@ -703,10 +703,10 @@ struct KeyboardWidget {
char one[5], one_t[8];
kbUtf8CharAt(buf + cursor_pos, 0, one);
display.translateUTF8ToBlocks(one_t, one, sizeof(one_t));
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
display.setCursor(bx, by);
display.print(one_t);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
} else {
display.fillRect(bx, by + lh - display.sepH(), cw - display.sepH(), display.sepH());
@@ -718,11 +718,11 @@ struct KeyboardWidget {
const int tw = display.getTextWidth(count), y = (prev_lines - 1) * lh;
if (count[0] == '-') { // over (a placeholder grew): inverted
display.fillRect(display.width() - tw - 2, y, tw + 2, lh);
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
}
display.setCursor(display.width() - tw - (count[0] == '-' ? 1 : 0), y);
display.print(count);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
} else if (!isPin()) {
// Bottom-right of the preview: what the field is, or near the limit how
// much room is left. Only when it clears the text on that line.
@@ -795,7 +795,7 @@ struct KeyboardWidget {
// instead of/alongside CardKB) still drive row/col/page as normal; it
// just won't be visible on this screen which cell is selected.
if (compact_ui) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (cursor_mode) {
display.drawTextCentered(display.width() / 2, chars_y, "<> char ^v word");
} else {
@@ -889,7 +889,7 @@ struct KeyboardWidget {
// ink colour is the one that shows against it.
if (i == 0 && caps_lock) display.fillRect(sx + 2, spec_y + cell_h - 3, spec_w - 5, display.sepH());
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
}
}
@@ -919,17 +919,17 @@ struct KeyboardWidget {
char shown[5]; kbApplyCapsUtf8(one, caps, shown, sizeof(shown));
int x = bx + i * seg_w;
if (i == accent_sel) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillSoftRect(x + 1, by + 1, seg_w - 1, bh - 2);
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
} else {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
int tw = display.getTextWidth(shown);
display.setCursor(x + (seg_w - tw) / 2, by + 1);
display.print(shown);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
// placeholder picker overlay (drawn on top of keyboard)
@@ -100,7 +100,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Live share");
int mq_delay = 0;
@@ -108,7 +108,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_picking) { int mq = renderPicker(display); return (mq > 0 && mq < 400) ? mq : 400; }
drawScreenHeader(display, "Locator");
@@ -499,10 +499,10 @@ class MessagesScreen : public UIScreen {
// Spans exactly [box_x, box_x+box_w) — the caller sizes/positions the bubble
// (see computeBubbleBox below), this just draws whatever box it's given.
static void drawHistRowFrame(DisplayDriver& d, int box_x, int box_w, int y, int bh, int lh, bool sel) {
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
if (sel) {
d.fillSoftRect(box_x, y, box_w, bh);
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
} else {
d.drawSoftRect(box_x, y, box_w, bh);
}
@@ -1076,7 +1076,7 @@ public:
const char* t = "New";
int tw = d.getTextWidth(t);
int tx = (w - tw) / 2, mid = y + lh / 2;
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.fillRect(1, mid, tx - 4, d.sepH());
d.fillRect(tx + tw + 3, mid, w - 1 - (tx + tw + 3), d.sepH());
d.setCursor(tx, y + 1);
@@ -1313,7 +1313,7 @@ public:
int render(DisplayDriver& display) override {
int mq_delay = 0; // >0 while a selected row's text is marquee-scrolling
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
// Channel Add/Edit form owns the screen while active.
if (_ch_view.active()) {
@@ -1358,7 +1358,7 @@ public:
if (badges[i] > 0)
display.drawUnreadBadge(display.width() - 1, y, badges[i], sel, overflow[i]);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
// Fold the popup's own suggested redraw delay into mq_delay -- otherwise
// a marquee inside it (see PopupMenu::render()) only ever advances at
// whatever slower cadence this phase's own return statement below picks,
@@ -1422,7 +1422,7 @@ public:
drawRowSelection(display, y, sel, reserve);
if (list_idx == _num_channels) { // the synthetic "Add" row
display.setCursor(2, y); display.print("+ Add channel");
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
return;
}
ChannelDetails ch;
@@ -1470,10 +1470,10 @@ public:
_dm_hist_sel < dm_count - 1,
_dm_hist_sel > 0);
if (e.outgoing) { // delivery marker in the (inverted) header bar
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
drawAckGlyph(display, 2 + display.getTextWidth(sender) + 3, 1,
_history.dmEffectiveStatus(e), e.attempt + 1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
// Fold the popup's own suggested redraw delay into mq_delay -- otherwise
// a marquee inside it (see PopupMenu::render()) only ever advances at
@@ -1669,7 +1669,7 @@ public:
if (div_y >= 0) drawNewDivider(display, div_y, display.width() - reserve, lh);
if (dm_count == 0) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.drawTextCentered(display.width()/2, display.height()/2, "No messages yet");
}
@@ -1717,10 +1717,10 @@ public:
// plus the distinct-echoing-repeater count as tiny digits (path_len's
// hop_count -- see markChannelRelayed/showPathDetail's "Relayed by").
if (strcmp(fsender, "Me") == 0 && _history.chAtPos(ring_pos).relay_status == ACK_OK) {
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
int relay_count = _history.chAtPos(ring_pos).path_len & 63;
drawAckGlyph(display, 2 + display.getTextWidth(fsender) + 3, 1, ACK_OK, 1, relay_count);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
// Fold the popup's own suggested redraw delay into mq_delay -- otherwise
// a marquee inside it (see PopupMenu::render()) only ever advances at
@@ -1858,7 +1858,7 @@ public:
if (div_y >= 0) drawNewDivider(display, div_y, display.width() - reserve, lh);
if (ch_hist_count == 0) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.drawTextCentered(display.width()/2, display.height()/2, "No messages yet");
}
@@ -162,7 +162,7 @@ public:
const int rw = right[0] ? display.getTextWidth(right) + display.getCharWidth() : 0;
display.drawTextEllipsized(2, y, display.width() - reserve - 4 - rw, left, sel);
if (right[0]) {
display.setColor(sel ? DisplayDriver::DARK : DisplayDriver::LIGHT);
display.setColor(sel ? UIColor::window_bkg : UIColor::primary_txt);
display.drawTextRightAlign(display.width() - reserve - 2, y, right);
}
});
@@ -894,7 +894,7 @@ class NearbyScreen : public UIScreen, protected NearbyModel {
void renderMap(DisplayDriver& d) {
const int W = d.width(), H = d.height(), lh = d.getLineHeight(), s = miniIconScale(d);
const int bar_y = H - lh - 1, ax = 1, ay = 1, aw = W - 2, ah = bar_y - 3;
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
int32_t tla = 0, tlo = 0;
const bool target = _task->activeTargetPos(tla, tlo);
int32_t mnla = 0, mxla = 0, mnlo = 0, mxlo = 0;
@@ -1048,7 +1048,7 @@ class NearbyScreen : public UIScreen, protected NearbyModel {
// matching the wrap-around LEFT/RIGHT cycle.
void drawFilterTabs(DisplayDriver& display) {
tabbar::draw(display, filterLabels(), F_COUNT, _filter, display.menuHintWidth());
display.drawContextMenuHint(DisplayDriver::LIGHT, ctxMenuOpen()); // Nodes list has a Hold-Enter menu
display.drawContextMenuHint(UIColor::primary_txt, ctxMenuOpen()); // Nodes list has a Hold-Enter menu
}
public:
@@ -1159,7 +1159,7 @@ public:
const bool arrows = _source == SRC_STORED && _sort != SORT_TIME;
int dist_col = lw - display.getCharWidth() * (arrows ? 9 : 7);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
const char* flt = (_filter != F_ALL) ? filterLabel(_filter) : nullptr;
if (_source == SRC_SCAN) {
char title[28];
@@ -1227,7 +1227,7 @@ public:
int mqr = display.drawTextEllipsized(tx, y, dist_col - tx - 2, filt, sel);
if (sel && mqr > 0) mq_delay = mqr;
display.setColor(sel ? DisplayDriver::DARK : DisplayDriver::LIGHT);
display.setColor(sel ? UIColor::window_bkg : UIColor::primary_txt);
char right[10];
if (_source == SRC_SCAN) { // live scan: how well we hear it, as bars
drawSignalBars(display, lw - reserve - 2, y, e.snr_x4);
@@ -1249,7 +1249,7 @@ public:
}, lw);
if (split && _sel < _count) {
const int top = display.listStart();
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillRect(lw + 2, top, display.sepH(), display.height() - top);
drawStoredFields(display, _entries[_sel], lw + 2 + display.sepH() + 2, top,
display.width() - lw - 4 - display.sepH(), display.height());
+5 -5
View File
@@ -179,14 +179,14 @@ struct PopupMenu {
int idx = _scroll + i;
int py = list_y + i * item_h + 1;
if (idx == _sel) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
// Stops short of the scroll-indicator gutter, like every other list's
// selection bar (e.g. drawList's row width - reserve) — otherwise the
// bar paints over the indicator's column instead of framing it.
display.fillSoftRect(bx + 2, py - 1, bw - 4 - arrow_w, item_h);
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
} else {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
// Return value not needed here: this popup already redraws every 50ms
// (below), faster than any marquee step, so the animation is already smooth.
@@ -196,14 +196,14 @@ struct PopupMenu {
else
display.drawTextEllipsized(bx + pad, py, text_w, _items[idx], idx == _sel);
if (_has_checkboxes) drawCheckbox(display, bx + bw - arrow_w - pad - checkboxWidth(display), py, isChecked(idx));
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
// Same proportional track + thumb indicator the rest of the UI uses,
// anchored to the box's own right edge (a couple px clear of the border)
// instead of the screen edge since this box floats centred on screen.
drawScrollIndicator(display, bx + bw - 2, list_y, vis * item_h, _count, vis, _scroll);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
return 50;
}
@@ -149,7 +149,7 @@ public:
NodePrefs* p = _task->getNodePrefs();
buildItems(p);
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Repeater");
// Config only — live forwarding stats live on Status › Mesh.
@@ -165,9 +165,9 @@ public:
itemValue(item, p, val, sizeof(val));
info::listRow(display, y, itemLabel(item), val, sel, reserve);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
});
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_picker.menu.active) _picker.menu.render(display);
if (_scope_picker_active) _scope_menu.render(display);
return (_picker.menu.active || _editor.active() || _scope_picker_active) ? 50 : 500;
@@ -78,7 +78,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
const int lh = display.getLineHeight();
const int cw = display.getCharWidth();
@@ -117,21 +117,21 @@ public:
label[2] = '\0';
}
if (sel) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillSoftRect(cx, notes_y, cell_w - 1, cell_h);
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
} else {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.drawRect(cx, notes_y, cell_w - 1, cell_h);
}
display.setCursor(cx + (cell_w - cw * 2) / 2, notes_y + 3);
display.print(label);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
} else if (ni == _len && _len < MAX_NOTES) {
display.drawSelectionRow(cx, notes_y, cell_w - 1, cell_h, sel);
display.setCursor(cx + (cell_w - cw) / 2, notes_y + 3);
display.print("+");
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
}
@@ -168,7 +168,7 @@ public:
const int h = y1 - y0, W = _visible_notes * cell_w;
if (h < steps * 2) return;
const int bar_h = h / steps > 5 ? 5 : h / steps > 2 ? h / steps : 2;
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
for (int o = 0; o <= soundctl::OCT_MAX - soundctl::OCT_MIN; o++) {
const int y = y1 - (o * 7) * h / steps;
for (int x = 0; x < W; x += 3) d.fillRect(x, y, 1, 1);
@@ -618,7 +618,7 @@ class SettingsScreen : public UIScreen {
uint8_t _reset_stage = 0;
int renderScopeMgmt(DisplayDriver& display) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Scope", -1, 0, true, _scope_action_menu.active);
const ScopeList& sl = the_mesh.scopeList();
int total = sl.totalCount() + 1; // +1 synthetic "+ Add scope" row
@@ -632,7 +632,7 @@ class SettingsScreen : public UIScreen {
if ((uint8_t)idx == sl.default_idx)
display.drawTextRightAlign(display.width() - reserve - 2, y, "default");
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
});
if (_scope_action_menu.active) _scope_action_menu.render(display);
return _scope_action_menu.active ? 50 : 500;
@@ -692,7 +692,7 @@ public:
// Section header: disclosure mark + name
[&](int sec, int y, bool sel, int reserve, bool collapsed) {
_reserve = reserve;
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawRowSelection(display, y, sel, reserve);
drawDisclosure(display, 2, y, !collapsed);
display.setCursor(2 + 2 * display.getCharWidth(), y);
+6 -6
View File
@@ -63,9 +63,9 @@ namespace skyview {
info::circle(d, cx, cy, r); // the horizon
info::circle(d, cx, cy, r / 2, 2); // 45 degrees up, dotted
dot(d, cx, cy); // straight up
d.setColor(DisplayDriver::DARK); // north, on a gap in the rim
d.setColor(UIColor::window_bkg); // north, on a gap in the rim
d.fillRect(cx - cw / 2 - 1, cy - r - lh / 2, cw + 2, lh);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.setCursor(cx - cw / 2, cy - r - lh / 2);
d.print("N");
@@ -80,9 +80,9 @@ namespace skyview {
if (used) {
d.fillRect(x - s, y - s, 2 * s + 1, 2 * s + 1);
} else if (sat.snr >= 0) {
d.setColor(DisplayDriver::DARK); // clear inside, over a ring
d.setColor(UIColor::window_bkg); // clear inside, over a ring
d.fillRect(x - s, y - s, 2 * s + 1, 2 * s + 1);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.drawRect(x - s, y - s, 2 * s + 1, 2 * s + 1);
} else if (s > 1) { // in view, no signal: a small point
d.fillRect(x - 1, y - 1, 3, 3);
@@ -197,9 +197,9 @@ namespace skyview {
int h = snr < 0 ? 1 : (H * snr / 50 > 2 ? H * snr / 50 : 2);
if (g.used(sat) || h <= 2) d.fillRect(x, y1 - h + 1, bw, h);
else {
d.setColor(DisplayDriver::DARK); // over the dotted line
d.setColor(UIColor::window_bkg); // over the dotted line
d.fillRect(x, y1 - h + 1, bw, h);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
d.drawRect(x, y1 - h + 1, bw, h);
}
}
@@ -48,7 +48,7 @@ public:
const bool anim = !display.isEink();
const unsigned long t = anim ? millis() - _start : 100000UL; // e-ink: the settled frame
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
const int lh = display.getLineHeight();
const int cx = display.width() / 2;
@@ -355,13 +355,13 @@ private:
const int x0 = tall ? (W - px) / 2 : 0;
const int y0 = tall ? (H - px - lh / 2 - lines * lh) / 2 : (H - px) / 2;
const bool eink = d.isEink();
if (!eink) { d.setColor(DisplayDriver::LIGHT); d.fillRect(x0, y0, px, px); }
d.setColor(eink ? DisplayDriver::LIGHT : DisplayDriver::DARK);
if (!eink) { d.setColor(UIColor::primary_txt); d.fillRect(x0, y0, px, px); }
d.setColor(eink ? UIColor::primary_txt : UIColor::window_bkg);
const int q = x0 + siteqr::QUIET * s, r = y0 + siteqr::QUIET * s;
for (int y = 0; y < n; y++)
for (int x = 0; x < n; x++)
if (dark(x, y)) d.fillRect(q + x * s, r + y * s, s, s);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
int ty = tall ? y0 + px + lh / 2 : (H - lines * lh) / 2;
for (int i = 0; i < lines; i++) {
int w = d.getTextWidth(cap[i]);
@@ -434,7 +434,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_qr) { renderQr(display); return 1000; }
tabbar::draw(display, _labels, _count, _cur);
const int top = display.listStart(), bottom = display.height();
@@ -457,7 +457,7 @@ public:
if (rsv) drawScrollIndicatorPx(display, top, view, f.total_px, view, f.skipped_px);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_reset_menu.active) { _reset_menu.render(display); return 50; }
return next;
}
+8 -8
View File
@@ -61,21 +61,21 @@ inline bool endFrame(DisplayDriver& d) {
inline void drawPill(DisplayDriver& display, int x, int w, const char* label, bool active) {
int lh = display.getLineHeight();
if (active) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillSoftRect(x, 0, w, lh + 1);
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
} else {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
display.drawTextCentered(x + w / 2, 0, label);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
// Small solid triangle pointing left (dir < 0) or right, 3 px wide and 5
// tall (times sepH()), centred on row y_mid: "more tabs this way".
inline void drawEdgeArrow(DisplayDriver& display, int x, int y_mid, int dir) {
const int t = display.sepH();
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
for (int c = 0; c < 3; c++) {
int h = (dir < 0 ? c * 2 + 1 : 5 - c * 2) * t;
display.fillRect(x + c * t, y_mid - h / 2, t, h);
@@ -151,14 +151,14 @@ inline void draw(DisplayDriver& display, const char* const* labels, int count, i
Fit f = layout(0, false);
if (f.shown < count && f.left_free < arr + 1 && f.right_free < arr + 1) f = layout(arr + 2, false);
const int bh = display.headerH() - display.sepH(), y_mid = display.getLineHeight() / 2;
display.setColor(DisplayDriver::DARK);
display.setColor(UIColor::window_bkg);
display.fillRect(0, 0, f.left_free, bh);
display.fillRect(rx_limit - f.right_free, 0, f.right_free + right_reserve, bh);
if (f.shown < count) {
if (f.left_free >= arr + 1) drawEdgeArrow(display, 0, y_mid, -1);
if (f.right_free >= arr + 1) drawEdgeArrow(display, rx_limit - arr, y_mid, +1);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillRect(0, display.headerH() - display.sepH(), display.width(), display.sepH());
return;
}
@@ -175,7 +175,7 @@ inline void draw(DisplayDriver& display, const char* const* labels, int count, i
if (f.left_free >= arr + 1) drawEdgeArrow(display, 0, y_mid, -1);
if (f.right_free >= arr + 1) drawEdgeArrow(display, rx_limit - arr, y_mid, +1);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
display.fillRect(0, display.headerH() - display.sepH(), display.width(), display.sepH());
}
@@ -81,7 +81,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Tools");
const int cw = display.getCharWidth();
@@ -120,7 +120,7 @@ public:
int render(DisplayDriver& display) override {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
// Waypoint management UI owns the screen while active.
if (_wp.active()) return _wp.render(display);
+5 -5
View File
@@ -703,9 +703,9 @@ void UITask::renderAlertOverlay() {
k = 100 - (100 - k) * (100 - k) / 100;
}
const int y = -h + h * k / 100;
_display->setColor(DisplayDriver::DARK);
_display->setColor(UIColor::window_bkg);
_display->fillRect(0, y, W, h);
_display->setColor(DisplayDriver::LIGHT);
_display->setColor(UIColor::primary_txt);
_display->drawRect(0, y, W, h);
for (int i = 0; i < nl; i++)
_display->drawTextCentered(W / 2, y + pad + i * lh, s_wrap_lines[i]);
@@ -720,9 +720,9 @@ void UITask::renderMsgBadge() {
DisplayDriver& d = *_display;
const int s = miniIconScale(d), h = d.headerH() - d.sepH(), w = mailCountWidth(d, _alert_count);
const int x = d.width() - w - 2 * s;
d.setColor(DisplayDriver::DARK);
d.setColor(UIColor::window_bkg);
d.fillRect(x - 2 * s, 0, w + 4 * s, h);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
if (msgBadgeLit()) drawMailCount(d, x, 0, h, _alert_count);
}
@@ -1488,7 +1488,7 @@ void UITask::loop() {
if (_display != NULL) {
_display->startFrame();
_display->setTextSize(1);
_display->setColor(DisplayDriver::LIGHT);
_display->setColor(UIColor::primary_txt);
int mid = _display->height() / 2;
int step = _display->lineStep();
_display->drawTextCentered(_display->width() / 2, mid - step, "Low Battery");
@@ -140,7 +140,7 @@ class WaypointsView {
}
void renderAddForm(DisplayDriver& display) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Add waypoint");
const int top = display.listStart();
const int step = display.lineStep();
@@ -169,14 +169,14 @@ class WaypointsView {
else snprintf(val, sizeof(val), "%s", _add_label[0] ? _add_label : "(auto)");
info::valueRow(display, y, label, val, sel, 0);
}
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
}
}
// GPS-averaging progress screen. Sampling itself happens in poll(); this only
// reports remaining time and the running sample count.
void renderAvg(DisplayDriver& display) {
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
drawScreenHeader(display, "Averaging GPS");
const int top = display.listStart();
const int step = display.lineStep();
@@ -192,7 +192,7 @@ class WaypointsView {
// keep a marquee animation going (see DisplayDriver::drawTextEllipsized).
int renderWpList(DisplayDriver& display) {
int mq_delay = 0;
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
char title[24];
snprintf(title, sizeof(title), "Waypoints %d/%d",
_task->waypoints().count(), WaypointStore::CAPACITY);
@@ -207,7 +207,7 @@ class WaypointsView {
if (row == n) { // the synthetic "Add" row
display.setCursor(2, y); display.print("+ Add by coords");
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
return;
}
@@ -223,7 +223,7 @@ class WaypointsView {
int mqr = display.drawTextEllipsized(2, y, display.width() - 2 - bw - reserve, nm, sel);
if (sel && mqr > 0) mq_delay = mqr;
if (dist[0]) { display.setCursor(display.width() - bw + 1 - reserve, y); display.print(dist); }
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
});
return mq_delay;
}
@@ -337,7 +337,7 @@ public:
// Only called while active().
int render(DisplayDriver& display) {
display.setTextSize(1);
display.setColor(DisplayDriver::LIGHT);
display.setColor(UIColor::primary_txt);
if (_kb_active) return _task->keyboard().render(display); // keyboard owns the screen
if (_mode == ADD) { renderAddForm(display); return 1000; }
if (_mode == AVG) { renderAvg(display); return display.isEink() ? 1000 : 300; }
+7 -7
View File
@@ -1486,7 +1486,7 @@ inline void drawScrollIndicatorPx(DisplayDriver& d, int right_x, int top_y, int
if (thumb_h > track_h) thumb_h = track_h;
const int thumb_y = top_y + (int)((long)(track_h - thumb_h) * scroll_px / span);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
for (int y = top_y; y < top_y + track_h; y += 2)
if (y < thumb_y - 1 || y > thumb_y + thumb_h) d.fillRect(mid, y, 1, 1);
d.fillSoftRect(x, thumb_y, bar_w, thumb_h);
@@ -1573,7 +1573,7 @@ inline int drawLoadingDots(DisplayDriver& d, int cx, int y_bottom) {
const int dot = 3 * s, pitch = 9 * s, lift_max = 3 * s;
const bool anim = !d.isEink();
const unsigned long t = millis();
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
for (int i = 0; i < 3; i++) {
int lift = 0;
if (anim) {
@@ -1643,7 +1643,7 @@ inline void drawPageDots(DisplayDriver& d, int x_right, int cy, int page, int pa
inline void drawScreenHeader(DisplayDriver& d, const char* title, int page = -1, int pages = 0,
bool menu_hint = false, bool menu_open = false) {
const int s = miniIconScale(d);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
const int hint = menu_hint ? d.menuHintWidth() : 0;
const int dots = pages > 1 ? pageDotsWidth(d, pages) + 3 * s : 0;
const int reserve = hint + dots;
@@ -1660,7 +1660,7 @@ inline void drawScreenHeader(DisplayDriver& d, const char* title, int page = -1,
}
d.fillRect(0, d.headerH() - d.sepH(), d.width(), d.sepH());
if (pages > 1) drawPageDots(d, d.width() - hint - s, (d.headerH() - d.sepH()) / 2, page, pages);
if (menu_hint) d.drawContextMenuHint(DisplayDriver::LIGHT, menu_open);
if (menu_hint) d.drawContextMenuHint(UIColor::primary_txt, menu_open);
}
// An accordion section's disclosure mark, one character wide: a triangle
@@ -1676,11 +1676,11 @@ inline void drawDisclosure(DisplayDriver& d, int x, int y, bool open) {
inline int buttonWidth(DisplayDriver& d, const char* label) { return d.getTextWidth(label) + 6; }
inline int drawButton(DisplayDriver& d, int x, int y, const char* label, bool sel) {
const int w = buttonWidth(d, label), h = d.getLineHeight();
d.setColor(DisplayDriver::LIGHT);
if (sel) { d.fillSoftRect(x, y, w, h); d.setColor(DisplayDriver::DARK); }
d.setColor(UIColor::primary_txt);
if (sel) { d.fillSoftRect(x, y, w, h); d.setColor(UIColor::window_bkg); }
else d.drawSoftRect(x, y, w, h);
d.setCursor(x + 3, y);
d.print(label);
d.setColor(DisplayDriver::LIGHT);
d.setColor(UIColor::primary_txt);
return w;
}
+13 -14
View File
@@ -169,7 +169,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);
@@ -190,7 +190,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;
@@ -199,30 +199,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);
@@ -231,7 +230,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
@@ -239,7 +238,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);
@@ -250,14 +249,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
@@ -57,24 +57,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);
}
@@ -164,7 +164,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);
@@ -181,19 +181,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];
@@ -217,7 +217,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);
@@ -239,14 +239,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->isBluetoothEnabled() ? 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
@@ -265,9 +265,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()) {
@@ -275,6 +277,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",
@@ -350,8 +353,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
);
@@ -362,7 +367,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...");
@@ -694,9 +699,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
+53 -27
View File
@@ -1,4 +1,5 @@
#include "UITask.h"
#include "target.h"
#include <Arduino.h>
#include <helpers/CommonCLI.h>
@@ -9,6 +10,8 @@
#define AUTO_OFF_MILLIS 20000 // 20 seconds
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
#define POWEROFF_DELAY 3000
// 'meshcore', 128x13px
static const uint8_t meshcore_logo [] PROGMEM = {
0x3c, 0x01, 0xe3, 0xff, 0xc7, 0xff, 0x8f, 0x03, 0x87, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe,
@@ -29,9 +32,14 @@ static const uint8_t meshcore_logo [] PROGMEM = {
void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version) {
_prevBtnState = HIGH;
_auto_off = millis() + AUTO_OFF_MILLIS;
_started_at = millis();
_node_prefs = node_prefs;
_display->turnOn();
#if defined(PIN_USER_BTN) && defined(DISPLAY_CLASS)
user_btn.begin();
#endif
// strip off dash and commit hash by changing dash to null terminator
// e.g: v1.2.3-abcdef -> v1.2.3
char *version = strdup(firmware_version);
@@ -41,47 +49,56 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi
}
// v1.2.3 (1 Jan 2025)
sprintf(_version_info, "%s (%s)", version, build_date);
snprintf(_version_info, sizeof(_version_info), "%s (%s)", version, build_date);
free(version);
}
void UITask::renderCurrScreen() {
char tmp[80];
if (millis() < BOOT_SCREEN_MILLIS) { // boot screen
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);
uint16_t websiteWidth = _display->getTextWidth(website);
_display->setCursor((_display->width() - websiteWidth) / 2, 22);
_display->print(website);
_display->drawTextCentered(_display->width() / 2, 22, website);
// version info
_display->setColor(DisplayDriver::LIGHT);
_display->setTextSize(1);
uint16_t versionWidth = _display->getTextWidth(_version_info);
_display->setCursor((_display->width() - versionWidth) / 2, 35);
_display->print(_version_info);
_display->drawTextCentered(_display->width() / 2, 35, _version_info);
// node type
const char* node_type = "< Repeater >";
uint16_t typeWidth = _display->getTextWidth(node_type);
_display->setCursor((_display->width() - typeWidth) / 2, 48);
_display->print(node_type);
} else { // home screen
// node name
_display->drawTextCentered(_display->width() / 2, 48, node_type);
} else if (_powering_off_at > 0) {
// meshcore logo
_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(UIColor::primary_txt);
_display->setTextSize(1);
_display->drawTextCentered(_display->width()/ 2, 22, website);
// Powering off
const char* poweroff_string = "Turning OFF";
uint16_t poffWidth = _display->getTextWidth(poweroff_string);
_display->setCursor((_display->width() - poffWidth) / 2, 48);
_display->drawTextCentered(_display->width()/2, 48, poweroff_string);
} 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);
@@ -93,21 +110,19 @@ void UITask::renderCurrScreen() {
}
void UITask::loop() {
#ifdef PIN_USER_BTN
if (millis() >= _next_read) {
int btnState = digitalRead(PIN_USER_BTN);
if (btnState != _prevBtnState) {
if (btnState == USER_BTN_PRESSED) { // pressed?
#if defined(PIN_USER_BTN) && defined(DISPLAY_CLASS)
int ev = user_btn.check();
if (ev == BUTTON_EVENT_CLICK) {
if (_display->isOn()) {
// TODO: any action ?
} else {
_display->turnOn();
}
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
}
_prevBtnState = btnState;
}
_next_read = millis() + 200; // 5 reads per second
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
_display->turnOn();
Serial.println("Powering Off");
_powering_off_at = millis() + POWEROFF_DELAY;
}
#endif
@@ -123,4 +138,15 @@ void UITask::loop() {
_display->turnOff();
}
}
if (_powering_off_at > 0) { // power off timer armed
#if defined(LED_PIN) && defined(LED_STATE_ON)
digitalWrite(LED_PIN, LED_STATE_ON); // switch on the led until poweroff
delay(1000);
digitalWrite(LED_PIN, !LED_STATE_ON); // off LED
#endif
if (millis() > _powering_off_at) {
_board->powerOff(); // should not return
}
}
}
+4 -1
View File
@@ -4,15 +4,18 @@
#include <helpers/CommonCLI.h>
class UITask {
mesh::MainBoard* _board;
DisplayDriver* _display;
unsigned long _next_read, _next_refresh, _auto_off;
int _prevBtnState;
NodePrefs* _node_prefs;
char _version_info[32];
unsigned long _powering_off_at = 0;
unsigned long _started_at = 0;
void renderCurrScreen();
public:
UITask(DisplayDriver& display) : _display(&display) { _next_read = _next_refresh = 0; }
UITask(mesh::MainBoard& board, DisplayDriver& display) : _board(&board), _display(&display) { _next_read = _next_refresh = 0; }
void begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version);
void loop();
+1 -1
View File
@@ -5,7 +5,7 @@
#ifdef DISPLAY_CLASS
#include "UITask.h"
static UITask ui_task(display);
static UITask ui_task(board, display);
#endif
#ifdef ETHERNET_ENABLED
+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);
+36 -29
View File
@@ -4,6 +4,15 @@
#include <string.h>
#include <Arduino.h>
using ColorVal = uint16_t;
// Colours by element type, in the display's own native values. Each display
// driver's .cpp defines the palette (mono panels: background 0, ink 1).
class UIColor {
public:
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:
@@ -39,8 +48,6 @@ protected:
void* _busy_pump_ctx = nullptr;
void callBusyPump() { if (_busy_pump_fn) _busy_pump_fn(_busy_pump_ctx); }
public:
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; }
@@ -50,9 +57,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
@@ -186,15 +193,15 @@ public:
}
// Common selection-row pattern: when sel, fills (x,y,w,h) with ink and sets
// colour to DARK so the next text render appears inverted; when not sel,
// just sets ink colour to LIGHT. Replaces the 5-line if/else copy-paste
// colour to window_bkg so the next text render appears inverted; when not sel,
// just sets ink colour to primary_txt. Replaces the 5-line if/else copy-paste
// present in every list-style screen.
void drawSelectionRow(int x, int y, int w, int h, bool sel) {
setColor(LIGHT);
setColor(UIColor::primary_txt);
if (sel) {
if (w > 2 && h > 2) fillSoftRect(x, y, w, h); // soft corners, like every box
else fillRect(x, y, w, h);
setColor(DARK);
setColor(UIColor::window_bkg);
}
}
@@ -217,11 +224,11 @@ public:
}
// A box floating over the screen (alert, popup, hint): clears a 1 px moat
// around it so lines of the view below stop short of the border instead of
// running into it, fills it dark and draws the soft border. Leaves ink LIGHT.
// running into it, fills it dark and draws the soft border. Leaves ink primary_txt.
void drawPanel(int x, int y, int w, int h) {
setColor(DARK);
setColor(UIColor::window_bkg);
fillRect(x - 1, y - 1, w + 2, h + 2);
setColor(LIGHT);
setColor(UIColor::primary_txt);
drawSoftRect(x, y, w, h);
}
@@ -262,15 +269,15 @@ public:
// too (paper capsule + ink digits) and stays visible. The four corners are
// knocked back to the surrounding colour for a rounded-capsule look.
// overflow: see fmtBadgeCount -- appends "+" for a ring-capped, understated count.
// Restores ink to LIGHT. Returns the pill width.
// Restores ink to primary_txt. Returns the pill width.
int drawUnreadBadge(int right_x, int y, int count, bool sel, bool overflow = false) {
char buf[5]; fmtBadgeCount(buf, count, overflow);
int pad = sepH() + 1;
int pw = getTextWidth(buf) - textWidthTrailingGap() + pad * 2;
int ph = getLineHeight();
int px = right_x - pw;
Color body = sel ? DARK : LIGHT;
Color ink = sel ? LIGHT : DARK;
ColorVal body = sel ? UIColor::window_bkg : UIColor::primary_txt;
ColorVal ink = sel ? UIColor::primary_txt : UIColor::window_bkg;
setColor(body);
fillRect(px, y, pw, ph);
setColor(ink);
@@ -280,56 +287,56 @@ public:
fillRect(px + pw - 1, y + ph - 1, 1, 1);
setCursor(px + pad, y);
print(buf);
setColor(LIGHT);
setColor(UIColor::primary_txt);
return pw;
}
// Inverted title bar: light background, dark ellipsized label, then the
// standard separator line. The label is UTF-8 translated by
// drawTextEllipsized. Leaves ink colour LIGHT for following content.
// drawTextEllipsized. Leaves ink colour primary_txt for following content.
// Pixel width the ≡ context-menu hint reserves at the header's right edge.
int menuHintWidth() const { return getCharWidth() + 3; }
// Small ≡ glyph at the header's top-right, signalling the screen has a
// Hold-Enter context menu. Three stacked bars, drawn in colour c (LIGHT on a
// plain header, DARK on an inverted bar). When active (the menu is open) the
// Hold-Enter context menu. Three stacked bars, drawn in colour c (primary_txt on a
// plain header, window_bkg on an inverted bar). When active (the menu is open) the
// corner cell is highlighted and the bars knocked out, tying the glyph to the
// popup it spawned. Call after the header body.
void drawContextMenuHint(Color c = LIGHT, bool active = false) {
void drawContextMenuHint(ColorVal c = UIColor::primary_txt, bool active = false) {
int gw = getCharWidth() + 1;
int gx = width() - gw - 1;
int th = sepH();
int gy = (getLineHeight() - (th * 3 + 4)) / 2;
if (gy < 0) gy = 0;
Color bars = c;
ColorVal bars = c;
if (active) {
setColor(c);
fillRect(gx - 1, 0, gw + 2, headerH() - sepH());
bars = (c == LIGHT) ? DARK : LIGHT;
bars = (c == UIColor::primary_txt) ? UIColor::window_bkg : UIColor::primary_txt;
}
setColor(bars);
for (int i = 0; i < 3; i++) fillRect(gx, gy + i * (th + 2), gw, th);
setColor(LIGHT);
setColor(UIColor::primary_txt);
}
void drawInvertedHeader(const char* label, bool menu_hint = false, bool menu_open = false) {
int hdr = headerH();
setColor(LIGHT);
setColor(UIColor::primary_txt);
fillRect(0, 0, width(), hdr - 1);
int reserve = menu_hint ? menuHintWidth() : 0;
setColor(DARK);
setColor(UIColor::window_bkg);
drawTextEllipsized(2, 1, width() - 4 - reserve, (label && label[0]) ? label : "");
if (menu_hint) drawContextMenuHint(DARK, menu_open);
setColor(LIGHT);
if (menu_hint) drawContextMenuHint(UIColor::window_bkg, menu_open);
setColor(UIColor::primary_txt);
fillRect(0, hdr - 1, width(), sepH());
}
// Centred screen title + bottom separator line — the standard top bar for
// full-screen list/detail views. Leaves ink LIGHT; callers can draw extra
// full-screen list/detail views. Leaves ink primary_txt; callers can draw extra
// header content (counters, etc.) afterwards. menu_hint adds the ≡ glyph;
// menu_open highlights it while the context menu is on screen.
void drawCenteredHeader(const char* title, bool menu_hint = false, bool menu_open = false) {
setColor(LIGHT);
setColor(UIColor::primary_txt);
int reserve = menu_hint ? menuHintWidth() : 0;
char buf[96];
translateUTF8ToBlocks(buf, (title && title[0]) ? title : "", sizeof(buf));
@@ -345,7 +352,7 @@ public:
drawTextEllipsized(2, 0, avail, buf);
}
fillRect(0, headerH() - sepH(), width(), sepH());
if (menu_hint) drawContextMenuHint(LIGHT, menu_open);
if (menu_hint) drawContextMenuHint(UIColor::primary_txt, menu_open);
}
// Advance a UTF-8 pointer by one codepoint, returning the decoded value.
+22 -8
View File
@@ -2,6 +2,17 @@
#include "../../MeshCore.h"
// Color scheme
ColorVal UIColor::window_bkg = WHITE;
ColorVal UIColor::title_bkg = WHITE;
ColorVal UIColor::title_txt = BLACK;
ColorVal UIColor::primary_txt = BLACK;
ColorVal UIColor::secondary_txt = BLACK;
ColorVal UIColor::warning_txt = BLACK;
ColorVal UIColor::popup_bkg = WHITE;
ColorVal UIColor::popup_txt = BLACK;
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 = WHITE;
ColorVal UIColor::title_txt = BLACK;
ColorVal UIColor::primary_txt = BLACK;
ColorVal UIColor::secondary_txt = BLACK;
ColorVal UIColor::warning_txt = BLACK;
ColorVal UIColor::popup_bkg = WHITE;
ColorVal UIColor::popup_txt = BLACK;
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;
+4 -5
View File
@@ -25,8 +25,7 @@ class Adafruit_GFX;
class EinkGfxDisplay : public DisplayDriver {
Adafruit_GFX& _gfx;
const uint16_t _ink, _paper; // LIGHT and DARK in the panel's colours
uint16_t _curr;
ColorVal _curr;
const GFXfont* _font;
int _cell_w = 6, _cell_h = 9; // the font's cell, before _px and the text size
int _px = 1; // pixel multiplier (landscape: EINK_FONT_PX, or Text size)
@@ -43,7 +42,7 @@ class EinkGfxDisplay : public DisplayDriver {
template <class T> void mix(T v) { mix(&v, sizeof(v)); }
protected:
EinkGfxDisplay(int w, int h, Adafruit_GFX& gfx, uint16_t ink, uint16_t paper);
EinkGfxDisplay(int w, int h, Adafruit_GFX& gfx);
// After a size or rotation change: picks the font for the new shape.
void updateLayout();
@@ -83,9 +82,9 @@ public:
updateLayout();
}
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;
+8 -8
View File
@@ -22,8 +22,8 @@
#define EINK_LARGE_GFXFONT MiscFixed8x13
#endif
EinkGfxDisplay::EinkGfxDisplay(int w, int h, Adafruit_GFX& gfx, uint16_t ink, uint16_t paper)
: DisplayDriver(w, h), _gfx(gfx), _ink(ink), _paper(paper), _curr(ink), _font(&MiscFixed) {
EinkGfxDisplay::EinkGfxDisplay(int w, int h, Adafruit_GFX& gfx)
: DisplayDriver(w, h), _gfx(gfx), _curr(UIColor::primary_txt), _font(&MiscFixed) {
updateLayout();
}
@@ -38,9 +38,9 @@ void EinkGfxDisplay::updateLayout() {
_force = true;
}
void EinkGfxDisplay::startFrame(Color bkg) {
_gfx.fillScreen(_paper);
_curr = _ink;
void EinkGfxDisplay::startFrame(ColorVal bkg) {
_gfx.fillScreen(bkg);
_curr = UIColor::primary_txt;
_text_sz = 1;
_hash = 2166136261u;
}
@@ -51,9 +51,9 @@ void EinkGfxDisplay::setTextSize(int sz) {
mix<int>(sz);
}
void EinkGfxDisplay::setColor(Color c) {
mix<Color>(c);
_curr = (c == DARK) ? _paper : _ink; // DARK is the paper, LIGHT the ink
void EinkGfxDisplay::setColor(ColorVal c) {
mix<ColorVal>(c);
_curr = c;
}
void EinkGfxDisplay::setCursor(int x, int y) {
+11
View File
@@ -22,6 +22,17 @@
#define EINK_SPI_HZ 4000000
#endif
// Color scheme
ColorVal UIColor::window_bkg = GxEPD_WHITE;
ColorVal UIColor::title_bkg = GxEPD_WHITE;
ColorVal UIColor::title_txt = GxEPD_BLACK;
ColorVal UIColor::primary_txt = GxEPD_BLACK;
ColorVal UIColor::secondary_txt = GxEPD_BLACK;
ColorVal UIColor::warning_txt = GxEPD_BLACK;
ColorVal UIColor::popup_bkg = GxEPD_WHITE;
ColorVal UIColor::popup_txt = GxEPD_BLACK;
ColorVal UIColor::corp_blue = GxEPD_BLACK;
bool GxEPDDisplay::begin() {
display.epd2.selectSPI(SPI1, SPISettings(EINK_SPI_HZ, MSBFIRST, SPI_MODE0));
#ifdef ESP32
+1 -1
View File
@@ -92,7 +92,7 @@ class GxEPDDisplay : private GxEPDPanel, public EinkGfxDisplay {
}
public:
GxEPDDisplay() : EinkGfxDisplay(EINK_DISP_W, EINK_DISP_H, display, GxEPD_BLACK, GxEPD_WHITE) {}
GxEPDDisplay() : EinkGfxDisplay(EINK_DISP_W, EINK_DISP_H, display) {}
#ifdef ENABLE_SCREENSHOT
const uint8_t* getBuffer() override { return display.getBuffer(); }
+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;
+10
View File
@@ -1 +1,11 @@
#include "NullDisplayDriver.h"
ColorVal UIColor::window_bkg = 0;
ColorVal UIColor::title_bkg = 0;
ColorVal UIColor::title_txt = 0;
ColorVal UIColor::primary_txt = 0;
ColorVal UIColor::secondary_txt = 0;
ColorVal UIColor::warning_txt = 0;
ColorVal UIColor::popup_bkg = 0;
ColorVal UIColor::popup_txt = 0;
ColorVal UIColor::corp_blue = 0;
+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 { }
+14 -3
View File
@@ -11,6 +11,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_BLACK;
ColorVal UIColor::title_txt = SH110X_WHITE;
ColorVal UIColor::primary_txt = SH110X_WHITE;
ColorVal UIColor::secondary_txt = SH110X_WHITE;
ColorVal UIColor::warning_txt = SH110X_WHITE;
ColorVal UIColor::popup_bkg = SH110X_BLACK;
ColorVal UIColor::popup_txt = SH110X_WHITE;
ColorVal UIColor::corp_blue = SH110X_WHITE;
bool SH1106Display::begin()
{
// Wire must already be initialised by board.begin() before this is called.
@@ -55,7 +66,7 @@ void SH1106Display::clear()
_force_redraw = true; // next endFrame() must flush even if its CRC matches a pre-clear frame
}
void SH1106Display::startFrame(Color bkg)
void SH1106Display::startFrame(ColorVal bkg)
{
display.clearDisplay(); // TODO: apply 'bkg'
_color = SH110X_WHITE;
@@ -102,9 +113,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);
}
+2 -2
View File
@@ -61,11 +61,11 @@ public:
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
bool slideBegin(int y0) override;
void slideCompose(int dx) 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;
+14 -3
View File
@@ -9,6 +9,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_BLACK;
ColorVal UIColor::title_txt = SSD1306_WHITE;
ColorVal UIColor::primary_txt = SSD1306_WHITE;
ColorVal UIColor::secondary_txt = SSD1306_WHITE;
ColorVal UIColor::warning_txt = SSD1306_WHITE;
ColorVal UIColor::popup_bkg = SSD1306_BLACK;
ColorVal UIColor::popup_txt = SSD1306_WHITE;
ColorVal UIColor::corp_blue = SSD1306_WHITE;
bool SSD1306Display::begin() {
if (!_isOn) {
if (_peripher_power) _peripher_power->claim();
@@ -50,7 +61,7 @@ void SSD1306Display::clear() {
_force_redraw = true; // next endFrame() must flush even if its hash matches a pre-clear frame
}
void SSD1306Display::startFrame(Color bkg) {
void SSD1306Display::startFrame(ColorVal bkg) {
display.clearDisplay(); // TODO: apply 'bkg'
_color = SSD1306_WHITE;
display.setTextColor(_color);
@@ -64,8 +75,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);
}
+2 -2
View File
@@ -86,9 +86,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;
+527 -75
View File
@@ -1,12 +1,409 @@
#include "ST7735Display.h"
#ifndef DISPLAY_ROTATION
#define DISPLAY_ROTATION 2
//#include <Fonts/GFXFF/FreeSans9pt7b.h>
// Optimised ST7735 display driver, derived from Adafruit_ST7735 library.
#define ST_CMD_DELAY 0x80 // special signifier for command lists
#define ST77XX_NOP 0x00
#define ST77XX_SWRESET 0x01
#define ST77XX_RDDID 0x04
#define ST77XX_RDDST 0x09
#define ST77XX_SLPIN 0x10
#define ST77XX_SLPOUT 0x11
#define ST77XX_PTLON 0x12
#define ST77XX_NORON 0x13
#define ST77XX_INVOFF 0x20
#define ST77XX_INVON 0x21
#define ST77XX_DISPOFF 0x28
#define ST77XX_DISPON 0x29
#define ST77XX_CASET 0x2A
#define ST77XX_RASET 0x2B
#define ST77XX_RAMWR 0x2C
#define ST77XX_RAMRD 0x2E
#define ST77XX_PTLAR 0x30
#define ST77XX_TEOFF 0x34
#define ST77XX_TEON 0x35
#define ST77XX_MADCTL 0x36
#define ST77XX_COLMOD 0x3A
#define ST77XX_MADCTL_MY 0x80
#define ST77XX_MADCTL_MX 0x40
#define ST77XX_MADCTL_MV 0x20
#define ST77XX_MADCTL_ML 0x10
#define ST77XX_MADCTL_RGB 0x00
#define ST77XX_RDID1 0xDA
#define ST77XX_RDID2 0xDB
#define ST77XX_RDID3 0xDC
#define ST77XX_RDID4 0xDD
// Some ready-made 16-bit ('565') color settings:
#define ST77XX_BLACK 0x0000
#define ST77XX_WHITE 0xFFFF
#define ST77XX_RED 0xF800
#define ST77XX_GREEN 0x07E0
#define ST77XX_BLUE 0x001F
#define ST77XX_CYAN 0x07FF
#define ST77XX_MAGENTA 0xF81F
#define ST77XX_YELLOW 0xFFE0
#define ST77XX_ORANGE 0xFC00
// some flags for initR() :(
#define INITR_GREENTAB 0x00
#define INITR_REDTAB 0x01
#define INITR_BLACKTAB 0x02
#define INITR_18GREENTAB INITR_GREENTAB
#define INITR_18REDTAB INITR_REDTAB
#define INITR_18BLACKTAB INITR_BLACKTAB
#define INITR_144GREENTAB 0x01
#define INITR_MINI160x80 0x04
#define INITR_HALLOWING 0x05
#define INITR_MINI160x80_PLUGIN 0x06
// Some register settings
#define ST7735_MADCTL_BGR 0x08
#define ST7735_MADCTL_MH 0x04
#define ST7735_FRMCTR1 0xB1
#define ST7735_FRMCTR2 0xB2
#define ST7735_FRMCTR3 0xB3
#define ST7735_INVCTR 0xB4
#define ST7735_DISSET5 0xB6
#define ST7735_PWCTR1 0xC0
#define ST7735_PWCTR2 0xC1
#define ST7735_PWCTR3 0xC2
#define ST7735_PWCTR4 0xC3
#define ST7735_PWCTR5 0xC4
#define ST7735_VMCTR1 0xC5
#define ST7735_PWCTR6 0xFC
#define ST7735_GMCTRP1 0xE0
#define ST7735_GMCTRN1 0xE1
// Some ready-made 16-bit ('565') color settings:
#define ST7735_BLACK ST77XX_BLACK
#define ST7735_WHITE ST77XX_WHITE
#define ST7735_RED ST77XX_RED
#define ST7735_GREEN ST77XX_GREEN
#define ST7735_BLUE ST77XX_BLUE
#define ST7735_CYAN ST77XX_CYAN
#define ST7735_MAGENTA ST77XX_MAGENTA
#define ST7735_YELLOW ST77XX_YELLOW
#define ST7735_ORANGE ST77XX_ORANGE
static TFT_eSPI lcd = TFT_eSPI(160, 80);
static uint32_t curr_color;
#if defined(HELTEC_LORA_V3) || defined(HELTEC_TRACKER_V2)
static SPIClass tft_spi(HSPI);
#define _spi (&tft_spi)
#else
#define _spi (&SPI1)
#endif
SPISettings _spiSettings = SPISettings(40000000, MSBFIRST, SPI_MODE0);
// clang-format off
static const uint8_t PROGMEM
Bcmd[] = { // Init commands for 7735B screens
18, // 18 commands in list:
ST77XX_SWRESET, ST_CMD_DELAY, // 1: Software reset, no args, w/delay
50, // 50 ms delay
ST77XX_SLPOUT, ST_CMD_DELAY, // 2: Out of sleep mode, no args, w/delay
255, // 255 = max (500 ms) delay
ST77XX_COLMOD, 1+ST_CMD_DELAY, // 3: Set color mode, 1 arg + delay:
0x05, // 16-bit color
10, // 10 ms delay
ST7735_FRMCTR1, 3+ST_CMD_DELAY, // 4: Frame rate control, 3 args + delay:
0x00, // fastest refresh
0x06, // 6 lines front porch
0x03, // 3 lines back porch
10, // 10 ms delay
ST77XX_MADCTL, 1, // 5: Mem access ctl (directions), 1 arg:
0x08, // Row/col addr, bottom-top refresh
ST7735_DISSET5, 2, // 6: Display settings #5, 2 args:
0x15, // 1 clk cycle nonoverlap, 2 cycle gate
// rise, 3 cycle osc equalize
0x02, // Fix on VTL
ST7735_INVCTR, 1, // 7: Display inversion control, 1 arg:
0x0, // Line inversion
ST7735_PWCTR1, 2+ST_CMD_DELAY, // 8: Power control, 2 args + delay:
0x02, // GVDD = 4.7V
0x70, // 1.0uA
10, // 10 ms delay
ST7735_PWCTR2, 1, // 9: Power control, 1 arg, no delay:
0x05, // VGH = 14.7V, VGL = -7.35V
ST7735_PWCTR3, 2, // 10: Power control, 2 args, no delay:
0x01, // Opamp current small
0x02, // Boost frequency
ST7735_VMCTR1, 2+ST_CMD_DELAY, // 11: Power control, 2 args + delay:
0x3C, // VCOMH = 4V
0x38, // VCOML = -1.1V
10, // 10 ms delay
ST7735_PWCTR6, 2, // 12: Power control, 2 args, no delay:
0x11, 0x15,
ST7735_GMCTRP1,16, // 13: Gamma Adjustments (pos. polarity), 16 args + delay:
0x09, 0x16, 0x09, 0x20, // (Not entirely necessary, but provides
0x21, 0x1B, 0x13, 0x19, // accurate colors)
0x17, 0x15, 0x1E, 0x2B,
0x04, 0x05, 0x02, 0x0E,
ST7735_GMCTRN1,16+ST_CMD_DELAY, // 14: Gamma Adjustments (neg. polarity), 16 args + delay:
0x0B, 0x14, 0x08, 0x1E, // (Not entirely necessary, but provides
0x22, 0x1D, 0x18, 0x1E, // accurate colors)
0x1B, 0x1A, 0x24, 0x2B,
0x06, 0x06, 0x02, 0x0F,
10, // 10 ms delay
ST77XX_CASET, 4, // 15: Column addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 2
0x00, 0x81, // XEND = 129
ST77XX_RASET, 4, // 16: Row addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 1
0x00, 0x81, // XEND = 160
ST77XX_NORON, ST_CMD_DELAY, // 17: Normal display on, no args, w/delay
10, // 10 ms delay
ST77XX_DISPON, ST_CMD_DELAY, // 18: Main screen turn on, no args, delay
255 }, // 255 = max (500 ms) delay
Rcmd1[] = { // 7735R init, part 1 (red or green tab)
14, // 14 commands in list:
/*ST77XX_SWRESET, ST_CMD_DELAY, // 1: Software reset, 0 args, w/delay
150, */ // 150 ms delay
ST77XX_SLPOUT, ST_CMD_DELAY, // 2: Out of sleep mode, 0 args, w/delay
120, // 120 ms delay
ST7735_FRMCTR1, 3, // 3: Framerate ctrl - normal mode, 3 arg:
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
ST7735_FRMCTR2, 3, // 4: Framerate ctrl - idle mode, 3 args:
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
ST7735_FRMCTR3, 6, // 5: Framerate - partial mode, 6 args:
0x01, 0x2C, 0x2D, // Dot inversion mode
0x01, 0x2C, 0x2D, // Line inversion mode
ST7735_INVCTR, 1, // 6: Display inversion ctrl, 1 arg:
0x07, // No inversion
ST7735_PWCTR1, 3, // 7: Power control, 3 args, no delay:
0xA2,
0x02, // -4.6V
0x84, // AUTO mode
ST7735_PWCTR2, 1, // 8: Power control, 1 arg, no delay:
0xC5, // VGH25=2.4C VGSEL=-10 VGH=3 * AVDD
ST7735_PWCTR3, 2, // 9: Power control, 2 args, no delay:
0x0A, // Opamp current small
0x00, // Boost frequency
ST7735_PWCTR4, 2, // 10: Power control, 2 args, no delay:
0x8A, // BCLK/2,
0x2A, // opamp current small & medium low
ST7735_PWCTR5, 2, // 11: Power control, 2 args, no delay:
0x8A, 0xEE,
ST7735_VMCTR1, 1, // 12: Power control, 1 arg, no delay:
0x0E,
ST77XX_INVOFF, 0, // 13: Don't invert display, no args
ST77XX_MADCTL, 1, // 14: Mem access ctl (directions), 1 arg:
0xC8, // row/col addr, bottom-top refresh
ST77XX_COLMOD, 1, // 15: set color mode, 1 arg, no delay:
0x05 }, // 16-bit color
Rcmd2green[] = { // 7735R init, part 2 (green tab only)
2, // 2 commands in list:
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 0
0x00, 0x7F+0x02, // XEND = 127
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
0x00, 0x01, // XSTART = 0
0x00, 0x9F+0x01 }, // XEND = 159
Rcmd2red[] = { // 7735R init, part 2 (red tab only)
2, // 2 commands in list:
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x7F, // XEND = 127
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x9F }, // XEND = 159
Rcmd2green144[] = { // 7735R init, part 2 (green 1.44 tab)
2, // 2 commands in list:
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x7F, // XEND = 127
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x7F }, // XEND = 127
Rcmd2green160x80[] = { // 7735R init, part 2 (mini 160x80)
2, // 2 commands in list:
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x4F, // XEND = 79
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x9F }, // XEND = 159
Rcmd2green160x80plugin[] = { // 7735R init, part 2 (mini 160x80 with plugin FPC)
3, // 3 commands in list:
ST77XX_INVON, 0, // 1: Display is inverted
ST77XX_CASET, 4, // 2: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x4F, // XEND = 79
ST77XX_RASET, 4, // 3: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x9F }, // XEND = 159
Rcmd2invert[] = { // Tracker V1, part 2
1, // 1 command in list:
ST77XX_INVON, 0 }, // 1: Display is inverted
Rcmd3[] = { // 7735R init, part 3 (red or green tab)
2, // 2 commands in list:
ST7735_GMCTRP1, 16 , // 1: Gamma Adjustments (pos. polarity), 16 args + delay:
0x02, 0x1c, 0x07, 0x12, // (Not entirely necessary, but provides
0x37, 0x32, 0x29, 0x2d, // accurate colors)
0x29, 0x25, 0x2B, 0x39,
0x00, 0x01, 0x03, 0x10,
ST7735_GMCTRN1, 16 , // 2: Gamma Adjustments (neg. polarity), 16 args + delay:
0x03, 0x1d, 0x07, 0x06, // (Not entirely necessary, but provides
0x2E, 0x2C, 0x29, 0x2D, // accurate colors)
0x2E, 0x2E, 0x37, 0x3F,
0x00, 0x00, 0x02, 0x10 }; // 100 ms delay
static int16_t _xstart = 0; ///< Internal framebuffer X offset
static int16_t _ystart = 0; ///< Internal framebuffer Y offset
static uint8_t _colstart = 0; ///< Some displays need this changed to offset
static uint8_t _rowstart = 0; ///< Some displays need this changed to offset
static uint8_t rotation = 0;
static int16_t _width = 0; ///< Display width as modified by current rotation
static int16_t _height = 0; ///< Display height as modified by current rotation
static void set_CS(uint8_t level) {
//if (_cs != (uint8_t) -1) {
digitalWrite(PIN_TFT_CS, level);
//}
}
static void sendCommand(uint8_t com) {
set_CS(HIGH);
digitalWrite(PIN_TFT_DC, LOW);
set_CS(LOW);
_spi->beginTransaction(_spiSettings);
_spi->transfer(com);
_spi->endTransaction();
set_CS(HIGH);
digitalWrite(PIN_TFT_DC, HIGH);
}
static void WriteData(uint8_t data) {
digitalWrite(PIN_TFT_CS, LOW);
_spi->beginTransaction(_spiSettings);
_spi->transfer(data);
_spi->endTransaction();
digitalWrite(PIN_TFT_CS, HIGH);
}
static void SPI_WRITE32(uint32_t l) {
_spi->transfer(l >> 24);
_spi->transfer(l >> 16);
_spi->transfer(l >> 8);
_spi->transfer(l);
}
static void writeCommand(uint8_t cmd) {
digitalWrite(PIN_TFT_DC, LOW);
_spi->transfer(cmd);
digitalWrite(PIN_TFT_DC, HIGH);
}
static void displayInit(const uint8_t *addr) {
uint8_t numCommands, cmd, numArgs;
uint16_t ms;
numCommands = pgm_read_byte(addr++); // Number of commands to follow
while (numCommands--) { // For each command...
cmd = pgm_read_byte(addr++); // Read command
numArgs = pgm_read_byte(addr++); // Number of args to follow
ms = numArgs & ST_CMD_DELAY; // If hibit set, delay follows args
numArgs &= ~ST_CMD_DELAY; // Mask out delay bit
sendCommand(cmd);
for (int k = 0; k < numArgs; k++) {
WriteData(addr[k]);
}
addr += numArgs;
if (ms) {
ms = pgm_read_byte(addr++); // Read post-command delay time (ms)
if (ms == 255)
ms = 500; // If 255, delay for 500 ms
delay(ms);
}
}
}
static void setRotation(uint8_t m) {
uint8_t madctl = 0;
rotation = m & 3; // can't be higher than 3
switch (rotation) {
case 0:
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST7735_MADCTL_BGR;
_height = 160;
_width = 80;
_xstart = _colstart;
_ystart = _rowstart;
break;
case 1:
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST7735_MADCTL_BGR;
_width = 160;
_height = 80;
_ystart = _colstart;
_xstart = _rowstart;
break;
case 2:
madctl = ST7735_MADCTL_BGR;
_height = 160;
_width = 80;
_xstart = _colstart;
_ystart = _rowstart;
break;
case 3:
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST7735_MADCTL_BGR;
_width = 160;
_height = 80;
_ystart = _colstart;
_xstart = _rowstart;
break;
}
sendCommand(ST77XX_MADCTL);
WriteData(madctl);
}
static void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
x += _xstart;
y += _ystart;
uint32_t xa = ((uint32_t)x << 16) | (x + w - 1);
uint32_t ya = ((uint32_t)y << 16) | (y + h - 1);
writeCommand(ST77XX_CASET); // Column addr set
SPI_WRITE32(xa);
writeCommand(ST77XX_RASET); // Row addr set
SPI_WRITE32(ya);
writeCommand(ST77XX_RAMWR); // write to RAM
}
#define SCALE_X 1.25f // 160 / 128
#define SCALE_Y 1.25f // 80 / 64
static TFT_eSprite *sprite = NULL;
bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
return true;
/*
@@ -16,53 +413,121 @@ bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
*/
}
#ifndef PIN_TFT_LEDA_CTL_ACTIVE
#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
sprite = new TFT_eSprite(&lcd);
if (sprite) {
if (sprite->createSprite(160, 80)) {
sprite->fillScreen(ST77XX_BLACK);
sprite->setTextColor(curr_color = ST77XX_WHITE);
} else {
Serial.printf("ST7735Display: failed to alloc canvas pixels");
}
} else {
Serial.printf("ST7735Display: failed to alloc canvas");
}
}
if (!_isOn) {
if (_peripher_power) _peripher_power->claim();
delay(100); // TEMP!!
pinMode(PIN_TFT_RST, OUTPUT);
pinMode(PIN_TFT_CS, OUTPUT);
pinMode(PIN_TFT_DC, OUTPUT);
pinMode(PIN_TFT_LEDA_CTL, OUTPUT);
#if defined(PIN_TFT_LEDA_CTL_ACTIVE)
digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
#else
digitalWrite(PIN_TFT_LEDA_CTL, HIGH);
#endif
digitalWrite(PIN_TFT_RST, HIGH);
#if defined(HELTEC_T1)
display.initR(INITR_MINI160x80);
display.setRotation(DISPLAY_ROTATION);
#elif defined(HELTEC_TRACKER_V2) || defined(HELTEC_T096)
display.initR(INITR_MINI160x80);
display.setRotation(DISPLAY_ROTATION);
uint8_t madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV |ST7735_MADCTL_BGR;//Adjust color to BGR
display.sendCommand(ST77XX_MADCTL, &madctl, 1);
#ifdef ESP_PLATFORM
_spi->begin(PIN_TFT_SCL, -1 /* _miso */, PIN_TFT_SDA /* _mosi */, -1);
#else
display.initR(INITR_MINI160x80_PLUGIN);
display.setRotation(DISPLAY_ROTATION);
_spi->begin();
#endif
display.setSPISpeed(40000000);
display.fillScreen(ST77XX_BLACK);
display.setTextColor(ST77XX_WHITE);
display.setTextSize(2);
display.cp437(true); // Use full 256 char 'Code Page 437' font
_spi->setClockDivider(SPI_CLOCK_DIV2);
_height = 80;
_width = 160;
#if defined(HELTEC_LORA_V3) // Tracker v1
_colstart = 26;
_rowstart = 1;
#else
_colstart = 24;
_rowstart = 0;
#endif
_resetAndInit();
sendCommand(ST77XX_DISPON);
_isOn = true;
}
return true;
}
void ST7735Display::_resetAndInit() {
// Pulse Reset low for 10ms
digitalWrite(PIN_TFT_RST, HIGH);
delay(2);
digitalWrite(PIN_TFT_RST, LOW);
delay(10);
digitalWrite(PIN_TFT_RST, HIGH);
delay(2);
// run init commands
displayInit(Rcmd1);
#if defined(HELTEC_TRACKER_V2) || defined(HELTEC_T096)
displayInit(Rcmd2green160x80);
//uint8_t madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV |ST7735_MADCTL_BGR;//Adjust color to BGR
//display.sendCommand(ST77XX_MADCTL, &madctl, 1);
#elif defined(HELTEC_LORA_V3) // Tracker v1
displayInit(Rcmd2invert); // invert RGB
#endif
displayInit(Rcmd3);
setRotation(DISPLAY_ROTATION);
// clear the buffer before display on
sprite->fillScreen(ST77XX_BLACK);
endFrame();
// turn on backlight
digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
}
void ST7735Display::turnOn() {
ST7735Display::begin();
if (!_isOn) {
if (_peripher_power) _peripher_power->claim();
_resetAndInit();
sendCommand(ST77XX_DISPON);
// Now turn on the backlight
// digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
_isOn = true;
}
}
void ST7735Display::turnOff() {
if (_isOn) {
digitalWrite(PIN_TFT_RST, LOW);
#if defined(PIN_TFT_LEDA_CTL_ACTIVE)
sendCommand(ST77XX_DISPOFF);
//digitalWrite(PIN_TFT_RST, LOW);
// Now turn off the backlight
digitalWrite(PIN_TFT_LEDA_CTL, !PIN_TFT_LEDA_CTL_ACTIVE);
#else
digitalWrite(PIN_TFT_LEDA_CTL, LOW);
#endif
_isOn = false;
if (_peripher_power) _peripher_power->release();
@@ -70,78 +535,65 @@ void ST7735Display::turnOff() {
}
void ST7735Display::clear() {
//Serial.println("DBG: display.Clear");
display.fillScreen(ST77XX_BLACK);
sprite->fillScreen(ST77XX_BLACK);
}
void ST7735Display::startFrame(Color bkg) {
display.fillScreen(0x00);
display.setTextColor(ST77XX_WHITE);
display.setTextSize(1); // This one affects size of Please wait... message
display.cp437(true); // Use full 256 char 'Code Page 437' font
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
}
void ST7735Display::setTextSize(int sz) {
display.setTextSize(sz);
sprite->setTextSize(sz);
}
void ST7735Display::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 ST7735Display::setColor(ColorVal c) {
curr_color = c;
sprite->setTextColor(curr_color);
}
void ST7735Display::setCursor(int x, int y) {
display.setCursor(x*SCALE_X, y*SCALE_Y);
sprite->setCursor(x*SCALE_X, y*SCALE_Y);
}
void ST7735Display::print(const char* str) {
display.print(str);
sprite->print(str);
}
void ST7735Display::fillRect(int x, int y, int w, int h) {
display.fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _color);
sprite->fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, curr_color);
}
void ST7735Display::drawRect(int x, int y, int w, int h) {
display.drawRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _color);
sprite->drawRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, curr_color);
}
void ST7735Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
display.drawBitmap(x*SCALE_X, y*SCALE_Y, bits, w, h, _color);
sprite->drawBitmap(x*SCALE_X, y*SCALE_Y, bits, w, h, curr_color);
}
uint16_t ST7735Display::getTextWidth(const char* str) {
int16_t x1, y1;
uint16_t w, h;
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
return w / SCALE_X;
return sprite->textWidth(str) / SCALE_X;
}
void ST7735Display::endFrame() {
// display.display();
// blit the canvas buffer to LCD
set_CS(LOW);
_spi->beginTransaction(_spiSettings);
uint16_t x, y;
uint16_t* pixels = (uint16_t *) ((TFT_eSprite *) sprite)->getPointer();
for (y = 0; y < 80; y++, pixels += 160) {
setAddrWindow(0, y, 160, 1);
#ifdef ESP_PLATFORM
_spi->transferBytes((uint8_t *)pixels, NULL, 2 * 160);
#else
_spi->transfer(pixels, NULL, 2 * 160);
#endif
}
_spi->endTransaction();
set_CS(HIGH);
}
+8 -8
View File
@@ -3,28 +3,25 @@
#include "DisplayDriver.h"
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include "TFT_eSPI.h"
#include <helpers/RefCountedDigitalPin.h>
class ST7735Display : public DisplayDriver {
Adafruit_ST7735 display;
bool _isOn;
uint16_t _color;
RefCountedDigitalPin* _peripher_power;
bool i2c_probe(TwoWire& wire, uint8_t addr);
public:
#ifdef USE_PIN_TFT
ST7735Display(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
display(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_SDA, PIN_TFT_SCL, PIN_TFT_RST),
// display(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_SDA, PIN_TFT_SCL, PIN_TFT_RST),
_peripher_power(peripher_power)
{
_isOn = false;
}
#else
ST7735Display(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
display(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST),
// display(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST),
_peripher_power(peripher_power)
{
_isOn = false;
@@ -36,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;
@@ -46,4 +43,7 @@ public:
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
uint16_t getTextWidth(const char* str) override;
void endFrame() override;
protected:
void _resetAndInit();
};
+18 -36
View File
@@ -33,6 +33,17 @@
#define SCALE_Y DISPLAY_SCALE_Y
#endif
// Color scheme
ColorVal UIColor::window_bkg = OLEDDISPLAY_COLOR::BLACK;
ColorVal UIColor::title_bkg = OLEDDISPLAY_COLOR::BLACK;
ColorVal UIColor::title_txt = OLEDDISPLAY_COLOR::WHITE;
ColorVal UIColor::primary_txt = OLEDDISPLAY_COLOR::WHITE;
ColorVal UIColor::secondary_txt = OLEDDISPLAY_COLOR::WHITE;
ColorVal UIColor::warning_txt = OLEDDISPLAY_COLOR::WHITE;
ColorVal UIColor::popup_bkg = OLEDDISPLAY_COLOR::BLACK;
ColorVal UIColor::popup_txt = OLEDDISPLAY_COLOR::WHITE;
ColorVal UIColor::corp_blue = OLEDDISPLAY_COLOR::WHITE;
#ifdef OLED_MISC_FIXED_FONT
// MiscFixedFont.h/LemonIcons.h store each glyph's rows bit-packed
// *continuously* (Adafruit_GFX's native GFXfont convention -- no per-row byte
@@ -132,10 +143,9 @@ void ST7789Display::clear() {
display.clear();
}
void ST7789Display::startFrame(Color bkg) {
display.clear();
_color = ST77XX_WHITE;
display.setRGB(_color);
void ST7789Display::startFrame(ColorVal bkg) {
display.clear(); // TODO: use bkg
setColor(UIColor::primary_txt);
display.setFont(ArialMT_Plain_16);
}
@@ -152,38 +162,10 @@ 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) {
_color = c;
display.setColor((OLEDDISPLAY_COLOR)_color);
display.setRGB(_color == OLEDDISPLAY_COLOR::WHITE ? ST77XX_WHITE : ST77XX_BLACK);
}
void ST7789Display::setCursor(int x, int y) {
+2 -2
View File
@@ -56,9 +56,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;
+22 -33
View File
@@ -1,5 +1,9 @@
#include "ST7789LCDDisplay.h"
#ifndef PIN_TFT_MISO
#define PIN_TFT_MISO -1
#endif
#ifndef DISPLAY_ROTATION
#define DISPLAY_ROTATION 3
#endif
@@ -19,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();
@@ -29,8 +44,8 @@ bool ST7789LCDDisplay::begin() {
}
// Im not sure if this is just a t-deck problem or not, if your display is slow try this.
#if defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT)
displaySPI.begin(PIN_TFT_SCL, -1, PIN_TFT_SDA, PIN_TFT_CS);
#if defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT) || defined(HELTEC_V4_R8_TFT)
displaySPI.begin(PIN_TFT_SCL, PIN_TFT_MISO, PIN_TFT_SDA, PIN_TFT_CS);
#endif
display.init(DISPLAY_WIDTH, DISPLAY_HEIGHT);
@@ -74,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
}
@@ -85,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) {
+4 -4
View File
@@ -8,7 +8,7 @@
#include <helpers/RefCountedDigitalPin.h>
class ST7789LCDDisplay : public DisplayDriver {
#if defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT)
#if defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT) || defined(HELTEC_V4_R8_TFT)
SPIClass displaySPI;
#endif
Adafruit_ST7789 display;
@@ -25,7 +25,7 @@ public:
{
_isOn = false;
}
#elif defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT)
#elif defined(LILYGO_TDECK) || defined(HELTEC_LORA_V4_TFT) || defined(HELTEC_V4_R8_TFT)
ST7789LCDDisplay(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
displaySPI(HSPI),
display(&displaySPI, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST),
@@ -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;
+11
View File
@@ -1 +1,12 @@
#include "U8g2Display.h"
// Color scheme
ColorVal UIColor::window_bkg = 0;
ColorVal UIColor::title_bkg = 0;
ColorVal UIColor::title_txt = 1;
ColorVal UIColor::primary_txt = 1;
ColorVal UIColor::secondary_txt = 1;
ColorVal UIColor::warning_txt = 1;
ColorVal UIColor::popup_bkg = 0;
ColorVal UIColor::popup_txt = 1;
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);
}
+17 -20
View File
@@ -34,7 +34,7 @@ class SimDisplayDriver : public DisplayDriver {
bool _on = false;
int _cursor_x = 0, _cursor_y = 0;
Color _color = LIGHT;
ColorVal _color = UIColor::primary_txt;
bool _filled[ROWS][COLS];
char _text[ROWS][COLS]; // 0 = no character placed
bool _dirty = false;
@@ -59,14 +59,14 @@ public:
void turnOff() override { _on = false; }
void clear() override { clearBuffers(); }
void startFrame(Color bkg = DARK) override {
void startFrame(ColorVal bkg = UIColor::window_bkg) override {
clearBuffers();
_color = LIGHT;
_color = UIColor::primary_txt;
}
void setTextSize(int sz) override { /* one fixed size in ASCII output */ }
void setColor(Color c) override { _color = c; }
void setColor(ColorVal c) override { _color = c; }
void setCursor(int x, int y) override { _cursor_x = x; _cursor_y = y; }
@@ -124,7 +124,7 @@ public:
private:
void markRect(int x, int y, int w, int h) {
bool lit = (_color != DARK);
bool lit = (_color != UIColor::window_bkg);
int cx0, cy0, cx1, cy1;
cellOf(x, y, cx0, cy0);
cellOf(x + w - 1, y + h - 1, cx1, cy1);
@@ -195,7 +195,7 @@ private:
class SimDisplayDriverCanvas : public DisplayDriver {
bool _on = false;
int _cursor_x = 0, _cursor_y = 0;
Color _color = LIGHT;
ColorVal _color = UIColor::primary_txt;
int _text_sz = 1;
public:
@@ -226,8 +226,8 @@ public:
}
void clear() override { turnOff(); _on = true; }
void startFrame(Color bkg = DARK) override {
_color = LIGHT;
void startFrame(ColorVal bkg = UIColor::window_bkg) override {
_color = UIColor::primary_txt;
EM_ASM({
if (!Module.__simCtx) return;
Module.__simCtx.fillStyle = '#000';
@@ -236,7 +236,7 @@ public:
}
void setTextSize(int sz) override { _text_sz = sz; }
void setColor(Color c) override { _color = c; }
void setColor(ColorVal c) override { _color = c; }
void setCursor(int x, int y) override { _cursor_x = x; _cursor_y = y; }
// MiscFixed's real metrics (6px advance, 9px row height -- see
@@ -258,12 +258,9 @@ public:
// real board it's mirroring.
bool isSingleFont() const override { return true; }
// White-on-black palette (matches a real monochrome SSD1306/SH1106 OLED)
// for LIGHT/DARK; the other Color enumerators (RED/GREEN/BLUE/YELLOW/
// ORANGE) aren't used on the real monochrome OLED boards this sim mirrors
// either (DisplayDriver.h's own comment: "on b/w screen, colors will be
// !=0 synonym of light").
static const char* jsColor(Color c) { return c == DARK ? "#000" : "#fff"; }
// White-on-black palette (matches a real monochrome SSD1306/SH1106 OLED):
// the sim's UIColor palette (target.cpp) is 0 for background, 1 for ink.
static const char* jsColor(ColorVal c) { return c == 0 ? "#000" : "#fff"; }
// Real bitmap-font rendering (byte-identical glyphs to a real MeshCore-Solo
// board with OLED_MISC_FIXED_FONT=1 -- see solo/heltec_v3/platformio.ini),
@@ -298,7 +295,7 @@ public:
if (!Module.__simCtx) return;
Module.__simCtx.fillStyle = UTF8ToString($4) === 'L' ? '#fff' : '#000';
Module.__simCtx.fillRect($0, $1, $2, $3);
}, x, y, w, h, (_color != DARK) ? "L" : "D");
}, x, y, w, h, (_color != UIColor::window_bkg) ? "L" : "D");
}
void drawRect(int x, int y, int w, int h) override {
@@ -308,7 +305,7 @@ public:
ctx.strokeStyle = UTF8ToString($4) === 'L' ? '#fff' : '#000';
ctx.lineWidth = 1;
ctx.strokeRect($0 + 0.5, $1 + 0.5, $2 - 1, $3 - 1);
}, x, y, w, h, (_color != DARK) ? "L" : "D");
}, x, y, w, h, (_color != UIColor::window_bkg) ? "L" : "D");
}
// Real XBM bit-unpacking (row-major, MSB-first, rows padded to whole
@@ -338,7 +335,7 @@ public:
if (HEAPU8[byteOff] & mask) ctx.fillRect(x0 + rx, y0 + ry, 1, 1);
}
}
}, x, y, w, h, bits, (_color != DARK) ? "L" : "D");
}, x, y, w, h, bits, (_color != UIColor::window_bkg) ? "L" : "D");
}
// Measured off the real MiscFixed glyph table, per CODEPOINT -- not
@@ -450,9 +447,9 @@ public:
}, W, H);
}
void clear() override { }
void startFrame(Color bkg = DARK) override { (void)bkg; }
void startFrame(ColorVal bkg = UIColor::window_bkg) override { (void)bkg; }
void setTextSize(int sz) override { (void)sz; }
void setColor(Color c) override { (void)c; }
void setColor(ColorVal c) override { (void)c; }
void setCursor(int x, int y) override { (void)x; (void)y; }
void print(const char* str) override { (void)str; }
void fillRect(int x, int y, int w, int h) override { (void)x; (void)y; (void)w; (void)h; }
+13 -2
View File
@@ -17,6 +17,17 @@ SimSensorManager sensors;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
// Color scheme: every sim panel is 1-bit (0 = background, 1 = ink)
ColorVal UIColor::window_bkg = 0;
ColorVal UIColor::title_bkg = 0;
ColorVal UIColor::title_txt = 1;
ColorVal UIColor::primary_txt = 1;
ColorVal UIColor::secondary_txt = 1;
ColorVal UIColor::warning_txt = 1;
ColorVal UIColor::popup_bkg = 0;
ColorVal UIColor::popup_txt = 1;
ColorVal UIColor::corp_blue = 1;
#endif
// SimSensorManager's methods (see that header's comment on why they're
@@ -147,7 +158,7 @@ void SimDisplayDriverCanvas::print(const char* str) {
if (HEAPU8[buf + y * 128 + x]) ctx.fillRect(x, y, 1, 1);
}
}
}, gfx.px, gfx.dx0, gfx.dy0, gfx.dx1, gfx.dy1, (_color != DARK) ? "L" : "D");
}, gfx.px, gfx.dx0, gfx.dy0, gfx.dx1, gfx.dy1, (_color != UIColor::window_bkg) ? "L" : "D");
}
// Same external contract as every other DisplayDriver backend here (see
@@ -169,7 +180,7 @@ Adafruit_GFX& SimEinkDisplay::canvas() {
SimEinkDisplay::SimEinkDisplay()
: EinkGfxDisplay((DISPLAY_ROTATION & 1) ? PANEL_H : PANEL_W,
(DISPLAY_ROTATION & 1) ? PANEL_W : PANEL_H, canvas(), 1, 0) {
(DISPLAY_ROTATION & 1) ? PANEL_W : PANEL_H, canvas()) {
canvas().setRotation(DISPLAY_ROTATION);
}