- Neue Kategorie Extras: Lampe in wählbarer Farbe, Laufschrift mit eigener 5-LED-Schrift (A-Z, ÄÖÜß, Ziffern, Satzzeichen, °, ♥), Uhr per NTP, Wetter von Open-Meteo (eigener Task auf Kern 0, alle 15 min) - Favoriten: bis zu 12, aus den Favoriten gestartet wechselt der Würfel nur durch sie (playFavorites) - Effekt, Autowechsel, Helligkeit, Favoriten, Lampenfarbe, Text und Ort werden 2 s nach einer Änderung im NVS gespeichert und beim Start geladen - API: neue Felder in /api/state, GET /api/weather - App: Favoriten-Zeile, langes Drücken = Favorit, Einstellungen für Lampe, Laufschrift und Wetter-Ort (Suche über Open-Meteo) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
190 lines
6.8 KiB
C
190 lines
6.8 KiB
C
#pragma once
|
||
|
||
#include <Arduino.h>
|
||
#include <FastLED.h>
|
||
#include "config.h"
|
||
|
||
extern CRGB leds[NUM_LEDS];
|
||
|
||
// Grundhelligkeit der Effekte und Helligkeit für Funken, Raketen, Bälle
|
||
// (per Taster 2 oder REST-API einstellbar, siehe cube.ino)
|
||
extern uint8_t brightness, highlight;
|
||
|
||
const uint8_t TOP = NUM_LAYERS - 1; // oberste Etage
|
||
|
||
// Koordinaten: z = Etage (0 = Etage 1 am ESP, unten), x/y = Position in der Etage.
|
||
// Reihenfolge der LEDs innerhalb einer Etage – ungeprüfte Annahme (Schlangenlinie).
|
||
const uint8_t LAYER_MAP[CUBE_SIZE][CUBE_SIZE] = {
|
||
{ 0, 1, 2, 3, 4 },
|
||
{ 9, 8, 7, 6, 5 },
|
||
{ 10, 11, 12, 13, 14 },
|
||
{ 19, 18, 17, 16, 15 },
|
||
{ 20, 21, 22, 23, 24 },
|
||
};
|
||
|
||
inline CRGB &at(uint8_t x, uint8_t y, uint8_t z) {
|
||
return leds[z * CUBE_SIZE * CUBE_SIZE + LAYER_MAP[y][x]];
|
||
}
|
||
|
||
// Steuerung (cube.ino), z. B. für die REST-API
|
||
uint8_t numCategories();
|
||
const char *categoryId(uint8_t c); // feste Kennung, z. B. "musik"
|
||
const char *categoryName(uint8_t c); // Anzeigename, z. B. "Musik"
|
||
uint8_t numEffects();
|
||
const char *effectId(uint8_t i); // feste Kennung, z. B. "feuer"
|
||
const char *effectName(uint8_t i); // Anzeigename, z. B. "Feuer"
|
||
uint8_t effectCategory(uint8_t i); // Index der Kategorie
|
||
uint8_t currentEffect();
|
||
void selectEffect(uint8_t i);
|
||
void setBaseBrightness(uint8_t b); // Grundhelligkeit 0..255
|
||
int findEffect(const char *id); // Index zur id, -1 = unbekannt
|
||
extern bool autoAdvance; // Effekte automatisch weiterschalten
|
||
extern bool autoAll; // dabei zufällig alle Kategorien statt nur die laufende
|
||
// Favoriten: so viele, wie die App Plätze je Kategorie hat
|
||
const uint8_t MAX_FAVORITES = 12;
|
||
uint8_t numFavorites();
|
||
uint8_t favorite(uint8_t k); // Effekt-Index des k-ten Favoriten
|
||
void setFavorites(const uint8_t *list, uint8_t n);
|
||
extern bool playFavorites; // automatisch nur durch die Favoriten wechseln
|
||
|
||
// Einstellungen im Flash (settings.cpp)
|
||
void settingsLoad(); // beim Start
|
||
void settingsChanged(); // nach jeder Änderung; gespeichert wird 2 s später
|
||
void settingsUpdate(uint32_t now); // einmal pro Frame aufrufen
|
||
|
||
// Wetter (weather.cpp): holt im Hintergrund alle 15 min das aktuelle Wetter am
|
||
// eingestellten Ort bei Open-Meteo
|
||
struct WeatherInfo {
|
||
bool valid; // Daten vorhanden
|
||
float temperature; // °C
|
||
uint8_t code; // WMO-Wettercode, z. B. 0 klar, 3 bedeckt, 61 Regen, 71 Schnee
|
||
bool isDay;
|
||
uint32_t updated; // millis() beim Abruf
|
||
};
|
||
void weatherBegin();
|
||
WeatherInfo weatherNow();
|
||
void setLocation(const char *place, float latitude, float longitude); // place "" = kein Ort
|
||
bool getLocation(char *place, size_t size, float &latitude, float &longitude); // false = kein Ort
|
||
|
||
// Extras (fx_extras.cpp), in der App einstellbar
|
||
extern CRGB lampColor;
|
||
extern String tickerText;
|
||
|
||
// WLAN und REST-API (web.cpp)
|
||
void webBegin();
|
||
void webUpdate(uint32_t now); // einmal pro Frame aufrufen
|
||
|
||
// Mikrofon (audio.cpp)
|
||
void audioBegin();
|
||
void audioUpdate(uint32_t now); // einmal pro Frame aufrufen
|
||
bool audioClap(); // true, wenn seit dem letzten Aufruf geklatscht wurde
|
||
bool audioBeat(); // true, wenn seit dem letzten Aufruf ein Bass-Schlag kam
|
||
float audioLevel(); // Lautstärke 0..1, passt sich automatisch an
|
||
void audioSpectrum(float bands[CUBE_SIZE]); // 5 Frequenzbänder 0..1, Bass zuerst
|
||
|
||
// Spezialeffekte, die kurz über jedem Effekt laufen (effects.cpp)
|
||
void triggerLightning(uint32_t now);
|
||
void triggerExplosion(uint32_t now);
|
||
void triggerRainbowWave(uint32_t now);
|
||
void drawLightning(uint32_t now);
|
||
void drawSpecials(uint32_t now); // alle laufenden Spezialeffekte zeichnen
|
||
|
||
// Effekte (effects.cpp und fx_*.cpp, eine Datei je Kategorie); now = millis()
|
||
void resetEffects(); // beim Effektwechsel
|
||
// Flash
|
||
void renderShells(uint32_t now);
|
||
void renderMatrix(uint32_t now);
|
||
void renderBounce(uint32_t now);
|
||
void renderStrobe(uint32_t now);
|
||
void renderScanner(uint32_t now);
|
||
void renderComets(uint32_t now);
|
||
void renderSnake(uint32_t now);
|
||
void renderRotor(uint32_t now);
|
||
void renderStack(uint32_t now);
|
||
void renderPolice(uint32_t now);
|
||
void renderPixelStorm(uint32_t now);
|
||
void renderLaser(uint32_t now);
|
||
// Festtage
|
||
void renderTree(uint32_t now);
|
||
void renderWreath(uint32_t now);
|
||
void renderSnow(uint32_t now);
|
||
void renderFairyLights(uint32_t now);
|
||
void renderXmasStar(uint32_t now);
|
||
void renderGift(uint32_t now);
|
||
void renderCandyCane(uint32_t now);
|
||
void renderGlitter(uint32_t now);
|
||
void renderCountdown(uint32_t now);
|
||
void renderFireworks(uint32_t now);
|
||
void renderSparkler(uint32_t now);
|
||
void renderBubbly(uint32_t now);
|
||
// Musik
|
||
void renderSpectrum(uint32_t now);
|
||
void renderPulse(uint32_t now);
|
||
void renderShockwave(uint32_t now);
|
||
void renderSoundLayers(uint32_t now);
|
||
void renderSoundWave(uint32_t now);
|
||
void renderDisco(uint32_t now);
|
||
void renderVu(uint32_t now);
|
||
void renderBeatPlanes(uint32_t now);
|
||
void renderSoundCube(uint32_t now);
|
||
void renderSparkRain(uint32_t now);
|
||
void renderScope(uint32_t now);
|
||
void renderRings(uint32_t now);
|
||
// Floating
|
||
void renderRainbow(uint32_t now);
|
||
void renderLava(uint32_t now);
|
||
void renderWave(uint32_t now);
|
||
void renderHelix(uint32_t now);
|
||
void renderPlasma(uint32_t now);
|
||
void renderBubbles(uint32_t now);
|
||
void renderColorFog(uint32_t now);
|
||
void renderMetaballs(uint32_t now);
|
||
void renderVortex(uint32_t now);
|
||
void renderWeightless(uint32_t now);
|
||
void renderRings3d(uint32_t now);
|
||
void renderPendulums(uint32_t now);
|
||
// Natur
|
||
void renderStorm(uint32_t now);
|
||
void renderFire(uint32_t now);
|
||
void renderRain(uint32_t now);
|
||
void renderAurora(uint32_t now);
|
||
void renderOcean(uint32_t now);
|
||
void renderFireflies(uint32_t now);
|
||
void renderSunrise(uint32_t now);
|
||
void renderMeadow(uint32_t now);
|
||
void renderWaterfall(uint32_t now);
|
||
void renderVolcano(uint32_t now);
|
||
void renderAutumn(uint32_t now);
|
||
void renderShootingStars(uint32_t now);
|
||
// Fraktal
|
||
void renderMandelbrot(uint32_t now);
|
||
void renderJulia(uint32_t now);
|
||
void renderBitPattern(uint32_t now);
|
||
void renderFractalTree(uint32_t now);
|
||
void renderChaosGame(uint32_t now);
|
||
void renderLorenz(uint32_t now);
|
||
void renderThomas(uint32_t now);
|
||
void renderLife3d(uint32_t now);
|
||
void renderAutomaton(uint32_t now);
|
||
void renderHilbert(uint32_t now);
|
||
void renderCrystal(uint32_t now);
|
||
void renderFractalClouds(uint32_t now);
|
||
// Ruhe
|
||
void renderBreathe(uint32_t now);
|
||
void renderCandle(uint32_t now);
|
||
void renderStarrySky(uint32_t now);
|
||
void renderMoonlight(uint32_t now);
|
||
void renderColorCycle(uint32_t now);
|
||
void renderEmbers(uint32_t now);
|
||
void renderDeepSea(uint32_t now);
|
||
void renderDusk(uint32_t now);
|
||
void renderTide(uint32_t now);
|
||
void renderLanterns(uint32_t now);
|
||
void renderHourglass(uint32_t now);
|
||
void renderPastel(uint32_t now);
|
||
// Extras
|
||
void renderLamp(uint32_t now);
|
||
void renderTicker(uint32_t now);
|
||
void renderClock(uint32_t now);
|
||
void renderWeather(uint32_t now);
|