Skip to content

Conversation

@gemenerik
Copy link
Member

@gemenerik gemenerik commented Nov 5, 2025

EDIT: Replaced by #1561


This PR adds proper distinction between the top and bottom variants of the Color LED deck. Previously, the driver treated them as a single generic deck type without differentiating between mounting positions. The driver now supports both variants simultaneously, with each maintaining separate state, parameters, and logging. The parameter and log group names have changed from colorled to colorLedBot and colorLedTop. The brightnessCorr parameter was shortened to brightCorr to stay within firmware name length limits. Detection parameters are now deck.bcColorLedBot and deck.bcColorLedTop. The example app has been updated to detect which variant is present.

GPIO initialization now includes proper error handling with improved debug messages. GPIO 11 is now configured for the top deck to set the I2C address selection.

The driver now supports LED position detection and current monitoring. New log variables ledPos, ledCurR, ledCurG, ledCurB, and ledCurW report the hardware-detected position and real-time LED current in milliamps. Note: LED current readings are PWM-based and only provide stable values at full intensity (when PWM duty cycle is 100%). This feature (and the LED position detection feature) is primarily intended for production testing. For full duty cycle, brightness correction may need to be disabled depending on the color channel being tested. The task loop has been refactored to use dedicated polling functions with separate intervals (thermal: 100ms, current: 1000ms). LED luminance correction now accounts for the red LED's higher actual current due to lower forward voltage. Doxygen documentation has been added for all parameters and log variables.

Protocol version requirement bumped to v2 with new commands CMD_GET_LED_POSITION and CMD_GET_LED_CURRENT. RXBUFFERSIZE increased to 9 bytes.

Requires bitcraze/color-led-deck-firmware#3

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors the Color LED deck driver to support multiple deck instances (bottom and top) simultaneously. The driver transitions from static global variables to a context-based architecture that maintains separate state for each deck instance.

Key changes:

  • Introduces a colorLedContext_t structure to encapsulate per-instance state
  • Creates separate deck drivers for bottom (PID 0x13) and top (PID 0x14) deck positions
  • Updates parameter and log groups to use instance-specific names (colorLedBot and colorLedTop)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/deck/drivers/src/color_led_deck.c Refactors driver from global state to context-based architecture supporting two deck instances with separate parameters, logs, and I2C addressing
examples/app_color_led_cycle/src/led_cycle.c Updates example to detect which deck instance is attached and use the appropriate parameter/log groups

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemenerik
Copy link
Member Author

For this to work with both simultaneously we need unique I2C addresses for top and bottom. Converting this to draft until then.

@gemenerik gemenerik marked this pull request as draft November 6, 2025 14:19
@gemenerik gemenerik marked this pull request as ready for review November 6, 2025 15:49
@gemenerik gemenerik requested a review from Copilot November 11, 2025 14:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


static wrgb_t output;
if (brightnessCorr) {
wrgb_t output;
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The output variable is now declared inside the conditional block but is used after the block ends. While this works in C99, the variable should be declared before the conditional to improve code clarity, or the usage should be moved inside appropriate scopes. Consider moving the declaration to line 373 before the conditional.

Copilot uses AI. Check for mistakes.
@gemenerik
Copy link
Member Author

I2C address changing not working consistently

- Configure GPIO 11 for I2C address selection on top deck only
- Make debug messages more specific and unique for easier troubleshooting
- Clarify GPIO 0 and GPIO 11 purposes in error messages

GPIO 11 controls the I2C address to differentiate between top and
bottom decks when both are installed, so it only needs to be configured
for the top deck variant.
Red gets 1.54× more current (lower V_F despite higher R_sense).
Sets physics-based baseline; perceptual result may need tuning.
- Add CMD_GET_LED_POSITION and CMD_GET_LED_CURRENT commands
- Bump protocol version requirement to v2
- Add ledPosition and ledCurrent[4] fields to context
- Refactor task loop to use dedicated polling functions
- Poll LED current every 1000ms, thermal status every 100ms
- Add comprehensive documentation for all parameters and logs
- Increase RXBUFFERSIZE to 9 bytes for larger responses
@gemenerik
Copy link
Member Author

Rebasing on / merging with master was tough, dropping this PR in favor of #1561

@gemenerik gemenerik closed this Nov 20, 2025
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.

2 participants