Usermod seven segment display reloaded - add more options so it can be used on many different projects
Changelog for UsermodSSDR Update
Configurable Settings
- Introduced preprocessor macros for configuration:
umSSDR_ENABLED– enable/disable the usermod.umSSDR_ENABLE_AUTO_BRIGHTNESS– control auto brightness.umSSDR_BRIGHTNESS_MINandumSSDR_BRIGHTNESS_MAX– set brightness range.umSSDR_INVERT_AUTO_BRIGHTNESS– invert the brightness mapping.umSSDR_LUX_MINandumSSDR_LUX_MAX– define the sensor lux range.umSSDR_INVERTED,umSSDR_COLONBLINK, andumSSDR_LEADING_ZERO– adjust display settings.umSSDR_DISPLAY_MASKand related strings (umSSDR_HOURS,umSSDR_MINUTES,umSSDR_SECONDS,umSSDR_COLONS,umSSDR_LIGHT,umSSDR_DAYS,umSSDR_MONTHS,umSSDR_YEARS) – configure the physical layout.
- The numbers array (
umSSDRNumbers) can now be overridden via the macroumSSDR_NUMBERS.
New Variables and Adjustments
- Added new runtime variables:
umSSDRInvertAutoBrightness– controls inversion of the brightness mapping.umSSDRLuxMinandumSSDRLuxMax– sensor lux thresholds.umSSDRLight– a string to represent a Light LED in the display.
- Grouped configuration values together for clarity.
Display Functionality Enhancements
- In
_overlaySevenSegmentDraw(), added a new case'L'to handle the Light LED, calling_showElements()forumSSDRLight. - Modified logic in
_showElements()for consistent handling of digit elements and improved ordering when populating the time array.
MQTT Publishing and Connection Updates
- Updated
_publishMQTTint_P()and_publishMQTTstr_P()to check for a connected MQTT state usingWLED_MQTT_CONNECTED(wrapped in#ifndef WLED_DISABLE_MQTT). - Adjusted
onMqttConnect()to return early ifumSSDRDisplayTimeis disabled, avoiding unnecessary MQTT subscriptions. - Extended MQTT state updates in
_updateMQTT()to include the new parameters (lux limits, auto brightness inversion, and Light LED).
Brightness Adjustment and Sensor Handling
- Refactored the
loop()function to:- Combine sensor handling for both photoresistor and BH1750.
- Introduce a new flag (
disableUmLedControl) for external control over LED updates. - Implement conditional brightness mapping that inverts the brightness curve if
umSSDRInvertAutoBrightnessis set. - Use a unified sensor reading variable (
lux) updated from whichever sensor is available.
Additional Public API
- Added the public method
disableOutputFunction(bool state)to allow external control over LED output (disable/enable).
JSON API and Configuration Updates
- Enhanced
addToJsonInfo()by:- Adding a nested array to indicate if the module is disabled.
- Including new parameters such as "Auto Brightness inverted" along with existing display settings.
- Updated
_addJSONObject()andreadFromConfig()to incorporate new parameters (lux values, auto brightness inversion, and Light LED) into the state and configuration JSON objects.
With these modifications, the SSDR usermod becomes even more versatile, allowing it to be used on a wide variety of segment clocks and projects.
Look at the readme -> ## Additional Projects
Summary by CodeRabbit
-
New Features
- Introduced a new "Seven Segment Display Reloaded" usermod, offering a highly configurable seven-segment LED display for time and date, with overlay support, MQTT control, and customizable segment layouts.
- Added automatic brightness adjustment based on ambient light sensors, with configurable thresholds and inversion options.
- Enabled dynamic control of display features such as colon blinking, leading zeros, and display masks via settings or MQTT.
- Provided a function to externally disable LED output.
-
Documentation
- Significantly enhanced documentation with detailed parameter tables, clear configuration examples, and expanded setup instructions for both versions of the usermod.
-
Chores
- Added build configuration and setup scripts to support conditional compilation with related usermods.
- Updated internal references to reflect new usermod file naming.
Walkthrough
Adds a new "Seven Segment Display Reloaded v2" usermod: implementation (header + cpp), build metadata and dependency setup, improved documentation for both v1 and v2, and a small const.h comment update. Features include overlay drawing, time/date masks, MQTT/JSON integration, and optional auto-brightness support via photoresistor/BH1750 usermods.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Docs — v1 README updateusermods/seven_segment_display_reloaded/readme.md |
Rewrote and reorganized documentation: added "Available Compile-Time Parameters" table, expanded settings descriptions, brightness parameters, LED definition examples, and documented new public function disableOutputFunction(bool state). |
Docs — v2 README addedusermods/seven_segment_display_reloaded_v2/readme.md |
New README for v2: installation, compile-time options, dependencies, settings, examples, and usage notes including auto-brightness and public API. |
Usermod implementation (v2)usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h, .../seven_segment_display_reloaded_v2.cpp |
New UsermodSSDR class and implementation: overlay drawing, mask parsing, segment-to-LED mapping, colon handling, MQTT publish/subscribe and handlers, JSON config/state persistence, auto-brightness integration, memory management, public disableOutputFunction, and usermod registration. |
Build metadata & depsusermods/seven_segment_display_reloaded_v2/library.json, .../setup_deps.py |
Added library.json (name + extraScript) and setup_deps.py that conditionally appends CPPDEFINES for USERMOD_SN_PHOTORESISTOR or USERMOD_BH1750 when partner usermods are present. |
WLED const updatewled00/const.h |
Updated comment referencing the new v2 usermod source file for USERMOD_ID_SSDR; no functional changes. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Reasoning: Several new files introducing non-trivial logic (parsing/mapping, MQTT, JSON, memory management) plus build integration and docs. Changes are concentrated and cohesive (single new feature), but require review of new logic, boundary checks, and dependency handling.
Possibly related PRs
- wled/WLED#4623 — Overlapping changes: adds setup_deps.py, library.json, and conditional USERMOD_SN_PHOTORESISTOR/USERMOD_BH1750 support for the same SSDR usermod.
- wled/WLED#4592 — Related CI/workflow and usermod packaging changes that introduce/consume library.json and setup_deps.py for usermod builds.
Suggested reviewers
- netmindz
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 clearly summarizes the main change by stating that the seven segment display usermod is being extended with additional options for broader reuse across projects. |
| 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
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between ab84d13fa2d5d961896e54ca3e8e12337a22f435 and 70760cc206a34b137fb81c9f33ba294cd978d691.
📒 Files selected for processing (1)
wled00/const.h(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- wled00/const.h
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@derqurps please have a look.
Just needs the merge conflict fixing, please pull in the latest code from main branch into yours. You might also need to update your readme for the new usermod build configuration
Just needs the merge conflict fixing, please pull in the latest code from main branch into yours. You might also need to update your readme for the new usermod build configuration
I tried, but i wasn't able to push to this PR.
Can i do something to help merge this PR?
hi, i synced my fork and readded the changes and also added at
seven_segment_display_reloaded.cpp
static UsermodSSDR seven_segment_display_reloaded; REGISTER_USERMOD(seven_segment_display_reloaded);
but now im not sure how compile it with the usermod, not just this but every usermod i.e. auto_save
i tried it on lolin_s2_mini and i added to custom_usermods this and the auto save usermod. Am i right that the name from the library.json need to be added to custom_usermods ?
so i added to
[env:lolin_s2_mini] custom_usermods = audioreactive seven_segment_display_reloaded auto_save
but at WLED under usermod its just empty:
So i got it working. Should be finished now.
The problem that i couldnt compile it right seems to be related to
https://github.com/wled/WLED/issues/4597
On my windows 10 pc it doesnt work (where the build for 0.15.X works), so i created on my unraid server a docker with VS Code and there i can compile it...
Are any of you guys on the WLED discord? I am noticing some issues and would be down to contrib too just not sure where to start the conversation with you all. I'm noticing some weirdness with it if you set the WLED clock into countdown mode. It is off by one minute if not showing seconds. And if using 12hr format in SSDR and countdown clock 00 hour gets automatically reset to 12. Not sure where to track SSDR development since it's a usermod and not technically part of the main WLED repo. I'm @kendrick90 there as well.
Are any of you guys on the WLED discord? I am noticing some issues and would be down to contrib too just not sure where to start the conversation with you all. I'm noticing some weirdness with it if you set the WLED clock into countdown mode. It is off by one minute if not showing seconds. And if using 12hr format in SSDR and countdown clock 00 hour gets automatically reset to 12. Not sure where to track SSDR development since it's a usermod and not technically part of the main WLED repo. I'm @kendrick90 there as well.
Hi,
im not using discord. The problems you have are related to my changes here? or the unchanged usermod?
Can you discribe more your problem and how i can reproduce it?
as i understand there are 2 things
- some problem with countdown mode (WLED function? i never used it so far). is the countdown off by 1 min or the clock afterwards? is it off by the amount you set the countdown?
- a problem when setting ssdr to 12hr format. so the problem is that it shows at midnight 12 instead of 00 ? As im not using 12hr format, is it normal to show 00 at midnight? Or does it depend on i.e. which country you are? so what i want to know is if i should change it from 12 to 00 or make an option to be able to pick 12/00
👍 i hope i will be able to review on the next weekend
Hey! This pull request has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs. Thank you for contributing to WLED! ❤️
@github-actions
dont close it, it still works and this PR still wait for merge