Skip to content

Commit 44d666c

Browse files
committed
Give HUB75 Color Order Overrides
1 parent 75e1ade commit 44d666c

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

wled00/bus_manager.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
10351035

10361036
USER_PRINT(F("heap usage: ")); USER_PRINTLN(int(lastHeap - ESP.getFreeHeap()));
10371037
delay(18); // experiment - give the driver a moment (~ one full frame @ 60hz) to settle
1038+
_colorOrder = bc.colorOrder;
10381039
_valid = true;
10391040
display->setBrightness8(_bri); // range is 0-255, 0 - 0%, 255 - 100% // [setBrightness()] Tried to set output brightness before begin()
10401041
display->clearScreen(); // initially clear the screen buffer
@@ -1196,8 +1197,19 @@ void __attribute__((hot)) IRAM_ATTR BusHub75Matrix::show(void) {
11961197
uint8_t g = c.g;
11971198
uint8_t b = c.b;
11981199
#endif
1199-
if (isFourScan) fourScanPanel->drawPixelRGB888(int16_t(x), int16_t(y), r, g, b);
1200-
else display->drawPixelRGB888(int16_t(x), int16_t(y), r, g, b);
1200+
// apply color order mapping (COL_ORDER_* values from const.h)
1201+
uint8_t r2=r, g2=g, b2=b;
1202+
switch (_colorOrder & 0x0F) {
1203+
case COL_ORDER_RGB: /* 1 */ break; // no swap (HUB75 default)
1204+
case COL_ORDER_GRB: /* 0 */ r2=g; g2=r; break; // swap R and G
1205+
case COL_ORDER_BRG: /* 2 */ r2=b; g2=r; b2=g; break;
1206+
case COL_ORDER_RBG: /* 3 */ g2=b; b2=g; break; // swap G and B
1207+
case COL_ORDER_BGR: /* 4 */ r2=b; b2=r; break; // swap R and B
1208+
case COL_ORDER_GBR: /* 5 */ r2=g; g2=b; b2=r; break;
1209+
default: break;
1210+
}
1211+
if (isFourScan) fourScanPanel->drawPixelRGB888(int16_t(x), int16_t(y), r2, g2, b2);
1212+
else display->drawPixelRGB888(int16_t(x), int16_t(y), r2, g2, b2);
12011213
}
12021214
pix ++;
12031215
}

wled00/bus_manager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,15 @@ class BusHub75Matrix : public Bus {
426426

427427
void cleanup(void) override;
428428

429+
uint8_t getColorOrder() const override { return _colorOrder; }
430+
429431
~BusHub75Matrix() {
430432
cleanup();
431433
}
432434

433435
private:
434436
unsigned _panelWidth = 0;
437+
uint8_t _colorOrder = COL_ORDER_RGB;
435438
CRGB *_ledBuffer = nullptr;
436439
byte *_ledsDirty = nullptr;
437440
// C++ dirty trick: private static variables are actually _not_ part of the class (however only visibile to class instances).

wled00/data/settings_leds.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
}
224224
gId("rf"+n).onclick = (t == 31) ? (()=>{return false}) : (()=>{}); // prevent change for TM1814
225225
gRGBW |= isRGBW = ((t > 17 && t < 22) || (t > 28 && t < 32) || (t > 40 && t < 46 && t != 43) || t == 88); // RGBW checkbox, TYPE_xxxx values from const.h
226-
gId("co"+n).style.display = ((t >= 83 && t < 96) || (t >= 40 && t < 48)||(t >= 100 && t < 110)) ? "none":"inline"; // hide color order for PWM
226+
gId("co"+n).style.display = ((t >= 83 && t < 96) || (t >= 40 && t < 48)) ? "none":"inline"; // hide color order for PWM/analog (not HUB75)
227227
gId("dig"+n+"w").style.display = (t > 28 && t < 32) ? "inline":"none"; // show swap channels dropdown
228228
gId("dig"+n+"O").style.display = (t == 82 || t == 83) ? "inline":"none"; // show Art-Net output number
229229
gId("dig"+n+"L").style.display = (t == 82 || t == 83) ? "inline":"none"; // show Art-Net LEDs per output

0 commit comments

Comments
 (0)