Skip to content

Commit c0ea7c8

Browse files
authored
Merge pull request #155 from MoonModules/integration
Arti-FX effects
2 parents a0020d3 + 395d4eb commit c0ea7c8

60 files changed

Lines changed: 1446 additions & 51 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/moonbase/inputoutput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ The **I2C frequency** can be adjusted (default 100 kHz). Higher frequencies (400
326326
* Choose the esp32-s3-n8r8v board in the [MoonLight Installer](../../gettingstarted/installer/)
327327
* Set Switch1 the same as you set the jumper on the board: off / default: Infrared. on: Ethernet.
328328
* Only 5 boards were ever produced. If you are one of the lucky few, feel free to reach out to limpkin on [Discord](https://discord.gg/TC8NSUSCdV)
329+
* Use the [L_SE16.sc](https://github.com/MoonModules/MoonLight/blob/main/livescripts/Layouts/L_SE16.sc) Live Script layout for this board. Controls: `mirroredPins` (wiring mode), `pinsAreColumns` (axis orientation), `ledsPerPin` (LEDs per output).
329330

330331

331332
#### LightCrafter16
@@ -334,3 +335,4 @@ The **I2C frequency** can be adjusted (default 100 kHz). Higher frequencies (400
334335

335336
* Choose the esp32-s3-n8r8v board in the [MoonLight Installer](../../gettingstarted/installer/)
336337
* Documentation to be soon published on [limpkin's website](https://www.limpkin.fr)
338+
* Use the [L_LC16.sc](https://github.com/MoonModules/MoonLight/blob/main/livescripts/Layouts/L_LC16.sc) Live Script layout for this board. Controls: `pinsAreColumns` (axis orientation), `ledsPerPin` (LEDs per output).

docs/moonlight/livescripts.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The **Live Scripts module** itself does not create scripts — it shows all curr
3636

3737
<img width="300" alt="image" src="https://github.com/user-attachments/assets/3b7eca3c-ae57-43f6-910e-3fc03f6fa380" />
3838

39-
See [example scripts on GitHub](https://github.com/MoonModules/MoonLight/tree/main/misc/livescripts)`E_*.sc` for effects, `L_*.sc` for layouts, `P_*.sc` for palettes.
39+
See example scripts on GitHub: [Effects](https://github.com/MoonModules/MoonLight/tree/main/livescripts/Effects), [Layouts](https://github.com/MoonModules/MoonLight/tree/main/livescripts/Layouts), [Palettes](https://github.com/MoonModules/MoonLight/tree/main/livescripts/Palettes).
4040

4141
**Step 3**: Select the script in the appropriate module:
4242

@@ -74,9 +74,11 @@ A script can combine these — for example, an effect with both `setup()` (to cr
7474

7575
`uint8_t`, `uint16_t`, `uint32_t`, `int`, `float`, `bool`, `void`, `CRGB`
7676

77-
### Predefined variable: `NUM_LEDS`
77+
### Predefined types and constants
7878

79-
`NUM_LEDS` is automatically defined as the current number of lights before compilation.
79+
| Name | Definition | Description |
80+
|---|---|---|
81+
| `NUM_LEDS` | `#define` | Current number of lights, set before compilation |
8082

8183
---
8284

@@ -113,10 +115,18 @@ A script can combine these — for example, an effect with both `setup()` (to cr
113115
| Function | Description |
114116
|---|---|
115117
| `void fadeToBlackBy(uint8_t amount)` | Fade all LEDs toward black |
118+
| `CRGB ColorFromPalette(uint8_t index, uint8_t brightness)` | Look up a color from the current global palette (index 0–255) |
119+
| `CRGB getRGB(uint16_t index)` | Read the current color of LED at index |
116120
| `void setRGB(uint16_t index, CRGB color)` | Set LED at index to an RGB color |
121+
| `void setRGBXY(int x, int y, CRGB color)` | Set LED at coordinate (x, y) — runs through modifier chain |
122+
| `void setRGBXYZ(int x, int y, int z, CRGB color)` | Set LED at coordinate (x, y, z) — runs through modifier chain |
123+
| `void setHSV(uint16_t index, uint8_t h, uint8_t s, uint8_t v)` | Set LED at index to an HSV color |
124+
| `void setHSVXY(int x, int y, uint8_t h, uint8_t s, uint8_t v)` | Set LED at coordinate (x, y) to an HSV color |
117125
| `void setRGBPal(uint16_t index, uint8_t palIndex, uint8_t brightness)` | Set LED using the current palette |
118126
| `void setPan(uint16_t index, uint8_t value)` | Set pan channel (moving heads) |
119127
| `void setTilt(uint16_t index, uint8_t value)` | Set tilt channel (moving heads) |
128+
| `void drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, CRGB color)` | Draw a 2D line between two points |
129+
| `void drawCircle(int cx, int cy, uint8_t radius, CRGB color)` | Draw a 2D circle outline |
120130

121131
### Layout functions (for `L_` scripts)
122132

@@ -153,6 +163,9 @@ A script can combine these — for example, an effect with both `setup()` (to cr
153163
| `gravityX` | `int` | IMU gravity vector X component |
154164
| `gravityY` | `int` | IMU gravity vector Y component |
155165
| `gravityZ` | `int` | IMU gravity vector Z component |
166+
| `hour` | `uint8_t` | Current hour (0–23), requires NTP |
167+
| `minute` | `uint8_t` | Current minute (0–59), requires NTP |
168+
| `second` | `uint8_t` | Current second (0–59), requires NTP |
156169

157170
---
158171

@@ -265,4 +278,4 @@ void loop() {
265278

266279
---
267280

268-
More example scripts are available on [GitHub](https://github.com/MoonModules/MoonLight/tree/main/misc/livescripts). To request new functions, send a [ping on Discord](https://discord.com/channels/700041398778331156/1369578126450884608).
281+
More example scripts are available on GitHub: [Effects](https://github.com/MoonModules/MoonLight/tree/main/livescripts/Effects), [Layouts](https://github.com/MoonModules/MoonLight/tree/main/livescripts/Layouts), [Palettes](https://github.com/MoonModules/MoonLight/tree/main/livescripts/Palettes). To request new functions, send a [ping on Discord](https://discord.com/channels/700041398778331156/1369578126450884608).
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Beatmania - beat-synced moving lights
2+
// Original: beatmania.wled by Andrew Tuline
3+
4+
uint8_t speed = 128;
5+
uint8_t intensity = 128;
6+
7+
void setup() {
8+
addControl(&speed, "speed", "slider", 1, 255);
9+
addControl(&intensity, "intensity", "slider", 1, 255);
10+
}
11+
12+
void loop() {
13+
fadeToBlackBy(intensity / 8);
14+
15+
uint8_t locn1 = beatsin8(speed / 3 + 1, 0, NUM_LEDS - 1, 0, 0);
16+
uint8_t locn2 = beatsin8(speed / 4 + 1, 0, NUM_LEDS - 1, 0, 0);
17+
18+
uint8_t colr1 = beatsin8(intensity / 6 + 1, 0, 255, 0, 0);
19+
uint8_t colr2 = beatsin8(intensity / 7 + 1, 0, 255, 0, 0);
20+
21+
uint8_t bri1 = beatsin8(intensity / 6 + 1, 32, 255, 0, 0);
22+
uint8_t bri2 = beatsin8(intensity / 7 + 1, 32, 255, 0, 0);
23+
24+
int locn12 = (locn1 + locn2) % NUM_LEDS;
25+
uint8_t colr12 = colr1 + colr2;
26+
uint8_t bri12 = bri1 + bri2;
27+
28+
setRGBPal(locn12, colr12, bri12);
29+
setRGBPal(locn1, colr2, bri1);
30+
setRGBPal(locn2, colr1, bri2);
31+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Block Reflections - shifting reflected blocks
2+
// Original: block_reflections.wled (PixelBlaze, converted by Andrew Tuline)
3+
4+
#define PI2 6.28318
5+
6+
void loop() {
7+
float t2 = (millis() % 6553) / 6553.0 * PI2;
8+
float t1 = (millis() % 6553) / 6553.0;
9+
float t3 = (millis() % 32767) / 32767.0;
10+
float t4 = (millis() % 13107) / 13107.0 * PI2;
11+
12+
// triangle(t1)
13+
float tf = t1 * 2.0 - 1.0;
14+
if (tf < 0.0) tf = 0.0 - tf;
15+
float trit1 = 1.0 - tf;
16+
17+
// triangle(t3)
18+
float t3f = t3 * 2.0 - 1.0;
19+
if (t3f < 0.0) t3f = 0.0 - t3f;
20+
float trit3 = 1.0 - t3f;
21+
22+
float m = 0.3 + trit1 * 0.2;
23+
24+
for (int i = 0; i < NUM_LEDS; i++) {
25+
float h = sin(t2);
26+
float hh = (i - NUM_LEDS / 2.0) / NUM_LEDS;
27+
float hhh = trit3 * 10.0 + 4.0 * sin(t4);
28+
float hmod = hh * hhh;
29+
float mf = hmod - (int)(hmod / m) * m;
30+
h = h + mf;
31+
32+
float vv = h;
33+
if (vv < 0.0) vv = 0.0 - vv;
34+
float vm = m;
35+
if (vm < 0.0) vm = 0.0 - vm;
36+
float v = (vv + vm + t1);
37+
float vf = v - (int)v;
38+
v = vf * vf;
39+
setHSV(i, h * 255, 255, v * 255);
40+
}
41+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Bright Pulse - fill LEDs based on audio volume
2+
// Original: BrightPulseSR.wled (idea by @tony)
3+
// Requires an audio driver (WLED Audio or FastLED Audio)
4+
5+
uint8_t speed = 128;
6+
7+
void setup() {
8+
addControl(&speed, "sensitivity", "slider", 1, 255);
9+
}
10+
11+
void loop() {
12+
int lum = volume * 256 / (256 - speed);
13+
if (lum > 255) lum = 255;
14+
if (lum < 0) lum = 0;
15+
16+
for (int i = 0; i < NUM_LEDS; i++) {
17+
setHSV(i, 0, 0, lum);
18+
}
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Clock - show hour, minute, second as colored pixels
2+
// Original: Clock.wled from MoonModules/MM-Effects
3+
// Requires NTP to be configured for correct time
4+
5+
void loop() {
6+
fadeToBlackBy(255); // instant clear
7+
8+
// hour, minute, second as dots at positions along the strip
9+
if (hour < NUM_LEDS) setRGBPal(hour, 25, 255);
10+
if (minute < NUM_LEDS) setRGBPal(minute, 125, 255);
11+
if (second < NUM_LEDS) setRGBPal(second, 225, 255);
12+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Clock 2D - analog clock on a 2D matrix
2+
// Original: Clock2D.wled from MoonModules/MM-Effects
3+
// Requires a 2D layout (panel) and NTP for correct time
4+
5+
#define PI2 6.28318
6+
7+
void loop() {
8+
fadeToBlackBy(255); // instant clear
9+
10+
int cx = width / 2;
11+
int cy = height / 2;
12+
int radius = cx;
13+
if (cy < radius) radius = cy;
14+
15+
// draw 12 hour markers
16+
for (int h = 0; h < 12; h++) {
17+
float angle = h * PI2 / 12.0;
18+
int mx = cx + sin(angle) * (radius - 1);
19+
int my = cy - cos(angle) * (radius - 1);
20+
if (mx >= 0 && mx < width && my >= 0 && my < height) {
21+
setRGBXY(mx, my, ColorFromPalette(225, 128));
22+
}
23+
}
24+
25+
// second hand
26+
float sa = second * PI2 / 60.0;
27+
int sx = cx + sin(sa) * (radius - 1);
28+
int sy = cy - cos(sa) * (radius - 1);
29+
drawLine(cx, cy, sx, sy, ColorFromPalette(25, 255));
30+
31+
// minute hand
32+
float ma = minute * PI2 / 60.0;
33+
int mx = cx + sin(ma) * (radius - 2);
34+
int my = cy - cos(ma) * (radius - 2);
35+
drawLine(cx, cy, mx, my, ColorFromPalette(92, 255));
36+
37+
// hour hand (shorter)
38+
float ha = (hour % 12) * PI2 / 12.0 + minute * PI2 / 720.0;
39+
int hx = cx + sin(ha) * (radius / 2);
40+
int hy = cy - cos(ha) * (radius / 2);
41+
drawLine(cx, cy, hx, hy, ColorFromPalette(160, 255));
42+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Color Fade Pulse - fading color pulse
2+
// Original: color_fade_pulse.wled (PixelBlaze, converted by Andrew Tuline)
3+
4+
#define PI 3.14159
5+
#define PI2 6.28318
6+
7+
void loop() {
8+
float t1 = (millis() % 655) / 655.0;
9+
float t2 = (millis() % 6553) / 6553.0 * PI2;
10+
float t3 = (millis() % 1310) / 1310.0;
11+
12+
for (int i = 0; i < NUM_LEDS; i++) {
13+
float il = i * 1.0 / NUM_LEDS;
14+
float h = il * 2.0 - t1;
15+
float s = (1.0 + sin(t2 + il * PI)) / 2.0;
16+
float vt = (t3 + il * 4.0);
17+
float vf = vt - (int)vt;
18+
float v = vf * 2.0 - 1.0;
19+
if (v < 0.0) v = 0.0 - v;
20+
v = 1.0 - v;
21+
setHSV(i, h * 255, s * 255, v * 255);
22+
}
23+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ColorRandom - random palette colors
2+
// Original: ColorRandom.wled from MoonModules/MM-Effects
3+
4+
void loop() {
5+
setRGBPal(random16(NUM_LEDS), random16(255), 255);
6+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Color Twinkle Bounce - twinkling bouncing colors
2+
// Original: color_twinkle_bounce.wled (PixelBlaze, converted by Andrew Tuline)
3+
4+
#define PI2 6.28318
5+
6+
void loop() {
7+
float t1 = (millis() % 3276) / 3276.0 * PI2;
8+
float t2 = (millis() % 3276) / 3276.0 * PI2;
9+
float tb = (millis() % 6553) / 6553.0;
10+
11+
for (int i = 0; i < NUM_LEDS; i++) {
12+
float aa = i / 2.0 + 5.0 * sin(t1);
13+
float a = (1.0 + sin(aa)) / 2.0;
14+
float ba = i / 2.0 + 5.0 * sin(t2);
15+
float b = tb + 1.0 + sin(ba);
16+
float v = a * a * a;
17+
setHSV(i, b * 255, 255, v * 255);
18+
}
19+
}

0 commit comments

Comments
 (0)