Skip to content

Commit

Permalink
setPixelColor color compression: round blue
Browse files Browse the repository at this point in the history
LedLeds
- setPixelColor, round blue to nearest multitude of 32
- PhysMap, init r,g,b = 0
  • Loading branch information
ewoudwijma committed Jul 26, 2024
1 parent 7067e8d commit a8805f2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/App/LedEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -2689,7 +2689,7 @@ class PixelMapEffect: public Effect {
}
}; // PixelMap

class Test: public Effect {
class Byte2TestEffect: public Effect {
const char * name() {return "2ByteTest";}
uint8_t dim() {return _2D;}
const char * tags() {return "💫";}
Expand Down Expand Up @@ -2729,7 +2729,7 @@ class Test: public Effect {
byte b = random8();
for (int x = 0; x < leds.size.x; x++) {
if (drawMethod == 0) leds.setPixelColor(leds.XY(x, 0), ColorFromPalette(leds.palette, r), 0);
else if (drawMethod == 1) leds.setPixelColorPal(leds.XY(x, 0), r, 0);
else if (drawMethod == 1) leds.setPixelColorPal(leds.XY(x, 0), r, 255, 0);
else if (drawMethod == 2) leds.setPixelColor(leds.XY(x, 0), CRGB(r, g, b), 0);
else if (drawMethod == 3) leds.setPixelColor(leds.XY(x, 0), CRGB(color.x, color.y, color.z), 0);
}
Expand Down
6 changes: 3 additions & 3 deletions src/App/LedLeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ void Leds::setPixelColor(unsigned16 indexV, CRGB color, unsigned8 blendAmount) {
if (mappingTable[indexV].mapType == m_colorPal) mappingTable[indexV].mapType = m_color;
switch (mappingTable[indexV].mapType) {
case m_color:{
mappingTable[indexV].r = color.r >> 2; // 8 to 6 bits
mappingTable[indexV].g = color.g >> 3; // 8 to 5 bits
mappingTable[indexV].b = color.b >> 5; // 8 to 3 bits
mappingTable[indexV].r = color.r >> 2; // 8 to 6 bits, 64 values
mappingTable[indexV].g = color.g >> 3; // 8 to 5 bits, 32 values
mappingTable[indexV].b = min(color.b + 15, 255) >> 5; // 8 to 3 bits, 8 values
break;
}
case m_onePixel: {
Expand Down
3 changes: 3 additions & 0 deletions src/App/LedLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ struct PhysMap {

PhysMap() {
mapType = m_color; // the default until indexP is added
r = 0;
g = 0;
b = 0;
}

void addIndexP(Leds &leds, uint16_t indexP);
Expand Down
2 changes: 1 addition & 1 deletion src/App/LedModEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class LedModEffects:public SysModule {
effects.push_back(new RipplesEffect);
effects.push_back(new SphereMoveEffect);
effects.push_back(new PixelMapEffect);
effects.push_back(new Test); // not 3D but next to pixelMap for testing
effects.push_back(new Byte2TestEffect); // not 3D but next to pixelMap for testing

//load projections
fixture.projections.push_back(new NoneProjection);
Expand Down

0 comments on commit a8805f2

Please sign in to comment.