Skip to content

Conversation

@evoggy
Copy link
Member

@evoggy evoggy commented Nov 19, 2025

This fixes a couple of issues with the GPIO subsystem:

  • Do not set output unless the pin is set as output
  • Do not read pin input if GPIO is set as output, use the value set as output instead
  • Clean up the code a bit

gemenerik added a commit to bitcraze/crazyflie-firmware that referenced this pull request Nov 20, 2025
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
@evoggy evoggy force-pushed the evoggy/gpio_improvements branch from a96aa8c to 236dd30 Compare November 24, 2025 15:15
@evoggy evoggy merged commit 822208b into main Nov 24, 2025
1 check passed
tobbeanton pushed a commit to EliaCereda/crazyflie-firmware that referenced this pull request Dec 16, 2025
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
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