diff --git a/WeatherPredictor/WeatherPredictor.ino b/WeatherPredictor/WeatherPredictor.ino index 72715c6..33f6007 100644 --- a/WeatherPredictor/WeatherPredictor.ino +++ b/WeatherPredictor/WeatherPredictor.ino @@ -43,6 +43,8 @@ void setup() { displayBegin(); displaySplash("Weather", "Predictor"); + delay(800); + displayDemo(); if (!sensorsBegin()) Serial.println(F("BMP180 not found!")); if (!rtcBegin()) Serial.println(F("DS3231 not found!")); diff --git a/WeatherPredictor/display_ui.cpp b/WeatherPredictor/display_ui.cpp index ff82eb5..9a83585 100644 --- a/WeatherPredictor/display_ui.cpp +++ b/WeatherPredictor/display_ui.cpp @@ -99,6 +99,46 @@ static void drawIcon(WxCategory c, int x, int y, int W, int H) { } // 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) { tft.fillScreen(ST77XX_BLACK); tft.setTextColor(ST77XX_WHITE); diff --git a/WeatherPredictor/display_ui.h b/WeatherPredictor/display_ui.h index 480781b..b6c1e1b 100644 --- a/WeatherPredictor/display_ui.h +++ b/WeatherPredictor/display_ui.h @@ -4,4 +4,5 @@ void displayBegin(); void displaySplash(const char* line1, const char* line2); +void displayDemo(); // boot animation: icons slide in one by one void displayRender(const AppState& s);