feat: 屏幕跟随改为多线程执行。

性能没有提升。
This commit is contained in:
2022-11-26 10:17:25 +08:00
parent 56edd8ac77
commit 7e1c4dd245
4 changed files with 177 additions and 167 deletions

View File

@@ -6,10 +6,7 @@ use tokio::sync::Mutex;
use crate::picker::screen::Screen;
use super::{
led_color::LedColor,
screenshot::{Screenshot},
};
use super::{led_color::LedColor, screenshot::Screenshot};
pub struct Picker {
pub screens: Arc<Mutex<Vec<Screen>>>,

View File

@@ -53,11 +53,11 @@ impl Screenshot {
match bitmap.as_ref() {
Some(bitmap) => {
let cell_size_x = self.width / self.led_number_of_x;
let cell_size_y = self.height / 5;
let cell_size_y = self.height / 8;
let cell_size = cell_size_x * cell_size_y;
let y_range = match position {
XPosition::Top => 0..cell_size_y,
XPosition::Bottom => self.height - cell_size_y..self.height,
XPosition::Top => 20..cell_size_y + 20,
XPosition::Bottom => self.height - 20 - cell_size_y..self.height - 20,
};
let mut colors = Vec::new();