Skip to content

Conversation

KrX3D
Copy link

@KrX3D KrX3D commented Oct 8, 2025

Hi,

i added some missing define examples to platformio_override.sample.ini
The defines where present but no info was there how to use them, i also added the location of the option on the webpage like:

Settings -> Wifi Setup -> Network name (SSID, empty to not connect)

for a better understanding what this define is for.

And together with that i added a couple more things that can be defined. Mostly the one i currently use, since i got an device i bought that keeps resetting to the compiled defaults... , but i would like to add more in future when i got time (not in this PR)

The defines can also be added to the my_config file like i did, here is an list of the new and already present once added with the PR.

// Device identity / User Interface
#define SERVERNAME                 "ClientXYZ"                     // Settings -> User Interface -> Server description

// Settings -> Wifi Setup
#define CLIENT_SSID                ""                              // Settings -> Wifi Setup -> Network name (SSID, empty to not connect)
#define CLIENT_PASS                ""                              // Settings -> Wifi Setup -> Network password
#define WIFI_DEFAULT_NO_WIFI_SLEEP true                            // Settings -> Wifi Setup -> Experimental -> Disable WiFi sleep
#define MDNS_NAME                  "wled-ClientXYZ"                         // Settings -> Wifi Setup -> mDNS address (leave empty for no mDNS)
#define WLED_AP_SSID               "WLED-ClientXYZ-AP"              // Settings -> Wifi Setup -> Configure Access Point -> AP SSID (leave empty for no AP)
#define WLED_AP_PASS               ""                              // Settings -> Wifi Setup -> Configure Access Point -> AP password (leave empty for open)

// Settings -> Security & Update
#define WLED_ENABLE_AOTA                                        // Settings -> Security & Update -> Software Update -> Enable ArduinoOTA
#define WLED_DISABLE_OTA                                        // Settings -> Security & Update -> Software Update -> OTA
#define OTA_DEFAULT_SAME_SUBNET    false                         // Settings -> Security & Update -> Software Update -> Only allow update from same network/WiFi

// Settings -> Time & Macros
#define WLED_NTP_ENABLED          true                           // Settings -> Time & Macros -> Time setup -> Get time from NTP server
#define WLED_NTP_SERVER           "192.168.178.11"               // Settings -> Time & Macros -> Time setup -> NTP Server
#define WLED_NTP_AMPM             true                           // Settings -> Time & Macros -> Time setup -> Use 24h format
#define WLED_TIMEZONE             2                              // Settings -> Time & Macros -> Time setup -> Time zone
#define WLED_UTC_OFFSET           0                              // Settings -> Time & Macros -> Time setup -> UTC offset
#define WLED_LAT                  50.51f                         // Settings -> Time & Macros -> Time setup -> Latitude
#define WLED_LON                  8.13f                          // Settings -> Time & Macros -> Time setup -> Longitude

// Settings -> Usermods
#define I2CSDAPIN                 8                              // Settings -> Usermods -> Global I2C GPIOs (HW) -> SDA
#define I2CSCLPIN                 9                              // Settings -> Usermods -> Global I2C GPIOs (HW) -> SCL

// Settings -> Sync Interfaces -> MQTT
#define MQTT_DEFAULT_ENABLED      true                           // Settings -> Sync Interfaces -> MQTT -> Enable MQTT
#define MQTT_DEFAULT_SERVER       "192.168.178.95"               // Settings -> Sync Interfaces -> MQTT -> Broker
#define MQTT_DEFAULT_PORT         1883                           // Settings -> Sync Interfaces -> MQTT -> Port
#define MQTT_DEFAULT_USER         "emqx_user"                    // Settings -> Sync Interfaces -> MQTT -> Username
#define MQTT_DEFAULT_PASS         "emqx_pass"                    // Settings -> Sync Interfaces -> MQTT -> Password
#define MQTT_DEFAULT_GROUP_TOPIC  "wled/all"                     // Settings -> Sync Interfaces -> MQTT -> Group Topic
#define MQTT_DEFAULT_BUTTON_PUBLISH false                        // Settings -> Sync Interfaces -> MQTT -> Publish on button press
#define MQTT_DEFAULT_RETAIN       true                           // Settings -> Sync Interfaces -> MQTT -> Retain brightness & color messages
#define MQTT_DEFAULT_CLIENTID     "ClientXYZ"                     // Settings -> Sync Interfaces -> MQTT -> Client ID
#define MQTT_DEFAULT_DEVICE_TOPIC "wled/ClientXYZ"             // Settings -> Sync Interfaces -> MQTT -> Device Topic

