From 9c46438c36069783063e162874509be7ff5101a7 Mon Sep 17 00:00:00 2001 From: John Hoar Date: Mon, 2 Apr 2018 09:25:18 +0200 Subject: [PATCH] #15 Fix lights --- Makefile | 2 +- src/Progress.cpp | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7030830..91d2331 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SLUG = AmalgamatedHarmonics # Must follow the format in the Versioning section of https://vcvrack.com/manual/PluginDevelopmentTutorial.html -VERSION = 0.6.0 +VERSION = 0.6.1 # FLAGS will be passed to both the C and C++ compiler FLAGS += diff --git a/src/Progress.cpp b/src/Progress.cpp index 1f7175a..5dde8fa 100644 --- a/src/Progress.cpp +++ b/src/Progress.cpp @@ -39,7 +39,7 @@ struct Progress : AHModule { RUNNING_LIGHT, RESET_LIGHT, GATES_LIGHT, - ENUMS(GATE_LIGHTS,8), + ENUMS(GATE_LIGHTS,16), NUM_LIGHTS }; @@ -396,8 +396,30 @@ void Progress::step() { gateOn = gateOn && !pulse; } - outputs[GATE_OUTPUT + i].value = gateOn ? 10.0f : 0.0f; - lights[GATE_LIGHTS + i].setBrightnessSmooth((pulse && i == index) ? (gates[i] ? 1.f : 0.33) : (gates[i] ? 0.66 : 0.0)); + outputs[GATE_OUTPUT + i].value = gateOn ? 10.0f : 0.0f; + + if (gateOn && i == index) { + if (gates[i]) { + // Gate is on and active = flash green + lights[GATE_LIGHTS + i * 2].setBrightnessSmooth(1.0f); + lights[GATE_LIGHTS + i * 2 + 1].setBrightnessSmooth(0.0f); + } else { + // Gate is off and active = flash red - this seems to not have any effect :( + lights[GATE_LIGHTS + i * 2].setBrightnessSmooth(0.0); + lights[GATE_LIGHTS + i * 2 + 1].setBrightnessSmooth(0.33f); + } + } else { + if (gates[i]) { + // Gate is on and not active = red + lights[GATE_LIGHTS + i * 2].setBrightnessSmooth(0.0f); + lights[GATE_LIGHTS + i * 2 + 1].setBrightnessSmooth(1.0f); + } else { + // Gate is off and not active = black + lights[GATE_LIGHTS + i * 2].setBrightnessSmooth(0.0f); + lights[GATE_LIGHTS + i * 2 + 1].setBrightnessSmooth(0.0f); + } + } + } bool gatesOn = (running && gates[index]); @@ -490,7 +512,8 @@ ProgressWidget::ProgressWidget(Progress *module) : ModuleWidget(module) { addParam(invW); addParam(ParamWidget::create(ui.getPosition(UI::BUTTON, i + 1, 7, true, true), module, Progress::GATE_PARAM + i, 0.0, 1.0, 0.0)); - addChild(ModuleLightWidget::create>(ui.getPosition(UI::LIGHT, i + 1, 7, true, true), module, Progress::GATE_LIGHTS + i)); + addChild(ModuleLightWidget::create>(ui.getPosition(UI::LIGHT, i + 1, 7, true, true), module, Progress::GATE_LIGHTS + i * 2)); + addOutput(Port::create(ui.getPosition(UI::PORT, i + 1, 5, true, false), Port::OUTPUT, module, Progress::GATE_OUTPUT + i)); }