diff --git a/src-tauri/src/ambient_light/config.rs b/src-tauri/src/ambient_light/config.rs index 989aac8..5a084c2 100644 --- a/src-tauri/src/ambient_light/config.rs +++ b/src-tauri/src/ambient_light/config.rs @@ -18,13 +18,13 @@ pub enum Border { #[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq)] pub enum LedType { - RGB, - RGBW, + WS2812B, + SK6812, } impl Default for LedType { fn default() -> Self { - LedType::RGB + LedType::WS2812B } } @@ -151,7 +151,7 @@ impl LedStripConfigGroup { }, start_pos: j + i * 4 * 30, len: 30, - led_type: LedType::RGB, + led_type: LedType::WS2812B, }; configs.push(item); strips.push(item); diff --git a/src-tauri/src/ambient_light/publisher.rs b/src-tauri/src/ambient_light/publisher.rs index 83a0b08..9ba8d36 100644 --- a/src-tauri/src/ambient_light/publisher.rs +++ b/src-tauri/src/ambient_light/publisher.rs @@ -322,12 +322,12 @@ impl LedColorsPublisher { let led_type = if group_index < strips.len() { strips[group_index].led_type } else { - LedType::RGB // fallback to RGB + LedType::WS2812B // fallback to WS2812B }; let bytes_per_led = match led_type { - LedType::RGB => 3, - LedType::RGBW => 4, + LedType::WS2812B => 3, + LedType::SK6812 => 4, }; let mut buffer = Vec::::with_capacity(group_size * bytes_per_led); @@ -348,7 +348,7 @@ impl LedColorsPublisher { for i in start_index..end_index { if i < colors.len() { let bytes = match led_type { - LedType::RGB => { + LedType::WS2812B => { let calibration_bytes = color_calibration.to_bytes(); let color_bytes = colors[i].as_bytes(); // Apply calibration to RGB values @@ -358,7 +358,7 @@ impl LedColorsPublisher { ((color_bytes[2] as f32 * calibration_bytes[2] as f32 / 255.0) as u8), ] } - LedType::RGBW => { + LedType::SK6812 => { let calibration_bytes = color_calibration.to_bytes_rgbw(); let color_bytes = colors[i].as_bytes(); // Apply calibration to RGB values and use calibrated W @@ -375,8 +375,8 @@ impl LedColorsPublisher { log::warn!("Index {} out of bounds for colors array of length {}", i, colors.len()); // Add black color as fallback match led_type { - LedType::RGB => buffer.extend_from_slice(&[0, 0, 0]), - LedType::RGBW => buffer.extend_from_slice(&[0, 0, 0, 0]), + LedType::WS2812B => buffer.extend_from_slice(&[0, 0, 0]), + LedType::SK6812 => buffer.extend_from_slice(&[0, 0, 0, 0]), } } } @@ -396,7 +396,7 @@ impl LedColorsPublisher { for i in (start_index..end_index).rev() { if i < colors.len() { let bytes = match led_type { - LedType::RGB => { + LedType::WS2812B => { let calibration_bytes = color_calibration.to_bytes(); let color_bytes = colors[i].as_bytes(); // Apply calibration to RGB values @@ -406,7 +406,7 @@ impl LedColorsPublisher { ((color_bytes[2] as f32 * calibration_bytes[2] as f32 / 255.0) as u8), ] } - LedType::RGBW => { + LedType::SK6812 => { let calibration_bytes = color_calibration.to_bytes_rgbw(); let color_bytes = colors[i].as_bytes(); // Apply calibration to RGB values and use calibrated W @@ -423,8 +423,8 @@ impl LedColorsPublisher { log::warn!("Index {} out of bounds for colors array of length {}", i, colors.len()); // Add black color as fallback match led_type { - LedType::RGB => buffer.extend_from_slice(&[0, 0, 0]), - LedType::RGBW => buffer.extend_from_slice(&[0, 0, 0, 0]), + LedType::WS2812B => buffer.extend_from_slice(&[0, 0, 0]), + LedType::SK6812 => buffer.extend_from_slice(&[0, 0, 0, 0]), } } } diff --git a/src-tauri/src/led_test_effects.rs b/src-tauri/src/led_test_effects.rs index cbba028..56f5061 100644 --- a/src-tauri/src/led_test_effects.rs +++ b/src-tauri/src/led_test_effects.rs @@ -19,13 +19,17 @@ pub struct TestEffectConfig { #[derive(Debug, Clone, Serialize, Deserialize)] pub enum LedType { - RGB, - RGBW, + WS2812B, + SK6812, } pub struct LedTestEffects; impl LedTestEffects { + /// Check if LED type supports white channel (RGBW) + fn is_rgbw_type(led_type: &LedType) -> bool { + matches!(led_type, LedType::SK6812) + } /// Generate LED colors for a specific test effect at a given time pub fn generate_colors(config: &TestEffectConfig, time_ms: u64) -> Vec { let time_seconds = time_ms as f64 / 1000.0; @@ -60,7 +64,7 @@ impl LedTestEffects { buffer.push(rgb.1); buffer.push(rgb.2); - if matches!(led_type, LedType::RGBW) { + if Self::is_rgbw_type(&led_type) { buffer.push(0); // White channel } } @@ -93,7 +97,7 @@ impl LedTestEffects { buffer.push(color.1); buffer.push(color.2); - if matches!(led_type, LedType::RGBW) { + if Self::is_rgbw_type(&led_type) { buffer.push(0); // White channel } } @@ -114,7 +118,7 @@ impl LedTestEffects { buffer.push(255); buffer.push(255); - if matches!(led_type, LedType::RGBW) { + if Self::is_rgbw_type(&led_type) { buffer.push(255); // White channel } } else { @@ -123,7 +127,7 @@ impl LedTestEffects { buffer.push(0); buffer.push(0); - if matches!(led_type, LedType::RGBW) { + if Self::is_rgbw_type(&led_type) { buffer.push(0); // White channel } } @@ -144,7 +148,7 @@ impl LedTestEffects { buffer.push(brightness); buffer.push(brightness); - if matches!(led_type, LedType::RGBW) { + if Self::is_rgbw_type(&led_type) { buffer.push(brightness); // White channel } } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 8da5e4c..040b678 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -324,8 +324,8 @@ async fn stop_led_test_effect(board_address: String, led_count: u32, led_type: l // Turn off all LEDs let bytes_per_led = match led_type { - led_test_effects::LedType::RGB => 3, - led_test_effects::LedType::RGBW => 4, + led_test_effects::LedType::WS2812B => 3, + led_test_effects::LedType::SK6812 => 4, }; let buffer = vec![0u8; (led_count * bytes_per_led) as usize];