Skip to content

Commit

Permalink
UserModLive: move main/setup/loop code out of sc file and generate
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudwijma committed Aug 9, 2024
1 parent 0036269 commit 0ebb3a3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 59 deletions.
21 changes: 10 additions & 11 deletions misc/animwleSL.sc
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,22 @@ void render2D(int x1, int y1)
}
}

void main()
void setup()
{
clear();
resetStat();
clear();
cR = -0.94299;
cI = 0.3162;
int h = 1 ;
while (h > 0)
}

void loop()
{
beforeRender();
for (int i = 0; i < width; i++)
{
beforeRender();
for (int i = 0; i < width; i++)
for (int j = 0; j < height; j++)
{
for (int j = 0; j < height; j++)
{
render2D(i, j);
}
render2D(i, j);
}
show();
}
}
45 changes: 15 additions & 30 deletions misc/ballsSL.sc
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,9 @@ void updateBall(int index)
drawBall(_xc, _yc, _r, _color);
}

void init()
{
for(int i=0;i<max_nb_balls;i++)
{
vx[i] = rand(280)/255+0.7;
vy[i] = rand(280)/255+0.5;
r[i] = (rmax-rmin)*(rand(280)/180) +rmin;
xc[i] = width/2*(rand(280)/255+0.3)+15;
yc[i] = height/2*(rand(280)/255+0.3)+15;

color[i] = rand(255);
}
}
void updateParams()
{
nb_balls=slider1;
nb_balls=slider1;
if(nb_balls>max_nb_balls)
{
nb_balls=max_nb_balls;
Expand All @@ -113,11 +100,20 @@ nb_balls=slider1;
}

int h;

void setup()
{
resetStat();
//initleds(pins,NUM_STRIPS,NUM_LEDS_PER_STRIP);
init();
for(int i=0;i<max_nb_balls;i++)
{
vx[i] = rand(280)/255+0.7;
vy[i] = rand(280)/255+0.5;
r[i] = (rmax-rmin)*(rand(280)/180) +rmin;
xc[i] = width/2*(rand(280)/255+0.3)+15;
yc[i] = height/2*(rand(280)/255+0.3)+15;

color[i] = rand(255);
}

h=0;
}

Expand All @@ -131,25 +127,14 @@ void loop()
CRGB gg = hsv(i+h+j,255,180);
sPC(i+panel_width*j, gg);
}
}
}

updateParams();
updateParams();
for (int i = 0; i < nb_balls; i++)
{
updateBall(i);
// drawBall(1,1,1,CRGB(255,255,255));
}

show();
h++;
}


void main()
{
setup();
while (2 > 0)
{
loop();
}
}
9 changes: 0 additions & 9 deletions misc/beatmaniaSL.sc
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,4 @@ void loop() {
sCFP(y*panel_width+locn1,colr2,bri1);
sCFP(y*panel_width+locn2%(length-1),colr1,bri2);
}
}

void main() {
resetStat();
setup();
while (2>1) {
loop();
show();
}
}
9 changes: 0 additions & 9 deletions misc/green_ripple_reflectionsSL.sc
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,4 @@ void loop() {
sPC(y*panel_width+index, gg);
}
}
}

void main() {
resetStat();
setup();
while (2>1) {
loop();
show();
}
}
2 changes: 2 additions & 0 deletions src/User/UserModLive.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ class UserModLive:public SysModule {

scScript += string(f.readString().c_str()); // add sc file

scScript += "void main(){resetStat();setup();while(2>1){loop();show();}}";

ppf("Before parsing of %s\n", fileName);
ppf("%s:%d f:%d / t:%d (l:%d) B [%d %d]\n", __FUNCTION__, __LINE__, ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getMaxAllocHeap(), esp_get_free_heap_size(), esp_get_free_internal_heap_size());

Expand Down

0 comments on commit 0ebb3a3

Please sign in to comment.