Skip to content

Commit 661e1ee

Browse files
committed
Merge branch 'main' into unify-hostname
2 parents 929f58f + da7f107 commit 661e1ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1574
-827
lines changed

.github/copilot-instructions.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# WLED - ESP32/ESP8266 LED Controller Firmware
2+
3+
WLED is a fast and feature-rich implementation of an ESP32 and ESP8266 webserver to control NeoPixel (WS2812B, WS2811, SK6812) LEDs and SPI-based chipsets. The project consists of C++ firmware for microcontrollers and a modern web interface.
4+
5+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
6+
7+
## Working Effectively
8+
9+
### Initial Setup
10+
- Install Node.js 20+ (specified in `.nvmrc`): Check your version with `node --version`
11+
- Install dependencies: `npm install` (takes ~5 seconds)
12+
- Install PlatformIO for hardware builds: `pip install -r requirements.txt` (takes ~60 seconds)
13+
14+
### Build and Test Workflow
15+
- **ALWAYS build web UI first**: `npm run build` -- takes 3 seconds. NEVER CANCEL.
16+
- **Run tests**: `npm test` -- takes 40 seconds. NEVER CANCEL. Set timeout to 2+ minutes.
17+
- **Development mode**: `npm run dev` -- monitors file changes and auto-rebuilds web UI
18+
- **Hardware firmware build**: `pio run -e [environment]` -- takes 15+ minutes. NEVER CANCEL. Set timeout to 30+ minutes.
19+
20+
### Build Process Details
21+
The build has two main phases:
22+
1. **Web UI Generation** (`npm run build`):
23+
- Processes files in `wled00/data/` (HTML, CSS, JS)
24+
- Minifies and compresses web content
25+
- Generates `wled00/html_*.h` files with embedded web content
26+
- **CRITICAL**: Must be done before any hardware build
27+
28+
2. **Hardware Compilation** (`pio run`):
29+
- Compiles C++ firmware for various ESP32/ESP8266 targets
30+
- Common environments: `nodemcuv2`, `esp32dev`, `esp8266_2m`
31+
- List all targets: `pio run --list-targets`
32+
33+
## Validation and Testing
34+
35+
### Web UI Testing
36+
- **ALWAYS validate web UI changes manually**:
37+
- Start local server: `cd wled00/data && python3 -m http.server 8080`
38+
- Open `http://localhost:8080/index.htm` in browser
39+
- Test basic functionality: color picker, effects, settings pages
40+
- **Check for JavaScript errors** in browser console
41+
42+
### Code Validation
43+
- **No automated linting configured** - follow existing code style in files you edit
44+
- **Code style**: Use tabs for web files (.html/.css/.js), spaces (2 per level) for C++ files
45+
- **C++ formatting available**: `clang-format` is installed but not in CI
46+
- **Always run tests before finishing**: `npm test`
47+
48+
### Manual Testing Scenarios
49+
After making changes to web UI, always test:
50+
- **Load main interface**: Verify index.htm loads without errors
51+
- **Navigation**: Test switching between main page and settings pages
52+
- **Color controls**: Verify color picker and brightness controls work
53+
- **Effects**: Test effect selection and parameter changes
54+
- **Settings**: Test form submission and validation
55+
56+
## Common Tasks
57+
58+
### Repository Structure
59+
```
60+
wled00/ # Main firmware source (C++)
61+
├── data/ # Web interface files
62+
│ ├── index.htm # Main UI
63+
│ ├── settings*.htm # Settings pages
64+
│ └── *.js/*.css # Frontend resources
65+
├── *.cpp/*.h # Firmware source files
66+
└── html_*.h # Generated embedded web files (DO NOT EDIT)
67+
tools/ # Build tools (Node.js)
68+
├── cdata.js # Web UI build script
69+
└── cdata-test.js # Test suite
70+
platformio.ini # Hardware build configuration
71+
package.json # Node.js dependencies and scripts
72+
.github/workflows/ # CI/CD pipelines
73+
```
74+
75+
### Key Files and Their Purpose
76+
- `wled00/data/index.htm` - Main web interface
77+
- `wled00/data/settings*.htm` - Configuration pages
78+
- `tools/cdata.js` - Converts web files to C++ headers
79+
- `wled00/wled.h` - Main firmware configuration
80+
- `platformio.ini` - Hardware build targets and settings
81+
82+
### Development Workflow
83+
1. **For web UI changes**:
84+
- Edit files in `wled00/data/`
85+
- Run `npm run build` to regenerate headers
86+
- Test with local HTTP server
87+
- Run `npm test` to validate build system
88+
89+
2. **For firmware changes**:
90+
- Edit files in `wled00/` (but NOT `html_*.h` files)
91+
- Ensure web UI is built first (`npm run build`)
92+
- Build firmware: `pio run -e [target]`
93+
- Flash to device: `pio run -e [target] --target upload`
94+
95+
3. **For both web and firmware**:
96+
- Always build web UI first
97+
- Test web interface manually
98+
- Build and test firmware if making firmware changes
99+
100+
## Build Timing and Timeouts
101+
102+
- **Web UI build**: 3 seconds - Set timeout to 30 seconds minimum
103+
- **Test suite**: 40 seconds - Set timeout to 2 minutes minimum
104+
- **Hardware builds**: 15+ minutes - Set timeout to 30+ minutes minimum
105+
- **NEVER CANCEL long-running builds** - PlatformIO downloads and compilation can take significant time
106+
107+
## Troubleshooting
108+
109+
### Common Issues
110+
- **Build fails with missing html_*.h**: Run `npm run build` first
111+
- **Web UI looks broken**: Check browser console for JavaScript errors
112+
- **PlatformIO network errors**: Try again, downloads can be flaky
113+
- **Node.js version issues**: Ensure Node.js 20+ is installed (check `.nvmrc`)
114+
115+
### When Things Go Wrong
116+
- **Clear generated files**: `rm -f wled00/html_*.h` then rebuild
117+
- **Force web UI rebuild**: `npm run build -- --force` or `npm run build -- -f`
118+
- **Clean PlatformIO cache**: `pio run --target clean`
119+
- **Reinstall dependencies**: `rm -rf node_modules && npm install`
120+
121+
## Important Notes
122+
123+
- **DO NOT edit `wled00/html_*.h` files** - they are auto-generated
124+
- **Always commit both source files AND generated html_*.h files**
125+
- **Web UI must be built before firmware compilation**
126+
- **Test web interface manually after any web UI changes**
127+
- **Use VS Code with PlatformIO extension for best development experience**
128+
- **Hardware builds require appropriate ESP32/ESP8266 development board**
129+
130+
## CI/CD Pipeline
131+
The GitHub Actions workflow:
132+
1. Installs Node.js and Python dependencies
133+
2. Runs `npm test` to validate build system
134+
3. Builds web UI with `npm run build`
135+
4. Compiles firmware for multiple hardware targets
136+
5. Uploads build artifacts
137+
138+
Match this workflow in your local development to ensure CI success.

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ jobs:
4040
with:
4141
node-version-file: '.nvmrc'
4242
cache: 'npm'
43-
- run: npm ci
43+
- run: |
44+
npm ci
45+
VERSION=`date +%y%m%d0`
46+
sed -i -r -e "s/define VERSION .+/define VERSION $VERSION/" wled00/wled.h
4447
- name: Cache PlatformIO
4548
uses: actions/cache@v4
4649
with:

