Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/moonbase/inputoutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ The **I2C frequency** can be adjusted (default 100 kHz). Higher frequencies (400
* Choose the esp32-s3-n8r8v board in the [MoonLight Installer](../../gettingstarted/installer/)
* Set Switch1 the same as you set the jumper on the board: off / default: Infrared. on: Ethernet.
* 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)
* 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).


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

* Choose the esp32-s3-n8r8v board in the [MoonLight Installer](../../gettingstarted/installer/)
* Documentation to be soon published on [limpkin's website](https://www.limpkin.fr)
* 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).
21 changes: 17 additions & 4 deletions docs/moonlight/livescripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The **Live Scripts module** itself does not create scripts — it shows all curr

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

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.
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).

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

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

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

### Predefined variable: `NUM_LEDS`
### Predefined types and constants

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

---

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

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

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

---

Expand Down Expand Up @@ -265,4 +278,4 @@ void loop() {

---

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).
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).
31 changes: 31 additions & 0 deletions livescripts/Effects/Arti-FX/E_Beatmania.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Beatmania - beat-synced moving lights
// Original: beatmania.wled by Andrew Tuline

uint8_t speed = 128;
uint8_t intensity = 128;

void setup() {
addControl(&speed, "speed", "slider", 1, 255);
addControl(&intensity, "intensity", "slider", 1, 255);
}

void loop() {
fadeToBlackBy(intensity / 8);

uint8_t locn1 = beatsin8(speed / 3 + 1, 0, NUM_LEDS - 1, 0, 0);
uint8_t locn2 = beatsin8(speed / 4 + 1, 0, NUM_LEDS - 1, 0, 0);

uint8_t colr1 = beatsin8(intensity / 6 + 1, 0, 255, 0, 0);
uint8_t colr2 = beatsin8(intensity / 7 + 1, 0, 255, 0, 0);

uint8_t bri1 = beatsin8(intensity / 6 + 1, 32, 255, 0, 0);
uint8_t bri2 = beatsin8(intensity / 7 + 1, 32, 255, 0, 0);

int locn12 = (locn1 + locn2) % NUM_LEDS;
uint8_t colr12 = colr1 + colr2;
uint8_t bri12 = bri1 + bri2;

setRGBPal(locn12, colr12, bri12);
setRGBPal(locn1, colr2, bri1);
setRGBPal(locn2, colr1, bri2);
}
41 changes: 41 additions & 0 deletions livescripts/Effects/Arti-FX/E_BlockReflections.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Block Reflections - shifting reflected blocks
// Original: block_reflections.wled (PixelBlaze, converted by Andrew Tuline)

#define PI2 6.28318

void loop() {
float t2 = (millis() % 6553) / 6553.0 * PI2;
float t1 = (millis() % 6553) / 6553.0;
float t3 = (millis() % 32767) / 32767.0;
float t4 = (millis() % 13107) / 13107.0 * PI2;

// triangle(t1)
float tf = t1 * 2.0 - 1.0;
if (tf < 0.0) tf = 0.0 - tf;
float trit1 = 1.0 - tf;

// triangle(t3)
float t3f = t3 * 2.0 - 1.0;
if (t3f < 0.0) t3f = 0.0 - t3f;
float trit3 = 1.0 - t3f;

float m = 0.3 + trit1 * 0.2;

for (int i = 0; i < NUM_LEDS; i++) {
float h = sin(t2);
float hh = (i - NUM_LEDS / 2.0) / NUM_LEDS;
float hhh = trit3 * 10.0 + 4.0 * sin(t4);
float hmod = hh * hhh;
float mf = hmod - (int)(hmod / m) * m;
h = h + mf;

float vv = h;
if (vv < 0.0) vv = 0.0 - vv;
float vm = m;
if (vm < 0.0) vm = 0.0 - vm;
float v = (vv + vm + t1);
float vf = v - (int)v;
v = vf * vf;
setHSV(i, h * 255, 255, v * 255);
}
}
19 changes: 19 additions & 0 deletions livescripts/Effects/Arti-FX/E_BrightPulse.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Bright Pulse - fill LEDs based on audio volume
// Original: BrightPulseSR.wled (idea by @tony)
// Requires an audio driver (WLED Audio or FastLED Audio)

uint8_t speed = 128;

void setup() {
addControl(&speed, "sensitivity", "slider", 1, 255);
}

