Skip to content

Commit

Permalink
Live Script latest updates: paintbrush, ripples, sphere support 3D
Browse files Browse the repository at this point in the history
Live scripts: update to latest version
- float CR = -0.94299 is possible
- t+=speed is possible
- ternary op update
- cube202020 updates

pio.ini
- latest ESP Live Script
- wrover default non virtual driver

LedEffects
- paintbrush effect: support 3D
- ripples and spheremove effect: time interval and distance float

LedLayer
- add drawLine3D (WIP)

UserModLive
- show errors in UI scripts table (WIP)
  • Loading branch information
ewowi committed Dec 8, 2024
1 parent 94d8b73 commit bbac830
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 81 deletions.
3 changes: 1 addition & 2 deletions misc/LiveScripts/E_animwle.sc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ uint32_t __deltamillis[1];

uint32_t __baseTime[1];

float cR; //= -0.94299; expecting external, __ASM__ or variable type at line:39 position:10 10
float cR = -0.94299;
float cI = 0.3162;

float cX;
Expand Down Expand Up @@ -60,7 +60,6 @@ void render2D(int x1, int y1)

void setup()
{
cR = -0.94299; //workaround see above
}

void loop()
Expand Down
7 changes: 3 additions & 4 deletions misc/LiveScripts/E_hello.sc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ void setup()
void loop() {
fadeToBlackBy(2);
sPC(index, rgb(custom1Control,custom2Control,custom3Control));
index = index + 1;
if ( index == width * height) {
index =0;
}
index += 1;

if ( index == width * height) index = 0;
}
2 changes: 1 addition & 1 deletion misc/LiveScripts/E_octo.sc
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ void loop() {
sPC(y*width+x, hsv(2*t - radius*mapp, 255, intensity));
}
}
t=t+speed;
t += speed;
}
23 changes: 9 additions & 14 deletions misc/LiveScripts/F_Cube202020.sc
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
//F_Cube202020.sc

define width 16
define height 16
define depth 48
define width 20
define height 20
define depth 6

define panelWidth 16
define panelHeight 16

int pins[6] = {9,10,12,8,18,17}; //for esp32-S3 //for virtual driver, max 6 pins supported atm
int pins[6] = {32,33,25,26,27,14}; //STARLIGHT_CLOCKLESS_LED_DRIVER on esp32-wrover (PSRAM)
//int pins[6] = {9,10,12,8,18,17}; //for esp32-S3

void main()
{
setLedSize(2); //smaller leds (default 5)

for (int z=0; z<depth;z++) {

for (int x=0; x<panelWidth;x++) {
for (int y=panelHeight - 1; y>=0; y--) {
int y2 = y; if (x%2 == 0) {y2 = panelHeight - 1 - y;} //serpentine
addPixel(x, y2, z);
}
}
for (int x=0; x<width;x++)
for (int y=0; y<height;y++)
addPixel(x, y, z);

addPin(pins[z/8]); //every 8 panels one pin on the esp32
addPin(pins[z]); //every 8 panels one pin on the esp32
}
}
6 changes: 2 additions & 4 deletions misc/LiveScripts/F_panel080-048.sc
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ void main() {

for (int panelX = horizontalPanels-1; panelX >=0; panelX--)
for (int x=0; x<panelWidth;x++)
for (int y=panelHeight - 1; y>=0; y--) {
int y2 = (x%2)? y: panelHeight - 1 - y; //serpentine
addPixel(panelX * panelWidth + x, panelY * panelHeight + y2, 0);
}
for (int y=panelHeight - 1; y>=0; y--)
addPixel(panelX * panelWidth + x, panelY * panelHeight + (x%2)? y: panelHeight - 1 - y, 0); //serpentine

addPin(pins[panelY]);
}
Expand Down
16 changes: 5 additions & 11 deletions misc/LiveScripts/F_panel128-096.sc
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@ void main() {

for (int panelY = 0; panelY < verticalPanels; panelY++) {

for (int panelX = horizontalPanels-1; panelX >=0; panelX--) {

for (int x=0; x<panelWidth;x++) {
for (int y=panelHeight - 1; y>=0; y--) {
int y2 = (x%2)? y: panelHeight - 1 - y; //serpentine
addPixel(panelX * panelWidth + x, panelY * panelHeight + y2, 0);
}
}

}
for (int panelX = horizontalPanels-1; panelX >=0; panelX--)
for (int x=0; x<panelWidth;x++)
for (int y=panelHeight - 1; y>=0; y--)
addPixel(panelX * panelWidth + x, panelY * panelHeight + (x%2)? y: panelHeight - 1 - y, 0); //serpentine

addPin(pins[panelY]);

}

}
15 changes: 4 additions & 11 deletions misc/LiveScripts/F_panel4x32x8.sc
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ void main() {

for (int panelY = verticalPanels - 1; panelY >=0; panelY--) { //first panel on the bottom

for (int panelX = 0; panelX < horizontalPanels; panelX++) {

for (int x=panelWidth-1; x>=0; x--) { //first coluumn on the right
for (int y=0; y<panelHeight; y++) {
int y2 = (x%2)? y: panelHeight - 1 - y; //serpentine
addPixel(panelX * panelWidth + x, panelY * panelHeight + y2, 0);
}
}

}
for (int panelX = 0; panelX < horizontalPanels; panelX++)
for (int x=panelWidth-1; x>=0; x--) //first coluumn on the right
for (int y=0; y<panelHeight; y++)
addPixel(panelX * panelWidth + x, panelY * panelHeight + (x%2)? y: panelHeight - 1 - y, 0); //serpentine

addPin(16);

}
}
13 changes: 7 additions & 6 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ build_flags =
-D STARBASE_USERMOD_LIVE
-D EXTPRINTF=ppf ;redirect Live Script prints to StarBase print
lib_deps =
https://github.com/ewowi/ESPLiveScript.git#v3.1 ;ewowi repo adds some proposed PR's and makes sure we don't have unexpected updates
https://github.com/ewowi/ESPLiveScript.git#d62bf25 ; v3.1 ;ewowi repo adds some proposed PR's and makes sure we don't have unexpected updates

