diff --git a/bin/src/daemon.rs b/bin/src/daemon.rs index a1b5273..253b2b2 100644 --- a/bin/src/daemon.rs +++ b/bin/src/daemon.rs @@ -115,11 +115,11 @@ fn run_ctrl_c_thread( }) } -fn update_ui(task_tracker: &TaskTracker){ - task_tracker.spawn(async move { +async fn update_ui(task_tracker: &TaskTracker){ + task_tracker.spawn_blocking(|| { let mut fb: Framebuffer = Framebuffer::new(); - fb.draw_img("orca.gif") - }); + fb.draw_img("/data/rayhunter/orca.gif"); + }).await.unwrap(); } #[tokio::main] @@ -146,8 +146,8 @@ async fn main() -> Result<(), RayhunterError> { let (server_shutdown_tx, server_shutdown_rx) = oneshot::channel::<()>(); run_ctrl_c_thread(&task_tracker, tx.clone(), server_shutdown_tx, qmdl_store_lock.clone()); - update_ui(&task_tracker); run_server(&task_tracker, &config, qmdl_store_lock.clone(), server_shutdown_rx, tx).await; + update_ui(&task_tracker).await; task_tracker.close(); task_tracker.wait().await; diff --git a/bin/src/framebuffer.rs b/bin/src/framebuffer.rs index 89259dc..afa643a 100644 --- a/bin/src/framebuffer.rs +++ b/bin/src/framebuffer.rs @@ -1,6 +1,7 @@ use image::{io::Reader as ImageReader, AnimationDecoder, imageops::FilterType, codecs::gif::GifDecoder, DynamicImage}; use std::{io::BufReader, fs::File, time::Duration}; use include_dir::{include_dir, Dir}; +use log::{info, error}; const FB_PATH:&str = "/dev/fb0"; static IMAGE_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/static/images/"); @@ -29,6 +30,7 @@ impl Framebuffer<'_>{ fn write(&mut self, img: DynamicImage) { + let resized_img = img.resize( self.dimensions.width, self.dimensions.height, FilterType::CatmullRom); let width = self.dimensions.width.min(resized_img.width()); let height = self.dimensions.height.min(resized_img.height()); @@ -48,9 +50,11 @@ impl Framebuffer<'_>{ pub fn draw_img(&mut self, img_name: &str) { - let img_path = IMAGE_DIR.get_file(img_name).unwrap().path(); + //let img_path = IMAGE_DIR.get_file(img_name).unwrap().path(); + let img_path = img_name; + info!("img_path: {:?}", img_path); if img_path.ends_with(".gif") { - loop { + loop{ // this is dumb and i'm sure there's a better way to loop this let stream = BufReader::new(File::open(&img_path).unwrap()); let decoder = GifDecoder::new(stream).unwrap();