Skip to content

Conversation

@gemenerik
Copy link
Member

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:

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
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 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 colorled to colorLedBot/colorLedTop with shortened brightCorr parameter 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.

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 1 comment.


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

@gemenerik gemenerik requested review from tobbeanton and removed request for ArisMorgens and evoggy November 24, 2025 13:21
evoggy
evoggy previously approved these changes Nov 24, 2025
Copy link
Member

@evoggy evoggy left a comment

Choose a reason for hiding this comment

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

Nice!

@gemenerik gemenerik merged commit 5bc20cc into master Nov 24, 2025
6 checks passed
@gemenerik gemenerik deleted the color_led_dual_deck_v2 branch November 24, 2025 15:57
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