[STARLIGHT_CLOCKLESS_LED_DRIVER]
build_flags =
Expand All @@ -104,7 +104,7 @@ build_flags =
; 10 is enough in LedOS, but not enough for StarLight, flickering stays
; 60: [ 4453][E][WiFiUdp.cpp:49] begin(): could not create tx buffer: 61
-D NBIS2SERIALPINS=6 ;nr of shift registers (6 * 8 * 256 = 12288) I2SClocklessVirtualLedDriver variable!
; ESP32 config:
; ESP32 (wrover) config:
; -D STARLIGHT_ICVLD_CLOCK_PIN=26
; -D STARLIGHT_ICVLD_LATCH_PIN=27
; ESP32 S3 config:
Expand Down Expand Up @@ -236,7 +236,8 @@ lib_deps =

; https://github.com/platformio/platform-espressif32/issues/1360
; https://community.platformio.org/t/support-esp32-wrover-module/17717
; note: flasghing to new board goes wrong, try first without ICVD then with and without etc until it works (witchcraft)
; note: flashing to new board goes wrong, try first without ICVD then with and without etc until it works (witchcraft)
; Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed).
[env:esp-wrover-kit]
board = esp-wrover-kit ; esp-wrover-kit ;https://github.com/platformio/platform-espressif32/blob/develop/boards/esp-wrover-kit.json
; recommended to pin to a platform version, see https://github.com/platformio/platform-espressif32/releases
Expand All @@ -248,12 +249,12 @@ build_flags =
-D ARDUINO_USB_CDC_ON_BOOT=0 ; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32")
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
${STARLIGHT_CLOCKLESS_VIRTUAL_LED_DRIVER.build_flags}
; ${STARLIGHT_CLOCKLESS_LED_DRIVER.build_flags}
-D STARLIGHT_MAXLEDS=12288 ;LEDs specific
-D STARLIGHT_LIVE_MAPPING
; -D STARLIGHT_LIVE_MAPPING
lib_deps =
${env.lib_deps}
${STARLIGHT_CLOCKLESS_VIRTUAL_LED_DRIVER.lib_deps}
; ${STARLIGHT_CLOCKLESS_LED_DRIVER.lib_deps}

;End LEDs specific builds

