Index under- shooting.

Fix for arc 1D to 2D mapping.
UI segment 2D mapping fix.
Watchdog reposition & flicker reduction.
This commit is contained in:
Blaz Kristan 2022-08-22 16:47:25 +02:00
parent e14c5bbd25
commit fb6dfcd3fc
5 changed files with 1792 additions and 1785 deletions

View File

@ -150,7 +150,7 @@ uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y) {
void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col) void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
{ {
if (!strip.isMatrix) return; // not a matrix set-up if (!strip.isMatrix) return; // not a matrix set-up
if (x >= virtualWidth() || y >= virtualHeight()) return; // if pixel would fall out of virtual segment just exit if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit
if (leds) leds[XY(x,y)] = col; if (leds) leds[XY(x,y)] = col;

View File

@ -445,8 +445,8 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
if (i==0) if (i==0)
setPixelColorXY(0, 0, col); setPixelColorXY(0, 0, col);
else { else {
float step = HALF_PI / (2*i+1); // sqrtf((float)max(vH,vW))*i+1 float step = HALF_PI / (2*i);
for (float rad = 0.0f; rad <= HALF_PI; rad += step) { for (float rad = 0.0f; rad <= HALF_PI+step/2; rad += step) {
// may want to try float version as well (with or without antialiasing) // may want to try float version as well (with or without antialiasing)
int x = roundf(sin_t(rad) * i); int x = roundf(sin_t(rad) * i);
int y = roundf(cos_t(rad) * i); int y = roundf(cos_t(rad) * i);
@ -469,7 +469,7 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
} }
#endif #endif
if (i >= virtualLength()) return; // if pixel would fall out of segment just exit if (i >= virtualLength() || i<0) return; // if pixel would fall out of segment just exit
if (leds) leds[i] = col; if (leds) leds[i] = col;
uint16_t len = length(); uint16_t len = length();

View File

@ -701,6 +701,10 @@ function populateSegments(s)
<div class="sliderdisplay"></div> <div class="sliderdisplay"></div>
</div> </div>
</div>`; </div>`;
let staX = inst.start;
let stoX = inst.stop;
let staY = inst.startY;
let stoY = inst.stopY;
let rvXck = `<label class="check revchkl">Reverse ${isM?'':'direction'}<input type="checkbox" id="seg${i}rev" onchange="setRev(${i})" ${inst.rev?"checked":""}><span class="checkmark"></span></label>`; let rvXck = `<label class="check revchkl">Reverse ${isM?'':'direction'}<input type="checkbox" id="seg${i}rev" onchange="setRev(${i})" ${inst.rev?"checked":""}><span class="checkmark"></span></label>`;
let miXck = `<label class="check revchkl">Mirror<input type="checkbox" id="seg${i}mi" onchange="setMi(${i})" ${inst.mi?"checked":""}><span class="checkmark"></span></label>`; let miXck = `<label class="check revchkl">Mirror<input type="checkbox" id="seg${i}mi" onchange="setMi(${i})" ${inst.mi?"checked":""}><span class="checkmark"></span></label>`;
let rvYck = "", miYck =""; let rvYck = "", miYck ="";
@ -745,14 +749,14 @@ function populateSegments(s)
<td>${isM?'':'Offset'}</td> <td>${isM?'':'Offset'}</td>
</tr> </tr>
<tr> <tr>
<td><input class="noslide segn" id="seg${i}s" type="number" min="0" max="${(isM?mw:ledCount)-1}" value="${inst.start}" oninput="updateLen(${i})" onkeydown="segEnter(${i})"></td> <td><input class="noslide segn" id="seg${i}s" type="number" min="0" max="${(isM?mw:ledCount)-1}" value="${staX}" oninput="updateLen(${i})" onkeydown="segEnter(${i})"></td>
<td><input class="noslide segn" id="seg${i}e" type="number" min="0" max="${(isM?mw:ledCount)-(cfg.comp.seglen?inst.start:0)}" value="${inst.stop-(cfg.comp.seglen?inst.start:0)}" oninput="updateLen(${i})" onkeydown="segEnter(${i})"></td> <td><input class="noslide segn" id="seg${i}e" type="number" min="0" max="${(isM?mw:ledCount)-(cfg.comp.seglen?staX:0)}" value="${stoX-(cfg.comp.seglen?staX:0)}" oninput="updateLen(${i})" onkeydown="segEnter(${i})"></td>
<td style="text-align:revert;">${isM?miXck+'<br>'+rvXck:''}<input class="noslide segn ${isM?'hide':''}" id="seg${i}of" type="number" value="${inst.of}" oninput="updateLen(${i})"></td> <td style="text-align:revert;">${isM?miXck+'<br>'+rvXck:''}<input class="noslide segn ${isM?'hide':''}" id="seg${i}of" type="number" value="${inst.of}" oninput="updateLen(${i})"></td>
</tr> </tr>
${isM ? '<tr><td>Start Y</td><td>'+(cfg.comp.seglen?'Height':'Stop Y')+'</td><td></td></tr>'+ ${isM ? '<tr><td>Start Y</td><td>'+(cfg.comp.seglen?'Height':'Stop Y')+'</td><td></td></tr>'+
'<tr>'+ '<tr>'+
'<td><input class="noslide segn" id="seg'+i+'sY" type="number" min="0" max="'+(mh-1)+'" value="'+inst.startY+'" oninput="updateLen('+i+')" onkeydown="segEnter('+i+')"></td>'+ '<td><input class="noslide segn" id="seg'+i+'sY" type="number" min="0" max="'+(mh-1)+'" value="'+staY+'" oninput="updateLen('+i+')" onkeydown="segEnter('+i+')"></td>'+
'<td><input class="noslide segn" id="seg'+i+'eY" type="number" min="0" max="'+(mh-(cfg.comp.seglen?inst.startY:0))+'" value="'+(inst.stopY-(cfg.comp.seglen?inst.startY:0))+'" oninput="updateLen('+i+')" onkeydown="segEnter('+i+')"></td>'+ '<td><input class="noslide segn" id="seg'+i+'eY" type="number" min="0" max="'+(mh-(cfg.comp.seglen?staY:0))+'" value="'+(stoY-(cfg.comp.seglen?staY:0))+'" oninput="updateLen('+i+')" onkeydown="segEnter('+i+')"></td>'+
'<td style="text-align:revert;">'+miYck+'<br>'+rvYck+'</td>'+ '<td style="text-align:revert;">'+miYck+'<br>'+rvYck+'</td>'+
'</tr>':''} '</tr>':''}
<tr> <tr>
@ -768,7 +772,7 @@ function populateSegments(s)
</table> </table>
<div class="h bp" id="seg${i}len"></div> <div class="h bp" id="seg${i}len"></div>
${!isM?rvXck:''} ${!isM?rvXck:''}
${isM?map2D:''} ${isM&&stoY-staY>1&&stoX-staX>1?map2D:''}
${s.AudioReactive && s.AudioReactive.on ? "" : sndSim} ${s.AudioReactive && s.AudioReactive.on ? "" : sndSim}
<label class="check revchkl"> <label class="check revchkl">
${isM?'Transpose':'Mirror effect'} ${isM?'Transpose':'Mirror effect'}
@ -1031,14 +1035,16 @@ function updateLen(s)
var stop = parseInt(gId(`seg${s}e`).value); var stop = parseInt(gId(`seg${s}e`).value);
var len = stop - (cfg.comp.seglen?0:start); var len = stop - (cfg.comp.seglen?0:start);
if (isM) { if (isM) {
start = parseInt(gId(`seg${s}sY`).value); let startY = parseInt(gId(`seg${s}sY`).value);
stop = parseInt(gId(`seg${s}eY`).value); let stopY = parseInt(gId(`seg${s}eY`).value);
len *= (stop-(cfg.comp.seglen?0:start)); len *= (stopY-(cfg.comp.seglen?0:startY));
if (stop-start>1 && stopY-startY>1) {
let sE = gId('fxlist').querySelector(`.lstI[data-id="${selectedFx}"]`); let sE = gId('fxlist').querySelector(`.lstI[data-id="${selectedFx}"]`);
if (sE) { if (sE) {
let sN = sE.querySelector(".lstIname").innerText; let sN = sE.querySelector(".lstIname").innerText;
let seg = gId(`seg${s}map2D`); let seg = gId(`seg${s}map2D`);
if (stop-start>1 && sN.indexOf("\u25A6")<0) seg.classList.remove("hide"); else seg.classList.add("hide"); if (seg && sN.indexOf("\u25A6")<0) seg.classList.remove("hide"); else seg.classList.add("hide");
}
} }
} }
var out = "(delete)"; var out = "(delete)";

File diff suppressed because it is too large Load Diff

View File

@ -219,6 +219,7 @@ void WLED::loop()
#if WLED_WATCHDOG_TIMEOUT > 0 #if WLED_WATCHDOG_TIMEOUT > 0
// we finished our mainloop, reset the watchdog timer // we finished our mainloop, reset the watchdog timer
if (!strip.isUpdating())
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
esp_task_wdt_reset(); esp_task_wdt_reset();
#else #else
@ -280,8 +281,6 @@ void WLED::setup()
DEBUG_PRINT(F("heap ")); DEBUG_PRINT(F("heap "));
DEBUG_PRINTLN(ESP.getFreeHeap()); DEBUG_PRINTLN(ESP.getFreeHeap());
enableWatchdog();
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
if (psramFound()) { if (psramFound()) {
// GPIO16/GPIO17 reserved for SPI RAM // GPIO16/GPIO17 reserved for SPI RAM
@ -406,6 +405,8 @@ void WLED::setup()
// HTTP server page init // HTTP server page init
initServer(); initServer();
enableWatchdog();
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET) #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET)
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); //enable brownout detector WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); //enable brownout detector
#endif #endif