void loop() {
int lum = volume * 256 / (256 - speed);
if (lum > 255) lum = 255;
if (lum < 0) lum = 0;

for (int i = 0; i < NUM_LEDS; i++) {
setHSV(i, 0, 0, lum);
}
}
12 changes: 12 additions & 0 deletions livescripts/Effects/Arti-FX/E_Clock.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Clock - show hour, minute, second as colored pixels
// Original: Clock.wled from MoonModules/MM-Effects
// Requires NTP to be configured for correct time

void loop() {
fadeToBlackBy(255); // instant clear

// hour, minute, second as dots at positions along the strip
if (hour < NUM_LEDS) setRGBPal(hour, 25, 255);
if (minute < NUM_LEDS) setRGBPal(minute, 125, 255);
if (second < NUM_LEDS) setRGBPal(second, 225, 255);
}
42 changes: 42 additions & 0 deletions livescripts/Effects/Arti-FX/E_Clock2D.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Clock 2D - analog clock on a 2D matrix
// Original: Clock2D.wled from MoonModules/MM-Effects
// Requires a 2D layout (panel) and NTP for correct time

#define PI2 6.28318

void loop() {
fadeToBlackBy(255); // instant clear

int cx = width / 2;
int cy = height / 2;
int radius = cx;
if (cy < radius) radius = cy;

// draw 12 hour markers
for (int h = 0; h < 12; h++) {
float angle = h * PI2 / 12.0;
int mx = cx + sin(angle) * (radius - 1);
int my = cy - cos(angle) * (radius - 1);
if (mx >= 0 && mx < width && my >= 0 && my < height) {
setRGBXY(mx, my, ColorFromPalette(225, 128));
}
}

// second hand
float sa = second * PI2 / 60.0;
int sx = cx + sin(sa) * (radius - 1);
int sy = cy - cos(sa) * (radius - 1);
drawLine(cx, cy, sx, sy, ColorFromPalette(25, 255));

// minute hand
float ma = minute * PI2 / 60.0;
int mx = cx + sin(ma) * (radius - 2);
int my = cy - cos(ma) * (radius - 2);
drawLine(cx, cy, mx, my, ColorFromPalette(92, 255));

// hour hand (shorter)
float ha = (hour % 12) * PI2 / 12.0 + minute * PI2 / 720.0;
int hx = cx + sin(ha) * (radius / 2);
int hy = cy - cos(ha) * (radius / 2);
drawLine(cx, cy, hx, hy, ColorFromPalette(160, 255));
}
23 changes: 23 additions & 0 deletions livescripts/Effects/Arti-FX/E_ColorFadePulse.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Color Fade Pulse - fading color pulse
// Original: color_fade_pulse.wled (PixelBlaze, converted by Andrew Tuline)

#define PI 3.14159
#define PI2 6.28318

void loop() {
float t1 = (millis() % 655) / 655.0;
float t2 = (millis() % 6553) / 6553.0 * PI2;
float t3 = (millis() % 1310) / 1310.0;

for (int i = 0; i < NUM_LEDS; i++) {
float il = i * 1.0 / NUM_LEDS;
float h = il * 2.0 - t1;
float s = (1.0 + sin(t2 + il * PI)) / 2.0;
float vt = (t3 + il * 4.0);
float vf = vt - (int)vt;
float v = vf * 2.0 - 1.0;
if (v < 0.0) v = 0.0 - v;
v = 1.0 - v;
setHSV(i, h * 255, s * 255, v * 255);
}
}
6 changes: 6 additions & 0 deletions livescripts/Effects/Arti-FX/E_ColorRandom.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ColorRandom - random palette colors
// Original: ColorRandom.wled from MoonModules/MM-Effects

void loop() {
setRGBPal(random16(NUM_LEDS), random16(255), 255);
}
19 changes: 19 additions & 0 deletions livescripts/Effects/Arti-FX/E_ColorTwinkleBounce.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Color Twinkle Bounce - twinkling bouncing colors
// Original: color_twinkle_bounce.wled (PixelBlaze, converted by Andrew Tuline)

#define PI2 6.28318

