diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index d0dae78d24..d1cc851ecd 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -476,12 +476,29 @@ BusSmartMatrix::BusSmartMatrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh const uint32_t kMatrixOptions = (SM_HUB75_OPTIONS_NONE); // see docs for options: https://github.com/pixelmatix/SmartMatrix/wiki const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE); - SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions); + SMARTMATRIX_ALLOCATE_BUFFERS(smartMatrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions); SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions); - matrix.addLayer(&backgroundLayer); - matrix.setBrightness(brightness); - matrix.begin(); + + smartMatrix.addLayer(&backgroundLayer); + smartMatrix.setBrightness(brightness); + Serial.printf("BusSmartMatrix: kMatrixWidth=%u, kMatrixHeight=%u", kMatrixWidth, kMatrixHeight); + smartMatrix.begin(); + + this->buffer = backgroundLayer.backBuffer(); + this->backgroundLayer = &backgroundLayer; + this->smartMatrix = &smartMatrix; +} + +void BusSmartMatrix::setPixelColor(uint16_t pix, uint32_t c) { + uint8_t r = R(c); + uint8_t g = G(c); + uint8_t b = B(c); + this->buffer[pix] = rgb24(r, g, b); +} + +void BusSmartMatrix::setBrightness(uint8_t b, bool immediate) { + this->smartMatrix->setBrightness(b); } // *************************************************************************** diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index b41a93e8db..e4bd30e472 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -44,6 +44,7 @@ struct BusConfig { if (type >= TYPE_NET_DDP_RGB && type < 96) nPins = 4; //virtual network bus. 4 "pins" store IP address else if (type > 47) nPins = 2; else if (type > 40 && type < 46) nPins = NUM_PWM_PINS(type); + else if (type == TYPE_SMARTMATRIX) nPins = 0; for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i]; } @@ -342,28 +343,34 @@ class BusSmartMatrix : public Bus { void setPixelColor(uint16_t pix, uint32_t c); - uint32_t __attribute__((pure)) getPixelColor(uint16_t pix); // WLEDMM attribute added - - void show(); + void show() { + Serial.println("SmartMatrix: show()"); + backgroundLayer->swapBuffers(true); + } bool canShow() { - // this should be a return value from UDP routine if it is still sending data out - return true; // !_broadcastLock; // TODO + // busy swapping still + return !backgroundLayer->isSwapPending(); } + + void setBrightness(uint8_t b, bool immediate); - uint8_t getPins(uint8_t* pinArray); + // uint8_t getPins(uint8_t* pinArray) {} // todo uint16_t getLength() { return _len; } - void cleanup(); + void cleanup() {} ~BusSmartMatrix() { cleanup(); } private: + rgb24* buffer; + SMLayerBackground* backgroundLayer; + SmartMatrixHub75Calc<48, 64, 64, 0u, 0u>* smartMatrix; }; #endif diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index db68c9201c..9879afa05f 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -355,6 +355,7 @@ +
Color Order:  
`; f.insertAdjacentHTML("beforeend", cn); + // TODO: selective addition of SM } if (n==-1) { o[--i].remove();--i;