.github/workflows/pr-merge.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: Notify Discord on PR Merge
22
on:
33
workflow_dispatch:
4-
pull_request:
4+
pull_request_target:
55
types: [closed]
66

77
jobs:
88
notify:
99
runs-on: ubuntu-latest
10+
if: github.event.pull_request.merged == true
1011
steps:
1112
- name: Get User Permission
1213
id: checkAccess
@@ -23,11 +24,15 @@
2324
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
2425
echo "Job originally triggered by ${{ github.actor }}"
2526
exit 1
26-
- name: Checkout code
27-
uses: actions/checkout@v3
28-
with:
29-
ref: ${{ github.event.pull_request.head.sha }} # This is dangerous without the first access check
3027
- name: Send Discord notification
31-
# if: github.event.pull_request.merged == true
28+
env:
29+
PR_NUMBER: ${{ github.event.pull_request.number }}
30+
PR_TITLE: ${{ github.event.pull_request.title }}
31+
PR_URL: ${{ github.event.pull_request.html_url }}
32+
ACTOR: ${{ github.actor }}
3233
run: |
33-
curl -H "Content-Type: application/json" -d '{"content": "Pull Request ${{ github.event.pull_request.number }} merged by ${{ github.actor }}"}' ${{ secrets.DISCORD_WEBHOOK_BETA_TESTERS }}
34+
jq -n \
35+
--arg content "Pull Request #${PR_NUMBER} \"${PR_TITLE}\" merged by ${ACTOR}
36+
${PR_URL}" \
37+
'{content: $content}' \
38+
| curl -H "Content-Type: application/json" -d @- ${{ secrets.DISCORD_WEBHOOK_BETA_TESTERS }}

platformio.ini

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# ------------------------------------------------------------------------------
1111

1212
# CI/release binaries
13-
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32dev_V4, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover, usermods
13+
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover, usermods
1414

