feat: 配置结构调整和初步灯条配置界面。
This commit is contained in:
@ -1,5 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||
pub struct LedStripConfigOfBorders {
|
||||
pub top: Option<LedStripConfig>,
|
||||
pub bottom: Option<LedStripConfig>,
|
||||
pub left: Option<LedStripConfig>,
|
||||
pub right: Option<LedStripConfig>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||
pub struct LedStripConfig {
|
||||
pub index: usize,
|
||||
@ -13,23 +21,33 @@ pub struct DisplayConfig {
|
||||
pub index_of_display: usize,
|
||||
pub display_width: usize,
|
||||
pub display_height: usize,
|
||||
pub top_led_strip: Option<LedStripConfig>,
|
||||
pub bottom_led_strip: Option<LedStripConfig>,
|
||||
pub left_led_strip: Option<LedStripConfig>,
|
||||
pub right_led_strip: Option<LedStripConfig>,
|
||||
pub led_strip_of_borders: LedStripConfigOfBorders,
|
||||
}
|
||||
|
||||
impl LedStripConfigOfBorders {
|
||||
pub fn default() -> Self {
|
||||
Self {
|
||||
top: None,
|
||||
bottom: None,
|
||||
left: None,
|
||||
right: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DisplayConfig {
|
||||
pub fn default(id: usize, index_of_display: usize, display_width: usize, display_height: usize) -> Self {
|
||||
pub fn default(
|
||||
id: usize,
|
||||
index_of_display: usize,
|
||||
display_width: usize,
|
||||
display_height: usize,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
index_of_display,
|
||||
display_width,
|
||||
display_height,
|
||||
top_led_strip: None,
|
||||
bottom_led_strip: None,
|
||||
left_led_strip: None,
|
||||
right_led_strip: None,
|
||||
led_strip_of_borders: LedStripConfigOfBorders::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ impl Screenshot {
|
||||
}
|
||||
|
||||
fn get_sample_points(config: DisplayConfig) -> ScreenSamplePoints {
|
||||
let top = match config.top_led_strip {
|
||||
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,
|
||||
@ -48,7 +48,7 @@ impl Screenshot {
|
||||
}
|
||||
};
|
||||
|
||||
let bottom: Vec<LedSamplePoints> = match config.bottom_led_strip {
|
||||
let bottom: Vec<LedSamplePoints> = match config.led_strip_of_borders.bottom {
|
||||
Some(led_strip_config) => {
|
||||
let points = Self::get_one_edge_sample_points(
|
||||
config.display_height / 9,
|
||||
@ -73,7 +73,7 @@ impl Screenshot {
|
||||
}
|
||||
};
|
||||
|
||||
let left: Vec<LedSamplePoints> = match config.left_led_strip {
|
||||
let left: Vec<LedSamplePoints> = match config.led_strip_of_borders.left {
|
||||
Some(led_strip_config) => {
|
||||
let points = Self::get_one_edge_sample_points(
|
||||
config.display_width / 16,
|
||||
@ -95,7 +95,7 @@ impl Screenshot {
|
||||
}
|
||||
};
|
||||
|
||||
let right: Vec<LedSamplePoints> = match config.right_led_strip {
|
||||
let right: Vec<LedSamplePoints> = match config.led_strip_of_borders.right {
|
||||
Some(led_strip_config) => {
|
||||
let points = Self::get_one_edge_sample_points(
|
||||
config.display_width / 16,
|
||||
@ -217,13 +217,13 @@ impl Screenshot {
|
||||
|
||||
pub fn get_top_of_led_start_at(&self) -> usize {
|
||||
self.config
|
||||
.top_led_strip
|
||||
.led_strip_of_borders.top
|
||||
.and_then(|c| Some(c.global_start_position))
|
||||
.unwrap_or(0)
|
||||
}
|
||||
pub fn get_top_of_led_end_at(&self) -> usize {
|
||||
self.config
|
||||
.top_led_strip
|
||||
.led_strip_of_borders.top
|
||||
.and_then(|c| Some(c.global_end_position))
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user