implement dashboard on wake
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <TFT_eSPI.h>
|
||||
#include "ScreenData.h"
|
||||
|
||||
// Grid layout constants
|
||||
#define DASH_COLS 3
|
||||
@@ -8,8 +9,8 @@
|
||||
#define DASH_TOP_BAR 40
|
||||
|
||||
// Tile dimensions (calculated for 480x320)
|
||||
#define TILE_W ((480 - (DASH_COLS + 1) * DASH_MARGIN) / DASH_COLS) // ~148
|
||||
#define TILE_H ((320 - DASH_TOP_BAR - (DASH_ROWS + 1) * DASH_MARGIN) / DASH_ROWS) // ~128
|
||||
#define TILE_W ((480 - (DASH_COLS + 1) * DASH_MARGIN) / DASH_COLS) // ~148
|
||||
#define TILE_H ((320 - DASH_TOP_BAR - (DASH_ROWS + 1) * DASH_MARGIN) / DASH_ROWS) // ~128
|
||||
|
||||
// Tile IDs
|
||||
enum TileID : uint8_t {
|
||||
@@ -23,30 +24,38 @@ enum TileID : uint8_t {
|
||||
};
|
||||
|
||||
struct TileData {
|
||||
const char* icon; // emoji/symbol character
|
||||
const char* label; // tile name
|
||||
char value[32]; // dynamic value text
|
||||
char sub[32]; // secondary line
|
||||
const char* icon;
|
||||
const char* label;
|
||||
char value[32];
|
||||
char sub[32];
|
||||
uint16_t bgColor;
|
||||
uint16_t fgColor;
|
||||
bool dirty; // needs redraw
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
class Dashboard {
|
||||
public:
|
||||
Dashboard(TFT_eSPI& tft);
|
||||
|
||||
void begin();
|
||||
void drawAll();
|
||||
void begin(); // create sprite (call once)
|
||||
void drawAll(); // fill screen + draw all tiles
|
||||
void drawTopBar(const char* time, int rssi, bool wifiOk);
|
||||
void updateTile(TileID id, const char* value, const char* sub = nullptr);
|
||||
int handleTouch(int x, int y); // returns TileID or -1
|
||||
int handleTouch(int x, int y); // returns TileID or -1
|
||||
|
||||
// Populate tiles from ScreenState — only redraws changed tiles
|
||||
void refreshFromState(const ScreenState& state);
|
||||
|
||||
private:
|
||||
TFT_eSPI& _tft;
|
||||
TFT_eSprite _sprite;
|
||||
TileData _tiles[TILE_COUNT];
|
||||
|
||||
// Cached top bar values for dirty check
|
||||
char _barTime[12] = "";
|
||||
int _barRSSI = 0;
|
||||
bool _barWifiOk = false;
|
||||
|
||||
void drawTile(TileID id);
|
||||
void tilePosition(TileID id, int& x, int& y);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user