-
Notifications
You must be signed in to change notification settings - Fork 223
Summit/blink/solution #248
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
Summit/blink/solution #248
Conversation
Reviewer's Guide by SourceryThis pull request introduces a blink functionality for the PSLab device's onboard RGB LED, including a Python implementation and a firmware implementation. It refactors the connection and rgb_led methods to use the new exchange method. Sequence diagram for get_version methodsequenceDiagram
participant S as ScienceLab
participant C as Connection
S->>C: get_version()
activate C
C->>C: exchange(COMMON + GET_VERSION)
C->>C: write(header + data)
C->>C: read(CP.Header.size)
C->>C: read(response_size)
C-->>S: version
deactivate C
Sequence diagram for get_firmware_version methodsequenceDiagram
participant S as ScienceLab
participant C as Connection
S->>C: get_firmware_version()
activate C
C->>C: exchange(COMMON + GET_FW_VERSION)
C->>C: write(header + data)
C->>C: read(CP.Header.size)
C->>C: read(response_size)
C-->>S: FirmwareVersion(major, minor, patch)
deactivate C
Sequence diagram for rgb_led methodsequenceDiagram
participant S as ScienceLab
participant C as Connection
S->>S: rgb_led(colors, output, order)
S->>C: exchange(cmd, args)
activate C
C->>C: write(header + data)
C->>C: read(CP.Header.size)
C->>C: read(response_size)
C-->>S:
deactivate C
Sequence diagram for blink_c method with periodsequenceDiagram
participant S as ScienceLab
participant C as Connection
S->>S: blink_c(psl, color, period)
S->>C: exchange(cmd, args)
activate C
C->>C: write(header + data)
C->>C: read(CP.Header.size)
C->>C: read(response_size)
C-->>S:
deactivate C
Sequence diagram for blink_c method without periodsequenceDiagram
participant S as ScienceLab
participant C as Connection
S->>S: blink_c(psl, color, period)
S->>C: exchange(cmd)
activate C
C->>C: write(header + data)
C->>C: read(CP.Header.size)
C->>C: read(response_size)
C-->>S:
deactivate C
S->>S: rgb_led(color)
S->>C: exchange(cmd, args)
activate C
C->>C: write(header + data)
C->>C: read(CP.Header.size)
C->>C: read(response_size)
C-->>S:
deactivate C
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bessman - I've reviewed your changes - here's some feedback:
Overall Comments:
- The new
exchange
method looks good, but consider adding a timeout parameter to handle cases where the device doesn't respond. - It looks like the
rgb_led
method is being modified to use the newexchange
method, which is great. However, the conditional logic based on device version could be simplified for better readability.
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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
self.device.send_byte(pin) | ||
|
||
self.device.get_ack() | ||
cmd = CP.COMMON + CP.SET_RGB_COMMON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Undefined variable 'pin' in rgb_led.
The code packs a 'pin' variable with CP.Byte.pack(pin) but it is never defined. Likely the intention is to extract the correct value from 'pins' (e.g. 'pin = pins[output]').
This includes a solution for the PSLab Development 101 workshop at FOSSASIA Summit 2025.
It shall not be merged into main.
Summary by Sourcery
Implements a blink functionality for the PSLab device's onboard RGB LED, including a Python implementation and a firmware implementation. Refactors the connection and RGB LED control logic to use a new exchange method for sending commands and data.
New Features: