Skip to content
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

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

Open
wants to merge 7 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

  • New Features

    • Introduced enhanced configuration options, including additional brightness and sensor controls for improved display behavior.
    • Added an external control interface for LED output.
  • Documentation

    • Revamped documentation with a new, organized table of compile-time parameters.
    • Expanded settings section with clear definitions and concise descriptions for user-configurable parameters.
    • Included specific examples on display segment configuration for easier setup and reference.

KrX3D added 3 commits March 4, 2025 16:54
**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.
Copy link

coderabbitai bot commented Mar 4, 2025

Walkthrough

The update focuses on enhancing the documentation and refactoring the configuration code for the Seven Segment Display Reloaded usermod. The README now features a structured table of compile-time parameters, clearer settings descriptions with LED configuration examples, and a new public function. In parallel, the header file has been refactored to replace runtime configuration variables with preprocessor definitions and static constants, while adjustments to MQTT publishing and JSON configuration handling improve brightness and lux parameter management.

Changes

Files Change Summaries
usermods/seven_segment_display_reloaded/readme.md - Enhanced documentation with a new "Available Compile-Time Parameters" section including a detailed table of parameters (e.g., SSDR_ENABLED, SSDR_ENABLE_AUTO_BRIGHTNESS, etc.)
- Reorganized settings descriptions with concise definitions for parameters like enabled, inverted, and Colon-blinking
- Added examples for LED definitions and documented the new public function disableOutputFunction(bool state)
usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h - Refactored configuration by replacing runtime booleans and strings with preprocessor definitions (e.g., umSSDR_ENABLED, umSSDR_BRIGHTNESS_MIN, umSSDR_INVERT_AUTO_BRIGHTNESS, etc.)
- Introduced new static constant strings for brightness and lux parameters
- Updated MQTT messaging and JSON configuration handling to include brightness and lux settings adjustments
✨ 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 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

@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 and others added 4 commits March 5, 2025 20:15
Co-authored-by: Roman Reitschmied <derqurps@users.noreply.github.com>
Co-authored-by: Roman Reitschmied <derqurps@users.noreply.github.com>
…reloaded.h

Co-authored-by: Roman Reitschmied <derqurps@users.noreply.github.com>
@KrX3D KrX3D requested a review from derqurps March 5, 2025 21:39
Copy link

@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 👍

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.

3 participants