1515
src_dir = ./wled00
1616
data_dir = ./wled00/data
@@ -142,7 +142,7 @@ lib_deps =
142142
IRremoteESP8266 @ 2.8.2
143143
makuna/NeoPixelBus @ 2.8.3
144144
#https://github.com/makuna/NeoPixelBus.git#CoreShaderBeta
145-
https://github.com/Aircoookie/ESPAsyncWebServer.git#v2.4.0
145+
https://github.com/Aircoookie/ESPAsyncWebServer.git#v2.4.2
146146
# for I2C interface
147147
;Wire
148148
# ESP-NOW library
@@ -234,45 +234,36 @@ lib_deps_compat =
234234

235235
[esp32_all_variants]
236236
lib_deps =
237-
willmmiles/AsyncTCP @ 1.3.1
237+
esp32async/AsyncTCP @ 3.4.7
238238
bitbank2/AnimatedGIF@^1.4.7
239239
https://github.com/Aircoookie/GifDecoder#bc3af18
240240
build_flags =
241241
-D CONFIG_ASYNC_TCP_USE_WDT=0
242+
-D CONFIG_ASYNC_TCP_STACK_SIZE=8192
242243
-D WLED_ENABLE_GIF
243244

244245
[esp32]
245-
#platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.3/platform-espressif32-2.0.2.3.zip
246-
platform = espressif32@3.5.0
247-
platform_packages = framework-arduinoespressif32 @ https://github.com/Aircoookie/arduino-esp32.git#1.0.6.4
246+
platform = ${esp32_idf_V4.platform}
247+
platform_packages =
248248
build_unflags = ${common.build_unflags}
249-
build_flags = -g
250-
-DARDUINO_ARCH_ESP32
251-
#-DCONFIG_LITTLEFS_FOR_IDF_3_2
252-
#use LITTLEFS library by lorol in ESP32 core 1.x.x instead of built-in in 2.x.x
253-
-D LOROL_LITTLEFS
254-
; -DARDUINO_USB_CDC_ON_BOOT=0 ;; this flag is mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3
255-
${esp32_all_variants.build_flags}
249+
build_flags = ${esp32_idf_V4.build_flags}
250+
lib_deps = ${esp32_idf_V4.lib_deps}
256251

257252
tiny_partitions = tools/WLED_ESP32_2MB_noOTA.csv
258253
default_partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
259254
extended_partitions = tools/WLED_ESP32_4MB_700k_FS.csv
260255
big_partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; 1.8MB firmware, 256KB filesystem, coredump support
261256
large_partitions = tools/WLED_ESP32_8MB.csv
262257
extreme_partitions = tools/WLED_ESP32_16MB_9MB_FS.csv
263-
lib_deps =
264-
https://github.com/lorol/LITTLEFS.git
265-
${esp32_all_variants.lib_deps}
266-
${env.lib_deps}
258+
267259
board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs
268260
# additional build flags for audioreactive - must be applied globally
269261
AR_build_flags = ;; -fsingle-precision-constant ;; forces ArduinoFFT to use float math (2x faster)
270262
AR_lib_deps = ;; for pre-usermod-library platformio_override compatibility
271263

272264

273265
[esp32_idf_V4]
274-
;; experimental build environment for ESP32 using ESP-IDF 4.4.x / arduino-esp32 v2.0.5
275-
;; very similar to the normal ESP32 flags, but omitting Lorol LittleFS, as littlefs is included in the new framework already.
266+
;; build environment for ESP32 using ESP-IDF 4.4.x / arduino-esp32 v2.0.5
276267
;;
277268
;; please note that you can NOT update existing ESP32 installs with a "V4" build. Also updating by OTA will not work properly.
278269
;; You need to completely erase your device (esptool erase_flash) first, then install the "V4" build from VSCode+platformio.
@@ -283,14 +274,12 @@ build_unflags = ${common.build_unflags}
283274
build_flags = -g
284275
-Wshadow=compatible-local ;; emit warning in case a local variable "shadows" another local one
285276
-DARDUINO_ARCH_ESP32 -DESP32
286-
-DARDUINO_USB_CDC_ON_BOOT=0 ;; this flag is mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3
287277
${esp32_all_variants.build_flags}
288278
-D WLED_ENABLE_DMX_INPUT
289279
lib_deps =
290280
${esp32_all_variants.lib_deps}
291281
https://github.com/someweisguy/esp_dmx.git#47db25d
292282
${env.lib_deps}
293-
board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs
294283

295284
[esp32s2]
296285
;; generic definitions for all ESP32-S2 boards
@@ -305,10 +294,9 @@ build_flags = -g
305294
-DARDUINO_USB_MODE=0 ;; this flag is mandatory for ESP32-S2 !
306295
;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry:
307296
;; ARDUINO_USB_CDC_ON_BOOT
308-
${esp32_all_variants.build_flags}
297+
${esp32_idf_V4.build_flags}
309298
lib_deps =
310-
${esp32_all_variants.lib_deps}
311-
${env.lib_deps}
299+
${esp32_idf_V4.lib_deps}
312300
board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs
313301

