Allow chain of 1-4 panels - subject to memory

This commit is contained in:
Will Tatam
2024-02-24 17:27:20 +00:00
parent 26de408626
commit e2aad4783d
3 changed files with 30 additions and 26 deletions

View File

@@ -466,6 +466,8 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
mxconfig.double_buff = false; // <------------- Turn on double buffer
mxconfig.chain_length = max((u_int8_t) 1, min(bc.pins[0], (u_int8_t) 4)); // prevent bad data preventing boot due to low memory
fourScanPanel = nullptr;
switch(bc.type) {
@@ -566,24 +568,11 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
#endif
USER_PRINTLN("MatrixPanel_I2S_DMA config");
USER_PRINTF("MatrixPanel_I2S_DMA config - %ux%u length: %u\n", mxconfig.mx_width, mxconfig.mx_height, mxconfig.chain_length);
// OK, now we can create our matrix object
display = new MatrixPanel_I2S_DMA(mxconfig);
switch(bc.type) {
case 105:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_16PX_HIGH");
fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 32, 32);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_16PX_HIGH);
break;
case 106:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH");
fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 64);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH);
break;
}
this->_len = (display->width() * display->height());
pinManager.allocatePin(mxconfig.gpio.r1, true, PinOwner::HUB75);
@@ -611,11 +600,28 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
// Allocate memory and start DMA display
if( not display->begin() ) {
USER_PRINTLN("****** !KABOOM! I2S memory allocation failed ***********");
USER_PRINTLN("****** MatrixPanel_I2S_DMA !KABOOM! I2S memory allocation failed ***********");
return;
}
else {
_valid = true;
}
switch(bc.type) {
case 105:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH");
fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 32, 32);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH);
fourScanPanel->setRotation(0);
break;
case 106:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_64PX_HIGH");
fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 64);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_64PX_HIGH);
fourScanPanel->setRotation(0);
break;
}
USER_PRINTLN("MatrixPanel_I2S_DMA started");
}
@@ -624,12 +630,14 @@ void BusHub75Matrix::setPixelColor(uint16_t pix, uint32_t c) {
r = R(c);
g = G(c);
b = B(c);
x = pix % mxconfig.mx_width;
y = floor(pix / mxconfig.mx_width);
if(fourScanPanel != nullptr) {
x = pix % fourScanPanel->width();
y = floor(pix / fourScanPanel->width());
fourScanPanel->drawPixelRGB888(x, y, r, g, b);
}
else {
x = pix % display->width();
y = floor(pix / display->width());
display->drawPixelRGB888(x, y, r, g, b);
}
}

View File

@@ -350,7 +350,10 @@ class BusHub75Matrix : public Bus {
void setBrightness(uint8_t b, bool immediate);
uint8_t getPins(uint8_t* pinArray) { return 1; } // Fake value due to keep finaliseInit happy
uint8_t getPins(uint8_t* pinArray) {
pinArray[0] = mxconfig.chain_length;
return 1;
} // Fake value due to keep finaliseInit happy
void deallocatePins();

View File

@@ -177,19 +177,12 @@
if (s[i].name.substring(0,2)=="LT") {
var n = s[i].name.substring(2);
var t = parseInt(s[i].value,10);
gId("p0d"+n).innerHTML = (t>=80 && t<96) ? "IP address:" : (t > 49) ? "Data GPIO:" : (t > 41) ? "GPIOs:" : "GPIO:";
gId("p0d"+n).innerHTML = (t >= 100 && t < 110) ? "Chain Length:" : (t>=80 && t<96) ? "IP address:" : (t > 49) ? "Data GPIO:" : (t > 41) ? "GPIOs:" : "GPIO:";
gId("p1d"+n).innerHTML = (t> 49 && t<64) ? "Clk GPIO:" : "";
var LK = d.getElementsByName("L1"+n)[0]; // clock pin
memu += getMem(t, n); // calc memory
if(t >= 100 && t < 110) {
var LK = d.getElementsByName("L00")[0]; // data pin
LK.style.display = "none";
LK.required = false;
LK.value="";
}
// enumerate pins
for (p=1; p<5; p++) {
var LK = d.getElementsByName("L"+p+n)[0]; // secondary pins