mirror of
https://github.com/4yn/slidershim.git
synced 2024-11-13 17:31:00 +01:00
rainbow reactive
This commit is contained in:
parent
d02990d5fc
commit
35da7d4874
@ -4,6 +4,7 @@ use serde_json::Value;
|
|||||||
pub enum ReactiveLayout {
|
pub enum ReactiveLayout {
|
||||||
Even { splits: usize },
|
Even { splits: usize },
|
||||||
Voltex,
|
Voltex,
|
||||||
|
Rainbow,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -39,6 +40,10 @@ impl LightsMode {
|
|||||||
layout: ReactiveLayout::Even { splits: 16 },
|
layout: ReactiveLayout::Even { splits: 16 },
|
||||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||||
},
|
},
|
||||||
|
"reactive-rainbow" => LightsMode::Reactive {
|
||||||
|
layout: ReactiveLayout::Rainbow,
|
||||||
|
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||||
|
},
|
||||||
"reactive-voltex" => LightsMode::Reactive {
|
"reactive-voltex" => LightsMode::Reactive {
|
||||||
layout: ReactiveLayout::Voltex,
|
layout: ReactiveLayout::Voltex,
|
||||||
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
sensitivity: u8::try_from(v["ledSensitivity"].as_i64()?).ok()?,
|
||||||
|
@ -114,6 +114,35 @@ impl LightsJob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ReactiveLayout::Rainbow => {
|
||||||
|
let banks: Vec<bool> = flat_input
|
||||||
|
.chunks(2)
|
||||||
|
.take(16)
|
||||||
|
.map(|x| x.contains(&true))
|
||||||
|
.collect();
|
||||||
|
let theta = self
|
||||||
|
.started
|
||||||
|
.elapsed()
|
||||||
|
.div_duration_f64(Duration::from_secs(4))
|
||||||
|
% 1.0;
|
||||||
|
for idx in 0..31 {
|
||||||
|
let slice_theta = (&theta + (idx as f64) / 32.0) % 1.0;
|
||||||
|
let color = Srgb::from_color(Hsv::new(
|
||||||
|
slice_theta * 360.0,
|
||||||
|
match idx % 2 {
|
||||||
|
0 => match banks[idx / 2] {
|
||||||
|
true => 0.2,
|
||||||
|
false => 1.0,
|
||||||
|
},
|
||||||
|
1 => 1.0,
|
||||||
|
_ => unreachable!(),
|
||||||
|
},
|
||||||
|
1.0,
|
||||||
|
))
|
||||||
|
.into_format::<u8>();
|
||||||
|
lights.paint(idx, &[color.red, color.green, color.blue]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LightsMode::Attract => {
|
LightsMode::Attract => {
|
||||||
|
@ -328,6 +328,7 @@
|
|||||||
<option value="reactive-4">Reactive, 4-Zone</option>
|
<option value="reactive-4">Reactive, 4-Zone</option>
|
||||||
<option value="reactive-8">Reactive, 8-Zone</option>
|
<option value="reactive-8">Reactive, 8-Zone</option>
|
||||||
<option value="reactive-16">Reactive, 16-Zone</option>
|
<option value="reactive-16">Reactive, 16-Zone</option>
|
||||||
|
<option value="reactive-rainbow">Reactive, 16-Zone Rainbow</option>
|
||||||
<option value="reactive-voltex">Reactive, Voltex Layout</option>
|
<option value="reactive-voltex">Reactive, Voltex Layout</option>
|
||||||
<option value="attract">Rainbow Attract Mode</option>
|
<option value="attract">Rainbow Attract Mode</option>
|
||||||
<!-- <option value="websocket">Websocket</option> -->
|
<!-- <option value="websocket">Websocket</option> -->
|
||||||
|
Loading…
Reference in New Issue
Block a user