Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions examples/app_color_led_cycle/src/led_cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,38 @@ void appMain()
{
DEBUG_PRINT("Starting WRGB color cycling app...\n");

paramVarId_t idWrgb = paramGetVarId("colorled", "wrgb8888");
paramVarId_t idBrightnessCorr = paramGetVarId("colorled", "brightnessCorr");
// Detect which Color LED deck is attached (bottom or top)
paramVarId_t idBottomDetect = paramGetVarId("deck", "bcColorLedBot");
paramVarId_t idTopDetect = paramGetVarId("deck", "bcColorLedTop");

uint8_t bottomAttached = paramGetUint(idBottomDetect);
uint8_t topAttached = paramGetUint(idTopDetect);

const char* deckParamGroup = NULL;

// Use the first detected deck
if (bottomAttached) {
deckParamGroup = "colorLedBot";
DEBUG_PRINT("Color LED Bottom deck detected\n");
} else if (topAttached) {
deckParamGroup = "colorLedTop";
DEBUG_PRINT("Color LED Top deck detected\n");
} else {
DEBUG_PRINT("ERROR: No Color LED deck detected!\n");
return;
}

paramVarId_t idWrgb = paramGetVarId(deckParamGroup, "wrgb8888");
paramVarId_t idBrightCorr = paramGetVarId(deckParamGroup, "brightCorr");

// Enable brightness correction for perceptually uniform colors
// Set to 1 (enabled) for balanced luminance across R/G/B/W channels
// Set to 0 (disabled) for maximum brightness per channel
paramSetInt(idBrightnessCorr, 1);
paramSetInt(idBrightCorr, 1);

// Subscribe to thermal throttle logs
logVarId_t idDeckTemp = logGetVarId("colorled", "deckTemp");
logVarId_t idThrottlePct = logGetVarId("colorled", "throttlePct");
logVarId_t idDeckTemp = logGetVarId(deckParamGroup, "deckTemp");
logVarId_t idThrottlePct = logGetVarId(deckParamGroup, "throttlePct");

uint8_t r = 0, g = 0, b = 0, w = 0;
int step = 0;
Expand Down
21 changes: 15 additions & 6 deletions src/deck/drivers/interface/color_led_deck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

#include <stdint.h>

#define COLORLED_DECK_I2C_ADDRESS 0x10

// Protocol commands
#define CMD_GET_VERSION 0x00
#define CMD_SET_COLOR 0x01
#define CMD_GET_THERMAL_STATUS 0x02
#define CMD_GET_LED_POSITION 0x03
#define CMD_GET_LED_CURRENT 0x04

// Expected protocol version
#define COLORLED_PROTOCOL_VERSION_REQUIRED 1
#define COLORLED_PROTOCOL_VERSION_REQUIRED 2

#define TXBUFFERSIZE 5
#define RXBUFFERSIZE 3
#define RXBUFFERSIZE 9

typedef struct {
uint8_t w, r, g, b;
Expand All @@ -26,9 +26,18 @@ typedef struct {
uint8_t w_lumens;
} ledLuminance_t;

// LED luminance values from datasheet
// LED luminance values from datasheet, adjusted for actual circuit current
// Datasheet values assume equal current, but actual current depends on both
// sense resistor AND LED forward voltage (V_F):
//
// Circuit: I = (Vsupply - V_F) / (R_mosfet + R_sense)
// - Red: I = (3.1V - 2.1V) / (0.070Ω + 3.4Ω) = 288 mA → 1.54× datasheet current
// - G/B/W: I = (3.1V - 2.9V) / (0.070Ω + 1.0Ω) = 187 mA → 1.0× datasheet current
//
// Red's lower V_F gives more voltage headroom, overcoming higher sense resistance
// LED brightness scales approximately linearly with current
static const ledLuminance_t LED_LUMINANCE = {
.r_lumens = 90,
.r_lumens = 139, // 90 lumens @ datasheet current × 1.54 current ratio = 139 lumens actual
.g_lumens = 210,
.b_lumens = 50,
.w_lumens = 250
Expand Down
Loading