Skip to content

Usermod seven segment display reloaded - add more options so it can be used on many different projects #4585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

KrX3D
Copy link

@KrX3D KrX3D commented Mar 4, 2025

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_MIN and umSSDR_BRIGHTNESS_MAX – set brightness range.
    • umSSDR_INVERT_AUTO_BRIGHTNESS – invert the brightness mapping.
    • umSSDR_LUX_MIN and umSSDR_LUX_MAX – define the sensor lux range.
    • umSSDR_INVERTED, umSSDR_COLONBLINK, and umSSDR_LEADING_ZERO – adjust display settings.
    • umSSDR_DISPLAY_MASK and 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 macro umSSDR_NUMBERS.

New Variables and Adjustments

  • Added new runtime variables:
    • umSSDRInvertAutoBrightness – controls inversion of the brightness mapping.
    • umSSDRLuxMin and umSSDRLuxMax – 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() for umSSDRLight.
  • 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 using WLED_MQTT_CONNECTED (wrapped in #ifndef WLED_DISABLE_MQTT).
  • Adjusted onMqttConnect() to return early if umSSDRDisplayTime is 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 umSSDRInvertAutoBrightness is 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() and readFromConfig() 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

  • Documentation

    • Enhanced usermod documentation with structured compile-time parameter tables and clearer, concise setting descriptions.
    • Added detailed LED segment definition examples to improve configuration clarity.
    • Published comprehensive documentation for the new Seven Segment Display Reloaded v2, covering installation, configuration, and usage.
  • New Features

    • Introduced new brightness control parameters and external LED output control.
    • Released the Seven Segment Display Reloaded v2 usermod featuring time display, auto brightness, MQTT support, and customizable display masks.
  • Chores

    • Replaced legacy module metadata with updated variant for improved module identification.
    • Added build dependency script enabling conditional compilation based on related usermods.
    • Updated internal references to align with new usermod file naming.

Copy link
Contributor

coderabbitai bot commented Mar 4, 2025

Walkthrough

This pull request revises the Seven Segment Display Reloaded usermod. The original version's readme has been updated with a new section detailing compile-time parameters, enhanced brightness control settings, and a new public function. Its metadata file (library.json) has been removed. A new version (v2) is introduced with a fresh readme, a new metadata (library.json) file including build script specification, and significant code additions implementing the usermod with configurable display masks, auto brightness, MQTT integration, and external control. Additionally, a build dependency script was added, and a comment in the constants header was updated for accuracy.

Changes

File(s) Change Summary
usermods/seven_segment_display_reloaded/readme.md
usermods/seven_segment_display_reloaded/library.json
Updated documentation with a new "Available Compile-Time Parameters" section, clearer and expanded settings descriptions including brightness control parameters, and added public function disableOutputFunction(bool state); removed the metadata file containing module identity.
usermods/seven_segment_display_reloaded_v2/readme.md
usermods/seven_segment_display_reloaded_v2/library.json
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h
usermods/seven_segment_display_reloaded_v2/setup_deps.py
Added new usermod v2 documentation with installation instructions, detailed compile-time parameters, LED configuration examples, and notes on dynamic brightness and MQTT control; introduced a new metadata file specifying module name and build script; implemented the UsermodSSDR class with configurable display mask, time display, auto brightness control, MQTT integration, JSON configuration, and public disable output function; added a build dependency script to conditionally define compile flags based on related usermods presence.
wled00/const.h Updated the comment for USERMOD_ID_SSDR to reference seven_segment_display_reloaded_v2.cpp instead of the old header filename.

Suggested reviewers

  • blazoncek

📜 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 114dd93 and 3736242.

📒 Files selected for processing (1)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🔭 Outside diff range comments (1)
usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h (1)

355-364: ⚠️ Potential issue

Potential array-out-of-bounds in LED loops.
Using i <= umSSDRLength will access an invalid index when i equals umSSDRLength. To avoid undefined behavior, the loop condition should be < umSSDRLength.

-for(int i = 0; i <= umSSDRLength; i++) {
+for(int i = 0; i < umSSDRLength; i++) {
-for(int i = 0; i <= umSSDRLength; i++) {
+for(int i = 0; i < umSSDRLength; i++) {

(Adjust in both loops at lines 355 and 363)

🧹 Nitpick comments (9)
usermods/seven_segment_display_reloaded/readme.md (9)

11-12: Cross-referencing prerequisites.
Providing direct links to the required sensor usermods (SN_Photoresistor/BH1750_V2) is helpful. Consider explicitly stating the minimum supported version of each sensor usermod, if any constraints apply.


39-40: Override for LED segment mapping.
Highlighting the macro umSSDR_NUMBERS early is beneficial. Consider providing a short code snippet or direct example here on how to override the segment array, so that new users can see how to integrate custom mappings.


52-52: Comma usage for compound sentence.
A comma before “and” can improve readability: “inverted mode in which the background is lit**,** and the digits are off (black).”

- Enables the inverted mode in which the background is lit and the digits are off (black).
+ Enables the inverted mode in which the background is lit, and the digits are off (black).
🧰 Tools
🪛 LanguageTool

[uncategorized] ~52-~52: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


67-70: Missing determiners in lux-limits descriptions.
For better grammar, insert “the” before “minimum/maximum brightness.”

- When the lux value is at or below this level, the display brightness is set to minimum brightness. Default is 0 lux.
+ When the lux value is at or below this level, the display brightness is set to the minimum brightness. Default is 0 lux.
- When the lux value is at or above this level, the display brightness is set to maximum brightness. Default is 1000 lux.
+ When the lux value is at or above this level, the display brightness is set to the maximum brightness. Default is 1000 lux.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~67-~67: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the minimum brightness. Default is 0 lux. - lux-max Defines ...

(AI_EN_LECTOR_MISSING_DETERMINER)


[uncategorized] ~70-~70: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)


104-104: Specify a language for fenced code blocks.
Modern markdown linting rules prefer language specification to enable syntax highlighting and consistency.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

104-104: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


164-164: Heading style mismatch.
Use a consistent heading style (e.g., ## My Title) instead of setext style to satisfy markdown linter rules.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

164-164: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


164-164: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


200-200: Horizontal rule style.
Change --- to a consistent style like -------------------------------- if you follow the linter’s convention or any internal guideline.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

200-200: Horizontal rule style
Expected: --------------------------------; Actual: ---

(MD035, hr-style)


206-206: Repeated heading with trailing punctuation.
Use a unique heading text and avoid trailing punctuation (e.g., “Projects” instead of “Projects:”), for lint rule compliance.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

206-206: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


206-206: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


206-206: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


209-209: Fenced code blocks lacking language specification.
Add a language identifier for improved readability, e.g., c++ or bash.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

209-209: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa2949a and acaa611.

📒 Files selected for processing (2)
  • usermods/seven_segment_display_reloaded/readme.md (1 hunks)
  • usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h (18 hunks)
🧰 Additional context used
🪛 LanguageTool
usermods/seven_segment_display_reloaded/readme.md

[uncategorized] ~52-~52: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~67-~67: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the minimum brightness. Default is 0 lux. - lux-max Defines ...

(AI_EN_LECTOR_MISSING_DETERMINER)


[uncategorized] ~70-~70: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)

🪛 markdownlint-cli2 (0.17.2)
usermods/seven_segment_display_reloaded/readme.md

104-104: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


164-164: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


164-164: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


167-167: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


200-200: Horizontal rule style
Expected: --------------------------------; Actual: ---

(MD035, hr-style)


206-206: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


206-206: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


206-206: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


209-209: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (11)
usermods/seven_segment_display_reloaded/readme.md (3)

3-4: Documentation clarity improved.
The newly added lines clarify the usermod’s purpose and reference the original overlay-based approach. This helps users grasp the display’s configurability more easily.


13-38: Structured table of compile-time parameters.
This table neatly summarizes the available parameters, their defaults, and purpose. The format is clear and significantly enhances user reference.


44-45: Clarified external control methods.
Stating that settings can be controlled via the usermod settings page, MQTT, or JSON is concise and informative. Good job!

usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h (8)

19-40: Compile-time definitions for configurability.
Defining these macros for default values is an excellent approach for flexible builds. They improve maintainability and make user overrides straightforward.


247-252: New light indicator logic.
The condition checks ensure that you only display the light indicator segment once. This is consistent with how colons are handled. The logic is clear and correct.


375-385: MQTT publishing logic
The check if (WLED_MQTT_CONNECTED && mqtt != NULL) is good for avoiding null pointer issues. The approach of building topic strings from mqttDeviceTopic looks correct and consistent.


435-457: Comprehensive MQTT updates
Updating all relevant settings upon connection is a solid approach for ensuring synchronization. Good practice.


467-471: JSON include for brightness fields
Storing minBrightness, maxBrightness, luxMin, luxMax, and invert-auto-brightness in JSON is consistent with the design. This ensures the usermod’s dynamic behavior is captured accurately.


642-645: MQTT subscription gating
Skipping subscription if the display is disabled avoids unnecessary overhead. Nicely done.


668-691: Topic prefix checks
This code carefully trims off the prefix /wledSS/ and checks the trailing /set. Good approach for structured MQTT commands.


752-761: String literals for new brightness-related parameters
Defining these PROGMEM constants ensures minimal RAM usage on embedded systems, which is a best practice for microcontrollers.

@blazoncek
Copy link
Collaborator

@derqurps please have a look.

Copy link
Contributor

@derqurps derqurps left a comment

Choose a reason for hiding this comment

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

@KrX3D Thank you for extending the function and the documentation of the usermod.

I added a couple of small suggestions. The only thing that i don't understand, is what the option "LED-Numbers-Light" is doing or what it is for :)

Thanks again!

@KrX3D KrX3D requested a review from derqurps March 5, 2025 21:39
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

🔭 Outside diff range comments (2)
usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h (2)

359-359: ⚠️ Potential issue

Potential buffer overflow in _setMaskToLeds

The loop should use < instead of <= to avoid accessing an out-of-bounds element at index umSSDRLength.

-    for(int i = 0; i <= umSSDRLength; i++) {
+    for(int i = 0; i < umSSDRLength; i++) {

367-367: ⚠️ Potential issue

Potential buffer overflow in _setAllFalse

Similar to the previous issue, the loop should use < instead of <= to avoid accessing an out-of-bounds element.

-    for(int i = 0; i <= umSSDRLength; i++) {
+    for(int i = 0; i < umSSDRLength; i++) {
🧹 Nitpick comments (9)
usermods/seven_segment_display_reloaded/readme.md (8)

76-87: Clear display mask documentation

The detailed explanation of the display mask characters is very helpful. Consider adding a brief example showing what a display would look like with a particular mask (e.g., "H:m" displays "14:35").


116-118: Missing comma in LED definitions section

There should be a comma after "In this example" for better readability.

-An example would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,30,31 and 32 would make up a Segment.
+An example would be 1,3,6-8,23,30-32. In this example, the LEDs with the numbers 1,3,6,7,8,23,30,31 and 32 would make up a Segment.
🧰 Tools
🪛 LanguageTool

[typographical] ~117-~117: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


157-158: Good documentation of new public function

The documentation clearly explains the purpose of the new function disableOutputFunction(bool state). Consider adding a brief example of how to call this function from other code.


104-114: Specify language for code block

The fenced code block should have a language specified for better syntax highlighting.

-```
+```ascii
   <  A  >
 /\       /\
 F         B
 \/       \/
   <  G  >
 /\       /\
 E         C
 \/       \/
   <  D  >
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

104-104: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


169-196: Specify language for code block

The fenced code block should have a language specified for better syntax highlighting.

-```
+```c
#define USERMOD_SSDR

#define umSSDR_ENABLED                  true        // Enable SSDR usermod
#define umSSDR_ENABLE_AUTO_BRIGHTNESS   false       // Enable auto brightness (requires USERMOD_SN_PHOTORESISTOR)
#define umSSDR_INVERTED                 false       // Inverted display
#define umSSDR_COLONBLINK               true        // Colon blink enabled
#define umSSDR_LEADING_ZERO             false       // Leading zero disabled
#define umSSDR_DISPLAY_MASK             "H:mL"      // Display mask for time format

// Segment definitions for hours, minutes, seconds, colons, light, days, months, and years
#define umSSDR_HOURS                    "135-143;126-134;162-170;171-179;180-188;144-152;153-161:198-206;189-197;225-233;234-242;243-251;207-215;216-224"
#define umSSDR_MINUTES                  "9-17;0-8;36-44;45-53;54-62;18-26;27-35:72-80;63-71;99-107;108-116;117-125;81-89;90-98"
#define umSSDR_SECONDS                  ""
#define umSSDR_COLONS                   "266-275"    // Segment range for colons
#define umSSDR_LIGHT                    "252-265"    // Segment range for light indicator (added for this project)
#define umSSDR_DAYS                     ""           // Reserved for days if needed
#define umSSDR_MONTHS                   ""           // Reserved for months if needed
#define umSSDR_YEARS                    ""           // Reserved for years if needed

#define umSSDR_INVERT_AUTO_BRIGHTNESS   true
#define umSSDR_LUX_MIN                  50
#define umSSDR_LUX_MAX                  1000

// Brightness limits
#define umSSDR_BRIGHTNESS_MIN           0            // Minimum brightness
#define umSSDR_BRIGHTNESS_MAX           128          // Maximum brightness
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

169-169: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


211-250: Specify language for code block

The fenced code block should have a language specified for better syntax highlighting.

-```
+```c
#define umSSDR_ENABLED                  true        // Enable SSDR usermod
#define umSSDR_ENABLE_AUTO_BRIGHTNESS   false       // Enable auto brightness (requires USERMOD_SN_PHOTORESISTOR)
#define umSSDR_INVERTED                 false       // Inverted display
#define umSSDR_COLONBLINK               false       // Colon blink disabled
#define umSSDR_LEADING_ZERO             true        // Leading zero enabled
#define umSSDR_DISPLAY_MASK             "H:m:s"     // Display mask for time format

// Segment definitions for hours, minutes, seconds, colons, light, days, months, and years
#define umSSDR_HOURS                    "20,30;21,31;22,32;23,33;24,34;25,35;26,36;27,37;28,38;29,39:0,10;1,11;2,12;3,13;4,14;5,15;6,16;7,17;8,18;9,19"
#define umSSDR_MINUTES                  "60,70;61,71;62,72;63,73;64,74;65,75;66,76;67,77;68,78;69,79:40,50;41,51;42,52;43,53;44,54;45,55;46,56;47,57;48,58;49,59"
#define umSSDR_SECONDS                  "100,110;101,111;102,112;103,113;104,114;105,115;106,116;107,117;108,118;109,119:80,90;81,91;82,92;83,93;84,94;85,95;86,96;87,97;88,98;89,99"
#define umSSDR_COLONS                   ""           // No colon segment mapping needed
#define umSSDR_LIGHT                    ""           // No light indicator defined
#define umSSDR_DAYS                     ""           // Reserved for days if needed
#define umSSDR_MONTHS                   ""           // Reserved for months if needed
#define umSSDR_YEARS                    ""           // Reserved for years if needed

#define umSSDR_INVERT_AUTO_BRIGHTNESS   true
#define umSSDR_LUX_MIN                  50
#define umSSDR_LUX_MAX                  1000

// Brightness limits
#define umSSDR_BRIGHTNESS_MIN           0            // Minimum brightness
#define umSSDR_BRIGHTNESS_MAX           128          // Maximum brightness

#define umSSDR_NUMBERS { \
    { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, /* 0 */ \
    { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* 1 */ \
    { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 }, /* 2 */ \
    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, /* 3 */ \
    { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, /* 4 */ \
    { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, /* 5 */ \
    { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, /* 6 */ \
    { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, /* 7 */ \
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* 8 */ \
    { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, /* 9 */ \
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }  /* Blank */ \
}
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

211-211: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


254-255: Missing comma in text

There should be a comma after "For example" for better readability.

-For example the Lazy 7 Quick build edition has the following settings - depending on the orientation.
+For example, the Lazy 7 Quick build edition has the following settings - depending on the orientation.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~254-~254: A comma might be missing here.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


52-52: Missing comma in text

For better readability, consider adding a comma between clauses in this sentence.

-Enables the inverted mode in which the background is lit and the digits are off (black).
+Enables the inverted mode in which the background is lit, and the digits are off (black).
🧰 Tools
🪛 LanguageTool

[uncategorized] ~52-~52: Possible missing comma found.
Context: ...- inverted Enables the inverted mode in which the background is lit and the ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~52-~52: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)

usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h (1)

712-730: Improve code readability by aligning the operators

Consider aligning the binary OR operators for better readability.

-    umSSDRDisplayTime      		  = (top[FPSTR(_str_timeEnabled)] | umSSDRDisplayTime);
-    umSSDREnableLDR        		  = (top[FPSTR(_str_ldrEnabled)] | umSSDREnableLDR);
+    umSSDRDisplayTime              = (top[FPSTR(_str_timeEnabled)]          | umSSDRDisplayTime);
+    umSSDREnableLDR                = (top[FPSTR(_str_ldrEnabled)]           | umSSDREnableLDR);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acaa611 and ea1e347.

📒 Files selected for processing (2)
  • usermods/seven_segment_display_reloaded/readme.md (1 hunks)
  • usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h (18 hunks)
🧰 Additional context used
🪛 LanguageTool
usermods/seven_segment_display_reloaded/readme.md

[uncategorized] ~52-~52: Possible missing comma found.
Context: ...- inverted Enables the inverted mode in which the background is lit and the ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~52-~52: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~67-~67: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the minimum brightness. Default is 0 lux. - lux-max Defines ...

(AI_EN_LECTOR_MISSING_DETERMINER)


[uncategorized] ~70-~70: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)


[typographical] ~117-~117: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


[uncategorized] ~254-~254: A comma might be missing here.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🪛 markdownlint-cli2 (0.17.2)
usermods/seven_segment_display_reloaded/readme.md

104-104: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


166-166: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


166-166: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


169-169: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


202-202: Horizontal rule style
Expected: --------------------------------; Actual: ---

(MD035, hr-style)


208-208: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


208-208: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


208-208: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


211-211: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (24)
usermods/seven_segment_display_reloaded/readme.md (6)

13-38: Great addition of compile-time parameters documentation

This structured table significantly improves the documentation by clearly documenting all available compile-time parameters with their default values and descriptions. It makes the usermod much more accessible to new users while providing a quick reference for experienced developers.


46-47: Well-organized settings section

The reorganization of the settings section with clear headings and descriptions improves readability and maintainability.


60-75: Enhanced documentation for auto-brightness features

The detailed explanation of auto-brightness parameters is excellent. The documentation now clearly explains how lux values are mapped to brightness and how the inversion works.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~67-~67: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the minimum brightness. Default is 0 lux. - lux-max Defines ...

(AI_EN_LECTOR_MISSING_DETERMINER)


[uncategorized] ~70-~70: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)


120-151: Excellent LED definition examples

The detailed examples showing how to define segments for digits is very helpful. The breakdown of each segment with explanations makes it much clearer for users to understand how to configure their own displays.


237-249: Nice addition of number array override support

The inclusion of the umSSDR_NUMBERS example demonstrates how to customize the segment mapping for different display types. This significantly increases the versatility of the usermod.


253-265: Helpful real-world project example

Including specific configurations for the Lazy Clock project is very useful. This provides a great starting point for users working with similar hardware.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~254-~254: A comma might be missing here.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h (18)

19-59: Great refactoring to use preprocessor definitions

Excellent conversion from runtime variables to preprocessor definitions. This approach allows for better compile-time optimization and makes the code more configurable through my_config.h. The default values are sensible and align with the documentation in the readme.


71-75: Well-documented Light LED option

The detailed comment explaining the Light LED option is very helpful for understanding its purpose and usage.


83-113: Good separation of segment definitions as preprocessor macros

Using preprocessor definitions for all segment configurations makes the code more flexible and easier to customize for different projects.


115-143: Smart conditional definition of segment number array

The conditional compilation of the segment number array allows for custom mapping while providing sensible defaults. This makes the code much more versatile for different hardware configurations.


145-163: Good initialization from preprocessor definitions

The initialization of runtime variables from preprocessor definitions ensures consistent initial state while allowing for runtime changes through the JSON API.


251-256: Well-implemented Light LED case

The addition of a 'L' case for handling light segments is well implemented with a check to prevent duplicate calls to _showElements.


285-285: Fixed digit order in time array

Correct update to the array value - ensures that the blank digit (10) is used for the leading zero case.


290-290: Fixed digit order in time array

Correct update to the array value - ensures that 0 is used when not removing leading zero.


377-401: Improved MQTT publishing with connection checks

The addition of connection state checks before MQTT publishing prevents unnecessary operations when MQTT is not connected. The proper preprocessor guards are also important for builds where MQTT is disabled.


443-447: Added new parameters to MQTT publication

The addition of brightness and lux parameters to MQTT publication ensures that all configuration options are properly synchronized between WLED and MQTT clients.


471-475: Added new parameters to JSON object

The addition of brightness and lux parameters to the JSON object ensures that all configuration options are properly exposed through the JSON API.


522-544: Improved auto-brightness handling with inversion support

The enhanced auto-brightness logic now properly handles both sensor types and includes an inversion option for the brightness mapping. The validation of lux values ensures that mapping only occurs with valid sensor readings.


558-560: Added external control of LED output

The addition of the disableUmLedControl check in the handleOverlayDraw method enables external control of the LED output.


564-566: Added useful public method for external control

The disableOutputFunction method provides a clean API for other code to control the LED output of this usermod, enhancing its integration capabilities.


578-601: Enhanced JSON info with more detailed information

The improved JSON info section now includes more comprehensive information about the usermod's state, making it easier for users to understand the current configuration.


626-642: Complete JSON configuration handling

The JSON configuration handling now includes all configuration parameters, ensuring that users can fully configure the usermod through the JSON API.


647-667: Improved MQTT connection handling

The addition of a check for umSSDRDisplayTime before subscribing to MQTT topics prevents unnecessary subscriptions when the usermod is disabled. The proper connection check also ensures that MQTT operations only occur when connected.


672-695: Added MQTT message handling with guards

The MQTT message handling now includes proper guards for disabled builds and checks the usermod's enabled state before processing messages.

Copy link
Contributor

@derqurps derqurps left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@netmindz
Copy link
Member

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

@KrX3D KrX3D closed this Mar 28, 2025
@KrX3D KrX3D force-pushed the usermod_seven_segment_display_reloaded branch from ea1e347 to e76e9a3 Compare March 28, 2025 15:32
@derqurps
Copy link
Contributor

derqurps commented Mar 28, 2025

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?

@KrX3D KrX3D reopened this Mar 28, 2025
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 (4)
usermods/seven_segment_display_reloaded/readme.md (3)

52-60: Possible missing comma.
At line 53, the text “in which the background is lit and the digits are off (black)” might benefit from a comma before “and” to adhere to the style guidelines, but this is a minor nitpick.

- Enables the inverted mode in which the background is lit and the digits are off (black).
+ Enables the inverted mode, in which the background is lit and the digits are off (black).
🧰 Tools
🪛 LanguageTool

[uncategorized] ~53-~53: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


117-121: Minor missing comma after “numbers 1,3,6,7,8,23.”
Static analysis suggests adding a comma to clarify the sentence.

- In this example the LEDs with the numbers 1,3,6,7,8,23,30,31 and 32 would make up a Segment.
+ In this example, the LEDs with the numbers 1,3,6,7,8,23,30,31, and 32 would make up a Segment.
🧰 Tools
🪛 LanguageTool

[typographical] ~119-~119: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


255-266: Possible missing comma.
At line 256, static analysis suggests adding a comma after the parenthetical link:

- ...by [paralyze](https://www.instructables.com/member/parallyze/) For example the Lazy 7 Quick build...
+ ...by [paralyze](https://www.instructables.com/member/parallyze/). For example, the Lazy 7 Quick build...
🧰 Tools
🪛 LanguageTool

[uncategorized] ~256-~256: Possible missing comma found.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_HYDRA_LEO_MISSING_COMMA)

usermods/seven_segment_display_reloaded/seven_segment_display_reloaded.cpp (1)

521-551: Auto brightness logic.
Potential range issue with map() if lux is below umSSDRLuxMin or above umSSDRLuxMax, but typically it still yields workable results. Consider constrain() for more robust bounding. Otherwise, the logic is correct.

+  // After map(...):
+  brightness = constrain(brightness, umSSDRBrightnessMin, umSSDRBrightnessMax);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea1e347 and 3849385.

📒 Files selected for processing (2)
  • usermods/seven_segment_display_reloaded/readme.md (1 hunks)
  • usermods/seven_segment_display_reloaded/seven_segment_display_reloaded.cpp (19 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
usermods/seven_segment_display_reloaded/seven_segment_display_reloaded.cpp (1)
usermods/seven_segment_display/seven_segment_display.cpp (13)
  • subTopic (272-281)
  • subTopic (272-272)
  • subTopic (283-289)
  • subTopic (283-283)
  • _publishMQTTint_P (291-302)
  • sessionPresent (397-414)
  • sessionPresent (397-397)
  • topic (304-313)
  • topic (304-304)
  • topic (315-342)
  • topic (315-315)
  • topic (416-437)
  • topic (416-416)
🪛 LanguageTool
usermods/seven_segment_display_reloaded/readme.md

[uncategorized] ~53-~53: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


[typographical] ~119-~119: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


[uncategorized] ~256-~256: Possible missing comma found.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_HYDRA_LEO_MISSING_COMMA)

🪛 markdownlint-cli2 (0.17.2)
usermods/seven_segment_display_reloaded/readme.md

106-106: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


168-168: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


168-168: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


171-171: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


204-204: Horizontal rule style
Expected: --------------------------------; Actual: ---

(MD035, hr-style)


210-210: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


210-210: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


210-210: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


213-213: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (38)
usermods/seven_segment_display_reloaded/readme.md (23)

4-4: Documentation note looks fine.
No functional or grammatical issues.


11-12: Cross-reference check.
References to other usermods (SN_Photoresistor/BH1750_V2) are correct. Ensure those usermods have consistent documentation.


13-45: Comprehensive parameter table.
The compile-time parameters are well-documented and align with usermod usage.


47-49: Markdown heading consistency.
This heading hierarchy is logical. No issues found.


61-66: Auto brightness documentation clarity.
Clear explanation on linking with sensor-based usermods. No issues.


68-73: Inversion logic reference.
The explanation for invert-auto-brightness is consistent. Looks good.


77-101: Display mask guidelines.
Well-defined placeholders (H, h, k, m, s, d, M, y, Y, L, :). Documentation is sufficiently detailed.


102-105: Example LED Definitions.
Provides a good starting point for newcomers. No issues.


109-109: No substantive changes.


113-113: No substantive changes.


122-153: Clock display examples.
Examples are thorough and beneficial for new users.


156-157: Clear note on dynamic brightness.
No issues.


159-160: Public function reference.
Documentation for disableOutputFunction is succinct and clear.


164-167: Giant Hidden Shelf Edge Clock references.
External link is properly mentioned. No issues.


168-198: Detailed configuration snippet.
Helpful example with macros. Looks good.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

168-168: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


168-168: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


171-171: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


202-202: Brief note.
No issues.


206-210: EleksTube heading style.
No major concerns with the updated heading.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

210-210: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


210-210: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


210-210: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


211-212: No substantive changes.


214-214: No substantive changes.


222-222: No issues found.


240-251: umSSDR_NUMBERS array example.
This example is well structured to illustrate custom mappings.


268-271: Versatility note.
Good summary of usermod expandability.


272-272: Final note.
Emphasizes LED mapping flexibility. Looks fine.

usermods/seven_segment_display_reloaded/seven_segment_display_reloaded.cpp (15)

3-5: MQTT check.
Forcing compilation error if MQTT is disabled is correct, ensuring usermod dependencies are explicit.


17-46: Compile-time macros for configuration.
This approach is clear and flexible. No issues.


59-73: Commented “Display mask” block.
Well-documented reference for placeholders. Good clarity.


139-141: Conditional array definition.
Defines a default umSSDRNumbers or uses the override. This is a good pattern for customization.


143-153: Initialization of booleans and strings.
Straightforward expansions from macros. No issues found.


247-254: Case 'L' handling.
Correct approach of a single lightDone check avoids repeated calls. Implementation looks good.


270-337: Time digit parsing logic.
Overall logic to parse segments (':' ‘;’ ‘,’ '-') is consistent with existing approach. Good layering.


375-400: MQTT publishing functions.
Guarded by #ifndef WLED_DISABLE_MQTT. This ensures safe compilation in non-MQTT builds. Implementation is correct.


439-459: _updateMQTT method.
Publishes new config values systematically. Code is consistent with the usermod’s approach.


461-486: Adding JSON object for the usermod.
A structured approach ensures consistent data in the JSON configuration. Good usage of nested objects.


562-564: External LED control disabling.
disableOutputFunction(bool state) is a straightforward approach to externally disable LED output. No issues.


644-667: MQTT connection handling.
Correctly avoids unnecessary subscriptions if the usermod is disabled. Clean implementation.


670-693: Trimming and handling MQTT “/set” messages.
Logic is consistent. Good approach for subtopic parsing.


699-699: Post-config update.
Automatically calls _updateMQTT() after reading config – this is helpful for keeping MQTT data in sync.


703-734: Reading from config file.
Reloads usermod settings from JSON. Implementation is coherent and consistent with the stored defaults.

@KrX3D
Copy link
Author

KrX3D commented Mar 28, 2025

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:

image

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

🔭 Outside diff range comments (2)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (2)

357-362: ⚠️ Potential issue

Prevent out-of-bounds array access.
for(int i = 0; i <= umSSDRLength; i++) iterates one past the last valid index, risking memory corruption.

- for(int i = 0; i <= umSSDRLength; i++) {
+ for(int i = 0; i < umSSDRLength; i++) {
    ...
}

Also applies to: 365-368


498-501: 🛠️ Refactor suggestion

Handle potential realloc failures.
If realloc returns nullptr, umSSDRMask may be lost. For safer memory handling, use a temporary pointer and verify success before assigning it back.

bool* temp = (bool*) realloc(umSSDRMask, umSSDRLength * sizeof(bool));
if (temp != nullptr) {
  umSSDRMask = temp;
} else {
  // handle memory allocation failure, e.g., log an error or revert to old pointer
}
🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 498-498: Common realloc mistake

(memleakOnRealloc)

🧹 Nitpick comments (11)
usermods/seven_segment_display_reloaded_v2/readme.md (10)

53-53: Consider adding commas for clarity.
The sentence can read more smoothly with additional commas to separate the clauses.

- Enables the inverted mode in which the background is lit and the digits are off (black).
+ Enables the inverted mode, in which the background is lit, and the digits are off (black).
🧰 Tools
🪛 LanguageTool

[uncategorized] ~53-~53: Possible missing comma found.
Context: ... - inverted Enables the inverted mode in which the background is lit and the ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~53-~53: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


72-72: Insert a determiner for clarity.
A small grammatical improvement can make the comment more readable.

- //  lighting for the display or serve as an ambient light source, without affecting the clock's visual display
+ //  the lighting for the display or serve as an ambient light source, without affecting the clock's visual display
🧰 Tools
🪛 LanguageTool

[uncategorized] ~72-~72: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)


106-106: Specify a language for the fenced code block.
For better syntax highlighting and compliance with lint rules, declare a language after the triple backticks.

- ```
+ ```plaintext
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

106-106: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


119-119: Add a comma after "example" for proper flow.
Adding a short pause improves readability.

- In this example the LEDs with the numbers 1,3,6,7,8,23,30,31 and 32 ...
+ In this example, the LEDs with the numbers 1,3,6,7,8,23,30,31 and 32 ...
🧰 Tools
🪛 LanguageTool

[typographical] ~119-~119: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


168-168: Convert to atx heading style and remove trailing punctuation.
For consistency with typical Markdown styles, switch to an atx (e.g., ##) heading.

- my_config.h Settings:
+ ## my_config.h Settings
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

168-168: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


168-168: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


171-171: Add a language specifier to the code block.
Similarly to line 106, specify a language for consistency.

- ```
+ ```plaintext
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

171-171: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


204-204: Use a consistent horizontal rule style.
Markdown lint expects a line of 30+ dashes rather than three.

- ---
+ --------------------------------
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

204-204: Horizontal rule style
Expected: --------------------------------; Actual: ---

(MD035, hr-style)


210-210: Apply atx headings and remove trailing punctuation.
Same reasoning as line 168.

- my_config.h Settings:
+ ## my_config.h Settings
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

210-210: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


210-210: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


210-210: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


213-213: Specify language for fenced code block.
Aligns with markdownlint checks.

- ```
+ ```plaintext
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

213-213: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


256-256: Add a comma after "example" for readability.

- (https://www.instructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the following...
+ (https://www.instructables.com/member/parallyze/) For example, the Lazy 7 Quick build edition has the following...
🧰 Tools
🪛 LanguageTool

[uncategorized] ~256-~256: A comma might be missing here.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1)

270-298: Consider an alternative to variable length arrays.
Modern C++ standards do not fully guarantee support for runtime-sized arrays (int timeArr[length]). Consider using a dynamic container like std::vector<int> for better portability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3849385 and 50d54e2.

📒 Files selected for processing (5)
  • usermods/seven_segment_display_reloaded/library.json (0 hunks)
  • usermods/seven_segment_display_reloaded_v2/library.json (1 hunks)
  • usermods/seven_segment_display_reloaded_v2/readme.md (1 hunks)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (18 hunks)
  • wled00/const.h (1 hunks)
💤 Files with no reviewable changes (1)
  • usermods/seven_segment_display_reloaded/library.json
✅ Files skipped from review due to trivial changes (2)
  • usermods/seven_segment_display_reloaded_v2/library.json
  • wled00/const.h
🧰 Additional context used
🧬 Code Graph Analysis (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1)
usermods/seven_segment_display/seven_segment_display.cpp (1)
  • _overlaySevenSegmentDraw (392-395)
🪛 LanguageTool
usermods/seven_segment_display_reloaded_v2/readme.md

[uncategorized] ~53-~53: Possible missing comma found.
Context: ... - inverted Enables the inverted mode in which the background is lit and the ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~53-~53: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~72-~72: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)


[typographical] ~119-~119: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


[uncategorized] ~256-~256: A comma might be missing here.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🪛 markdownlint-cli2 (0.17.2)
usermods/seven_segment_display_reloaded_v2/readme.md

106-106: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


168-168: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


168-168: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


171-171: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


204-204: Horizontal rule style
Expected: --------------------------------; Actual: ---

(MD035, hr-style)


210-210: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


210-210: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


210-210: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


213-213: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (3)
usermods/seven_segment_display_reloaded_v2/readme.md (1)

1-272: Comprehensive documentation.
The README is very detailed, covering installation, compile-time parameters, usage examples, and outlining clear design goals.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~53-~53: Possible missing comma found.
Context: ... - inverted Enables the inverted mode in which the background is lit and the ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~53-~53: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~72-~72: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)


[typographical] ~119-~119: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


[uncategorized] ~256-~256: A comma might be missing here.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🪛 markdownlint-cli2 (0.17.2)

106-106: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


168-168: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


168-168: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


171-171: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


204-204: Horizontal rule style
Expected: --------------------------------; Actual: ---

(MD035, hr-style)


210-210: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


210-210: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


210-210: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


213-213: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (2)

1-16: Initial configuration code looks good.
Defining compile-time checks for MQTT is clear and straightforward.


17-139: General structure and preprocessor directives.
The switching from preprocessor macros to runtime variables, as well as the organization of configurability, is well done. Handling different compile-time settings helps ensure broad applicability.

Also applies to: 143-253, 255-269, 271-356, 359-364, 367-497, 502-516, 518-520, 553-555, 557-560, 566-570, 572-580, 582-599, 602-610, 612-629, 631-644, 646-649, 667-669, 694-702, 704-710, 712-729

@KrX3D
Copy link
Author

KrX3D commented Apr 12, 2025

So i got it working. Should be finished now.

The problem that i couldnt compile it right seems to be related to

#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...

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 (10)
usermods/seven_segment_display_reloaded_v2/readme.md (10)

22-47: Detailed Compile-Time Parameter Table
The parameter table is comprehensive and well formatted. As a minor nitpick, consider rephrasing phrases such as “Default is 1000 lux” to “The default value is 1000 lux” for grammatical consistency.


56-63: Minor Punctuation Adjustment for Parameter Descriptions
In the "inverted" parameter description, consider adding a comma for clarity. For example:

“Enables the inverted mode in which the background is lit, and the digits are off (black).”
This small change improves readability.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~62-~62: Possible missing comma found.
Context: ... - inverted Enables the inverted mode in which the background is lit and the ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~62-~62: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


73-75: Brightness Mapping Details Are Informative
The description of the auto brightness min/max mapping (and the note on potential WLED current protection) is useful. A slight punctuation tweak here might further enhance clarity.


77-81: Clarify Default Value in Lux-Max Description
Consider altering “Default is 1000 lux” to “The default value is 1000 lux” to improve grammatical clarity.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~81-~81: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)


111-125: LED Layout Diagram: Specify a Language for the Fenced Code Block
The diagram illustrating the seven segment display layout is very useful. To address markdown lint warnings, consider adding a language identifier (e.g., text) to the fenced code block.

-```
+```text
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

115-115: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


127-130: Digit Segment Example Could Use a Minor Punctuation Check
The example explaining how LED segments are defined is clear. As a nitpick, verify that comma placement (for instance, after ranges like “6-8”) is optimal for readability.

🧰 Tools
🪛 LanguageTool

[typographical] ~128-~128: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


171-212: Project 1 (Giant Hidden Shelf Edge Clock) Documentation Suggestions
The configuration example for the Giant Hidden Shelf Edge Clock is detailed. For improved consistency:

  • Consider converting the setext-style heading “my_config.h Settings:” (line 177) to an atx-style heading (e.g., # my_config.h Settings).
  • Specify a language (for example, cpp) for the fenced code block (lines 180–207) to address markdown lint warnings.
-``` 
+```cpp
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

177-177: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


177-177: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


180-180: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


215-247: Project 2 (EleksTube Retro Glows Analog Nixie Tube Clock) Configuration Enhancements
The configuration details for Project 2 are comprehensive. Similar to Project 1, consider:

  • Changing the heading “my_config.h Settings:” (line 219) to atx-style for consistency.
  • Adding a language identifier (e.g., cpp) to the fenced code block (lines 222–247).
-``` 
+```cpp
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

219-219: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


219-219: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


219-219: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


222-222: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


262-275: Lazy Clock(s) Example: Consider Refining Punctuation and Clarity
The example for the Lazy Clock(s) by paralyze is informative. A couple of minor improvements:

  • At line 265, consider adding a comma after the URL to improve readability.
  • Review and streamline any repetitive phrasing to enhance clarity.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~265-~265: A comma might be missing here.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


177-177: Ensure Consistent Horizontal Rule and Heading Styles
Across the document, horizontal rules (e.g., at lines 178, 213, and 273) and heading styles should be consistent to comply with markdown lint guidelines. Consider standardizing these elements (for example, using “--------------------------------” uniformly and atx-style headings instead of setext).

Also applies to: 213-213, 273-273

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

177-177: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


177-177: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50d54e2 and ae78586.

📒 Files selected for processing (1)
  • usermods/seven_segment_display_reloaded_v2/readme.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
usermods/seven_segment_display_reloaded_v2/readme.md

[uncategorized] ~62-~62: Possible missing comma found.
Context: ... - inverted Enables the inverted mode in which the background is lit and the ...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~62-~62: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rted mode in which the background is lit and the digits are off (black). - **Colon-...

(COMMA_COMPOUND_SENTENCE_2)


[uncategorized] ~81-~81: A determiner appears to be missing. Consider inserting it.
Context: ...tness is set to the maximum brightness. Default is 1000 lux. - **invert-auto-brightn...

(AI_EN_LECTOR_MISSING_DETERMINER)


[typographical] ~128-~128: It appears that a comma is missing.
Context: ...mple would be 1,3,6-8,23,30-32. In this example the LEDs with the numbers 1,3,6,7,8,23,...

(DURING_THAT_TIME_COMMA)


[uncategorized] ~265-~265: A comma might be missing here.
Context: ...nstructables.com/member/parallyze/) For example the Lazy 7 Quick build edition has the ...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🪛 markdownlint-cli2 (0.17.2)
usermods/seven_segment_display_reloaded_v2/readme.md

115-115: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


177-177: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


177-177: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


180-180: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


213-213: Horizontal rule style
Expected: --------------------------------; Actual: ---

(MD035, hr-style)


219-219: Heading style
Expected: atx; Actual: setext

(MD003, heading-style)


219-219: Multiple headings with the same content
null

(MD024, no-duplicate-heading)


219-219: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


222-222: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (14)
usermods/seven_segment_display_reloaded_v2/readme.md (14)

1-6: Introduction and Project Overview Are Clear
The header and introductory lines provide a concise and informative overview of the project and appropriately credit the contributor.


7-10: Installation Instructions Are Concise
The instructions for adding the compile‑time option (either via platformio.ini/platformio_override.ini or my_config.h) are brief and clear.


11-19: Compiling Section Is Well-Structured
The steps explaining how to enable the usermod via the custom_usermods setting are straightforward and the fenced code block is correctly marked with ini.


20-21: Auto Brightness Dependency Documentation Is Helpful
The note on requiring the SN_Photoresistor or BH1750_V2 usermod for auto brightness is clear, with useful links for additional details.


48-50: Optional LED Segment Mapping Macro Explained
The note about overriding the internal LED segment mapping via the optional umSSDR_NUMBERS macro is succinct and clear.


51-55: Settings Section Overview Is Clear
This section effectively informs the user that all settings are accessible via the usermod settings page or through MQTT/JSON.


64-69: Additional Parameter Descriptions Look Good
The descriptions for "Colon-blinking" and "Leading-Zero" are clear and concise.


70-72: Auto-Brightness Enable Setting Is Well-Described
The explanation that the auto brightness feature relies on the SN_Photoresistor or BH1750_V2 usermod is clear.


83-85: Invert-Auto-Brightness Explanation Is Clear
The logic behind inverting the brightness mapping is well-explained.


86-99: Display-Mask Section Is Comprehensive
The explanation of the available mask characters (H, h, k, m, s, d, M, y, Y, L, and :) is clear and helpful for users when configuring their time/date display.


100-110: LED-Numbers Section Is Well-Organized
The list of LED segment definitions for various display elements is concise and clearly presented.


131-156: Clock Display Example Is Detailed and Illustrative
The step-by-step explanation of the hour digit segmentation, along with the sample values, is very illustrative.


163-170: Additional Notes Provide Useful Operational Context
The sections on dynamic brightness control and the public function to disable LED output are clear and informative.


248-260: umSSDR_NUMBERS Array Definition Is Clear
The LED segment mapping array is well-defined and provides flexibility for different physical displays.

fixed some problems, made  and BH1750_v2 work again from this
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: 2

🧹 Nitpick comments (4)
usermods/seven_segment_display_reloaded_v2/setup_deps.py (2)

3-8: Prefer AppendUnique to avoid duplicated CPPDEFINES

If the same usermod name ever appears twice (e.g. in release/build scripts that concatenate lists), env.Append will emit duplicate macros which can clutter the compiler command line:

-    env.Append(CPPDEFINES=["USERMOD_SN_PHOTORESISTOR"])
+    env.AppendUnique(CPPDEFINES=["USERMOD_SN_PHOTORESISTOR"])

Apply the same change for the BH1750 block.

🧰 Tools
🪛 Ruff (0.8.2)

3-3: Undefined name env

(F821)


6-6: Undefined name env

(F821)


8-8: Undefined name env

(F821)


3-3: Minor edge-case: skip empty list element after .split()

When custom_usermods is unset, split() returns [''], so the code would test an empty string. Guard with filter(None, …):

-usermods = env.GetProjectOption("custom_usermods","").split()
+usermods = list(filter(None, env.GetProjectOption("custom_usermods", "").split()))

Harmless today, but removes a meaningless list member.

🧰 Tools
🪛 Ruff (0.8.2)

3-3: Undefined name env

(F821)

usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (2)

200-210: Polymorphic pointers lose type safety

Current code falls back to untyped void* when the partner usermod isn’t enabled:

void* ptr = nullptr;
void* bh1750 = nullptr;

This makes accidental dereferencing a compile-time blind spot. Prefer a std::nullptr_t alias or wrap the member in #ifdef blocks so it disappears entirely when the feature is absent:

#ifndef USERMOD_SN_PHOTORESISTOR
-  void* ptr = nullptr;
+#define ptr nullptr  // remove member, avoids unused-field warnings
#endif

At minimum rename the generic ptr to something descriptive (photoResistor) to avoid confusion.


227-230: Guard DEBUG_PRINTF call behind the macro

If DEBUG_PRINTF is disabled in certain builds the statement still compiles but expands to nothing, leaving a stray semicolon. Wrap the log in #ifdef:

-  DEBUG_PRINTF("disableOutputFunction was triggered by an external Usermod: %s\n",
-               disableUmLedControl ? "true" : "false");
+#ifdef DEBUG_PRINTF
+  DEBUG_PRINTF("disableOutputFunction was triggered by an external Usermod: %s\n",
+               disableUmLedControl ? "true" : "false");
+#endif

Prevents “statement has no effect” warnings.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae78586 and 55b0326.

📒 Files selected for processing (4)
  • usermods/seven_segment_display_reloaded_v2/library.json (1 hunks)
  • usermods/seven_segment_display_reloaded_v2/setup_deps.py (1 hunks)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1 hunks)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • usermods/seven_segment_display_reloaded_v2/library.json
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp
🧰 Additional context used
🧬 Code Graph Analysis (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1)
  • UsermodSSDR (347-352)
🪛 Ruff (0.8.2)
usermods/seven_segment_display_reloaded_v2/setup_deps.py

1-1: Undefined name Import

(F821)


3-3: Undefined name env

(F821)


6-6: Undefined name env

(F821)


8-8: Undefined name env

(F821)

🔇 Additional comments (1)
usermods/seven_segment_display_reloaded_v2/setup_deps.py (1)

1-1: Linter “undefined-name” warnings are false positives in PlatformIO extraScripts

Import('env') is valid when the script is executed by SCons during PlatformIO’s build; env is created by that runtime. You can safely ignore Ruff’s F821 warnings or silence them via # noqa: F821 if they pollute CI logs.

If static-analysis CI fails on this, add the ignore pragma. Otherwise no action is required.

🧰 Tools
🪛 Ruff (0.8.2)

1-1: Undefined name Import

(F821)

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: 2

🧹 Nitpick comments (3)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (3)

3-4: Clarify the purpose of the commented-out REFRESHTIME define.

There's a commented-out #define REFRESHTIME 497 that doesn't seem to be used elsewhere in the code. Consider either removing it if it's not needed or adding a comment explaining its purpose if it might be useful for future development.


227-232: Add more descriptive documentation for the public disableOutputFunction method.

This public method is intended to be called by other usermods, but lacks context in the documentation. Consider adding a comment that explains its purpose, when it should be used, and the expected behavior when the LED output is disabled.

// Public function that can be called from other usermods
+ /**
+  * Allows external usermods to temporarily disable the LED output of this usermod.
+  * This is useful when multiple usermods might be trying to control the same LEDs.
+  * @param state true to disable LED output, false to enable
+  */
void disableOutputFunction(bool state) {

159-161: Improve variable naming for clarity.

While disableUmLedControl follows the naming convention, a more descriptive name would better communicate its purpose, especially for other developers working with this code.

bool* umSSDRMask = nullptr;
-bool disableUmLedControl = false;
+bool externalLedOutputDisabled = false;

Update the variable name in the disableOutputFunction method as well:

void disableOutputFunction(bool state) {
-  disableUmLedControl = state;
+  externalLedOutputDisabled = state;
#ifdef DEBUG_PRINTF
-  DEBUG_PRINTF("disableOutputFunction was triggered by an external Usermod: %s\n", disableUmLedControl ? "true" : "false");
+  DEBUG_PRINTF("disableOutputFunction was triggered by an external Usermod: %s\n", externalLedOutputDisabled ? "true" : "false");
#endif
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55b0326 and 291012b.

📒 Files selected for processing (2)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1 hunks)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp
🧰 Additional context used
🧠 Learnings (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1)
Learnt from: KrX3D
PR: wled/WLED#4585
File: usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h:121-136
Timestamp: 2025-04-27T09:37:28.393Z
Learning: Using PROGMEM for the seven-segment font array (umSSDRNumbers) in the WLED SSDR usermod causes compilation problems, so it should be left as a regular array.
🧬 Code Graph Analysis (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1)
  • UsermodSSDR (347-352)
🔇 Additional comments (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1)

1-236: Overall, excellent implementation of a highly configurable seven-segment display usermod.

The code is well-structured with good separation of compile-time vs. runtime configuration, proper memory management (nullptr initialization and cleanup in destructor), and comprehensive configuration options. The use of optional dependencies is handled cleanly, and the code follows consistent patterns throughout.

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 (2)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (2)

143-152: Consider adding conditional debug logging for auto-brightness behavior.

Since auto-brightness is a complex feature that integrates with multiple sensors, adding debug logging statements specifically for brightness adaptations would help with troubleshooting.

// Add after line 152
+   #ifdef DEBUG_PRINTF
+     bool umSSDRDebugBrightness = false; // Can be toggled via JSON API
+   #endif

19-21: Consider enabling the usermod by default.

The usermod is disabled by default (umSSDR_ENABLED false). Since users explicitly install this usermod, they likely expect it to be enabled by default.

-  #define umSSDR_ENABLED false
+  #define umSSDR_ENABLED true
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aeb430d and b753069.

📒 Files selected for processing (2)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1 hunks)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp
🧰 Additional context used
🧠 Learnings (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (2)
Learnt from: KrX3D
PR: wled/WLED#4585
File: usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h:121-136
Timestamp: 2025-04-27T09:37:28.393Z
Learning: Using PROGMEM for the seven-segment font array (umSSDRNumbers) in the WLED SSDR usermod causes compilation problems, so it should be left as a regular array.
Learnt from: KrX3D
PR: wled/WLED#4585
File: usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h:121-137
Timestamp: 2025-04-27T10:06:22.521Z
Learning: In the Seven Segment Display Reloaded usermod, the dimension mismatch between the default array (umSSDRNumbers[11][7]) and the override (umSSDRNumbers[11][10] = umSSDR_NUMBERS) is intentional by design, allowing for different use cases with varying numbers of segments per digit.
🧬 Code Graph Analysis (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1)
  • UsermodSSDR (396-401)
🔇 Additional comments (6)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (6)

59-79: Great documentation of display mask format.

The comment block explaining the display mask characters and their meanings is excellent - it provides clear documentation for users on how to configure their display layout.


236-241: Well-implemented external control function.

The disableOutputFunction is a nice addition that allows other usermods to temporarily take control of the LEDs. The debug logging is also helpful for troubleshooting integration issues.


204-214: Good implementation of optional usermod dependencies.

The code correctly handles optional dependencies on light sensors through conditional compilation. This allows the usermod to work with or without these sensors while maintaining clean dependencies.


125-141: Appropriate array structure for seven-segment digit patterns.

The seven-segment font array is well-structured with clear ASCII art documenting the segment layout. As mentioned in your prior feedback, the dimension difference between default and override arrays is intentional to support different use cases.


1-245: Overall well-designed header with comprehensive configurability.

The header provides extensive compile-time and runtime configuration options, making the usermod adaptable to different projects. The use of preprocessor macros for defaults with corresponding class variables allows both compile-time and runtime customization.


143-164:

❌ Incorrect review comment

Consider initializing umSSDRMask in the class declaration.

While I can see the destructor properly frees umSSDRMask (in the CPP file), there's no explicit initialization in the header. This could lead to undefined behavior if the setup() method doesn't properly allocate memory before using it.


🏁 Script executed:

#!/bin/bash
# Search for umSSDRMask allocation in the implementation file
rg -A 2 "umSSDRMask\s*=\s*(new|malloc|calloc)" --type cpp usermods/seven_segment_display_reloaded_v2/

Length of output: 103


Ignore initialization suggestion for umSSDRMask

The umSSDRMask pointer is already initialized to nullptr in the class declaration:

bool* umSSDRMask = nullptr;

No further action is needed here.

Likely an incorrect or invalid review comment.

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: 3

🧹 Nitpick comments (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1)

120-148: Make the digit-segment lookup table const to prevent accidental writes and enable compiler optimizations

The table is never modified after construction, yet it is a mutable data member.
Declaring it const (without moving it to PROGMEM, per the earlier learning) keeps the RAM footprint identical but:

  • Guards against unintended writes at compile-time.
  • Lets the compiler place it in .rodata instead of .data, saving a few bytes of RAM on ESP32.
-  uint8_t umSSDRNumbers[11][7] = {
+  const uint8_t umSSDRNumbers[11][7] = {

The same change is harmless for the [11][10] override variant below.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b753069 and 114dd93.

📒 Files selected for processing (2)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1 hunks)
  • usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (2)
Learnt from: KrX3D
PR: wled/WLED#4585
File: usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h:121-136
Timestamp: 2025-04-27T09:37:28.393Z
Learning: Using PROGMEM for the seven-segment font array (umSSDRNumbers) in the WLED SSDR usermod causes compilation problems, so it should be left as a regular array.
Learnt from: KrX3D
PR: wled/WLED#4585
File: usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h:121-137
Timestamp: 2025-04-27T10:06:22.521Z
Learning: In the Seven Segment Display Reloaded usermod, the dimension mismatch between the default array (umSSDRNumbers[11][7]) and the override (umSSDRNumbers[11][10] = umSSDR_NUMBERS) is intentional by design, allowing for different use cases with varying numbers of segments per digit.
🧬 Code Graph Analysis (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h (1)
usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp (1)
  • UsermodSSDR (389-394)

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.

4 participants