refactor: parameterize Dashboard for multi-target
- TFT_eSPI / TFT_eSprite -> Gfx / GfxSprite typedefs - Hard-coded 480x320 -> SCREEN_WIDTH / SCREEN_HEIGHT from BoardConfig - Top bar, WiFi bars, time position all scale to any resolution - Zero behavioral change on E32R35T (Gfx = TFT_eSPI typedef)
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
#pragma once
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
#include "DisplayDriver.h"
|
||||
#include "ScreenData.h"
|
||||
|
||||
#define DASH_COLS 3
|
||||
#define DASH_ROWS 2
|
||||
#define DASH_MARGIN 8
|
||||
#define DASH_TOP_BAR 40
|
||||
#define TILE_W ((480 - (DASH_COLS + 1) * DASH_MARGIN) / DASH_COLS)
|
||||
#define TILE_H ((320 - DASH_TOP_BAR - (DASH_ROWS + 1) * DASH_MARGIN) / DASH_ROWS)
|
||||
#define DASH_COLS 3
|
||||
#define DASH_ROWS 2
|
||||
#define DASH_MARGIN 8
|
||||
#define DASH_TOP_BAR 40
|
||||
|
||||
#define TILE_W ((SCREEN_WIDTH - (DASH_COLS + 1) * DASH_MARGIN) / DASH_COLS)
|
||||
#define TILE_H ((SCREEN_HEIGHT - DASH_TOP_BAR - (DASH_ROWS + 1) * DASH_MARGIN) / DASH_ROWS)
|
||||
|
||||
enum TileID : uint8_t {
|
||||
TILE_LAST_ALERT = 0,
|
||||
@@ -22,16 +24,16 @@ enum TileID : uint8_t {
|
||||
struct TileData {
|
||||
const char* icon;
|
||||
const char* label;
|
||||
char value[32];
|
||||
char sub[32];
|
||||
uint16_t bgColor;
|
||||
uint16_t fgColor;
|
||||
bool dirty;
|
||||
char value[32];
|
||||
char sub[32];
|
||||
uint16_t bgColor;
|
||||
uint16_t fgColor;
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
class Dashboard {
|
||||
public:
|
||||
Dashboard(TFT_eSPI& tft);
|
||||
Dashboard(Gfx& tft);
|
||||
|
||||
void begin();
|
||||
void drawAll();
|
||||
@@ -41,15 +43,14 @@ public:
|
||||
void refreshFromState(const ScreenState& state);
|
||||
|
||||
private:
|
||||
TFT_eSPI& _tft;
|
||||
TFT_eSprite _sprite;
|
||||
TileData _tiles[TILE_COUNT];
|
||||
Gfx& _tft;
|
||||
GfxSprite _sprite;
|
||||
TileData _tiles[TILE_COUNT];
|
||||
|
||||
char _barTime[12] = "";
|
||||
int _barRSSI = 0;
|
||||
bool _barWifiOk = false;
|
||||
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