Merge branch 'MoonModules:mdev' into mdev

This commit is contained in:
Troy
2026-02-05 16:46:56 -05:00
committed by GitHub
8 changed files with 156 additions and 43 deletions

View File

@@ -3012,24 +3012,29 @@ static const char _data_FX_MODE_TRI_STATIC_PATTERN[] PROGMEM = "Solid Pattern Tr
uint16_t spots_base(uint16_t threshold)
{
if (SEGLEN == 1) return mode_oops();
if (SEGLEN <= 1) return mode_oops();
if (!SEGMENT.check2) SEGMENT.fill(SEGCOLOR(1));
uint16_t maxZones = SEGLEN >> 2;
uint16_t zones = 1 + ((SEGMENT.intensity * maxZones) >> 8);
uint16_t zoneLen = SEGLEN / zones;
uint16_t offset = (SEGLEN - zones * zoneLen) >> 1;
// constants for fixed point scaling
constexpr uint8_t ZONELEN_FP_SHIFT = 3;
constexpr uint32_t ZONELEN_FP_SCALE = 1U << ZONELEN_FP_SHIFT;
for (int z = 0; z < zones; z++)
unsigned maxZones = max(1, SEGLEN >> 2); // prevents "0 zones"
unsigned zones = 1U + ((uint32_t(SEGMENT.intensity) * maxZones) >> 8);
unsigned zoneLen = uint32_t(SEGLEN) / zones;
unsigned zoneLen8 = (uint32_t(SEGLEN) * ZONELEN_FP_SCALE) / zones; // zoneLength * 8 (fixedpoint) -> avoids gaps at right/left sides
unsigned offset = (uint32_t(SEGLEN) - ((zones * zoneLen8) >> ZONELEN_FP_SHIFT)) >> 1;
for (unsigned z = 0; z < zones; z++)
{
uint16_t pos = offset + z * zoneLen;
for (int i = 0; i < zoneLen; i++)
unsigned pos = offset + ((z * zoneLen8) >> ZONELEN_FP_SHIFT);
for (unsigned i = 0; i < zoneLen; i++)
{
uint16_t wave = triwave16((i * 0xFFFF) / zoneLen);
unsigned wave = triwave16((i * 0xFFFF) / zoneLen);
if (wave > threshold) {
uint16_t index = 0 + pos + i;
uint8_t s = (wave - threshold)*255 / (0xFFFF - threshold);
SEGMENT.setPixelColor(index, color_blend(SEGMENT.color_from_palette(index, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), 255-s));
int index = pos + i;
unsigned s = ((wave - threshold)*255 / (0xFFFF - threshold)) & 0xFF; // & 0xFF prevents overflow in next line
SEGMENT.setPixelColor(index, color_blend(SEGMENT.color_from_palette(index, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), uint8_t(255-s)));
}
}
}
@@ -3054,7 +3059,7 @@ uint16_t mode_spots_fade()
uint16_t tr = (t >> 1) + (t >> 2);
return spots_base(tr);
}
static const char _data_FX_MODE_SPOTS_FADE[] PROGMEM = "Spots Fade@Spread,Width,,,,,Overlay;!,!;!";
static const char _data_FX_MODE_SPOTS_FADE[] PROGMEM = "Spots Fade@Speed,Width,,,,,Overlay;!,!;!";
//each needs 12 bytes
@@ -9455,7 +9460,7 @@ uint16_t mode_particlefireworks(void) {
return FRAMETIME;
}
#undef NUMBEROFSOURCES
static const char _data_FX_MODE_PARTICLEFIREWORKS[] PROGMEM = "PS Fireworks@Launches,Explosion Size,Fuse,Blur,Gravity,Cylinder,Ground,Fast;;!;2;pal=11,ix=200,sx=180,c1=196,c2=0,c3=10,o3=1";
static const char _data_FX_MODE_PARTICLEFIREWORKS[] PROGMEM = "PS Fireworks@Launches,Explosion Size,Fuse,Blur,Gravity,Cylinder,Ground,Fast;;!;2;pal=11,ix=200,sx=180,c1=196,c2=220,c3=10,o3=1";
/*
Particle Volcano

View File

@@ -67,7 +67,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
//int ap_pskl = ap[F("pskl")];
CJSON(apChannel, ap[F("chan")]);
if (apChannel > 13 || apChannel < 1) apChannel = 1;
if (apChannel > 13 || apChannel < 1) apChannel = 6; // reset to default if invalid
CJSON(apHide, ap[F("hide")]);
if (apHide > 1) apHide = 1;

View File

@@ -30,13 +30,15 @@ function peek(c) {
ctx.clearRect(0, 0, c.width, c.height); //WLEDMM
function colorAmp(color) {
if (color == 0) return 0;
return 25+225*color/255;
//return color; // no enhancement
//return 25+225*color/255; // legacy WLEDMM. problem: strong jump from 0 to 25 -> wrong colors
return Math.sqrt(color/255) * 255; // Square root provides gentle and jump-free enhancement of lower brightness pixels
} //WLEDMM in range 55 - 205
for (y=0.5;y<mH;y++) for (x=0.5; x<mW; x++) {
if (leds[i]!= 0 || leds[i+1]!= 0 || leds[i+2]!= 0) { //WLEDMM: do not show blacks
ctx.fillStyle = `rgb(${colorAmp(leds[i])},${colorAmp(leds[i+1])},${colorAmp(leds[i+2])})`;
ctx.beginPath();
ctx.arc(x*pPL+lOf, y*pPL, pPL*0.4, 0, 2 * Math.PI);
ctx.arc(x*pPL+lOf, y*pPL, pPL*0.45, 0, 2 * Math.PI); // WLEDMM legacy radius was 0.4 -> 0.45
ctx.fill();
}
i+=3;

View File

@@ -17,6 +17,7 @@
function gId(n){return d.getElementById(n);}
function hideNoIR(){gId("irOnOff2").style.display="none";} //WLEDMM
function hideHub75() {
window.hub75Hidden = true; // Track that Hub75 should be hidden
var s = d.getElementsByTagName("select");
for (i=0; i<s.length; i++) {
// is the field a LED type?
@@ -464,6 +465,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);
if (window.hub75Hidden) hideHub75(); // remove Hub75 options if not supported
}
if (n==-1) {
o[--i].remove();--i;

View File

@@ -10,6 +10,8 @@
d.um_p = [];
d.rsvd = [];
d.ro_gpio = [];
d.h_pins = [];
d.x_pins = [];
var umCfg = {};
var pins = [], pinO = [], owner;
var loc = false, locip;
@@ -56,6 +58,8 @@
// function check(o,k) {} //WLEDMM not needed as we use dropdowns
function getPins(o) {
if (isO(o)) {
// If this object is a bus instance, extract the "type" field
let busType = o.type !== undefined ? o.type : -1;
for (const [k,v] of Object.entries(o)) {
if (isO(v)) {
owner = k;
@@ -63,6 +67,10 @@
continue;
}
if (k.replace("[]","").substr(-3)=="pin") {
// Skip pin arrays for special bus types where pin array doesn't contain GPIO numbers, but allow all other entries
if (busType >= 80 && busType < 96) continue; // Network buses - pin array stores IP address
if (busType >= 100 && busType <= 110) continue; // HUB75 buses - pin array stores chain length
if (Array.isArray(v)) {
for (var i=0; i<v.length; i++) if (v[i]>=0) { pins.push(v[i]); pinO.push(owner); }
} else {
@@ -269,6 +277,8 @@
// console.log("pinPost option", c, c.value, d.ro_gpio.includes(c.value));
for (let j=0; j<d.ro_gpio.length; j++) if (d.ro_gpio[j] == c.value) c.text += " read only 🟠"; //if (d.ro_gpio.includes(c.value)) not working ???
for (let j=0; j<d.rsvd.length; j++) if (d.rsvd[j] == c.value) {c.text += " reserved 🟣"; c.disabled=true;} //now always disabled as post is done last if (d.rsvd.includes(c.value))
for (let j=0; j<d.h_pins.length; j++) if (d.h_pins[j] == c.value && c.text.length <= 4) {c.text += " HUB75 🔴"; c.disabled=true;} // HUB75 pins
for (let j=0; j<d.x_pins.length; j++) if (d.x_pins[j] == c.value && c.text.length <= 4) {c.text += " DMX 🔴"; c.disabled=true;} // DMX pins
//remove pins > max_gpio
if (c.value > d.max_gpio) {
select.removeChild(c);
@@ -278,7 +288,7 @@
//https://www.javascripttutorial.net/javascript-dom/javascript-remove-items-from-a-select-conditionally/
if (c.text.length <= 4) c.text += " 🟢"; //2 digit number space and ⍼/⎌. If no reserved/read only/other um, then pin can be freely used (green)
for (let jj=0; jj<d.dt_pins.length; jj++) if (d.dt_pins[jj] == c.value) c.text += ((jj<9)?` D${jj}`:((jj==9)?` RX`:` TX`)); //WLEDMM: Add D0-D8, RX/TX to name
for (let jj=0; jj<d.a_pins.length; jj++) if (d.a_pins[jj] == c.value) c.text += ` A${jj}`; //WLEDMM: Add A0-A10
for (let jj=0; jj<d.a_pins.length; jj++) if (d.a_pins[jj] == c.value) c.text += `   A${jj}`; //WLEDMM: Add A0-A10
}
}
}

View File

@@ -10,23 +10,9 @@
#define UDP_IN_MAXSIZE 1472
#define PRESUMED_NETWORK_DELAY 3 //how many ms could it take on avg to reach the receiver? This will be added to transmitted times
void notify(byte callMode, bool followUp)
{
if (!udpConnected) return;
if (!syncGroups) return;
switch (callMode)
{
case CALL_MODE_INIT: return;
case CALL_MODE_DIRECT_CHANGE: if (!notifyDirect) return; break;
case CALL_MODE_BUTTON: if (!notifyButton) return; break;
case CALL_MODE_BUTTON_PRESET: if (!notifyButton) return; break;
case CALL_MODE_NIGHTLIGHT: if (!notifyDirect) return; break;
case CALL_MODE_HUE: if (!notifyHue) return; break;
case CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break;
case CALL_MODE_ALEXA: if (!notifyAlexa) return; break;
default: return;
}
byte udpOut[WLEDPACKETSIZE];
static void do_notify(byte callMode, bool followUp) { // WLEDMM split into two functions, to avoid stack smashing - do_notify needs 1200 bytes on stack
// DEBUG_PRINTF("[%8u %s]\tnotify(%d, %s)\tmin stack %d\n", millis(), pcTaskGetTaskName(NULL), callMode, followUp?"true ":"false", uxTaskGetStackHighWaterMark(NULL));
byte udpOut[WLEDPACKETSIZE] = {0};
Segment& mainseg = strip.getMainSegment();
udpOut[0] = 0; //0: wled notifier protocol 1: WARLS protocol
udpOut[1] = callMode;
@@ -150,6 +136,27 @@ void notify(byte callMode, bool followUp)
notificationCount = followUp ? notificationCount + 1 : 0;
}
// WLEDMM wrapper function to avoid stack smashing - do_notify needs 1200 bytes on stack, but its not actually sending anything on most notify() calls
void notify(byte callMode, bool followUp)
{
if (!udpConnected) return;
if (!syncGroups) return;
switch (callMode)
{
case CALL_MODE_INIT: return;
case CALL_MODE_DIRECT_CHANGE: if (!notifyDirect) return; break;
case CALL_MODE_BUTTON: if (!notifyButton) return; break;
case CALL_MODE_BUTTON_PRESET: if (!notifyButton) return; break;
case CALL_MODE_NIGHTLIGHT: if (!notifyDirect) return; break;
case CALL_MODE_HUE: if (!notifyHue) return; break;
case CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break;
case CALL_MODE_ALEXA: if (!notifyAlexa) return; break;
default: return;
}
do_notify(callMode, followUp);
}
// WLEDMM cache current main segment: updated in realtimeLock, reset in exitRealtime, used in setRealTimePixel
static Segment* theMainSeg = nullptr;
static int theMainSegLength = 0;
@@ -736,6 +743,7 @@ void refreshNodeList()
void sendSysInfoUDP()
{
if (!udp2Connected) return;
// DEBUG_PRINTF("[%8u %s]\tsendSysInfoUDP()\tmin stack %d\n", millis(), pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL));
IPAddress ip = Network.localIP();
if (!ip || ip == IPAddress(255,255,255,255)) ip = IPAddress(4,3,2,1);

View File

@@ -287,6 +287,30 @@ void appendGPIOinfo() {
char a_pins[64] = { '\0' }; // fix warning: output 45 bytes into a destination of size 30
snprintf(a_pins, 64, "d.a_pins=[%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d];", pinManager.getADCPin(PM_ADC1, 0), pinManager.getADCPin(PM_ADC1, 1), pinManager.getADCPin(PM_ADC1, 2), pinManager.getADCPin(PM_ADC1, 3), pinManager.getADCPin(PM_ADC1, 4), pinManager.getADCPin(PM_ADC1, 5), pinManager.getADCPin(PM_ADC1, 6), pinManager.getADCPin(PM_ADC1, 7), pinManager.getADCPin(PM_ADC1, 8), pinManager.getADCPin(PM_ADC1, 9), pinManager.getADCPin(PM_ADC1, 10));
oappend(a_pins);
// WLEDMM add HUB75 pins, as they are not stored directly in cfg.json
strcpy(ro_gpio, "d.h_pins=["); // WLEDMM we re-use this array, instead of creating an addition one; 140 bytes is more than enough for 14 pins.
bool isFirstPin = true;
for(int pinNr = 0; pinNr < WLED_NUM_PINS; pinNr++) {
if ((pinManager.isPinOk(pinNr)) && (pinManager.getPinOwner(pinNr) == PinOwner::HUB75)) {
sprintf(pinString, "%s%d", isFirstPin ? "" : ",", pinNr);
strcat(ro_gpio, pinString); isFirstPin = false;
}
}
oappend(ro_gpio);
oappend(SET_F("];"));
// WLEDMM same procedure for DMX pins
strcpy(ro_gpio, "d.x_pins=["); // WLEDMM we re-use this array, instead of creating an addition one; 140 bytes is more than enough for max 4 pins.
isFirstPin = true;
for(int pinNr = 0; pinNr < WLED_NUM_PINS; pinNr++) {
if ((pinManager.isPinOk(pinNr)) && (pinManager.getPinOwner(pinNr) == PinOwner::DMX || pinManager.getPinOwner(pinNr) == PinOwner::DMX_INPUT)) {
sprintf(pinString, "%s%d", isFirstPin ? "" : ",", pinNr);
strcat(ro_gpio, pinString); isFirstPin = false;
}
}
oappend(ro_gpio);
oappend(SET_F("];"));
}
//get values for settings form in javascript