Skip to content

Commit

Permalink
Move I/O operations outside the instrument lock
Browse files Browse the repository at this point in the history
With this patch, operating of GPIO is handled only once the intrument
lock is released. Thanks to that, all operations done with the lock are
purely internal and should not block the DSP thread.

Signed-off-by: Petr Horacek <[email protected]>
  • Loading branch information
phoracek committed Feb 5, 2022
1 parent 68dc35a commit 881e051
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions eurorack/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,28 @@ const APP: () = {

controls.update();

let mut calibration_action = None;
let mut any_actions = None;
let mut pot_actions = None;
let mut chord_degrees = None;

cx.resources.instrument.lock(|instrument| {
let instrument = instrument.as_mut().unwrap();

let calibration_action = reconcile_calibration(controls);
let any_actions = reconcile_all_changes(controls, instrument);
let pot_actions = reconcile_pot_activity(controls, instrument);

if let Some(display_action) = activity.reconcile(
calibration_action,
pot_actions,
any_actions,
DisplayAction::SetChord(instrument.chord_degrees()),
) {
display.set(display_lib::reduce(display_action));
};
calibration_action = Some(reconcile_calibration(controls));
any_actions = Some(reconcile_all_changes(controls, instrument));
pot_actions = Some(reconcile_pot_activity(controls, instrument));
chord_degrees = Some(instrument.chord_degrees());
});

if let Some(display_action) = activity.reconcile(
calibration_action.unwrap(),
pot_actions.unwrap(),
any_actions.unwrap(),
DisplayAction::SetChord(chord_degrees.unwrap()),
) {
display.set(display_lib::reduce(display_action));
};

cx.schedule
.reconcile_controls(Instant::now() + CV_PERIOD.cycles())
.unwrap();
Expand Down

0 comments on commit 881e051

Please sign in to comment.