Skip to content

Commit

Permalink
Scrolling Projection WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon502 committed Aug 11, 2024
1 parent 875cf3e commit ae00708
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/App/LedLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum ProjectionsE
p_Spacing,
p_Transpose,
p_Kaleidoscope,
p_Scrolling,
p_count // keep as last entry
};

Expand Down
1 change: 1 addition & 0 deletions src/App/LedModEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class LedModEffects:public SysModule {
fixture.projections.push_back(new SpacingProjection);
fixture.projections.push_back(new TransposeProjection);
fixture.projections.push_back(new KaleidoscopeProjection);
fixture.projections.push_back(new ScrollingProjection);

#ifdef STARLIGHT_CLOCKLESS_LED_DRIVER
#if !(CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2)
Expand Down
39 changes: 39 additions & 0 deletions src/App/LedProjections.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,45 @@ class KaleidoscopeProjection: public Projection {
}
}; //KaleidoscopeProjection

class ScrollingProjection: public Projection {
const char * name() {return "Scrolling WIP";}
const char * tags() {return "💫";}

void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) {
MirrorProjection mp;
mp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV);
}

void adjustXYZ(LedsLayer &leds, Coord3D &pixel) {
leds.projectionData.begin();
bool mirrorX = leds.projectionData.read<bool>(); // Not used
bool mirrorY = leds.projectionData.read<bool>(); // Not used
bool mirrorZ = leds.projectionData.read<bool>(); // Not used

uint8_t xSpeed = leds.projectionData.read<uint8_t>();
uint8_t ySpeed = leds.projectionData.read<uint8_t>();
uint8_t zSpeed = leds.projectionData.read<uint8_t>();

if (xSpeed) pixel.x = (pixel.x + (sys->now * xSpeed / 255 / 100)) % leds.size.x;
if (ySpeed) pixel.y = (pixel.y + (sys->now * ySpeed / 255 / 100)) % leds.size.y;
if (zSpeed) pixel.z = (pixel.z + (sys->now * zSpeed / 255 / 100)) % leds.size.z;
}

void controls(LedsLayer &leds, JsonObject parentVar) {
MirrorProjection mp;
mp.controls(leds, parentVar);

uint8_t *xSpeed = leds.projectionData.write<uint8_t>(0);
uint8_t *ySpeed = leds.projectionData.write<uint8_t>(0);
uint8_t *zSpeed = leds.projectionData.write<uint8_t>(0);

ui->initSlider(parentVar, "X Speed", xSpeed, 0, 255, false);
if (leds.projectionDimension >= _2D) ui->initSlider(parentVar, "Y Speed", ySpeed, 0, 255, false);
if (leds.projectionDimension == _3D) ui->initSlider(parentVar, "Z Speed", zSpeed, 0, 255, false);
}

}; //ScrollingProjection

class TestProjection: public Projection {
const char * name() {return "Test";}
const char * tags() {return "💡";}
Expand Down

0 comments on commit ae00708

Please sign in to comment.