// Settings -> Sync Interfaces -> Send / Notifications
#define NOTIFY_DEFAULT_SEND_NOTIFICATIONS true                    // Settings -> Sync Interfaces -> Send -> Enable Sync on start
#define NOTIFY_DEFAULT_DIRECT     0                              // Settings -> Sync Interfaces -> Send -> Send notifications on direct change

// Settings -> Sync Interfaces -> Realtime
#define LED_DEFAULT_USE_MAIN_SEGMENT_ONLY false                   // Settings -> Sync Interfaces -> Realtime -> Use main segment only
#define REALTIME_DEFAULT_RESPECT_LED_MAPS true                    // Settings -> Sync Interfaces -> Realtime -> Respect LED Maps
#define RECEIVE_DEFAULT_DIRECT    1                              // Settings -> Sync Interfaces -> Realtime -> Receive UDP realtime

// Settings -> Sync Interfaces -> Sync groups
#define SYNC_DEFAULT_SEND_GROUPS   0x40                          // Settings -> Sync Interfaces -> Sync groups -> Send
#define SYNC_DEFAULT_RECEIVE_GROUPS 0x40                         // Settings -> Sync Interfaces -> Sync groups -> Receive

// Settings -> Sync Interfaces -> WLED Broadcast
#define UDP_DEFAULT_MAIN_PORT     21234                          // Settings -> Sync Interfaces -> WLED Broadcast -> UDP Port
#define UDP_DEFAULT_SECOND_PORT   65506                          // Settings -> Sync Interfaces -> WLED Broadcast -> 2nd Port

// Settings -> Sync Interfaces -> Instance List
#define NODE_DEFAULT_LIST_ENABLED  true                          // Settings -> Sync Interfaces -> Instance List -> Enable instance list
#define NODE_DEFAULT_BROADCAST_ENABLED true                       // Settings -> Sync Interfaces -> Instance List -> Make this instance discoverable

// Settings -> LED Preferences -> Defaults
#define ABL_MILLIAMPS_DEFAULT     0                              // Settings -> LED Preferences -> Maximum PSU Current
#define LED_DEFAULT_TURN_ON_AT_BOOT false                        // Settings -> LED Preferences -> Defaults -> Turn LEDs on after power up/reset
#define LED_DEFAULT_BRIGHTNESS    76                             // Settings -> LED Preferences -> Defaults -> Default brightness
#define LED_DEFAULT_BOOT_PRESET   0                              // Settings -> LED Preferences -> Defaults -> Apply preset

// Settings -> LED Preferences -> Hardware setup
#define DEFAULT_LED_COLOR_ORDER   COL_ORDER_GRB                  // Settings -> LED Preferences -> Hardware setup -> Color Order
#define WLED_AUTOSEGMENTS         false                          // Settings -> LED Preferences -> Hardware setup -> Make a segment for each output
#define BTNPIN                    3                              // Settings -> LED Preferences -> Hardware setup -> Button X GPIO
#define BTNTYPE                   BTN_TYPE_PUSH                  // Settings -> LED Preferences -> Hardware setup -> Button X GPIO

