-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add simultaneous top and bottom Color LED deck support #1561
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
Conversation
Refactor driver from single-deck to dual-deck architecture with context-based state management. Previously the driver only supported one deck at a time. Now both variants can operate simultaneously with separate state, parameters, and logging. Driver changes: - Context structure holds per-instance state (init, colors, thermal, current, position) - Two deck drivers: bcColorLEDBot (PID 0x13) and bcColorLEDTop (PID 0x14) - I2C addressing: bottom at 0x30, top at 0x31 (GPIO 11 controls address selection for top) - Separate bootloader reset functions for each deck (both use DFU address 0x64) - LED controller callback now forwards to all initialized instances Parameter and log group changes: - Renamed from colorled to colorLedBot and colorLedTop for separate control - brightnessCorr shortened to brightCorr (firmware name length limits) - Detection parameters: deck.bcColorLedBot and deck.bcColorLedTop - New log variables: ledPos, ledCurR, ledCurG, ledCurB, ledCurW Protocol enhancements (v1 → v2): - Add CMD_GET_LED_POSITION and CMD_GET_LED_CURRENT commands - Increase RXBUFFERSIZE to 9 bytes for current readings (4 channels × 2 bytes) - Task loop refactored with dedicated polling functions (thermal: 100ms, current: 1000ms) - LED position polled once during initialization (hardware-fixed value) Note: LED current readings are PWM-based and only provide stable values at full intensity (100% duty cycle). This feature and position detection are primarily for production testing. Luminance correction improvements: - Red LED value updated to 139 lumens (from 90) accounting for actual circuit current - Red's lower forward voltage (2.1V vs 2.9V) results in 1.54× higher current despite higher sense resistor, requiring luminance adjustment GPIO initialization now includes proper error handling with debug messages. Example app updated to auto-detect and select appropriate deck parameter group. Requires: - bitcraze/color-led-deck-firmware#3 - bitcraze/deck-ctrl-firmware#4
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.
Pull Request Overview
This PR refactors the Color LED deck driver from a single-deck to dual-deck architecture, enabling simultaneous operation of both bottom and top Color LED decks with independent control and state management.
Key Changes:
- Introduced context-based architecture with per-instance state tracking for concurrent bottom (I2C 0x30) and top (I2C 0x31) deck operation
- Upgraded protocol from v1 to v2 with new LED position and current monitoring commands
- Renamed and split parameter/log groups from
colorledtocolorLedBot/colorLedTopwith shortenedbrightCorrparameter name - Updated red LED luminance value to 139 lumens (from 90) based on actual circuit current calculations
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/deck/drivers/src/color_led_deck.c | Main driver refactored with context structure for dual-deck support, separate init/test/bootloader functions for bottom and top decks, new polling functions for thermal/current/position, and split parameter/log groups |
| src/deck/drivers/interface/color_led_deck.h | Added CMD_GET_LED_POSITION and CMD_GET_LED_CURRENT commands, increased RXBUFFERSIZE to 9 bytes, updated protocol version to 2, and corrected red LED luminance to 139 lumens with circuit analysis documentation |
| examples/app_color_led_cycle/src/led_cycle.c | Updated to auto-detect bottom or top deck attachment and use corresponding parameter group (colorLedBot/colorLedTop) with renamed brightCorr parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
evoggy
left a comment
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.
Nice!
…roved readability
Refactor driver from single-deck to dual-deck architecture with context-based state management. Previously the driver only supported one deck at a time. Now both variants can operate simultaneously with separate state, parameters, and logging.
Driver changes:
bcColorLEDBot(PID 0x13) andbcColorLEDTop(PID 0x14)Parameter and log group changes:
Protocol enhancements (v1 → v2):
CMD_GET_LED_POSITIONandCMD_GET_LED_CURRENTcommandsRXBUFFERSIZEto 9 bytes for current readings (4 channels × 2 bytes)Note: LED current readings are PWM-based and only provide stable values at full intensity (100% duty cycle). This feature and position detection are primarily for production testing.
Luminance correction improvements:
GPIO initialization now includes proper error handling with debug messages. Example app updated to auto-detect and select appropriate deck parameter group.
Requires: