Skip to content

Commit fdb86ea

Browse files
authored
Merge branch 'wled:main' into main
2 parents e2c8fc6 + cc5b504 commit fdb86ea

File tree

8 files changed

+60
-163
lines changed

8 files changed

+60
-163
lines changed

.github/workflows/usermods.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
name: Usermod CI
22

33
on:
4-
push:
5-
paths:
6-
- usermods/**
7-
- .github/workflows/usermods.yml
84
pull_request:
95
paths:
106
- usermods/**
117

128
jobs:
139

1410
get_usermod_envs:
11+
# Only run for pull requests from forks (not from branches within wled/WLED)
12+
if: github.event.pull_request.head.repo.full_name != github.repository
1513
name: Gather Usermods
1614
runs-on: ubuntu-latest
1715
steps:
@@ -31,6 +29,8 @@ jobs:
3129

3230

3331
build:
32+
# Only run for pull requests from forks (not from branches within wled/WLED)
33+
if: github.event.pull_request.head.repo.full_name != github.repository
3434
name: Build Enviornments
3535
runs-on: ubuntu-latest
3636
needs: get_usermod_envs

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,28 @@ Github will pick up the changes so your PR stays up-to-date.
2626
> It has many subtle and unexpected consequences on our github reposistory.
2727
> For example, we regularly lost review comments when the PR author force-pushes code changes. So, pretty please, do not force-push.
2828
29+
> [!TIP]
30+
> use [cherry-picking](https://docs.github.com/en/desktop/managing-commits/cherry-picking-a-commit-in-github-desktop) to copy commits from one branch to another.
2931
3032
You can find a collection of very useful tips and tricks here: https://github.com/wled-dev/WLED/wiki/How-to-properly-submit-a-PR
3133

34+
### Source Code from an AI agent or bot
35+
> [!IMPORTANT]
36+
> Its OK if you took help from an AI for writing your source code.
37+
>
38+
> However, we expect a few things from you as the person making a contribution to WLED:
39+
* Make sure you really understand the code suggested by the AI, and don't just accept it because it "seems to work".
40+
* Don't let the AI change existing code without double-checking by you as the contributor. Often, the result will not be complete. For example, previous source code comments may be lost.
41+
* Remember that AI are still "Often-Wrong" ;-)
42+
* If you don't feel very confident using English, you can use AI for translating code comments and descriptions into English. AI bots are very good at understanding language. However, always check if the results is correct. The translation might still have wrong technical terms, or errors in some details.
43+
44+
#### best practice with AI:
45+
* As the person who contributes source code to WLED, make sure you understand exactly what the AI generated code does
46+
* best practice: add a comment like ``'// below section of my code was generated by an AI``, when larger parts of your source code were not written by you personally.
47+
* always review translations and code comments for correctness
48+
* always review AI generated source code
49+
* If the AI has rewritten existing code, check that the change is necessary and that nothing has been lost or broken. Also check that previous code comments are still intact.
50+
3251

3352
### Code style
3453

lib/NeoESP8266DMAFix/include/NeoEsp8266DmaMethodFix.h

Lines changed: 0 additions & 122 deletions
This file was deleted.

lib/NeoESP8266DMAFix/library.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

platformio.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ lib_compat_mode = strict
160160
lib_deps =
161161
fastled/FastLED @ 3.6.0
162162
IRremoteESP8266 @ 2.8.2
163-
makuna/NeoPixelBus @ 2.8.3
163+
https://github.com/Makuna/NeoPixelBus.git#a0919d1c10696614625978dd6fb750a1317a14ce
164164
https://github.com/Aircoookie/ESPAsyncWebServer.git#v2.4.2
165165
marvinroger/AsyncMqttClient @ 0.9.0
166166
# for I2C interface
@@ -220,7 +220,6 @@ lib_deps =
220220
ESPAsyncUDP
221221
ESP8266PWM
222222
${env.lib_deps}
223-
NeoESP8266DMAFix
224223

225224
;; compatibilty flags - same as 0.14.0 which seems to work better on some 8266 boards. Not using PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48
226225
build_flags_compat =

usermods/audioreactive/audio_reactive.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ class AudioReactive : public Usermod {
13351335
disableSoundProcessing = true;
13361336
} else {
13371337
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DEBUG)
1338-
if ((disableSoundProcessing == true) && (audioSyncEnabled == 0) && audioSource->isInitialized()) { // we just switched to "enabled"
1338+
if ((disableSoundProcessing == true) && (audioSyncEnabled == 0) && audioSource && audioSource->isInitialized()) { // we just switched to "enabled"
13391339
DEBUG_PRINTLN(F("[AR userLoop] realtime mode ended - audio processing resumed."));
13401340
DEBUG_PRINTF_P(PSTR(" RealtimeMode = %d; RealtimeOverride = %d\n"), int(realtimeMode), int(realtimeOverride));
13411341
}
@@ -1347,7 +1347,7 @@ class AudioReactive : public Usermod {
13471347
if (audioSyncEnabled & 0x02) disableSoundProcessing = true; // make sure everything is disabled IF in audio Receive mode
13481348
if (audioSyncEnabled & 0x01) disableSoundProcessing = false; // keep running audio IF we're in audio Transmit mode
13491349
#ifdef ARDUINO_ARCH_ESP32
1350-
if (!audioSource->isInitialized()) disableSoundProcessing = true; // no audio source
1350+
if (!audioSource || !audioSource->isInitialized()) disableSoundProcessing = true; // no audio source
13511351

13521352

13531353
// Only run the sampling code IF we're not in Receive mode or realtime mode

wled00/bus_wrapper.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
//#define NPB_CONF_4STEP_CADENCE
66
#include "NeoPixelBus.h"
7-
#ifdef ARDUINO_ARCH_ESP8266
8-
#include <NeoEsp8266DmaMethodFix.h>
9-
#endif
107

118
//Hardware SPI Pins
129
#define P_8266_HS_MOSI 13

wled00/data/settings_leds.htm

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@
268268
}
269269

270270
// enable/disable LED fields
271+
updateTypeDropdowns(); // restrict bus types in dropdowns to max allowed digital/analog buses
271272
let dC = 0; // count of digital buses (for parallel I2S)
272273
let LTs = d.Sf.querySelectorAll("#mLC select[name^=LT]");
273274
LTs.forEach((s,i)=>{
274-
if (i < LTs.length-1) s.disabled = true; // prevent changing type (as we can't update options)
275275
// is the field a LED type?
276276
var n = s.name.substring(2,3); // bus number (0-Z)
277277
var t = parseInt(s.value);
@@ -448,17 +448,8 @@
448448
{
449449
var o = gEBCN("iST");
450450
var i = o.length;
451-
let disable = (sel,opt) => { sel.querySelectorAll(opt).forEach((o)=>{o.disabled=true;}); }
452451

453452
var f = gId("mLC");
454-
let digitalB = 0, analogB = 0, twopinB = 0, virtB = 0;
455-
f.querySelectorAll("select[name^=LT]").forEach((s)=>{
456-
let t = s.value;
457-
if (isDig(t) && !isD2P(t)) digitalB++;
458-
if (isD2P(t)) twopinB++;
459-
if (isPWM(t)) analogB += numPins(t); // each GPIO is assigned to a channel
460-
if (isVir(t)) virtB++;
461-
});
462453

463454
if ((n==1 && i>=36) || (n==-1 && i==0)) return; // used to be i>=maxB+maxV when virtual buses were limited (now :"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
464455
var s = chrID(i);
@@ -468,7 +459,7 @@
468459
var cn = `<div class="iST">
469460
<hr class="sml">
470461
${i+1}:
471-
<select name="LT${s}" onchange="UI(true)"></select><br>
462+
<select name="LT${s}" onchange="updateTypeDropdowns();UI(true)"></select><br>
472463
<div id="abl${s}">
473464
mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();">
474465
<option value="55" selected>55mA (typ. 5V WS281x)</option>
@@ -523,18 +514,15 @@
523514
}
524515
});
525516
enLA(d.Sf["LAsel"+s],s); // update LED mA
526-
// disable inappropriate LED types
517+
// temporarily set to virtual (network) type to avoid "same type" exception during dropdown update
527518
let sel = d.getElementsByName("LT"+s)[0];
528-
// 32 & S2 supports mono I2S as well as parallel so we need to take that into account; S3 only supports parallel
529-
let maxDB = maxD - (is32() || isS2() || isS3() ? (!d.Sf["PR"].checked)*8 - (!isS3()) : 0); // adjust max digital buses if parallel I2S is not used
530-
if (digitalB >= maxDB) disable(sel,'option[data-type="D"]'); // NOTE: see isDig()
531-
if (twopinB >= 2) disable(sel,'option[data-type="2P"]'); // NOTE: see isD2P() (we will only allow 2 2pin buses)
532-
disable(sel,`option[data-type^="${'A'.repeat(maxA-analogB+1)}"]`); // NOTE: see isPWM()
519+
sel.value = sel.querySelector('option[data-type="N"]').value;
520+
updateTypeDropdowns(); // update valid bus options including this new one
533521
sel.selectedIndex = sel.querySelector('option:not(:disabled)').index;
522+
updateTypeDropdowns(); // update again for the newly selected type
534523
}
535524
if (n==-1) {
536525
o[--i].remove();--i;
537-
o[i].querySelector("[name^=LT]").disabled = false;
538526
}
539527

540528
gId("+").style.display = (i<35) ? "inline":"none"; // was maxB+maxV-1 when virtual buses were limited (now :"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
@@ -829,6 +817,34 @@
829817
}
830818
return opt;
831819
}
820+
// dynamically enforce bus type availability based on current usage
821+
function updateTypeDropdowns() {
822+
let LTs = d.Sf.querySelectorAll("#mLC select[name^=LT]");
823+
let digitalB = 0, analogB = 0, twopinB = 0, virtB = 0;
824+
// count currently used buses
825+
LTs.forEach(sel => {
826+
let t = parseInt(sel.value);
827+
if (isDig(t) && !isD2P(t)) digitalB++;
828+
if (isPWM(t)) analogB += numPins(t);
829+
if (isD2P(t)) twopinB++;
830+
if (isVir(t)) virtB++;
831+
});
832+
// enable/disable type options according to limits in dropdowns
833+
LTs.forEach(sel => {
834+
const curType = parseInt(sel.value);
835+
const disable = (q) => sel.querySelectorAll(q).forEach(o => o.disabled = true);
836+
const enable = (q) => sel.querySelectorAll(q).forEach(o => o.disabled = false);
837+
enable('option'); // reset all first
838+
// max digital buses: ESP32 & S2 support mono I2S as well as parallel so we need to take that into account; S3 only supports parallel
839+
// supported outputs using parallel I2S/mono I2S: S2: 12/5, S3: 12/4, ESP32: 16/9
840+
let maxDB = maxD - ((is32() || isS2() || isS3()) ? (!d.Sf["PR"].checked) * 8 - (!isS3()) : 0); // adjust max digital buses if parallel I2S is not used
841+
// disallow adding more of a type that has reached its limit but allow changing the current type
842+
if (digitalB >= maxDB && !(isDig(curType) && !isD2P(curType))) disable('option[data-type="D"]');
843+
if (twopinB >= 2 && !isD2P(curType)) disable('option[data-type="2P"]');
844+
// Disable PWM types that need more pins than available (accounting for current type's pins if PWM)
845+
disable(`option[data-type^="${'A'.repeat(maxA - analogB + (isPWM(curType)?numPins(curType):0) + 1)}"]`);
846+
});
847+
}
832848
</script>
833849
<style>@import url("style.css");</style>
834850
</head>

0 commit comments

Comments
 (0)