From 5422cca393af3db7c6e35bc4767a6abbe2396204 Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Tue, 31 Jan 2023 16:29:56 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E3=80=82#5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/core/core.rs | 2 +- src-tauri/src/display/manager.rs | 10 ++++++---- src-tauri/src/rpc/mqtt.rs | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) 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,