From 210dc5fdf6fec4a1d5f8b891d8f63bca581eafec Mon Sep 17 00:00:00 2001 From: Valentin Weber Date: Sat, 19 Jul 2025 17:26:08 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20error=20in=20Brightness=20=E2=86=92=20f3?= =?UTF-8?q?2=20conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/protocol.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocol.rs b/src/protocol.rs index 32c41e8..79c2709 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -229,7 +229,7 @@ impl From for f32 { Brightness::Full => 1.0, Brightness::ThreeQuarters => 0.75, Brightness::Half => 0.5, - Brightness::OneQuarter => 0.5, + Brightness::OneQuarter => 0.25, } } } @@ -578,7 +578,7 @@ mod test { fn f32_to_brightness_and_back() { const VALID_BRIGHTNESS_VALUES: [f32; 4] = [0.25, 0.5, 0.75, 1.0]; for i in i8::MIN..i8::MAX { - let i = i as f32 / 4f32; + let i = f32::from(i) / 4f32; let Ok(brightness) = Brightness::try_from(i); assert!(VALID_BRIGHTNESS_VALUES.contains(&(f32::from(brightness)))); }