Support DS4 Plater Color on LED

This commit is contained in:
Frederik Walk 2023-12-03 16:30:36 +01:00
parent 092eeb4f07
commit 70846721cb
4 changed files with 17 additions and 5 deletions

View File

@ -40,9 +40,9 @@ const Peripherals::Drum::Config drum_config = {
// Trigger thresholds soft
{
80, // Don Left
50, // Ka Left
50, // Ka Left
80, // Don Right
50, // Ka Right
50, // Ka Right
},
10, // ADC sample count
@ -93,6 +93,7 @@ const Peripherals::Buttons::Config button_config = {
};
const Peripherals::StatusLed::Config led_config = {
{128, 128, 128}, // Idle Color
{255, 0, 0}, // Don Left Color
{0, 0, 255}, // Ka Left Color
{255, 255, 0}, // Don Right Color

View File

@ -16,6 +16,7 @@ class StatusLed {
uint8_t b;
};
Color idle_color;
Color don_left_color;
Color ka_left_color;
Color don_right_color;
@ -37,6 +38,7 @@ class StatusLed {
void setInputState(const Utils::InputState input_state);
void setBrightness(const uint8_t brightness);
void setPlayerColor(const Config::Color color);
void update();
};

View File

@ -67,9 +67,13 @@ void core1_task() {
display.setUsbMode(control_msg.data.usb_mode);
break;
case ControlCommand::SetPlayerLed:
if (control_msg.data.player_led.type == USB_PLAYER_LED_ID) {
switch (control_msg.data.player_led.type) {
case USB_PLAYER_LED_ID:
display.setPlayerId(control_msg.data.player_led.id);
} else if (control_msg.data.player_led.type == USB_PLAYER_LED_COLOR) {
break;
case USB_PLAYER_LED_COLOR:
led.setPlayerColor({control_msg.data.player_led.red, control_msg.data.player_led.green,
control_msg.data.player_led.blue});
}
break;
case ControlCommand::SetLedBrightness:

View File

@ -17,6 +17,8 @@ void StatusLed::setInputState(const Utils::InputState input_state) { m_input_sta
void StatusLed::setBrightness(const uint8_t brightness) { m_config.brightness = brightness; }
void StatusLed::setPlayerColor(const Config::Color color) { m_config.idle_color = color; }
void StatusLed::update() {
float brightness_factor = m_config.brightness / static_cast<float>(UINT8_MAX);
@ -57,7 +59,10 @@ void StatusLed::update() {
static_cast<uint8_t>((mixed_green / num_colors) * brightness_factor),
static_cast<uint8_t>((mixed_blue / num_colors) * brightness_factor)));
} else {
ws2812_put_pixel(0);
ws2812_put_pixel(
ws2812_rgb_to_gamma_corrected_u32pixel(static_cast<uint8_t>((m_config.idle_color.r) * brightness_factor),
static_cast<uint8_t>((m_config.idle_color.g) * brightness_factor),
static_cast<uint8_t>((m_config.idle_color.b) * brightness_factor)));
}
}