Skip to content

Commit

Permalink
Impliment BusSmartMatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Oct 23, 2023
1 parent 4734959 commit c693ee1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
25 changes: 21 additions & 4 deletions wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ***************************************************************************
Expand Down
21 changes: 14 additions & 7 deletions wled00/bus_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -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<rgb24, 0u>* backgroundLayer;
SmartMatrixHub75Calc<48, 64, 64, 0u, 0u>* smartMatrix;

};
#endif
Expand Down
2 changes: 2 additions & 0 deletions wled00/data/settings_leds.htm
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
<!--option value="81">E1.31 RGB (network)</option-->
<option value="82">Art-Net RGB (network)</option>
<option value="88">DDP RGBW (network)</option>
<option value="55">SmartMatrix</option>
</select><br>
<div id="co${i}" style="display:inline">Color Order:
<select name="CO${i}">
Expand Down Expand Up @@ -382,6 +383,7 @@
<div id="dig${i}a" style="display:inline"><br>Auto-calculate white channel from RGB:<br><select name="AW${i}"><option value=0>None</option><option value=1>Brighter</option><option value=2>Accurate</option><option value=3>Dual</option><option value=4>Max</option></select>&nbsp;</div>
</div>`;
f.insertAdjacentHTML("beforeend", cn);
// TODO: selective addition of SM
}
if (n==-1) {
o[--i].remove();--i;
Expand Down

0 comments on commit c693ee1

Please sign in to comment.