Fix cava
This commit is contained in:
parent
9abeb4492a
commit
c89ca20295
@ -27,7 +27,6 @@ impl Cava {
|
||||
let mut cava_process = Command::new("cava")
|
||||
.arg("-p")
|
||||
.arg(config_file)
|
||||
// .stdin(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()
|
||||
|
@ -12,12 +12,14 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct VisualizerParams {
|
||||
pub from_color: Rgb,
|
||||
pub color: Rgb,
|
||||
}
|
||||
|
||||
impl Default for VisualizerParams {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
from_color: color::BLACK,
|
||||
color: color::WHITE,
|
||||
}
|
||||
}
|
||||
@ -25,12 +27,17 @@ impl Default for VisualizerParams {
|
||||
|
||||
impl FormRender for VisualizerParams {
|
||||
fn render(&self) -> String {
|
||||
self.color.render("color", None)
|
||||
[
|
||||
self.color.render("from_color", None),
|
||||
self.color.render("color", None),
|
||||
]
|
||||
.concat()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Visualizer {
|
||||
from_color: Rgb,
|
||||
color: Rgb,
|
||||
lights_buf: VecDeque<Rgb>,
|
||||
cava: Option<Cava>,
|
||||
@ -46,6 +53,7 @@ impl Visualizer {
|
||||
pub fn new(params: &VisualizerParams) -> Self {
|
||||
Self {
|
||||
color: params.color,
|
||||
from_color: params.from_color,
|
||||
lights_buf: VecDeque::new(),
|
||||
cava: None,
|
||||
}
|
||||
@ -58,7 +66,7 @@ impl Pattern for Visualizer {
|
||||
let reading = c
|
||||
.get_latest_reading()
|
||||
.into_iter()
|
||||
.map(|b| color::BLACK.fade_to(self.color, b))
|
||||
.map(|b| self.from_color.fade_to(self.color, b))
|
||||
.collect();
|
||||
|
||||
let changed = self.lights_buf != reading;
|
||||
@ -76,7 +84,7 @@ impl Pattern for Visualizer {
|
||||
return Err(PatternError::LightCount);
|
||||
}
|
||||
|
||||
self.cava = Some(Cava::new(num_lights)?);
|
||||
self.cava = Some(Cava::new(num_lights * 2)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -64,10 +64,6 @@ fn parse_cmd(strip_tx: &Sender<strip::Message>, s: &str) -> Result<(), String> {
|
||||
let color = parse_color(r, g, b)?;
|
||||
change_pattern(strip_tx, Box::new(pattern::Solid::new(&pattern::SolidParams {color})))
|
||||
}
|
||||
["visualizer", c] => {
|
||||
let color = parse_color(c,c,c)?;
|
||||
change_pattern(strip_tx, Box::new(pattern::Visualizer::new(&pattern::VisualizerParams { color })))
|
||||
}
|
||||
["c", c] => {
|
||||
let color = parse_color(c, c, c)?;
|
||||
change_pattern(strip_tx, Box::new(pattern::Solid::new(&pattern::SolidParams {color})))
|
||||
|
Loading…
Reference in New Issue
Block a user