Merge remote-tracking branch 'upstream/mdev' into GoL-Fast

This commit is contained in:
Brandon502
2024-11-16 12:56:29 -05:00
5 changed files with 42 additions and 13 deletions

View File

@@ -6053,9 +6053,11 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https
const uint16_t cols = SEGMENT.virtualWidth();
const uint16_t rows = SEGMENT.virtualHeight();
const float maxRows = (rows <= 32) ? 32.0f : (rows <= 64) ? 64.0f : 128.0f; // WLEDMM safe up to 128x128
const float minScale = (rows <= 32) ? 12.0f : (rows <= 64) ? 4.6f : 2.1f; // WLEDMM
const float minScale = (rows <= 32) ? 12.0f : (rows <= 64) ? 7.2f : 4.6f; // WLEDMM
const float maxCols = (cols <= 32) ? 32.0f : (cols <= 64) ? 64.0f : 128.0f; // WLEDMM safe up to 128x128
const CRGBPalette16 auroraPalette = {0x000000, 0x003300, 0x006600, 0x009900, 0x00cc00, 0x00ff00, 0x33ff00, 0x66ff00, 0x99ff00, 0xccff00, 0xffff00, 0xffcc00, 0xff9900, 0xff6600, 0xff3300, 0xff0000};
const CRGBPalette16 &effectPalette = SEGENV.check1 ? SEGPALETTE : auroraPalette;
if (SEGENV.call == 0) {
SEGMENT.setUpLeds();
@@ -6063,7 +6065,7 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https
}
float adjustHeight = mapf(rows, 8, maxRows, 28, minScale); // maybe use mapf() ??? // WLEDMM yes!
uint16_t adjScale = map2(cols, 8, 64, 310, 63);
uint16_t adjScale = map2(cols, 8, maxCols, 310, 63); // WLEDMM
adjustHeight = max(min(adjustHeight, 28.0f), minScale); // WLEDMM bugfix for larger fixtures
adjScale = max(min(adjScale, uint16_t(310)), uint16_t(63)); // WLEDMM
@@ -6083,11 +6085,11 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https
}
*/
uint16_t _scale = map2(SEGMENT.intensity, 0, 255, 30, adjScale);
byte _speed = map2(SEGMENT.speed, 0, 255, 128, 16);
byte _speed = map2(SEGMENT.speed, 0, 255, 136, 20);
//WLEDMM add SuperSync control
uint16_t xStart, xEnd, yStart, yEnd;
if (SEGMENT.check1) { //Master (sync on needs to show the whole effect, children only their first panel)
if (SEGMENT.check2) { //Master (sync on needs to show the whole effect, children only their first panel)
xStart = strip.panel[0].xOffset;
xEnd = strip.panel[0].xOffset + strip.panel[0].width;
yStart = strip.panel[0].yOffset;
@@ -6105,16 +6107,17 @@ uint16_t mode_2DPolarLights(void) { // By: Kostyantyn Matviyevskyy https
for (int x = xStart; x < xEnd; x++) {
for (int y = yStart; y < yEnd; y++) {
SEGENV.step++;
SEGMENT.setPixelColorXY(x, y, ColorFromPalette(auroraPalette,
SEGMENT.setPixelColorXY(x, y, ColorFromPalette(effectPalette,
qsub8(
inoise8((SEGENV.step%2) + x * _scale, y * 16 + SEGENV.step % 16, SEGENV.step / _speed),
fabsf(rows_2 - (float)y) * adjustHeight))); // WLEDMM
}
}
if (SEGENV.check3) SEGMENT.blurRows(192);
return FRAMETIME;
} // mode_2DPolarLights()
static const char _data_FX_MODE_2DPOLARLIGHTS[] PROGMEM = "Polar Lights@!,Scale,,,,SuperSync;;;2";
static const char _data_FX_MODE_2DPOLARLIGHTS[] PROGMEM = "Polar Lights@!,Scale,,,,Use Palette,SuperSync, Blur;;!;2";
/////////////////////////

View File

@@ -528,6 +528,7 @@ VirtualMatrixPanel* BusHub75Matrix::activeFourScanPanel = nullptr;
HUB75_I2S_CFG BusHub75Matrix::activeMXconfig = HUB75_I2S_CFG();
uint8_t BusHub75Matrix::activeType = 0;
uint8_t BusHub75Matrix::instanceCount = 0;
uint8_t BusHub75Matrix::last_bri = 0;
// --------------------------
@@ -635,7 +636,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
mxconfig.mx_width = 64;
mxconfig.mx_height = 64;
break;
case 104: // untested
case 104:
mxconfig.mx_width = 128;
mxconfig.mx_height = 64;
break;
@@ -899,7 +900,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
USER_PRINTLN("MatrixPanel_I2S_DMA created");
// let's adjust default brightness
//display->setBrightness8(25); // range is 0-255, 0 - 0%, 255 - 100% // [setBrightness()] Tried to set output brightness before begin()
_bri = 25;
_bri = (last_bri > 0) ? last_bri : 25; // try to restore persistent brightness value
delay(24); // experimental
DEBUG_PRINT(F("heap usage: ")); DEBUG_PRINTLN(int(lastHeap - ESP.getFreeHeap()));
@@ -917,6 +918,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
USER_PRINT(F("heap usage: ")); USER_PRINTLN(int(lastHeap - ESP.getFreeHeap()));
delay(18); // experiment - give the driver a moment (~ one full frame @ 60hz) to settle
_valid = true;
display->setBrightness8(_bri); // range is 0-255, 0 - 0%, 255 - 100% // [setBrightness()] Tried to set output brightness before begin()
display->clearScreen(); // initially clear the screen buffer
USER_PRINTLN("MatrixPanel_I2S_DMA clear ok");
@@ -950,25 +952,25 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
switch(bc.type) {
case 105:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH - 32x32");
if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 32, 32);
if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, mxconfig.chain_length, 32, 32);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH);
fourScanPanel->setRotation(0);
break;
case 106:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH - 64x32");
if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 32);
if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, mxconfig.chain_length, 64, 32);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH);
fourScanPanel->setRotation(0);
break;
case 107:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_64PX_HIGH");
if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 64);
if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, mxconfig.chain_length, 64, 64);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_64PX_HIGH);
fourScanPanel->setRotation(0);
break;
case 108: // untested
USER_PRINTLN("MatrixPanel_I2S_DMA 128x64 FOUR_SCAN_64PX_HIGH");
if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 128, 64);
if (!fourScanPanel) fourScanPanel = new VirtualMatrixPanel((*display), 1, mxconfig.chain_length, 128, 64);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_64PX_HIGH);
fourScanPanel->setRotation(0);
break;
@@ -1057,6 +1059,7 @@ void BusHub75Matrix::setBrightness(uint8_t b, bool immediate) {
MatrixPanel_I2S_DMA* display = BusHub75Matrix::activeDisplay;
// if (_bri > 238) _bri=238; // not strictly needed. Enable this line if you see glitches at highest brightness.
if ((_bri > 253) && (activeMXconfig.latch_blanking < 2)) _bri=253; // prevent glitches at highest brightness.
last_bri = _bri;
if (display) display->setBrightness(_bri);
}

