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

Add support for controlling LED panel brightness #76

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

Conversation

weberval
Copy link

@weberval weberval commented Feb 22, 2025

Summary by Sourcery

Adds support for controlling the brightness of the LED panel. A new Brightness enum is introduced in the protocol, and the PayloadBuffer is updated to accept a Brightness value during initialization. A new --brightness argument is added to the CLI to control the brightness of the panel.

New Features:

  • Adds support for controlling the brightness of the LED panel.

Enhancements:

  • Updates the PayloadBuffer to accept a Brightness value during initialization, allowing control over the panel's brightness.
  • Updates the magic bytes to be 5 bytes instead of 6.

Build:

  • Increments the crate version to 0.2.0.

Documentation:

  • Fixes a typo in a comment, changing 'arround' to 'around'.

Summary by Sourcery

Adds support for controlling the LED panel brightness. A new Brightness enum is introduced, and the PayloadBuffer is updated to accept a Brightness value during initialization. A new --brightness argument is added to the CLI to control the brightness of the panel.

New Features:

  • Adds support for controlling the LED panel brightness via a new Brightness enum and a --brightness CLI argument.

Enhancements:

  • Updates the PayloadBuffer to accept a Brightness value during initialization.

Build:

  • Increments the crate version to 0.2.0.

Chores:

  • Updates the magic bytes to be 5 bytes instead of 6.

Copy link

sourcery-ai bot commented Feb 22, 2025

Reviewer's Guide by Sourcery

This pull request adds support for controlling the brightness of the LED panel. It introduces a new Brightness enum, updates the PayloadBuffer to accept a Brightness value, and adds a --brightness argument to the CLI. It also fixes a typo in a comment and increments the crate version.

Sequence diagram for PayloadBuffer creation with brightness

sequenceDiagram
    participant CLI
    participant PayloadBuffer
    participant Header

    CLI->>PayloadBuffer: new(brightness: Brightness)
    PayloadBuffer->>Header: Create Header with brightness
    Header-->>PayloadBuffer: Header data
    PayloadBuffer-->>CLI: PayloadBuffer instance
Loading

Updated class diagram for Brightness enum

classDiagram
    class Brightness {
        <<enumeration>>
        Full
        ThreeQuarters
        Half
        OneQuarter
    }
    Brightness : +From<Brightness> u8
Loading

File-Level Changes

Change Details Files
Introduces a Brightness enum to represent different brightness levels for the LED panel.
  • Adds a Brightness enum with Full, ThreeQuarters, Half, and OneQuarter variants.
  • Implements From<Brightness> for u8 to convert the enum to a byte representation.
  • Adds clap::ValueEnum derive to the Brightness enum to allow it to be used as a CLI argument.
  • Adds serde derives to the Brightness enum for serialization and deserialization.
src/protocol.rs
src/main.rs
examples/hello-world.rs
Updates the PayloadBuffer to include a brightness setting.
  • Modifies the Header struct to include a brightness field.
  • Updates the PayloadBuffer::new function to accept a Brightness value.
  • Modifies the PayloadBuffer::default function to use the Brightness::Full value.
  • Updates the magic bytes to be 5 bytes instead of 6.
src/protocol.rs
Adds a --brightness argument to the CLI to control the LED panel brightness.
  • Adds a brightness field to the Args struct, using Option<Brightness>.
  • Updates the gnerate_payload function to use the brightness argument when creating the PayloadBuffer.
src/main.rs
Fixes a typo in a comment.
  • Changes 'arround' to 'around' in a comment in src/protocol.rs.
src/protocol.rs
Increments the crate version.
  • Increments the crate version to 0.2.0 in Cargo.toml.
Cargo.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@weberval weberval changed the title Feat/brightnesscontrol feat: Add support for brightness control Feb 22, 2025
@weberval weberval closed this Feb 22, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @weberval - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a constructor method to PayloadBuffer that accepts all parameters to make it more ergonomic.
  • It might be worth adding some unit tests for the Brightness enum to ensure the From implementation works as expected.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@weberval weberval reopened this Feb 22, 2025
@weberval
Copy link
Author

@sourcery-ai dismiss

@weberval
Copy link
Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @weberval - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a constructor method to Brightness to encapsulate the From<Brightness> for u8 conversion logic.
  • The MAGIC constant was changed from 6 bytes to 5 bytes - is this intentional?
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -54,7 +53,7 @@ impl Style {
self
}

/// Show a dotted border arround the display.
/// Show a dotted border around the display.
Copy link

Choose a reason for hiding this comment

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

nitpick (typo): Fixed typo in the doc comment for Style.

The correction from "arround" to "around" improves readability. Double-check that similar fixes are applied consistently in related docs.

Suggested implementation:

    /// Show a dotted border around the display.
<!-- Ensure that every occurrence of "arround" is replaced with "around" in similar doc comments -->

Search through the rest of the file for the string "arround" and replace it with "around" to maintain consistency in documentation. This might also require checking similar documentation in other files if applicable.

@weberval weberval force-pushed the feat/brightnesscontrol branch from 1e3e988 to 1cb1562 Compare February 22, 2025 10:52
@weberval
Copy link
Author

@sourcery-ai dismiss

@weberval
Copy link
Author

@sourcery-ai review

@weberval weberval marked this pull request as draft February 22, 2025 11:00
@weberval weberval changed the title feat: Add support for brightness control feat: Add support for brightness control @sourcery-ai Feb 22, 2025
@sourcery-ai sourcery-ai bot changed the title feat: Add support for brightness control @sourcery-ai Add support for controlling LED panel brightness Feb 22, 2025
@weberval
Copy link
Author

@sourcery-ai guide

Add test for Brightness to u8 conversion.
@weberval
Copy link
Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @weberval - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a constructor to PayloadBuffer that takes all parameters to avoid using Default and then setting fields.
  • The brightness_to_u8 test could be improved by using a table-driven approach to avoid repetition.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@weberval weberval marked this pull request as ready for review February 22, 2025 19:14
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We have skipped reviewing this pull request. It looks like we've already reviewed the commit 1535b57 in this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant