Impliment BusSmartMatrix

This commit is contained in:
Will Tatam
2023-10-23 19:48:41 +01:00
parent 47349599e0
commit c693ee1536
3 changed files with 39 additions and 13 deletions

View File

@@ -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);
}
// ***************************************************************************

View File

@@ -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();
bool canShow() {
// this should be a return value from UDP routine if it is still sending data out
return true; // !_broadcastLock; // TODO
void show() {
Serial.println("SmartMatrix: show()");
backgroundLayer->swapBuffers(true);
}
uint8_t getPins(uint8_t* pinArray);
bool canShow() {
// busy swapping still
return !backgroundLayer->isSwapPending();
}
void setBrightness(uint8_t b, bool immediate);
// 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

View File

@@ -355,6 +355,7 @@ ${i+1}:
<!--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}">
@@ -382,6 +383,7 @@ ${i+1}:
<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;