Merge dev into master: boot icon carousel
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,8 @@ void setup() {
|
|||||||
|
|
||||||
displayBegin();
|
displayBegin();
|
||||||
displaySplash("Weather", "Predictor");
|
displaySplash("Weather", "Predictor");
|
||||||
|
delay(800);
|
||||||
|
displayDemo();
|
||||||
|
|
||||||
if (!sensorsBegin()) Serial.println(F("BMP180 not found!"));
|
if (!sensorsBegin()) Serial.println(F("BMP180 not found!"));
|
||||||
if (!rtcBegin()) Serial.println(F("DS3231 not found!"));
|
if (!rtcBegin()) Serial.println(F("DS3231 not found!"));
|
||||||
|
|||||||
@@ -99,6 +99,46 @@ static void drawIcon(WxCategory c, int x, int y, int W, int H) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Layout for landscape 160 x 80.
|
// Layout for landscape 160 x 80.
|
||||||
|
// Boot demo: each weather icon slides in from the right to centre, with its
|
||||||
|
// category label below in the matching colour.
|
||||||
|
void displayDemo() {
|
||||||
|
WxCategory cats[5] = {WX_FINE, WX_FAIR, WX_CHANGEABLE, WX_RAIN, WX_STORM};
|
||||||
|
const char* names[5] = {"Fine", "Fair", "Changeable", "Rain", "Storm"};
|
||||||
|
const int W = 64, H = 52, y = 4;
|
||||||
|
const int cxc = (160 - W) / 2; // centred icon x
|
||||||
|
tft.fillScreen(ST77XX_BLACK); // clear the splash before the carousel
|
||||||
|
for (int k = 0; k < 5; k++) {
|
||||||
|
// slide in from the right edge to centre
|
||||||
|
int px = 160 + 12;
|
||||||
|
for (int x = 160; x >= cxc; x -= 12) {
|
||||||
|
tft.fillRect(px, y, W, H, ST77XX_BLACK);
|
||||||
|
drawIcon(cats[k], x, y, W, H);
|
||||||
|
px = x;
|
||||||
|
delay(26);
|
||||||
|
}
|
||||||
|
tft.fillRect(px, y, W, H, ST77XX_BLACK);
|
||||||
|
drawIcon(cats[k], cxc, y, W, H);
|
||||||
|
// label centred below in the category colour
|
||||||
|
int len = 0; while (names[k][len]) len++; // size 2 = 12 px/char
|
||||||
|
tft.setTextSize(2);
|
||||||
|
tft.setTextColor(catColor(cats[k]));
|
||||||
|
tft.setCursor((160 - len * 12) / 2, 60);
|
||||||
|
tft.print(names[k]);
|
||||||
|
delay(360);
|
||||||
|
tft.fillRect(0, 60, 160, 20, ST77XX_BLACK); // drop the label before it leaves
|
||||||
|
// slide out to the left edge
|
||||||
|
px = cxc;
|
||||||
|
for (int x = cxc - 12; x >= -W; x -= 12) {
|
||||||
|
tft.fillRect(px, y, W, H, ST77XX_BLACK);
|
||||||
|
drawIcon(cats[k], x, y, W, H);
|
||||||
|
px = x;
|
||||||
|
delay(24);
|
||||||
|
}
|
||||||
|
tft.fillRect(px, y, W, H, ST77XX_BLACK); // clear the last remnant
|
||||||
|
}
|
||||||
|
tft.setTextColor(ST77XX_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
void displayRender(const AppState& s) {
|
void displayRender(const AppState& s) {
|
||||||
tft.fillScreen(ST77XX_BLACK);
|
tft.fillScreen(ST77XX_BLACK);
|
||||||
tft.setTextColor(ST77XX_WHITE);
|
tft.setTextColor(ST77XX_WHITE);
|
||||||
|
|||||||
@@ -4,4 +4,5 @@
|
|||||||
|
|
||||||
void displayBegin();
|
void displayBegin();
|
||||||
void displaySplash(const char* line1, const char* line2);
|
void displaySplash(const char* line1, const char* line2);
|
||||||
|
void displayDemo(); // boot animation: icons slide in one by one
|
||||||
void displayRender(const AppState& s);
|
void displayRender(const AppState& s);
|
||||||
|
|||||||
Reference in New Issue
Block a user