314302
[esp32c3]
@@ -323,10 +311,9 @@ build_flags = -g
323311
-DARDUINO_USB_MODE=1 ;; this flag is mandatory for ESP32-C3
324312
;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry:
325313
;; ARDUINO_USB_CDC_ON_BOOT
326-
${esp32_all_variants.build_flags}
314+
${esp32_idf_V4.build_flags}
327315
lib_deps =
328-
${esp32_all_variants.lib_deps}
329-
${env.lib_deps}
316+
${esp32_idf_V4.lib_deps}
330317
board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs
331318
board_build.flash_mode = qio
332319

@@ -343,10 +330,9 @@ build_flags = -g
343330
-DCO
344331
;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry:
345332
;; ARDUINO_USB_MODE, ARDUINO_USB_CDC_ON_BOOT
346-
${esp32_all_variants.build_flags}
333+
${esp32_idf_V4.build_flags}
347334
lib_deps =
348-
${esp32_all_variants.lib_deps}
349-
${env.lib_deps}
335+
${esp32_idf_V4.lib_deps}
350336
board_build.partitions = ${esp32.large_partitions} ;; default partioning for 8MB flash - can be overridden in build envs
351337

352338

@@ -441,21 +427,11 @@ custom_usermods = audioreactive
441427

442428
[env:esp32dev]
443429
board = esp32dev
444-
platform = ${esp32.platform}
445-
platform_packages = ${esp32.platform_packages}
446-
custom_usermods = audioreactive
447-
build_unflags = ${common.build_unflags}
448-
build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32\" #-D WLED_DISABLE_BROWNOUT_DET
449-
lib_deps = ${esp32.lib_deps}
450-
monitor_filters = esp32_exception_decoder
451-
board_build.partitions = ${esp32.default_partitions}
452-
453-
[env:esp32dev_V4]
454-
board = esp32dev
455430
platform = ${esp32_idf_V4.platform}
456431
build_unflags = ${common.build_unflags}
457432
custom_usermods = audioreactive
458433
build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_V4\" #-D WLED_DISABLE_BROWNOUT_DET
434+
-DARDUINO_USB_CDC_ON_BOOT=0 ;; this flag is mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3
459435
lib_deps = ${esp32_idf_V4.lib_deps}
460436
monitor_filters = esp32_exception_decoder
461437
board_build.partitions = ${esp32.default_partitions}
@@ -489,34 +465,20 @@ board_upload.maximum_size = 16777216
489465
board_build.f_flash = 80000000L
490466
board_build.flash_mode = dio
491467

492-
;[env:esp32dev_audioreactive]
493-
;board = esp32dev
494-
;platform = ${esp32.platform}
495-
;platform_packages = ${esp32.platform_packages}
496-
;custom_usermods = audioreactive
497-
;build_unflags = ${common.build_unflags}
498-
;build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32_audioreactive\" #-D WLED_DISABLE_BROWNOUT_DET
499-
;lib_deps = ${esp32.lib_deps}
500-
;monitor_filters = esp32_exception_decoder
501-
;board_build.partitions = ${esp32.default_partitions}
502-
;; board_build.f_flash = 80000000L
503-
;; board_build.flash_mode = dio
504-
505468
[env:esp32_eth]
506469
board = esp32-poe
507-
platform = ${esp32.platform}
508-
platform_packages = ${esp32.platform_packages}
470+
platform = ${esp32_idf_V4.platform}
509471
upload_speed = 921600
510472
custom_usermods = audioreactive
511473
build_unflags = ${common.build_unflags}
512474
build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32_Ethernet\" -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1
513475
; -D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only
514476
lib_deps = ${esp32.lib_deps}
515477
board_build.partitions = ${esp32.default_partitions}
478+
board_build.flash_mode = dio
516479

517480
[env:esp32_wrover]
518481
extends = esp32_idf_V4
519-
platform = ${esp32_idf_V4.platform}
520482
board = ttgo-t7-v14-mini32
521483
board_build.f_flash = 80000000L
522484
board_build.flash_mode = qio

platformio_override.sample.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ lib_deps = ${esp8266.lib_deps}
2828
; robtillaart/SHT85@~0.3.3
2929
; ;gmag11/QuickESPNow @ ~0.7.0 # will also load QuickDebug
3030
; https://github.com/blazoncek/QuickESPNow.git#optional-debug ;; exludes debug library
31-
; bitbank2/PNGdec@^1.0.1 ;; used for POV display uncomment following
3231
; ${esp32.AR_lib_deps} ;; needed for USERMOD_AUDIOREACTIVE
3332

3433
build_unflags = ${common.build_unflags}

0 commit comments

Comments
 (0)