From 5bf80248653d529ac358cc9f67c8ca7d7ab5d04c Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 15 Jun 2022 03:11:06 -0400 Subject: [PATCH] Logic: Process lights every 32 samples. --- src/Logic.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Logic.cpp b/src/Logic.cpp index 497af68..186f3aa 100644 --- a/src/Logic.cpp +++ b/src/Logic.cpp @@ -35,6 +35,8 @@ struct Logic : Module { LIGHTS_LEN }; + dsp::ClockDivider lightDivider; + Logic() { config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN); configButton(B_PARAM, "B"); @@ -48,6 +50,8 @@ struct Logic : Module { configOutput(NAND_OUTPUT, "NAND"); configOutput(XOR_OUTPUT, "XOR"); configOutput(XNOR_OUTPUT, "XNOR"); + + lightDivider.setDivision(32); } void process(const ProcessArgs& args) override { @@ -83,10 +87,12 @@ struct Logic : Module { } // Set lights - lights[B_BUTTON_LIGHT].setBrightness(bPush); - for (int i = 0; i < 8; i++) { - lights[NOTA_LIGHT + 2 * i + 0].setBrightness(anyState[i] && channels == 1); - lights[NOTA_LIGHT + 2 * i + 1].setBrightness(anyState[i] && channels > 1); + if (lightDivider.process()) { + lights[B_BUTTON_LIGHT].setBrightness(bPush); + for (int i = 0; i < 8; i++) { + lights[NOTA_LIGHT + 2 * i + 0].setBrightness(anyState[i] && channels == 1); + lights[NOTA_LIGHT + 2 * i + 1].setBrightness(anyState[i] && channels > 1); + } } } };