View File

@@ -411,6 +411,7 @@ class BusHub75Matrix : public Bus {
static HUB75_I2S_CFG activeMXconfig; // last used mxconfig
static uint8_t activeType; // last used type
static uint8_t instanceCount; // active instances - 0 or 1
static uint8_t last_bri; // last used brightness value (persists on driver delete)
};
#endif

View File

@@ -61,6 +61,11 @@ void esp_heap_trace_free_hook(void* ptr)
unsigned long lastMillis = 0; //WLEDMM
unsigned long loopCounter = 0; //WLEDMM
unsigned long lps = 0; // loops per second
unsigned long lps2 = 0; // lps without "show"
unsigned long long showtime = 0; // time spent in "show" (micros)
void setup() __attribute__((used)); // needed for -flto
void setup() {
#ifdef WLED_DEBUG_HEAP
@@ -73,13 +78,22 @@ void loop() __attribute__((used)); // needed for -flto
void loop() {
//WLEDMM show loops per second
loopCounter++;
if (millis() - lastMillis >= 10000) {
//if (millis() - lastMillis >= 10000) {
if (millis() - lastMillis >= 8000) {
long delta = millis() - lastMillis;
if (delta > 0) {
lps = (loopCounter*1000U) / delta;
//USER_PRINTF("%lu lps\n",(loopCounter*1000U) / delta);
if (delta > (showtime / 1000)) lps2 = (loopCounter*1000U) / (delta - (showtime / 1000));
USER_PRINTF("%lu lps\t", lps);
USER_PRINTF("%u fps\t", strip.getFps());
USER_PRINTF("%lu lps without show\t\t", lps2);
USER_PRINTF("frametime %d\t", int(strip.getFrameTime()));
USER_PRINTF("targetFPS %d\n", int(strip.getTargetFps()));
}
lastMillis = millis();
loopCounter = 0;
showtime = 0;
}
WLED::instance().loop();

View File

@@ -329,7 +329,15 @@ void initServer()
return;
}
if (Update.hasError() || otaLock) {
#ifdef ARDUINO_ARCH_ESP32
if (Update.hasError()) {
String updErr = Update.getError() == UPDATE_ERROR_ACTIVATE ? String("Could Not Activate The Firmware. (wrong board type?)") : String(Update.errorString());
serveMessage(request, 500, F("Update failed!"), updErr + String("<br>Please check your file and retry!"), 254);
} else
serveMessage(request, 500, F("Update failed!"), F("Please check your file and retry! (OTA may be locked)"), 254);
#else
serveMessage(request, 500, F("Update failed!"), F("Please check your file and retry!"), 254);
#endif
} else {
serveMessage(request, 200, F("Update successful!"), F("Rebooting..."), 131);
doReboot = true;