void loop() {
float t1 = (millis() % 3276) / 3276.0 * PI2;
float t2 = (millis() % 3276) / 3276.0 * PI2;
float tb = (millis() % 6553) / 6553.0;

for (int i = 0; i < NUM_LEDS; i++) {
float aa = i / 2.0 + 5.0 * sin(t1);
float a = (1.0 + sin(aa)) / 2.0;
float ba = i / 2.0 + 5.0 * sin(t2);
float b = tb + 1.0 + sin(ba);
float v = a * a * a;
setHSV(i, b * 255, 255, v * 255);
}
}
20 changes: 20 additions & 0 deletions livescripts/Effects/Arti-FX/E_ColorTwinkles.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Color Twinkles - sparkling color twinkles
// Original: color_twinkles.wled (PixelBlaze, converted by Andrew Tuline)

#define PI2 6.28318

void loop() {
float t1 = (millis() % 9830) / 9830.0 * PI2;
float t2 = (millis() % 32767) / 32767.0 * PI2;

for (int i = 0; i < NUM_LEDS; i++) {
float aa = i / 3.0 + PI2 * sin(i / 2.0 + t1);
float a = (1.0 + sin(aa)) / 2.0;
a = a * a * a * a;
if (a <= 0.1) a = 0.0;

float bb = i / 3.0 + PI2 * sin(i / 2.0 + t2);
float b = sin(bb);
setHSV(i, b * 255, 255, a * 255);
}
}
32 changes: 32 additions & 0 deletions livescripts/Effects/Arti-FX/E_Drip.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Drip - single drip falling with gravity
// Original: drip.wled by Andrew Tuline

uint8_t speed = 50;
uint8_t fade = 64;
float dripSpd = 0.0;
float dripLocn = 0.0;
uint8_t colr = 1;
uint8_t bri = 64;

void setup() {
addControl(&speed, "speed", "slider", 1, 255);
addControl(&fade, "fade", "slider", 1, 255);
dripLocn = NUM_LEDS - 1;
}

void loop() {
float grav = speed / 1000.0;
fadeToBlackBy(fade);

dripSpd = dripSpd + grav;
dripLocn = dripLocn - dripSpd;

if (dripLocn >= 0.0) {
setRGBPal((int)dripLocn, colr, bri);
}

if (dripLocn < 0.0) {
dripLocn = NUM_LEDS - 1;
dripSpd = 0.0;
}
}
30 changes: 30 additions & 0 deletions livescripts/Effects/Arti-FX/E_EdgeBurst.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Edge Burst - bursts from edges
// Original: edge_burst.wled (PixelBlaze, converted by Andrew Tuline)

void loop() {
// t1 = triangle(time(0.1))
float tval = (millis() % 6553) / 6553.0;
float tf = tval * 2.0 - 1.0;
if (tf < 0.0) tf = 0.0 - tf;
float t1 = 1.0 - tf;

for (int i = 0; i < NUM_LEDS; i++) {
float f = i * 1.0 / NUM_LEDS;
// triangle(f)
float ft = f * 2.0 - 1.0;
if (ft < 0.0) ft = 0.0 - ft;
float trif = 1.0 - ft;

float edge = trif + t1 * 4.0 - 2.0;
if (edge < 0.0) edge = 0.0;
if (edge > 1.0) edge = 1.0;

// triangle(edge)
float et = edge * 2.0 - 1.0;
if (et < 0.0) et = 0.0 - et;
float v = 1.0 - et;

float h = edge * edge - 0.2;
setHSV(i, h * 255, 255, v * 255);
}
}
9 changes: 9 additions & 0 deletions livescripts/Effects/Arti-FX/E_FFTBands.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// FFT Bands - frequency-reactive brightness per band
// Original: fftBrightness.wled by ewowi

void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
uint8_t band = i % 16;
setRGBPal(i, i * 16, bands[band]);
}
}
23 changes: 23 additions & 0 deletions livescripts/Effects/Arti-FX/E_FastPulse.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Fast Pulse - pulsing light wave
// Original: fast_pulse.wled (PixelBlaze, converted by Andrew Tuline)

#define PI2 6.28318

void loop() {
float t1 = (millis() % 6553) / 6553.0;
float w = (1.0 + sin(t1 * PI2)) / 2.0;

for (int i = 0; i < NUM_LEDS; i++) {
float il = i * 1.0 / NUM_LEDS;
float x = (2.0 * w + il);
float frac = x - (int)x;
// triangle of frac
float v = frac * 2.0 - 1.0;
if (v < 0.0) v = 0.0 - v;
v = 1.0 - v;
v = v * v * v * v * v;
uint8_t s = 255;
if (v >= 0.9) s = 0;
setHSV(i, t1 * 255, s, v * 255);
}
}
Loading
Loading