diff --git a/.vscode/settings.json b/.vscode/settings.json index 88392e4..0cb6219 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "files.autoSave": "onWindowChange" + "files.autoSave": "onWindowChange", + "cSpell.words": [ + "Itertools" + ] } \ No newline at end of file diff --git a/src-tauri/src/ambient_light/publisher.rs b/src-tauri/src/ambient_light/publisher.rs index 899b33f..4426669 100644 --- a/src-tauri/src/ambient_light/publisher.rs +++ b/src-tauri/src/ambient_light/publisher.rs @@ -1,8 +1,8 @@ -use std::{borrow::BorrowMut, collections::HashMap, sync::Arc, time::Duration}; +use std::sync::Arc; use paris::warn; use tauri::async_runtime::{Mutex, RwLock}; -use tokio::{sync::watch, time::sleep}; +use tokio::sync::watch; use crate::{ ambient_light::{config, ConfigManager}, diff --git a/src-tauri/src/display/manager.rs b/src-tauri/src/display/manager.rs index 7f0cc72..99627d0 100644 --- a/src-tauri/src/display/manager.rs +++ b/src-tauri/src/display/manager.rs @@ -159,7 +159,8 @@ impl Manager { let rpc = rpc::Manager::global().await; rpc.publish_desktop_cmd( - format!("display{}/brightness", display_brightness.display_index).as_str(), + format!("display{}/brightness", display_brightness.display_index) + .as_str(), target.to_be_bytes().to_vec(), ) .await; diff --git a/src-tauri/src/screenshot.rs b/src-tauri/src/screenshot.rs index d1798eb..39e799d 100644 --- a/src-tauri/src/screenshot.rs +++ b/src-tauri/src/screenshot.rs @@ -4,10 +4,7 @@ use std::sync::Arc; use serde::{Deserialize, Serialize}; use tauri::async_runtime::RwLock; -use crate::{ - ambient_light::{LedStripConfig, LedStripConfigOfDisplays}, - led_color::LedColor, -}; +use crate::{ambient_light::LedStripConfig, led_color::LedColor}; #[derive(Debug, Clone)] pub struct Screenshot { @@ -41,10 +38,7 @@ impl Screenshot { } } - pub fn get_sample_points( - &self, - config: &LedStripConfig, - ) -> Vec { + pub fn get_sample_points(&self, config: &LedStripConfig) -> Vec { let height = self.height as usize; let width = self.width as usize; @@ -82,93 +76,6 @@ impl Screenshot { } } - // fn get_sample_points(config: DisplayConfig) -> ScreenSamplePoints { - // let top = match config.led_strip_of_borders.top { - // Some(led_strip_config) => Self::get_one_edge_sample_points( - // config.display_height / 8, - // config.display_width, - // led_strip_config.len, - // 1, - // ), - // None => { - // vec![] - // } - // }; - - // let bottom: Vec = match config.led_strip_of_borders.bottom { - // Some(led_strip_config) => { - // let points = Self::get_one_edge_sample_points( - // config.display_height / 9, - // config.display_width, - // led_strip_config.len, - // 5, - // ); - // points - // .into_iter() - // .map(|groups| -> Vec { - // groups - // .into_iter() - // .map(|(x, y)| (x, config.display_height - y)) - // .collect() - // }) - // .collect() - // } - // None => { - // vec![] - // } - // }; - - // let left: Vec = match config.led_strip_of_borders.left { - // Some(led_strip_config) => { - // let points = Self::get_one_edge_sample_points( - // config.display_width / 16, - // config.display_height, - // led_strip_config.len, - // 5, - // ); - // points - // .into_iter() - // .map(|groups| -> Vec { - // groups.into_iter().map(|(x, y)| (y, x)).collect() - // }) - // .collect() - // } - // None => { - // vec![] - // } - // }; - - // let right: Vec = match config.led_strip_of_borders.right { - // Some(led_strip_config) => { - // let points = Self::get_one_edge_sample_points( - // config.display_width / 16, - // config.display_height, - // led_strip_config.len, - // 5, - // ); - // points - // .into_iter() - // .map(|groups| -> Vec { - // groups - // .into_iter() - // .map(|(x, y)| (config.display_width - y, x)) - // .collect() - // }) - // .collect() - // } - // None => { - // vec![] - // } - // }; - - // ScreenSamplePoints { - // top, - // bottom, - // left, - // right, - // } - // } - fn get_one_edge_sample_points( width: usize, length: usize, @@ -258,13 +165,15 @@ impl Screenshot { r += bitmap[position + 2] as f64; } let color = LedColor::new((r / len) as u8, (g / len) as u8, (b / len) as u8); - // paris::info!("color: {:?}", color.get_rgb()); colors.push(color); } colors } - pub async fn get_colors_by_sample_points(&self, points: &Vec) -> Vec { + pub async fn get_colors_by_sample_points( + &self, + points: &Vec, + ) -> Vec { let bytes = self.bytes.read().await; Self::get_one_edge_colors(points, &bytes, self.bytes_per_row) diff --git a/src/components/display-view.tsx b/src/components/display-view.tsx index 8befbd3..9441cd5 100644 --- a/src/components/display-view.tsx +++ b/src/components/display-view.tsx @@ -1,5 +1,4 @@ -import { Component, createMemo, ParentComponent } from 'solid-js'; -import { LedStripConfigOfBorders } from '../models/display-config'; +import { Component, createMemo } from 'solid-js'; import { DisplayInfo } from '../models/display-info.model'; import { displayStore } from '../stores/display.store'; import { ledStripStore } from '../stores/led-strip.store'; diff --git a/src/components/led-strip-parts-sorter.tsx b/src/components/led-strip-parts-sorter.tsx index 9b8f8af..161a495 100644 --- a/src/components/led-strip-parts-sorter.tsx +++ b/src/components/led-strip-parts-sorter.tsx @@ -1,14 +1,4 @@ -import { - Component, - createContext, - createEffect, - createMemo, - createSignal, - For, - JSX, - onCleanup, - untrack, -} from 'solid-js'; +import { Component, createContext, createEffect, createSignal, For } from 'solid-js'; import { LedStripConfig, LedStripPixelMapper } from '../models/led-strip-config'; import { ledStripStore } from '../stores/led-strip.store'; diff --git a/src/components/screen-view.tsx b/src/components/screen-view.tsx index 59fdfdb..3869116 100644 --- a/src/components/screen-view.tsx +++ b/src/components/screen-view.tsx @@ -14,12 +14,6 @@ type ScreenViewProps = { displayId: number; } & JSX.HTMLAttributes; -async function subscribeScreenshotUpdate(displayId: number) { - await invoke('subscribe_encoded_screenshot_updated', { - displayId, - }); -} - export const ScreenView: Component = (props) => { const [localProps, rootProps] = splitProps(props, ['displayId']); let canvas: HTMLCanvasElement;