Skip to content

Commit

Permalink
Merge pull request #201 from quartiq/trigger-unit
Browse files Browse the repository at this point in the history
sweep: redo trigger
  • Loading branch information
jordens authored Feb 5, 2025
2 parents 2498f2a + 12e1fbe commit 92a5d99
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/output_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ pub struct OutputChannel {

#[derive(Clone, Debug, Tree)]
pub struct SineSweep {
#[tree(skip)]
sweep: Take<AccuOsc<Sweep>>,
rate: Leaf<i32>,
state: Leaf<i64>,
length: Leaf<usize>,
amp: Leaf<f32>,
#[tree(validate=self.trigger)]
trigger: Leaf<bool>,
/// Trigger both signal sources
#[tree(validate=self.validate_trigger)]
trigger: Leaf<()>,
#[tree(skip)]
sweep: Take<AccuOsc<Sweep>>,
}

impl Default for SineSweep {
Expand All @@ -85,7 +86,7 @@ impl Default for SineSweep {
state: Leaf(0),
length: Leaf(0),
amp: Leaf(0.0),
trigger: Leaf(false),
trigger: Leaf(()),
}
}
}
Expand All @@ -101,9 +102,8 @@ impl Iterator for SineSweep {
}

impl SineSweep {
fn trigger(&mut self, depth: usize) -> Result<usize, &'static str> {
fn validate_trigger(&mut self, depth: usize) -> Result<usize, &'static str> {
self.sweep = AccuOsc::new(Sweep::new(*self.rate, *self.state)).take(*self.length);
self.trigger = Leaf(false);
Ok(depth)
}
}
Expand Down

0 comments on commit 92a5d99

Please sign in to comment.