feature/gui-configuration:支持从 GUI 配置程序。 #4
@ -150,26 +150,34 @@ impl CoreManager {
|
|||||||
] {
|
] {
|
||||||
match config {
|
match config {
|
||||||
Some(config) => {
|
Some(config) => {
|
||||||
let (sign, start) = if config.global_start_position <= config.global_end_position
|
let (sign, start) =
|
||||||
{
|
if config.global_start_position <= config.global_end_position {
|
||||||
(1, config.global_start_position as isize * 3)
|
(1, config.global_start_position as isize * 3)
|
||||||
} else {
|
} else {
|
||||||
(-1, (config.global_start_position as isize + 1) * 3 - 1)
|
(-1, (config.global_start_position as isize + 1) * 3 - 1)
|
||||||
};
|
};
|
||||||
for (index, color) in colors.into_iter().enumerate() {
|
for (index, color) in colors.into_iter().enumerate() {
|
||||||
global_sub_pixels
|
let pixel_index = index / 3;
|
||||||
.insert((sign * index as isize + start) as usize, color);
|
let sub_pixel_index = index % 3;
|
||||||
|
let offset = if sign < 0 {
|
||||||
|
2 - sub_pixel_index
|
||||||
|
} else {
|
||||||
|
sub_pixel_index
|
||||||
|
};
|
||||||
|
let global_sub_pixel_index =
|
||||||
|
(sign * (pixel_index as isize * 3 + offset as isize) + start ) as usize;
|
||||||
|
global_sub_pixels.insert(global_sub_pixel_index, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!(
|
// info!(
|
||||||
"led count: {}, spend: {:?}",
|
// "led count: {}, spend: {:?}",
|
||||||
global_sub_pixels.len(),
|
// global_sub_pixels.len(),
|
||||||
start_at.elapsed()
|
// start_at.elapsed()
|
||||||
);
|
// );
|
||||||
|
|
||||||
if global_sub_pixels.len() >= total_colors_count * 3 {
|
if global_sub_pixels.len() >= total_colors_count * 3 {
|
||||||
let mut colors = vec![];
|
let mut colors = vec![];
|
||||||
|
Loading…
Reference in New Issue
Block a user