Skip to content

Commit

Permalink
Renaming Leds to LedsLayer and listOfLeds to layers
Browse files Browse the repository at this point in the history
Renamed Leds class to LedsLayer
Renamed listOfLeds to layers
Renamed LedLeds.h/cpp to LedLayers.h/cpp
  • Loading branch information
ewoudwijma committed Aug 2, 2024
1 parent 759e19d commit e399dec
Show file tree
Hide file tree
Showing 11 changed files with 752 additions and 262 deletions.
4 changes: 2 additions & 2 deletions misc/testOutput.txt

Large diffs are not rendered by default.

202 changes: 101 additions & 101 deletions src/App/LedEffects.h

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/App/LedFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void Fixture::projectAndMap() {

// reset leds
stackUnsigned8 rowNr = 0;
for (Leds *leds: listOfLeds) {
for (LedsLayer *leds: layers) {
if (leds->doMap) {
leds->fill_solid(CRGB::Black);

Expand Down Expand Up @@ -64,7 +64,7 @@ void Fixture::projectAndMap() {
starJson.lookFor("nrOfLeds", &nrOfLeds);
starJson.lookFor("pin", &currPin);

//lookFor leds array and for each item in array call lambdo to make a projection
//lookFor leds array and for each item in array call lambda to make a projection
starJson.lookFor("leds", [this, &prevIndexP, &indexP, &currPin](std::vector<unsigned16> uint16CollectList) { //this will be called for each tuple of coordinates!

if (uint16CollectList.size()>=1) { // process one pixel
Expand All @@ -79,7 +79,7 @@ void Fixture::projectAndMap() {
if (indexP < NUM_LEDS_Max) {

stackUnsigned8 rowNr = 0;
for (Leds *leds: listOfLeds) {
for (LedsLayer *leds: layers) {

if (leds->projectionNr != p_Random && leds->projectionNr != p_None) //only real projections
if (leds->doMap) { //add pixel in leds mappingtable
Expand Down Expand Up @@ -150,7 +150,7 @@ void Fixture::projectAndMap() {
} //if x,y,z between start and endpos
} //if leds->doMap
rowNr++;
} //for listOfLeds
} //for layers
} //indexP < max
else
ppf("dev post indexP too high %d>=%d or %d p:%d,%d,%d\n", indexP, nrOfLeds, NUM_LEDS_Max, pixel.x, pixel.y, pixel.z);
Expand Down Expand Up @@ -197,7 +197,7 @@ void Fixture::projectAndMap() {
//after processing each led
stackUnsigned8 rowNr = 0;

for (Leds *leds: listOfLeds) {
for (LedsLayer *leds: layers) {
if (leds->doMap) {
ppf("projectAndMap post leds[%d] fx:%d pro:%d\n", rowNr, leds->fx, leds->projectionNr);

Expand Down Expand Up @@ -256,7 +256,7 @@ void Fixture::projectAndMap() {
print->fFormat(buf, sizeof(buf)-1,"%d x %d x %d -> %d", leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds);
mdl->setValue("ledsSize", JsonString(buf, JsonString::Copied), rowNr);

ppf("projectAndMap leds[%d].size = %d + m:(%d * %d) B\n", rowNr, sizeof(Leds), leds->mappingTable.size(), sizeof(PhysMap)); //44 -> 164
ppf("projectAndMap leds[%d].size = %d + m:(%d * %d) B\n", rowNr, sizeof(LedsLayer), leds->mappingTable.size(), sizeof(PhysMap)); //44 -> 164

leds->doMap = false;
} //leds->doMap
Expand Down
12 changes: 6 additions & 6 deletions src/App/LedFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "../Sys/SysModModel.h" //for Coord3D

#include "LedLeds.h"
#include "LedLayer.h"

#define NUM_LEDS_Max 8192

Expand All @@ -22,18 +22,18 @@
#define _3D 3


class Leds; //forward
class LedsLayer; //forward

class Projection {
public:
virtual const char * name() {return "noname";}
virtual const char * tags() {return "";}

virtual void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) {}
virtual void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) {}

virtual void adjustXYZ(Leds &leds, Coord3D &pixel) {}
virtual void adjustXYZ(LedsLayer &leds, Coord3D &pixel) {}

virtual void controls(Leds &leds, JsonObject parentVar) {}
virtual void controls(LedsLayer &leds, JsonObject parentVar) {}

};

Expand All @@ -59,7 +59,7 @@ class Fixture {
unsigned8 fixtureNr = -1;
Coord3D fixSize = {8,8,1};

std::vector<Leds *> listOfLeds; //virtual leds
std::vector<LedsLayer *> layers; //virtual leds

Coord3D head = {0,0,0};

Expand Down
30 changes: 15 additions & 15 deletions src/App/LedLeds.cpp → src/App/LedLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
@title StarLight
@file LedLeds.cpp
@file LedLayer.cpp
@date 20240720
@repo https://github.com/MoonModules/StarLight
@Authors https://github.com/MoonModules/StarLight/commits/main
Expand All @@ -9,7 +9,7 @@
@license For non GPL-v3 usage, commercial licenses must be purchased. Contact [email protected]
*/

#include "LedLeds.h"
#include "LedLayer.h"
#include "../Sys/SysModSystem.h" //for sys->now
#ifdef STARBASE_USERMOD_MPU6050
#include "../User/UserModMPU6050.h"
Expand All @@ -26,12 +26,12 @@ void fastled_fill_rainbow(struct CRGB * targetArray, int numToFill, unsigned8 in
fill_rainbow(targetArray, numToFill, initialhue, deltahue);
}

void Leds::triggerMapping() {
void LedsLayer::triggerMapping() {
doMap = true; //specify which leds to remap
fixture->doMap = true; //fixture will also be remapped
}

unsigned16 Leds::XYZ(Coord3D pixel) {
unsigned16 LedsLayer::XYZ(Coord3D pixel) {

//as this is a call to a virtual function it reduces the theoretical (no show) speed by half, even if XYZ is not implemented
// the real speed is hardly affected, but room for improvement!
Expand All @@ -48,7 +48,7 @@ unsigned16 Leds::XYZ(Coord3D pixel) {
}

// maps the virtual led to the physical led(s) and assign a color to it
void Leds::setPixelColor(unsigned16 indexV, CRGB color) {
void LedsLayer::setPixelColor(unsigned16 indexV, CRGB color) {
if (indexV < mappingTable.size()) {
switch (mappingTable[indexV].mapType) {
case m_color:{
Expand Down Expand Up @@ -79,15 +79,15 @@ void Leds::setPixelColor(unsigned16 indexV, CRGB color) {
ppf(" dev sPC V:%d >= %d", indexV, NUM_LEDS_Max);
}

void Leds::setPixelColorPal(unsigned16 indexV, uint8_t palIndex, uint8_t palBri) {
void LedsLayer::setPixelColorPal(unsigned16 indexV, uint8_t palIndex, uint8_t palBri) {
setPixelColor(indexV, ColorFromPalette(palette, palIndex, palBri));
}

void Leds::blendPixelColor(unsigned16 indexV, CRGB color, uint8_t blendAmount) {
void LedsLayer::blendPixelColor(unsigned16 indexV, CRGB color, uint8_t blendAmount) {
setPixelColor(indexV, blend(color, getPixelColor(indexV), blendAmount));
}

CRGB Leds::getPixelColor(unsigned16 indexV) {
CRGB LedsLayer::getPixelColor(unsigned16 indexV) {
if (indexV < mappingTable.size()) {
switch (mappingTable[indexV].mapType) {
case m_onePixel:
Expand All @@ -111,8 +111,8 @@ CRGB Leds::getPixelColor(unsigned16 indexV) {
}
}

void Leds::fadeToBlackBy(unsigned8 fadeBy) {
if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) {
void LedsLayer::fadeToBlackBy(unsigned8 fadeBy) {
if (projectionNr == p_None || projectionNr == p_Random || (fixture->layers.size() == 1)) {
fastled_fadeToBlackBy(fixture->ledsP, fixture->nrOfLeds, fadeBy);
} else {
for (uint16_t index = 0; index < mappingTable.size(); index++) {
Expand All @@ -123,17 +123,17 @@ void Leds::fadeToBlackBy(unsigned8 fadeBy) {
}
}

void Leds::fill_solid(const struct CRGB& color) {
if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) {
void LedsLayer::fill_solid(const struct CRGB& color) {
if (projectionNr == p_None || projectionNr == p_Random || (fixture->layers.size() == 1)) {
fastled_fill_solid(fixture->ledsP, fixture->nrOfLeds, color);
} else {
for (uint16_t index = 0; index < mappingTable.size(); index++)
setPixelColor(index, color);
}
}

void Leds::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) {
if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) {
void LedsLayer::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) {
if (projectionNr == p_None || projectionNr == p_Random || (fixture->layers.size() == 1)) {
fastled_fill_rainbow(fixture->ledsP, fixture->nrOfLeds, initialhue, deltahue);
} else {
CHSV hsv;
Expand All @@ -148,7 +148,7 @@ void Leds::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) {
}
}

void PhysMap::addIndexP(Leds &leds, uint16_t indexP) {
void PhysMap::addIndexP(LedsLayer &leds, uint16_t indexP) {
// ppf("addIndexP i:%d t:%d", indexP, mapType);
switch (mapType) {
case m_color:
Expand Down
Loading

0 comments on commit e399dec

Please sign in to comment.