// Settings -> LED Preferences -> LED outputs
#define PIXEL_COUNTS              281                            // Settings -> LED Preferences -> LED outputs -> Length
#define LED_TYPES                 22                             // Settings -> LED Preferences -> LED outputs -> LED Type
#define DATA_PINS                 5                              // Settings -> LED Preferences -> LED output -> Data GPIO

// LED color presets / defaults
#define LED_DEFAULT_PRIMARY_R     255                            // Primary LED value RED
#define LED_DEFAULT_PRIMARY_G     254                            // Primary LED value GREEN
#define LED_DEFAULT_PRIMARY_B     250                            // Primary LED value BLUE
#define LED_DEFAULT_PRIMARY_W     0                              // Primary LED value WHITE

#define LED_DEFAULT_SECONDARY_R   0                              // Secondary LED value RED
#define LED_DEFAULT_SECONDARY_G   0                              // Secondary LED value GREEN
#define LED_DEFAULT_SECONDARY_B   0                              // Secondary LED value BLUE
#define LED_DEFAULT_SECONDARY_W   0                              // Secondary LED value WHITE

Summary by CodeRabbit

  • Documentation

    • Expanded sample configuration with detailed, commented options and guidance for Wi‑Fi, time/NTP, MQTT, syncing, LED behavior, color order, hardware pins, and usermods. Users can enable features by uncommenting provided examples.
  • Chores

    • Updated default settings for Wi‑Fi power saving, NTP server/format, MQTT topics/credentials/retention, sync/receive behavior, UDP ports, OTA subnet restriction, LED brightness/boot preset/colors, and segment usage. These changes may adjust out‑of‑box behavior for new installations.

Copy link
Contributor

coderabbitai bot commented Oct 8, 2025

Walkthrough

Introduces macro-driven default configuration values in wled00/wled.h, replacing hard-coded initializers for WiFi, MQTT, NTP, colors, sync, UDP ports, and other flags. Adds extensive commented guidance and sample -D options to platformio_override.sample.ini. No public API or functional logic changes; only default initialization and documentation updates.

Changes

Cohort / File(s) Summary
Sample config documentation
platformio_override.sample.ini
Adds commented configuration options, -D defines, and explanatory comments covering WiFi, NTP/time, MQTT, sync interfaces, OTA, LED defaults, color order, usermods, and I2C/SPI pin examples. No active settings changed.
Core defaults refactor
wled00/wled.h
Replaces hard-coded _INIT values with DEFAULT macros for WiFi sleep, NTP (server, AM/PM, enable), MQTT topics/creds/port/retain, LED defaults (boot, brightness, colors, main-segment-only), sync/notify/receive flags, UDP ports, realtime/OTA flags. Initializes globals from these macros without changing signatures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • willmmiles
  • rapek412-prog

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and concisely describes the main change—adding missing define examples and new define options—without extraneous detail, giving a clear indication of the PR’s focus.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
wled00/wled.h (1)

755-778: Consider documenting the bit manipulation logic.

The macros RECEIVE_DEFAULT_OPTIONS (line 774) and NOTIFY_DEFAULT_OPTIONS (line 778) use complex bit manipulation with hardcoded bitmasks (0x67 and 0x0F). While functionally correct, the logic could benefit from inline comments explaining:

  • What each bit position represents
  • Why these specific bitmask values were chosen
  • How the conditional bit setting works

Example documentation to add above line 774:

+// RECEIVE_DEFAULT_OPTIONS builds a bitfield from 0x67 (0b01100111):
+// Bits 0-6: Brightness(1), Color(1), Effects(1), SegmentOptions(0), SegmentBounds(0), Direct(from RECEIVE_DEFAULT_DIRECT), Palette(1)
 #define RECEIVE_DEFAULT_OPTIONS ( (0x67 & ~(1<<5)) | ( (RECEIVE_DEFAULT_DIRECT) ? (1<<5) : 0 ) )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91fdb58 and 18374fa.

