Skip to content

Commit

Permalink
UserModLive: bug fixes
Browse files Browse the repository at this point in the history
BeatMania.sc: more compact notation and changed from 1D to 2D Bars (so Live effect is still a 2D effect)

animwleSL.sc added but not working yet

octo and balls, sPC remove first parameter, bug solved

UserModLive
- add cos8
- beatSin8 bug return uint8_t not float
- spCLive: remove first parameter, bug solved
  • Loading branch information
ewoudwijma committed Aug 8, 2024
1 parent f719ecf commit 553b6a8
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 43 deletions.
118 changes: 118 additions & 0 deletions misc/animwleSL.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// WIP, By Yves but time and triangle is now external
// Unexpected at line:115
// preScript has 27 lines, so should be 88, or a but around but looks okay there

define maxIterations 15
define scale 0.5
uint32_t __deltamillis[1];

uint32_t __baseTime[1];

__ASM__ uint32_t millis()
{
"entry a1,32"
"l32r a5,__baseTime"
"l32i a14,a5,0"
"rsr a13,234"
"l32r a4,__deltamillis"
"s32i a13,a4,0"
"sub a13,a13,a14"
"movi a14,240"
"quou a13,a13,a14"
"movi a14,1000"
"quou a13,a13,a14"
"l32r a4,stackr"
"s32i a13,a4,0"
"retw.n"
}

float cR; // = -0.94299;
float cI; // = 0.3162;


float cX;
float cY;
float fX;
float fY;

// timers used to animate movement and color
float t1;
float t2;
int iter;
// UI


void beforeRender()
{
// float jj=triangle(time(0.2));
// dp(2.4*(jj-0.5));
//§§float g=2.4;
//§ t1 = g*(triangle(time(0.2)) - 0.5)
;
//dp(t1);
t1 = (triangle(time(0.2)) - 0.5)*2.4 ;
//dp(t1);
t2 = time(0.05);

cX = cR + t1;
cY = cI + (t1 / 2.5);
// dp(cY);
// dp(cX);
// dp(t1);
// display(11111);
// dp(t2);
}


void render2D(int x1, int y1)
{
float x = (x1/width-0.5)/scale;
float y = (y1/height-0.5)/scale;
int iter;
for (iter = 0; iter < maxIterations; iter++)
{
float x2 = x ^ 2;
float y2 = y ^ 2;
if ((int)(x2 + y2) >= 4)
{
break;
}
fX = x2 - y2 + cX;
fY = 2 * x * y + cY;
x = fX;
y = fY;
}


if (iter < maxIterations)
{
CRGB gg = hsv((float)((t2 + (iter / maxIterations)) * 255), 255, 255);
sPC(panel_width * y1 + x1, gg);
}
else
{
CRGB gg = hsv(0,0,0);
sPC(panel_width * y1 + x1, gg);
}
}

void main()
{
clear();
resetStat();
cR = -0.94299;
cI = 0.3162;
int h = 1 ;
while (h > 0)
{
beforeRender();
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
render2D(i, j);
}
}
show();
}
}
10 changes: 5 additions & 5 deletions misc/ballsSL.sc
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ void drawBall(float xc, float yc, float r, int c)
{
v = (float)(255 * (1 - distance * distance / (r4)));
CRGB cc=hsv(c,255,v);
sPC(0, i + j * panel_width, cc);
sPC(i + j * panel_width, cc);
// int h=(int)(2 * xc - i) + j * panel_width;
sPC(0, (int)(2 * xc - i) + j * panel_width,cc);
sPC((int)(2 * xc - i) + j * panel_width,cc);
// h=(int)(2 * xc - i) + (int)(2 * yc - j) * panel_widthsdfsdf;
sPC(0, (int)(2 * xc - i) + (int)(2 * yc - j) * panel_width, cc);
sPC((int)(2 * xc - i) + (int)(2 * yc - j) * panel_width, cc);
// h=i + (int)(2 * yc - j) * panel_width;
sPC(0, i + (int)(2 * yc - j) * panel_width, cc);
sPC(i + (int)(2 * yc - j) * panel_width, cc);
}
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ void loop()
for(int j=0;j<height;j++)
{
CRGB gg = hsv(i+h+j,255,180);
sPC(0, i+panel_width*j, gg);
sPC(i+panel_width*j, gg);
}
}

Expand Down
50 changes: 20 additions & 30 deletions misc/beatmaniaSL.sc
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
//from https://github.com/MoonModules/WLED-Effects/blob/master/ARTIFX/wled/beatmania.wled
//Created by Andrew Tuline Converted by Ewoud Wijma

uint8_t locn1;
uint8_t locn2;
uint8_t locn3;
uint8_t locn12;

uint8_t colr1;
uint8_t colr2;
uint8_t colr3;
uint8_t colr12;

uint8_t bri1;
uint8_t bri2;
uint8_t bri3;
uint8_t bri12;

