- Tempo (66 Effekte): eigene Effekt-Uhr 0,25- bis 4-mal so schnell; bei mehr Tempo mehrere Rechenschritte pro Bild (aufwändige Effekte nur einer), bei weniger nicht in jedem Bild - Farbe (Blitzlicht, Blaulicht, Geschenk, Fraktalwolken, Lampe): Farbton des fertigen Bilds drehen - Empfindlichkeit (Musik): Pegel und Spektrum verstärken, Beat-Schwelle - Eigene: Gewitter Blitze, Feuer Hitze, Regen Stärke, Schnee Dichte, Weihnachtsbaum Kugelfarbe - Mitte 128 = ursprünglicher Effekt; Wert je Effekt im Flash - API: param in /api/state, Parametername in /api/effects - App: Regler „Effekt“ unter der Helligkeit (Titel antippen = Mitte), Schalter in einer Zeile, „Alle Kategorien“ heißt jetzt „Zufällig“ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
212 lines
8.1 KiB
C
212 lines
8.1 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 (geprüft 2026-11-17 mit /api/pixels), vorn = Seite mit dem Mikrofon:
|
|
// z = Etage von unten (0) nach oben, (0, 0, z) ist die Ecke hinten rechts,
|
|
// x läuft an der rechten Seite von hinten (0) nach vorn (4),
|
|
// y läuft an der Rückseite von rechts (0) nach links (4).
|
|
// Das ist ein linkshändiges System: Bilder und Schrift erscheinen gespiegelt,
|
|
// wenn man rechtshändig rechnet (siehe drawText in fx_extras.cpp).
|
|
// Reihenfolge der LEDs innerhalb einer Etage: alle Reihen laufen in dieselbe
|
|
// Richtung (eine Schlangenlinie ergab im Test Zickzack).
|
|
const uint8_t LAYER_MAP[CUBE_SIZE][CUBE_SIZE] = {
|
|
{ 0, 1, 2, 3, 4 },
|
|
{ 5, 6, 7, 8, 9 },
|
|
{ 10, 11, 12, 13, 14 },
|
|
{ 15, 16, 17, 18, 19 },
|
|
{ 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
|
|
// Regler "Effekt": ein Parameter je Effekt, 0..255, Mitte 128 = Original
|
|
const char *effectParamName(uint8_t i); // z. B. "Tempo", "Farbe", "Hitze"
|
|
uint8_t effectParam(uint8_t i);
|
|
void setEffectParam(uint8_t i, uint8_t value);
|
|
extern uint8_t fxParam; // Wert für den laufenden Effekt
|
|
// fxParam als Faktor: 0 -> 0,25, 128 -> 1, 255 -> ~4
|
|
inline float paramFactor() { return exp2f((fxParam - 128) / 64.0f); }
|
|
extern uint32_t effectClock; // Uhr der Effekte (läuft mit dem Tempo)
|
|
extern uint32_t frameNow; // echte Zeit des Bilds: für trigger...() aus Effekten
|
|
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
|
|
|
|
// Manueller Modus (/api/pixels): statt eines Effekts zeigt der Würfel genau diese
|
|
// Pixel, ohne Autowechsel und Blitze. Jeder Effektstart beendet ihn.
|
|
extern bool manualMode;
|
|
extern CRGB manualFrame[NUM_LAYERS][CUBE_SIZE][CUBE_SIZE]; // [z][y][x]
|
|
void setManual(bool on); // aus: der laufende Effekt startet neu
|
|
|
|
// 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
|
|
extern float audioSensitivity; // Verstärkung für Pegel, Spektrum und Beats (Regler "Effekt")
|
|
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);
|