📒 Files selected for processing (2)
  • platformio_override.sample.ini (5 hunks)
  • wled00/wled.h (17 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
wled00/**/!(html_*)*.h

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 2-space indentation for non-generated C++ header files (.h)

Files:

  • wled00/wled.h
🧠 Learnings (2)
📚 Learning: 2025-05-26T16:09:34.325Z
Learnt from: blazoncek
PR: wled/WLED#4700
File: wled00/wled_server.cpp:409-414
Timestamp: 2025-05-26T16:09:34.325Z
Learning: In wled00/wled_server.cpp, the OTA update access control logic intentionally allows OTA updates from different subnets when otaSameSubnet is true AND a PIN is set. This was a conscious design decision by blazoncek to provide flexibility for remote OTA updates with PIN protection, though they acknowledged it may not be the optimal security model.

Applied to files:

  • wled00/wled.h
📚 Learning: 2025-04-28T20:51:29.773Z
Learnt from: KrX3D
PR: wled/WLED#4585
File: usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp:430-435
Timestamp: 2025-04-28T20:51:29.773Z
Learning: In WLED, `bri` is a global variable used for brightness control.

Applied to files:

  • wled00/wled.h
🔇 Additional comments (13)
wled00/wled.h (13)

338-341: LGTM!

The NTP server default is properly defined with a fallback to a WLED-specific NTP pool address. The #ifndef guard allows customization via build flags.


348-379: LGTM!

The platform-specific WiFi sleep defaults are appropriate—ESP32 defaults to true (no sleep) for better stability, while ESP8266 defaults to false to conserve power. The macro is correctly applied to both the compact (WLED_SAVE_RAM) and standard struct variants.


416-424: LGTM!

The LED boot behavior defaults are sensible: turning LEDs on at boot by default (true) and not applying a preset (0). Both macros properly use #ifndef guards for customization.


446-474: LGTM!

The default color values are reasonable:

  • Primary color defaults to orange (255, 160, 0, 0) which is a warm, visible color
  • Secondary color defaults to black/off (0, 0, 0, 0)

All eight macros (four per color) have proper #ifndef guards for customization.


493-500: LGTM!

Both node list and broadcast features default to enabled (true), which allows WLED instances to discover and communicate with each other out of the box. This is appropriate for most use cases.


563-603: LGTM!

The extensive MQTT default macros are well-organized. Default values are appropriate:

  • MQTT disabled by default (false)
  • Standard MQTT port (1883)
  • Empty strings for server/credentials requiring user configuration
  • Group topic defaults to "wled/all"
  • Retain defaults to false

All macros properly use #ifndef guards for customization.


643-647: LGTM!

The NTP AM/PM format defaults to false (24-hour format), which is the international standard and appropriate for most use cases.


683-686: LGTM!

The OTA same-subnet restriction defaults to true, which is a secure default that prevents OTA updates from external networks unless a PIN is set (as noted in learnings).

Based on learnings


730-733: LGTM!

The default brightness of 128 (50% of 255) is a sensible middle-ground value that's visible but not overwhelming.


741-746: LGTM!

MQTT button publish defaults to false, which is appropriate as most users won't want button presses to trigger MQTT messages unless explicitly configured.


763-770: LGTM!

Sync send and receive groups both default to 0x01 (group 1), enabling basic synchronization out of the box while allowing users to customize via build flags.


861-906: LGTM!

UDP port defaults are correctly set:

  • Main port: 21234 (standard WLED notifier port)
  • Second port: 65506 (supplemental port)
  • RGB port: 19446 (Hyperion port)

Both compact (WLED_SAVE_RAM) and standard struct variants use the same default values via the new macros.


953-966: LGTM!

Realtime defaults are sensible:

  • Main segment only defaults to false (apply to all segments)
  • Respect LED maps defaults to true (honor user-defined mappings)

These defaults provide flexible behavior while respecting user configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant