From e2fc97fc6888469d72f9e4cc06de1a36bd6ff061 Mon Sep 17 00:00:00 2001 From: Michael Wesemann Date: Mon, 16 Nov 2026 15:09:13 +0100 Subject: [PATCH] =?UTF-8?q?Weihnachtsbaum:=20nur=20gr=C3=BCner=20Kegel=20m?= =?UTF-8?q?it=20roten=20Kugeln,=20Gr=C3=BCn=20heller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kein Stern, kein Schnee, keine bunten Kugeln mehr; der Kegel geht über alle fünf Etagen. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- fx_fest.cpp | 70 ++++++----------------------------------------------- 2 files changed, 9 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 3b0c764..106e276 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ Nach dem Einschalten läuft das Gewitter. | | Effekt | `id` | Dauer | Beschreibung | | --- | --- | --- | --- | --- | -| 🎄 | Weihnachtsbaum | `weihnachtsbaum` | 40 s | Grüner Kegel mit funkelnden Kugeln, Stern an der Spitze, leiser Schnee | +| 🎄 | Weihnachtsbaum | `weihnachtsbaum` | 40 s | Grüner Kegel über alle Etagen mit sieben langsam glimmenden roten Kugeln | | 🕯️ | Adventskranz | `adventskranz` | 40 s | Grüner Kranz mit Beeren, alle 8 s brennt eine Kerze mehr | | ❄️ | Schnee | `schnee` | 25 s | Flocken taumeln herab und bleiben unten kurz liegen | | 💡 | Lichterkette | `lichterkette` | 30 s | Bunte Birnen als Spirale um den Würfel, abwechselnd Lauflicht und Blinken | diff --git a/fx_fest.cpp b/fx_fest.cpp index 8f5fb3f..29764f0 100644 --- a/fx_fest.cpp +++ b/fx_fest.cpp @@ -3,74 +3,20 @@ #include "fx.h" -// --- Weihnachtsbaum: grüner Kegel mit Kugeln, Stern an der Spitze, leiser Schnee -- +// --- Weihnachtsbaum: grüner Kegel über alle Etagen mit ein paar roten Kugeln ----- static bool isTree(int x, int y, int z) { - float d = distAxis(x, y); - switch (z) { - case 1: return d <= 2.3f; // 21 LEDs - case 2: return d <= 2.0f; // 13 LEDs - case 3: return d <= 1.0f; // 5 LEDs - default: return false; // unten Stamm, oben Stern - } -} - -struct Bauble { - uint8_t x, y, z, phase; - CRGB color; -}; -static Bauble baubles[10]; - -static void placeBauble(Bauble &b) { - static const CRGB COLORS[] = {CRGB(255, 0, 0), CRGB(255, 170, 0), CRGB(0, 60, 255), CRGB(200, 0, 160), CRGB(255, 255, 255)}; - do { - b.x = random8(CUBE_SIZE); - b.y = random8(CUBE_SIZE); - b.z = random8(1, 4); - } while (!isTree(b.x, b.y, b.z) || (b.x == 2 && b.y == 2 && b.z < 3)); // nicht im Stamm-Inneren - b.color = COLORS[random8(5)]; - b.phase = random8(); + static const float RADIUS[] = {2.3f, 2.0f, 1.5f, 1.0f, 0.0f}; // 21, 13, 9, 5, 1 LEDs + return distAxis(x, y) <= RADIUS[z]; } void renderTree(uint32_t now) { - static uint32_t lastMove = 0; - if (fresh) { - fresh = false; - for (Bauble &b : baubles) placeBauble(b); - lastMove = now; - } - if (now - lastMove > 1500) { // ab und zu wandert ein Licht - lastMove = now; - placeBauble(baubles[random8(10)]); - } - + static const uint8_t BAUBLES[][3] = {{4, 1, 0}, {1, 4, 0}, {0, 1, 0}, {3, 3, 1}, {2, 0, 1}, {1, 3, 2}, {3, 2, 3}}; FastLED.clear(); - at(2, 2, 0) = CRGB(brightness / 2, brightness / 5, 0); // Stamm - FOR_XYZ { - if (!isTree(x, y, z)) continue; - uint8_t n = inoise8(x * 60, y * 60, z * 60 + now / 12); - at(x, y, z) = CHSV(96, 255, scale8(brightness, 140 + n / 3)); - } - for (Bauble &b : baubles) { - uint8_t v = 110 + scale8(sin8(now / 6 + b.phase), 145); - at(b.x, b.y, b.z) = CRGB(b.color).nscale8(scale8(highlight, v)); - } - // Stern: Mitte hell und funkelnd, die Zacken abwechselnd - uint8_t tw = sin8(now / 3); - at(2, 2, TOP) = CRGB(highlight, scale8(highlight, 200), scale8(highlight, tw / 3)); - for (uint8_t i = 0; i < 4; i++) { - static const int8_t DX[] = {1, -1, 0, 0}, DY[] = {0, 0, 1, -1}; - uint8_t v = scale8(highlight, 80 + scale8(sin8(now / 4 + i * 64), 120)); - at(2 + DX[i], 2 + DY[i], TOP) = CRGB(v, scale8(v, 170), 0); - } - if (random8() < 4) at(2, 2, TOP) = CRGB::White; - - // leiser Schnee rundherum - if (random8() < 6) spawnParticle(rnd(0, TOP), rnd(0, TOP), TOP + 0.4f, 0, 0, -rnd(0.015f, 0.025f), CRGB(brightness, brightness, brightness)); - moveParticles(0, 1, 0); - for (const Particle &p : particles) { - int x = lroundf(p.x), y = lroundf(p.y), z = lroundf(p.z); - if (p.life && !isTree(x, y, z) && !(x == 2 && y == 2)) plot(p.x, p.y, p.z, p.color); + FOR_XYZ if (isTree(x, y, z)) at(x, y, z) = CRGB(0, highlight, 0); + for (uint8_t i = 0; i < 7; i++) { + uint8_t glow = 180 + scale8(sin8(now / 20 + i * 37), 75); // langsames Glimmen + at(BAUBLES[i][0], BAUBLES[i][1], BAUBLES[i][2]) = CRGB(scale8(highlight, glow), 0, 0); } }