mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-30 00:38:13 +00:00
- DisplayDriver: add sepH() (2px landscape, 1px OLED); fix transliterateCodepoint fallback '?' (was '\xDB' which broke UTF-8 word-wrap and rendered tiny block char) - GxEPDDisplay: drawRect draws double border on landscape for visible 2px weight - UITask: navigation dots scale with lh; content_y saves 16px by using dots_y+6; battery iconW=lh*2, fill margin bm scales with orientation; indicator spacing fixed; clock separator uses sepH(); alert popup tight and vertically centred - KeyboardWidget: compact cell height (no stretch), multi-line preview, cursor always on last visible line - BotScreen / NearbyScreen detail: use lineStep() as natural item height, shrink only when items don't fit (fixes portrait stretch) - QuickMsgScreen: send button pinned to display bottom (height-lh-2), not floating - SettingsScreen: AUTO_OFF guarded with #if AUTO_OFF_MILLIS>0; default sel=AUTO_LOCK - All screens: separators updated to sepH() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
91 lines
3.0 KiB
C++
91 lines
3.0 KiB
C++
#pragma once
|
|
// Configures which data fields appear on the clock home page.
|
|
// Included by UITask.cpp after BotScreen.h.
|
|
|
|
// Field type constants — used here and in UITask.cpp HP_CLOCK render.
|
|
static const uint8_t DASH_NONE = 0;
|
|
static const uint8_t DASH_BATT = 1;
|
|
static const uint8_t DASH_TEMP = 2;
|
|
static const uint8_t DASH_HUM = 3;
|
|
static const uint8_t DASH_PRES = 4;
|
|
static const uint8_t DASH_GPS = 5;
|
|
static const uint8_t DASH_ALT = 6;
|
|
static const uint8_t DASH_LUX = 7;
|
|
static const uint8_t DASH_CO2 = 8;
|
|
static const uint8_t DASH_NODES = 9;
|
|
static const uint8_t DASH_MSGS = 10;
|
|
static const uint8_t DASH_COUNT = 11;
|
|
|
|
class DashboardConfigScreen : public UIScreen {
|
|
UITask* _task;
|
|
NodePrefs* _prefs;
|
|
|
|
static const int FIELD_SLOTS = 3;
|
|
|
|
static const char* OPTION_NAMES[DASH_COUNT];
|
|
|
|
int _sel;
|
|
bool _dirty;
|
|
|
|
void cycle(int slot, int dir) {
|
|
uint8_t& f = _prefs->dashboard_fields[slot];
|
|
f = (uint8_t)((f + DASH_COUNT + dir) % DASH_COUNT);
|
|
_dirty = true;
|
|
}
|
|
|
|
public:
|
|
DashboardConfigScreen(UITask* task, NodePrefs* prefs) : _task(task), _prefs(prefs) {}
|
|
|
|
void enter() { _sel = 0; _dirty = false; }
|
|
|
|
int render(DisplayDriver& display) override {
|
|
display.setTextSize(1);
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
int item_h = display.lineStep();
|
|
int start_y = display.listStart();
|
|
int val_x = display.valCol();
|
|
|
|
display.drawTextCentered(display.width() / 2, 0, "CLOCK FIELDS");
|
|
display.fillRect(0, display.headerH() - 1, display.width(), display.sepH());
|
|
|
|
static const char* labels[] = { "Field 1", "Field 2", "Field 3" };
|
|
for (int i = 0; i < FIELD_SLOTS; i++) {
|
|
int y = start_y + i * item_h;
|
|
bool sel = (i == _sel);
|
|
if (sel) {
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
display.fillRect(0, y - 1, display.width(), item_h);
|
|
display.setColor(DisplayDriver::DARK);
|
|
} else {
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
}
|
|
display.setCursor(2, y);
|
|
display.print(labels[i]);
|
|
display.setCursor(val_x, y);
|
|
uint8_t f = _prefs->dashboard_fields[i];
|
|
display.print(OPTION_NAMES[f < DASH_COUNT ? f : DASH_NONE]);
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
}
|
|
return 500;
|
|
}
|
|
|
|
bool handleInput(char c) override {
|
|
if (c == KEY_CANCEL || c == KEY_CONTEXT_MENU) {
|
|
if (_dirty) the_mesh.savePrefs();
|
|
_task->gotoHomeScreen();
|
|
return true;
|
|
}
|
|
if (c == KEY_UP && _sel > 0) { _sel--; return true; }
|
|
if (c == KEY_DOWN && _sel < FIELD_SLOTS - 1){ _sel++; return true; }
|
|
if (c == KEY_LEFT || c == KEY_PREV) { cycle(_sel, -1); return true; }
|
|
if (c == KEY_RIGHT || c == KEY_NEXT) { cycle(_sel, 1); return true; }
|
|
if (c == KEY_ENTER) { cycle(_sel, 1); return true; }
|
|
return false;
|
|
}
|
|
};
|
|
|
|
const char* DashboardConfigScreen::OPTION_NAMES[DASH_COUNT] = {
|
|
"None", "Battery", "Temp", "Humidity", "Pressure",
|
|
"GPS", "Altitude", "Lux", "CO2", "Contacts", "Messages"
|
|
};
|