void setup()
{
Expand All @@ -23,26 +9,30 @@ void setup()

void loop() {

//fadeToBlackBy(slider2/8); // Adjustable fade rate.
fadeToBlackBy(slider2/8); // Adjustable fade rate.

locn1 = beatSin8(slider1/3+1,0,width) ; // Adjustable speed.
locn2 = beatSin8(slider1/4+1,0,width);
locn3 = beatSin8(slider1/5+1,0,width/2+width/3);
uint8_t length = width-1;

colr1 = beatSin8(slider2/6+1,0,255);
colr2 = beatSin8(slider2/7+1,0,255);
colr3 = beatSin8(slider2/8+1,0,255);
uint8_t locn1 = beatSin8(slider1/3+1,0,length) ; // Adjustable speed.
uint8_t locn2 = beatSin8(slider1/4+1,0,length);
uint8_t locn3 = beatSin8(slider1/5+1,0,length/2+length/3);

bri1 = beatSin8(slider2/6+1,32,255);
bri2 = beatSin8(slider2/7+1,32,255);
bri3 = beatSin8(slider2/8+1,32,255) ; // One too many beats.
uint8_t colr1 = beatSin8(slider2/6+1,0,255);
uint8_t colr2 = beatSin8(slider2/7+1,0,255);
uint8_t colr3 = beatSin8(slider2/8+1,0,255);

locn12 = locn1+locn2;
colr12 = colr1+colr2;
bri12 = bri1+bri2;
sCFP(locn12,colr12,bri12);
sCFP(locn1,colr2,bri1);
sCFP(locn2%(width-1),colr1,bri2);
uint8_t bri1 = beatSin8(slider2/6+1,32,255);
uint8_t bri2 = beatSin8(slider2/7+1,32,255);
uint8_t bri3 = beatSin8(slider2/8+1,32,255) ; // One too many beats.

uint8_t locn12 = locn1+locn2;
uint8_t colr12 = colr1+colr2;
uint8_t bri12 = bri1+bri2;
for (uint8_t y = 0; y < height; y++) {
if (locn12 < length) {sCFP(y*panel_width+locn12,colr12,bri12);}
sCFP(y*panel_width+locn1,colr2,bri1);
sCFP(y*panel_width+locn2%(length-1),colr1,bri2);
}
}

void main() {
Expand Down
2 changes: 1 addition & 1 deletion misc/octoSL.sc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void loop() {
// leds[y*panel_width+x] = hsv(t + radius, 255, h);

CRGB gg = hsv(t + radius, 255, sin8(t*4+sin8(t * 4 - radius)+angle*nb_branches));
sPC(t, y*panel_width+x, gg);
sPC(y*panel_width+x, gg);
}
}
t=t+speed;
Expand Down
13 changes: 6 additions & 7 deletions src/User/UserModLive.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ static float _time(float j) {
//LEDS specific
static CRGB POSV(uint8_t h, uint8_t s, uint8_t v) {return CHSV(h, s, v);} //why call POSV and not hsv?
static uint8_t _sin8(uint8_t a) {return sin8(a);}
static float _beatSin8(uint8_t a1, uint8_t a2, uint8_t a3) {return beatsin8(a1, a2, a3);}
static uint8_t _cos8(uint8_t a) {return cos8(a);}
static uint8_t _beatSin8(uint8_t a1, uint8_t a2, uint8_t a3) {return beatsin8(a1, a2, a3);}
static LedsLayer *gLeds = nullptr;
static void _fadeToBlackBy(uint8_t a1) {gLeds->fadeToBlackBy(a1);}
static void sPCLive(int t, uint16_t pixel, CRGB color) { // int t needed - otherwise wrong colors, very strange
static void sPCLive(uint16_t pixel, CRGB color) { // int t needed - otherwise wrong colors, very strange
if (gLeds)
{
// if (t == 0) ppf(" %d,%d,%d", color.r, color.g, color.b);
Expand All @@ -100,10 +101,7 @@ static void sPCLive(int t, uint16_t pixel, CRGB color) { // int t needed - other
}
static void sCFPLive(uint16_t pixel, uint8_t index, uint8_t brightness) { // int t needed - otherwise wrong colors, very strange
if (gLeds)
{
// if (t == 0) ppf(" %d,%d,%d", color.r, color.g, color.b);
gLeds->setPixelColor(pixel, ColorFromPalette(gLeds->palette, index, brightness));
}
}
uint8_t slider1 = 128;
uint8_t slider2 = 128;
Expand Down Expand Up @@ -192,8 +190,9 @@ class UserModLive:public SysModule {
//LEDS specific
addExternalFun("CRGB", "hsv", "(int a1, int a2, int a3)", (void *)POSV);
addExternalFun("uint8_t", "sin8","(uint8_t a1)",(void*)_sin8); //using int here causes value must be between 0 and 16 error!!!
addExternalFun("void", "sPC", "(int a0, int a1, CRGB a2)", (void *)sPCLive); // int t needed - otherwise wrong colors, very strange
addExternalFun("void", "sCFP", "(uint16_t pixel, uint8_t index, uint8_t brightness)", (void *)sCFPLive);
addExternalFun("uint8_t", "cos8","(uint8_t a1)",(void*)_cos8); //using int here causes value must be between 0 and 16 error!!!
addExternalFun("void", "sPC", "(uint16_t a1, CRGB a2)", (void *)sPCLive); // int t needed - otherwise wrong colors, very strange
addExternalFun("void", "sCFP", "(uint16_t a1, uint8_t a2, uint8_t a3)", (void *)sCFPLive);
addExternalFun("void", "fadeToBlackBy", "(uint8_t a1)", (void *)_fadeToBlackBy);
//address of overloaded function with no contextual type information: setPixelColorLive
//ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say '&LedsLayer::setPixelColorLive' [-fpermissive]
Expand Down

0 comments on commit 553b6a8

Please sign in to comment.