v2.3: Twinkling star animation extended to all menus and splash screen, WiFi submenu removed

This commit is contained in:
Eiswolf-BG
2026-08-05 05:49:51 +02:00
parent d89024e419
commit 59aa5af1b2
16 changed files with 129 additions and 29 deletions

52
src/menu_stars.cpp Normal file
View File

@@ -0,0 +1,52 @@
#include "menu_stars.h"
#include "config.h"
namespace MenuStars {
namespace {
constexpr uint8_t STAR_COUNT = 34;
struct Star {
int16_t x, y;
uint8_t phase;
uint8_t speed;
};
Star stars[STAR_COUNT];
bool initialized = false;
uint32_t lastUpdateMs = 0;
constexpr uint32_t UPDATE_INTERVAL_MS = 60;
void initStars() {
randomSeed((uint32_t)esp_random());
for (uint8_t i = 0; i < STAR_COUNT; i++) {
stars[i].x = (int16_t)random(4, Config::SCREEN_WIDTH - 4);
stars[i].y = (int16_t)random(4, Config::SCREEN_HEIGHT - 4);
stars[i].phase = (uint8_t)random(0, 256);
stars[i].speed = (uint8_t)(1 + random(0, 3));
}
initialized = true;
}
}
void reset() {
initialized = false;
}
void update(TFT_eSPI& tft) {
if (!initialized) initStars();
uint32_t now = millis();
if (now - lastUpdateMs < UPDATE_INTERVAL_MS) return;
lastUpdateMs = now;
for (uint8_t i = 0; i < STAR_COUNT; i++) {
stars[i].phase += stars[i].speed;
uint8_t bright = (stars[i].phase < 128)
? (uint8_t)(stars[i].phase * 2)
: (uint8_t)((255 - stars[i].phase) * 2);
uint16_t color = tft.color565(0, bright, 0);
tft.drawPixel(stars[i].x, stars[i].y, color);
}
}
}