From aa8e9f10995bb71ecee78e2f7688deddbfbc0ebe Mon Sep 17 00:00:00 2001 From: Kemyt Date: Sat, 17 Apr 2021 12:48:05 +0200 Subject: [PATCH] Add rounding to volume percentage display Shows percentage is sometimes lower than actual because float number is cast to u16 without rounding, so for example 4.99_f64 becomes 4_u16 --- src/ui/statusbar.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/statusbar.rs b/src/ui/statusbar.rs index 037ecd3..75e3f98 100644 --- a/src/ui/statusbar.rs +++ b/src/ui/statusbar.rs @@ -125,7 +125,7 @@ impl View for StatusBar { let volume = format!( " [{}%]", - (self.spotify.volume() as f64 / 65535_f64 * 100.0) as u16 + (self.spotify.volume() as f64 / 65535_f64 * 100.0).round() as u16 ); printer.with_color(style_bar_bg, |printer| {