diff --git a/src-tauri/src/core/core.rs b/src-tauri/src/core/core.rs index da07422..9583b86 100644 --- a/src-tauri/src/core/core.rs +++ b/src-tauri/src/core/core.rs @@ -184,7 +184,7 @@ impl CoreManager { if global_sub_pixels.len() >= total_colors_count * 3 { let mut colors = vec![]; for index in 0..global_sub_pixels.len() { - colors.push(*global_sub_pixels.get(&index).unwrap()); + colors.push(*global_sub_pixels.get(&index).unwrap_or(&100)); } // info!("{:?}", colors); global_sub_pixels = HashMap::new(); diff --git a/src-tauri/src/display/manager.rs b/src-tauri/src/display/manager.rs index 39a776d..724da4e 100644 --- a/src-tauri/src/display/manager.rs +++ b/src-tauri/src/display/manager.rs @@ -1,5 +1,5 @@ use ddc_hi::Display; -use paris::{info, error}; +use paris::{error, info}; use tokio::sync::{broadcast, OnceCell}; use crate::{display::Brightness, rpc}; @@ -26,9 +26,11 @@ impl Manager { } pub async fn subscribe_display_brightness(mut rx: broadcast::Receiver) { - while let Ok(display_brightness) = rx.recv().await { - if let Err(err) = Self::set_display_brightness(display_brightness) { - error!("set_display_brightness failed. {:?}", err); + loop { + if let Ok(display_brightness) = rx.recv().await { + if let Err(err) = Self::set_display_brightness(display_brightness) { + error!("set_display_brightness failed. {:?}", err); + } } } } diff --git a/src-tauri/src/rpc/mqtt.rs b/src-tauri/src/rpc/mqtt.rs index eeadc5b..2da0940 100644 --- a/src-tauri/src/rpc/mqtt.rs +++ b/src-tauri/src/rpc/mqtt.rs @@ -2,13 +2,12 @@ use crate::display; use image::EncodableLayout; use paris::warn; use rumqttc::{AsyncClient, Event, Incoming, MqttOptions, QoS}; -use serde::Deserialize; use std::time::Duration; use time::{format_description, OffsetDateTime}; use tokio::{sync::broadcast, task}; const DISPLAY_TOPIC: &'static str = "display-ambient-light/display"; -const DISPLAY_BRIGHTNESS_TOPIC: &'static str = "display-ambient-light/display/brightness"; +const DISPLAY_BRIGHTNESS_TOPIC: &'static str = "display-ambient-light/board/brightness"; pub struct MqttRpc { client: AsyncClient,