mirror of
https://github.com/ALLFATHER-BV/wadamesh.git
synced 2026-11-07 22:58:51 +00:00
The host build laid out as the Pager: 480x222, no touch, keyboard and rotary
encoder as the only input, with the UI's own TLORA_PAGER branches compiled in,
so the Pager's screens can be reviewed and scripted without flashing.
- web/sim_pager/: keyboard/encoder bridge, stubs for the codec, I2S, haptics,
IMU, charger and gauge, README and a tour script. Environment switches fake
the hardware states: WADA_SIM_CHARGING, WADA_SIM_CHARGE_HOT,
WADA_SIM_CARE_HOLD, WADA_SIM_SOC (+ _DROP), WADA_SIM_USE_MA,
WADA_SIM_FACEDOWN, WADA_SIM_PICKUP, WADA_SIM_BAG.
- Script commands for the Pager: holdkey (accent picker; holdkey space to
lock; holdkey shift / fn for the modifier shortcuts).
- device_caps.h: a WADA_SIM_PAGER caps block. Off by default; the normal web
and host builds are unchanged.
- Host fixes it needed: INT_MAX include for glibc, SD.begin(ss, SPIClass&) in
the SD shim, panelSleep() on WebDisplay.
- Host SPIFFS lists a directory the way SPIFFS does: every file, with its
folder in the name ("/lock/a.jpg"). The host keeps such files in real
folders, and readdir() handed the folder back as an entry, which the file
manager showed as a 0 B file (/lock, /msgs). Affects the host builds only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Josh <8422439+MrYoshii@users.noreply.github.com>
78 lines
3.3 KiB
C++
78 lines
3.3 KiB
C++
#pragma once
|
|
// The web board's panel: an RGB565 framebuffer the LVGL flush writes into
|
|
// (display.writePixelsRGB565 in UITask's lvglFlushImpl) and the platform layer
|
|
// presents (SDL texture now, a <canvas> under Emscripten). Text drawing is the
|
|
// DisplayDriver contract for non-LVGL screens; the touch UI never uses it here.
|
|
#include <helpers/ui/DisplayDriver.h>
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
// The canvas size is the board's resolution, picked by the front end at boot from the
|
|
// window (web_main.cpp / host_main.cpp --size): 800x480 landscape, or a portrait
|
|
// canvas on a phone (WEB_BUILD.md "Phones"). It never changes while the UI runs: an
|
|
// orientation flip restarts the UI in the other layout, as a rotatable board does.
|
|
extern int g_wada_web_w, g_wada_web_h;
|
|
#define WADA_WEB_W g_wada_web_w
|
|
#define WADA_WEB_H g_wada_web_h
|
|
// Before the board boots (the display is a global, built before main()).
|
|
void wadaWebSetSize(int w, int h);
|
|
|
|
class WebDisplay : public DisplayDriver {
|
|
public:
|
|
WebDisplay();
|
|
bool begin() { return true; }
|
|
bool isOn() override { return _on; }
|
|
void turnOn() override { _on = true; }
|
|
void turnOff() override { _on = false; }
|
|
void panelSleep(bool) {} // the Pager's ST7796 sleep-in (T-LoRa Pager simulator)
|
|
void clear() override;
|
|
void startFrame(ColorVal bkg = UIColor::window_bkg) override { (void)bkg; }
|
|
void setTextSize(int sz) override { (void)sz; }
|
|
void setColor(ColorVal c) override { _color = 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 drawRect(int x, int y, int w, int h) override;
|
|
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override { (void)x; (void)y; (void)bits; (void)w; (void)h; }
|
|
uint16_t getTextWidth(const char* str) override;
|
|
void endFrame() override {}
|
|
|
|
// the LVGL flush target
|
|
void writePixelsRGB565(int x, int y, int w, int h, const uint16_t* px);
|
|
void setBrightness(uint8_t level) { _brightness = level; }
|
|
uint8_t brightness() const { return _brightness; }
|
|
void setDisplayRotation(uint8_t r) { (void)r; } // the canvas is already the right way up
|
|
void resize(int w, int h);
|
|
|
|
// platform side
|
|
const uint16_t* framebuffer() const { return _fb; }
|
|
bool takeDirty() { bool d = _dirty; _dirty = false; resetBox(); return d; }
|
|
// The changed area since the last take (x0,y0 inclusive, x1,y1 exclusive): the
|
|
// canvas front end uploads only that rectangle.
|
|
bool takeDirtyRect(int& x0, int& y0, int& x1, int& y1) {
|
|
if (!_dirty) return false;
|
|
x0 = _bx0; y0 = _by0; x1 = _bx1; y1 = _by1;
|
|
_dirty = false; resetBox();
|
|
return x1 > x0 && y1 > y0;
|
|
}
|
|
private:
|
|
void resetBox() { _bx0 = WADA_WEB_W; _by0 = WADA_WEB_H; _bx1 = 0; _by1 = 0; }
|
|
void addBox(int x0, int y0, int x1, int y1) {
|
|
if (x0 < 0) x0 = 0;
|
|
if (y0 < 0) y0 = 0;
|
|
if (x1 > WADA_WEB_W) x1 = WADA_WEB_W;
|
|
if (y1 > WADA_WEB_H) y1 = WADA_WEB_H;
|
|
if (x0 < _bx0) _bx0 = x0;
|
|
if (y0 < _by0) _by0 = y0;
|
|
if (x1 > _bx1) _bx1 = x1;
|
|
if (y1 > _by1) _by1 = y1;
|
|
_dirty = true;
|
|
}
|
|
int _bx0 = 0, _by0 = 0, _bx1 = WADA_WEB_W, _by1 = WADA_WEB_H;
|
|
uint16_t* _fb;
|
|
ColorVal _color = 0xFFFF;
|
|
uint8_t _brightness = 255;
|
|
bool _on = true;
|
|
volatile bool _dirty = true;
|
|
};
|