From 2e4da28a516c44c772b417f18e28cb4a555b9c42 Mon Sep 17 00:00:00 2001 From: CV funk Date: Thu, 28 Mar 2024 14:17:44 +0100 Subject: [PATCH] Reset Button Refinement Refined the action of reset button and inputs so that they only trigger once per gate. --- src/Magnets.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Magnets.cpp b/src/Magnets.cpp index fbdb48f..2ad1955 100644 --- a/src/Magnets.cpp +++ b/src/Magnets.cpp @@ -58,6 +58,8 @@ struct Magnets : Module { // Initialize variables for trigger detection dsp::SchmittTrigger Reset; + dsp::SchmittTrigger ResetBut; + float resetCount=0; float head = 0.0f; @@ -146,7 +148,7 @@ struct Magnets : Module { polarization = 0.5f * polarization + 0.5f; interactionStrength = clamp(interactionStrength, 0.f, 1.f); - if ( Reset.process( inputs[RESET_INPUT].getVoltage() ) || params[RESET_BUTTON].getValue() > 0.5f ) { + if ( Reset.process( inputs[RESET_INPUT].getVoltage() ) || ResetBut.process(params[RESET_BUTTON].getValue()) ) { resetSpinStates(polarization); }