feature/gui-configuration:支持从 GUI 配置程序。 #4

Merged
Ivan merged 19 commits from feature/gui-configuration into master 2023-01-26 23:44:19 +08:00
Showing only changes of commit d3dfdb4d82 - Show all commits

View File

@ -150,26 +150,34 @@ impl CoreManager {
] {
match 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)
} else {
(-1, (config.global_start_position as isize + 1) * 3 - 1)
};
for (index, color) in colors.into_iter().enumerate() {
global_sub_pixels
.insert((sign * index as isize + start) as usize, color);
let pixel_index = index / 3;
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 => {}
}
}
info!(
"led count: {}, spend: {:?}",
global_sub_pixels.len(),
start_at.elapsed()
);
// info!(
// "led count: {}, spend: {:?}",
// global_sub_pixels.len(),
// start_at.elapsed()
// );
if global_sub_pixels.len() >= total_colors_count * 3 {
let mut colors = vec![];