Expand Down
33 changes: 23 additions & 10 deletions src/App/LedEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -2812,7 +2812,7 @@ class LaserGEQEffect: public Effect {
// @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
class PaintbrushEffect: public Effect {
const char * name() override {return "Paintbrush";}
uint8_t dim() override {return _2D;}
uint8_t dim() override {return _3D;} //also 2D (change dim to multiple options?)
const char * tags() override {return "♫💡";}

void setup(LedsLayer &leds, Variable parentVar) override {
Expand Down Expand Up @@ -2845,6 +2845,7 @@ class PaintbrushEffect: public Effect {

const uint16_t cols = leds.size.x;
const uint16_t rows = leds.size.y;
const uint16_t depth = leds.size.z;

// byte numLines = map8(nrOfLines,1,64);

Expand All @@ -2860,8 +2861,17 @@ class PaintbrushEffect: public Effect {
byte x2 = beatsin8(oscillatorOffset*2 + audioSync->fftResults[0]/16, 0, (cols-1), audioSync->fftResults[bin], *aux1Chaos);
byte y1 = beatsin8(oscillatorOffset*3 + audioSync->fftResults[0]/16, 0, (rows-1), audioSync->fftResults[bin], *aux1Chaos);
byte y2 = beatsin8(oscillatorOffset*4 + audioSync->fftResults[0]/16, 0, (rows-1), audioSync->fftResults[bin], *aux1Chaos);
byte z1;
byte z2;
int length;
if (leds.projectionDimension == _3D) {
z1 = beatsin8(oscillatorOffset*3 + audioSync->fftResults[0]/16, 0, (depth-1), audioSync->fftResults[bin], *aux1Chaos);
z2 = beatsin8(oscillatorOffset*4 + audioSync->fftResults[0]/16, 0, (depth-1), audioSync->fftResults[bin], *aux1Chaos);

length = sqrt((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1) + (z2-z1) * (z2-z1));
} else
length = sqrt((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1));

int length = sqrt((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1));
length = map8(audioSync->fftResults[bin],0,length);

if (length > max(1, (int)minLength)) {
Expand All @@ -2870,7 +2880,10 @@ class PaintbrushEffect: public Effect {
color = ColorFromPalette(leds.palette, i * 255 / numLines + ((*aux0Hue)&0xFF), 255);
else
color = ColorFromPalette(leds.palette, map(i, 0, numLines, 0, 255), 255);
leds.drawLine(x1, y1, x2, y2, color, soft, length);
if (leds.projectionDimension == _3D)
leds.drawLine3D(x1, y1, z1, x2, y2, z2, color, soft, length); // no soft implemented in 3D yet
else
leds.drawLine(x1, y1, x2, y2, color, soft, length);
}
}
}
Expand Down Expand Up @@ -3137,7 +3150,7 @@ class RipplesEffect: public Effect {
uint8_t interval = leds.effectData.read<uint8_t>();

float ripple_interval = 1.3f * ((255.0f - interval)/128.0f) * sqrtf(leds.size.y);
uint32_t time_interval = sys->now/(100 - speed)/((256.0f-128.0f)/20.0f);
float time_interval = sys->now/(100.0 - speed)/((256.0f-128.0f)/20.0f);

leds.fill_solid(CRGB::Black);

Expand Down Expand Up @@ -3169,22 +3182,22 @@ class SphereMoveEffect: public Effect {

leds.fill_solid(CRGB::Black);

uint32_t time_interval = sys->now/(100 - speed)/((256.0f-128.0f)/20.0f);
float time_interval = sys->now/(100 - speed)/((256.0f-128.0f)/20.0f);

Coord3D origin;
origin.x = leds.size.x / 2.0 * ( 1 + sinf(time_interval));
origin.y = leds.size.y / 2.0 * ( 1 + cosf(time_interval));
origin.z = leds.size.z / 2.0 * ( 1 + cosf(time_interval));
origin.x = leds.size.x / 2.0 * ( 1.0 + sinf(time_interval));
origin.y = leds.size.y / 2.0 * ( 1.0 + cosf(time_interval));
origin.z = leds.size.z / 2.0 * ( 1.0 + cosf(time_interval));

float diameter = 2.0f+sinf(time_interval/3.0f);

Coord3D pos;
for (pos.x=0; pos.x<leds.size.x; pos.x++) {
for (pos.y=0; pos.y<leds.size.y; pos.y++) {
for (pos.z=0; pos.z<leds.size.z; pos.z++) {
uint16_t d = distance(pos.x, pos.y, pos.z, origin.x, origin.y, origin.z);
float d = distance(pos.x, pos.y, pos.z, origin.x, origin.y, origin.z);

if (d>diameter && d<diameter+1) {
if (d>diameter && d<diameter + 1.0) {
leds[pos] = CHSV( sys->now/50 + random8(64), 200, 255);// ColorFromPalette(leds.palette,call, bri);
}
}
Expand Down
Loading

0 comments on commit bbac830

Please sign in to comment.