Draw bar for backlight

This commit is contained in:
Kenny Levinsen
2019-08-01 00:09:51 +02:00
parent e426e1f884
commit 14a1611e9e
4 changed files with 48 additions and 10 deletions
+11 -3
View File
@@ -1,6 +1,6 @@
use crate::buffer::Buffer;
use crate::color::Color;
use crate::draw::{draw_text, ROBOTO_REGULAR};
use crate::draw::{draw_bar, draw_text, ROBOTO_REGULAR};
use crate::module::{Input, ModuleImpl};
use chrono::{DateTime, Local};
@@ -103,12 +103,20 @@ impl ModuleImpl for Backlight {
buf.memset(bg);
draw_text(
ROBOTO_REGULAR,
&mut buf.subdimensions((0, 0, 256, 24)),
&mut buf.subdimensions((0, 0, 128, 24)),
bg,
&Color::new(1.0, 1.0, 1.0, 1.0),
24.0,
&format!("backlight: {:}%", self.brightness() as u8),
"backlight",
)?;
draw_bar(
&mut buf.subdimensions((128, 0, 384, 24)),
bg,
&Color::new(1.0, 1.0, 1.0, 1.0),
384,
24,
self.brightness() / 100.0,
);
Ok(vec![buf.get_signed_bounds()])
}