refactor(display): extract tile layout logic to library helper class
This commit is contained in:
@@ -16,19 +16,35 @@ enum class TileAction {
|
||||
REBOOT, // Reboot device
|
||||
};
|
||||
|
||||
/// Dashboard tile layout constraints for flexible grid
|
||||
struct TileConstraint {
|
||||
uint8_t minCols = 1; // minimum columns this tile needs
|
||||
uint8_t minRows = 1; // minimum rows this tile needs
|
||||
uint8_t weight = 1; // priority for growing/shrinking (higher = more flexible)
|
||||
};
|
||||
|
||||
/// Computed tile position in the grid
|
||||
struct TileLayout {
|
||||
int x, y; // pixel position
|
||||
int w, h; // pixel size
|
||||
int col, row; // grid position
|
||||
int cols, rows; // grid span
|
||||
};
|
||||
|
||||
/// Dashboard tile definitions — shared across all boards
|
||||
struct DashboardTile {
|
||||
const char* label;
|
||||
uint16_t bgColor; // RGB565
|
||||
TileAction action;
|
||||
TileConstraint constraint;
|
||||
};
|
||||
|
||||
/// Standard dashboard tiles (auto-gridded based on count)
|
||||
/// Standard dashboard tiles (auto-gridded based on count and constraints)
|
||||
static constexpr DashboardTile DASHBOARD_TILES[] = {
|
||||
{ "Alert", 0x0280, TileAction::ALERT },
|
||||
{ "Silent", 0x0400, TileAction::SILENCE },
|
||||
{ "Status", 0x0440, TileAction::STATUS },
|
||||
{ "Reboot", 0x0100, TileAction::REBOOT },
|
||||
{ "Alert", 0x0280, TileAction::ALERT, {1, 1, 1} },
|
||||
{ "Silent", 0x0400, TileAction::SILENCE, {1, 1, 1} },
|
||||
{ "Status", 0x0440, TileAction::STATUS, {1, 1, 1} },
|
||||
{ "Reboot", 0x0100, TileAction::REBOOT, {1, 1, 1} },
|
||||
};
|
||||
static constexpr int DASHBOARD_TILE_COUNT = sizeof(DASHBOARD_TILES) / sizeof(DASHBOARD_TILES[0]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user