Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Will Greenberg <[email protected]>
  • Loading branch information
cooperq and wgreenberg authored Jun 17, 2024
1 parent aa730f3 commit a9842fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
15 changes: 5 additions & 10 deletions bin/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ async fn update_ui(task_tracker: &TaskTracker, config: &config::Config, mut ui_
task_tracker.spawn_blocking(move || {
let mut fb: Framebuffer = Framebuffer::new();
// this feels wrong, is there a more rusty way to do this?
let img;
let img: Option<&[u8]> = None;
if display_level == 2 {
img = IMAGE_DIR.get_file("orca.gif").unwrap().contents();
} else if display_level == 3{
img = IMAGE_DIR.get_file("eff.png").unwrap().contents();
} else {
img = &[];
img = Some(IMAGE_DIR.get_file("orca.gif").expect("failed to read orca.gif").contents());
} else if display_level == 3 {
img = Some(IMAGE_DIR.get_file("eff.png").expect("failed to read eff.png").contents());
}
loop {
match ui_shutdown_rx.try_recv() {
Expand All @@ -152,7 +150,7 @@ async fn update_ui(task_tracker: &TaskTracker, config: &config::Config, mut ui_

}
match display_level {
1 => {
1 | _ => {
fb.draw_line(framebuffer::Color565::Green, 2);
},
2 => {
Expand All @@ -168,9 +166,6 @@ async fn update_ui(task_tracker: &TaskTracker, config: &config::Config, mut ui_
fb.draw_line(framebuffer::Color565::Pink, 50);
fb.draw_line(framebuffer::Color565::Cyan, 25);
},
_ => {
fb.draw_line(framebuffer::Color565::Green, 2);
}
};
sleep(Duration::from_millis(100));
}
Expand Down
3 changes: 0 additions & 3 deletions bin/src/framebuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{io::Cursor, time::Duration};

const FB_PATH:&str = "/dev/fb0";


#[derive(Copy, Clone)]
// TODO actually poll for this, maybe w/ fbset?
struct Dimensions {
Expand Down Expand Up @@ -37,7 +36,6 @@ impl Framebuffer<'_>{
}
}


fn write(&mut self, img: DynamicImage) {
let mut width = img.width();
let mut height = img.height();
Expand All @@ -64,7 +62,6 @@ impl Framebuffer<'_>{
std::fs::write(self.path, &buf).unwrap();
}


pub fn draw_gif(&mut self, img_buffer: &[u8]) {
// this is dumb and i'm sure there's a better way to loop this
let cursor = Cursor::new(img_buffer);
Expand Down

0 comments on commit a9842fc

Please sign in to comment.