computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit e6aed00ee02f28fbfb440394067053e109f67858
parent 3a88f881c6c669e739397ecc4a8d9fd1c3accf54
Author: Adam M <[email protected]>
Date:   Mon, 12 Nov 2018 22:55:23 -0600

i think it works now

Diffstat:
Mres/ComputerscareILoveCookiesPanel.svg | 18+++++++++---------
Mres/computerscare-medium-knob-effed.svg | 18+++++++++---------
Msrc/ComputerscareILoveCookies.cpp | 93++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
3 files changed, 72 insertions(+), 57 deletions(-)

diff --git a/res/ComputerscareILoveCookiesPanel.svg b/res/ComputerscareILoveCookiesPanel.svg @@ -9,9 +9,9 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="240" + width="320" height="380" - viewBox="0 0 63.500003 100.54167" + viewBox="0 0 84.666671 100.54167" version="1.1" id="svg8" inkscape:version="0.92.2 5c3e80d, 2017-08-06" @@ -34,9 +34,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="8.0000002" - inkscape:cx="58.004184" - inkscape:cy="334.11196" + inkscape:zoom="1.4142136" + inkscape:cx="121.43564" + inkscape:cy="192.36446" inkscape:document-units="mm" inkscape:current-layer="g1669" showgrid="false" @@ -74,11 +74,11 @@ <path inkscape:connector-curvature="0" id="path1647" - d="M 0,196.45832 H 63.5 V 297 H 0 Z" - style="opacity:1;vector-effect:none;fill:#f9f9f9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.79375011;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" /> + d="M 0,196.45832 H 84.666667 V 297 H 0 Z" + style="opacity:1;vector-effect:none;fill:#f9f9f9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.91654366;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" /> <g aria-label="computerscare" - transform="matrix(0.98656289,0.0441007,-0.12576361,1.0079983,61.743995,-2.779225)" + transform="matrix(0.98656289,0.0441007,-0.12576361,1.0079983,81.852341,-2.779225)" style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332" id="text1651"> <path @@ -356,7 +356,7 @@ id="text1057" /> <g id="g8072" - transform="matrix(0.26889251,-0.01002392,-0.03200614,0.19788514,21.794004,292.24297)"> + transform="matrix(0.26889251,-0.01002392,-0.03200614,0.19788514,41.90235,292.24297)"> <g style="display:inline" inkscape:label="Layer 1" diff --git a/res/computerscare-medium-knob-effed.svg b/res/computerscare-medium-knob-effed.svg @@ -9,12 +9,12 @@ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" id="Layer_1" data-name="Layer 1" - viewBox="0 0 28 28" + viewBox="0 0 25 25" version="1.1" sodipodi:docname="computerscare-medium-knob-effed.svg" inkscape:version="0.92.2 5c3e80d, 2017-08-06" - width="28" - height="28"> + width="25" + height="25"> <metadata id="metadata1289"> <rdf:RDF> @@ -41,7 +41,7 @@ id="namedview1287" showgrid="false" inkscape:zoom="15.733333" - inkscape:cx="10.260513" + inkscape:cx="11.595259" inkscape:cy="14.442801" inkscape:window-x="0" inkscape:window-y="0" @@ -57,16 +57,16 @@ <g id="Big_Knob" data-name="Big Knob" - transform="translate(0,-32)"> + transform="translate(0,-35)"> <path - style="fill:#245559;stroke:#000000;stroke-width:0.44949234;stroke-opacity:1" - d="M 27.281965,45.86697 C 28.119596,55.806861 21.656355,60.098038 14.240308,59.415042 7.4209214,58.786996 -1.0884456,53.018905 0.75553789,45.930272 3.2325316,36.408223 8.7500225,31.88879 14.240308,32.445502 c 4.113807,0.417138 6.056174,1.699822 10.081252,4.298793 2.501437,1.615165 2.727415,6.357859 2.960405,9.122675 z" + style="fill:#245559;stroke:#000000;stroke-width:0.40182629;stroke-opacity:1" + d="M 24.481712,47.462047 C 25.230517,56.347871 19.452665,60.183994 12.823046,59.573425 6.7268169,59.011979 -0.88018101,53.855561 0.76825872,47.518636 2.9825816,39.006345 7.9149746,34.966172 12.823046,35.463848 c 3.677562,0.372903 5.413953,1.519566 9.012194,3.842931 2.236175,1.443886 2.438189,5.683646 2.646472,8.155268 z" id="Big_Button_Circle" inkscape:connector-curvature="0" sodipodi:nodetypes="ssssss" /> <path - style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#24c9a6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.27979493;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="m 14.045118,33.007491 c -0.901212,0.624222 -0.773465,3.36645 -0.773465,3.36645 l -0.45534,0.901175 -0.521089,0.915953 -0.04079,1.126303 0.828056,0.854017 -0.422931,0.983799 -0.574795,3.113605 c 1.538999,-0.310021 1.553591,-0.964526 4.197441,-0.729889 l -0.92262,-1.792916 -0.477568,-1.469672 -0.03868,-1.440186 0.304744,-0.623519 0.04412,-0.777177 -0.257525,-4.62905 c -0.733272,-0.06419 -0.832689,-0.08062 -0.838748,0.02061 -0.0042,0.06712 0,0 -0.05072,0.180496 0,0 -0.07689,0.06066 -0.09712,0.03956 -0.02032,-0.02109 0.09704,-0.03956 0.09704,-0.03956 z" + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#24c9a6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.25012431;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 12.648556,35.966241 c -0.805644,0.558027 -0.691444,3.009458 -0.691444,3.009458 l -0.407053,0.80561 -0.465831,0.818822 -0.03646,1.006865 0.740245,0.763454 -0.378082,0.879472 -0.51384,2.783426 c 1.375796,-0.277146 1.388841,-0.862244 3.752326,-0.652488 l -0.824782,-1.602788 -0.426925,-1.313821 -0.03457,-1.287464 0.272428,-0.557398 0.03944,-0.694762 -0.230216,-4.138167 c -0.655513,-0.05738 -0.744387,-0.07207 -0.749803,0.01842 -0.0038,0.06 0,0 -0.04534,0.161355 0,0 -0.06874,0.05423 -0.08683,0.03536 -0.01817,-0.01885 0.08676,-0.03536 0.08676,-0.03536 z" id="Button_Pointer" inkscape:connector-curvature="0" sodipodi:nodetypes="cccccccccccccccscacc" /> diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp @@ -11,12 +11,15 @@ struct ComputerscareILoveCookies; const int numFields = 3; -const int numKnobRows = 5; -const int numKnobColumns = 5; +const int numKnobRows = 13; +const int numKnobColumns = 2; const int numInputRows = 13; const int numInputColumns = 2; -const std::string knoblookup = "abcdefghijklmnopqrstuvwxy"; +const int numKnobs = numKnobRows * numKnobColumns; +const int numInputs = numInputRows * numInputColumns; + +const std::string knoblookup = "abcdefghijklmnopqrstuvwxyz"; const std::string inputlookup= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const std::string knobandinputlookup = knoblookup + inputlookup; const std::vector<NVGcolor> outlineColorMap = {COLOR_COMPUTERSCARE_RED,COLOR_COMPUTERSCARE_YELLOW,COLOR_COMPUTERSCARE_BLUE}; @@ -75,7 +78,7 @@ private: struct ComputerscareILoveCookies : Module { enum ParamIds { KNOB_PARAM, - NUM_PARAMS = KNOB_PARAM + numKnobRows * numKnobColumns + NUM_PARAMS = KNOB_PARAM + numKnobs }; enum InputIds { GLOBAL_CLOCK_INPUT, @@ -83,7 +86,7 @@ struct ComputerscareILoveCookies : Module { CLOCK_INPUT, RESET_INPUT = CLOCK_INPUT + numFields, SIGNAL_INPUT = RESET_INPUT + numFields , - NUM_INPUTS = RESET_INPUT+ numInputRows * numInputColumns + NUM_INPUTS = RESET_INPUT+ numInputs }; enum OutputIds { TRG_OUTPUT, @@ -92,7 +95,7 @@ struct ComputerscareILoveCookies : Module { }; enum LightIds { SWITCH_LIGHTS, - NUM_LIGHTS = SWITCH_LIGHTS + numKnobRows * numKnobColumns * numFields + NUM_LIGHTS = SWITCH_LIGHTS + (numKnobs + numInputs)*numFields }; SchmittTrigger globalClockTrigger; @@ -109,8 +112,12 @@ struct ComputerscareILoveCookies : Module { bool shouldChange[numFields] = {false}; int absoluteStep[numFields] = {0}; + int activeKnobIndex[numFields] = {0}; int numSteps[numFields] = {0}; - + + // SmallLetterDisplay* smallLetterDisplays[numKnobs + numInputs]; + + ComputerscareILoveCookies() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} void step() override; @@ -245,7 +252,6 @@ void ComputerscareILoveCookies::step() { bool globalGateIn = globalClockTrigger.isHigh(); bool activeStep = 0; - int activeKnob = 0; bool atFirstStep = false; bool clocked = globalClockTrigger.process(inputs[GLOBAL_CLOCK_INPUT].value); bool currentTriggerIsHigh; @@ -288,20 +294,22 @@ void ComputerscareILoveCookies::step() { } } - activeKnob = absoluteSequences[i][this->absoluteStep[i]]; + activeKnobIndex[i] = absoluteSequences[i][this->absoluteStep[i]]; atFirstStep = (this->absoluteStep[i] == 0); - for(int k = 0; k < numKnobRows * numKnobColumns; k++) { - lights[SWITCH_LIGHTS + i*numKnobRows*numKnobColumns + k].value = (k==activeKnob) ? 1.0 : 0.0; + for(int k = 0; k < (numKnobs + numInputs); k++) { + //params[SIGNAL_INPUT + k].backgroundColor = (k==2) ? COLOR_COMPUTERSCARE_LIGHT_GREEN : COLOR_COMPUTERSCARE_TRANSPARENT; + // lights[SWITCH_LIGHTS + i].value = (k==activeKnob) ? 1.0 : 0.0; + //currentActives[] } } //outputs[TRG_OUTPUT + i].value = params[KNOB_PARAM + activeKnob].value; - if(activeKnob < 25) { - knobRawValue = params[SIGNAL_INPUT + activeKnob].value; + if(activeKnobIndex[i] < 25) { + knobRawValue = params[SIGNAL_INPUT + activeKnobIndex[i]].value; } else { - knobRawValue = inputs[SIGNAL_INPUT + activeKnob - 25].value; + knobRawValue = inputs[SIGNAL_INPUT + activeKnobIndex[i] - 25].value; } outputs[TRG_OUTPUT + i].value = mapKnobValue(knobRawValue,i); @@ -320,6 +328,7 @@ struct NumberDisplayWidget3cookie : TransparentWidget { int *value; std::shared_ptr<Font> font; NVGcolor outlineColor; + //NVGcolor circleColor; NumberDisplayWidget3cookie() { font = Font::load(assetPlugin(plugin, "res/digital-7.ttf")); @@ -336,7 +345,7 @@ struct NumberDisplayWidget3cookie : TransparentWidget { nvgFill(vg); nvgBeginPath(vg); - nvgRoundedRect(vg, 0.0, 0.0, box.size.x, box.size.y, 4.0); + nvgRoundedRect(vg, 0.0, 0.0, box.size.x, box.size.y, 8.0); nvgFillColor(vg, backgroundColor); nvgFill(vg); @@ -397,14 +406,15 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { double verticalSpacing = 18.4; int verticalStart = 80; - double xStart = 16; + double xStart = 41; int index=0; + int inputindex=0; double knobPosX=0.0; double knobPosY=0.0; - double knobXStart = 3+xStart; - double knobYStart = 16; - double knobRowWidth = 13; - double knobColumnHeight = 10; + double knobXStart = 20; + double knobYStart = 2; + double knobRowWidth = 11; + double knobColumnHeight = 9.2; double inputPosX = 0.0; double inputPosY = 0.0; @@ -412,6 +422,9 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { double inputYStart = 0; double inputRowWidth = 8; double inputColumnHeight = 9.7; + + //SmallLetterDisplay smallLetterDisplays[numKnobs + numInputs]; + ComputerscareILoveCookiesWidget(ComputerscareILoveCookies *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/ComputerscareILoveCookiesPanel.svg"))); @@ -419,20 +432,20 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { for(int i = 0; i < numKnobRows; i++) { for(int j = 0; j < numKnobColumns; j++) { knobPosX = knobXStart + j*knobRowWidth; - knobPosY = knobYStart + i*knobColumnHeight; + knobPosY = knobYStart + i*knobColumnHeight + j*2.0; index = numKnobColumns*i + j; - addChild(ModuleLightWidget::create<ComputerscareMediumLight<ComputerscareRedLight>>(mm2px(Vec(knobPosX-3, knobPosY - 2)), module, ComputerscareILoveCookies::SWITCH_LIGHTS + index)); - addChild(ModuleLightWidget::create<ComputerscareMediumLight<ComputerscareYellowLight>>(mm2px(Vec(knobPosX-3, knobPosY )), module, ComputerscareILoveCookies::SWITCH_LIGHTS + index + numKnobColumns*numKnobRows)); - addChild(ModuleLightWidget::create<ComputerscareMediumLight<ComputerscareBlueLight>>(mm2px(Vec(knobPosX-3, knobPosY +2)), module, ComputerscareILoveCookies::SWITCH_LIGHTS + index + numKnobColumns*numKnobRows*2)); - - SmallLetterDisplay *letterDisplay = new SmallLetterDisplay(); - letterDisplay->box.pos = mm2px(Vec(knobPosX-3,knobPosY-2)); - letterDisplay->box.size = Vec(20, 20); - letterDisplay->value = knoblookup[index]; + // addChild(ModuleLightWidget::create<ComputerscareMediumLight<ComputerscareRedLight>>(mm2px(Vec(knobPosX-3, knobPosY - 2)), module, ComputerscareILoveCookies::SWITCH_LIGHTS + index)); + //addChild(ModuleLightWidget::create<ComputerscareMediumLight<ComputerscareYellowLight>>(mm2px(Vec(knobPosX-3, knobPosY )), module, ComputerscareILoveCookies::SWITCH_LIGHTS + index + numKnobColumns*numKnobRows)); + //addChild(ModuleLightWidget::create<ComputerscareMediumLight<ComputerscareBlueLight>>(mm2px(Vec(knobPosX-3, knobPosY +2)), module, ComputerscareILoveCookies::SWITCH_LIGHTS + index + numKnobColumns*numKnobRows*2)); - addChild(letterDisplay); + smallLetterDisplay = new SmallLetterDisplay(); + smallLetterDisplay->box.pos = mm2px(Vec(knobPosX+6,knobPosY-2)); + smallLetterDisplay->box.size = Vec(20, 20); + smallLetterDisplay->value = knoblookup[index]; + addChild(smallLetterDisplay); + //smallLetterDisplays.push_back(letterDisplay); ParamWidget* knob = ParamWidget::create<SmoothKnob>(mm2px(Vec(knobPosX,knobPosY)), module, ComputerscareILoveCookies::KNOB_PARAM +index, 0.f, 10.0f, 0.0f); @@ -446,21 +459,21 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { for(int m=0; m<numInputColumns; m++) { inputPosX = inputXStart + m*inputRowWidth; inputPosY = inputYStart + k*inputColumnHeight + m * 2.0; - index = numInputColumns*k + m; + inputindex = numInputColumns*k + m; if(m%2) { - addInput(Port::create<InPort>(mm2px(Vec(inputPosX , inputPosY)), Port::INPUT, module, ComputerscareILoveCookies::SIGNAL_INPUT + index)); + addInput(Port::create<InPort>(mm2px(Vec(inputPosX , inputPosY)), Port::INPUT, module, ComputerscareILoveCookies::SIGNAL_INPUT + inputindex)); } else { - addInput(Port::create<PointingUpPentagonPort>(mm2px(Vec(inputPosX , inputPosY)), Port::INPUT, module, ComputerscareILoveCookies::SIGNAL_INPUT + index)); + addInput(Port::create<PointingUpPentagonPort>(mm2px(Vec(inputPosX , inputPosY)), Port::INPUT, module, ComputerscareILoveCookies::SIGNAL_INPUT + inputindex)); } - SmallLetterDisplay *letterDisplay = new SmallLetterDisplay(); - letterDisplay->box.pos = mm2px(Vec(inputPosX-1,inputPosY)); - letterDisplay->box.size = Vec(20, 20); - letterDisplay->value = inputlookup[index]; - - addChild(letterDisplay); + smallLetterDisplay = new SmallLetterDisplay(); + smallLetterDisplay->box.pos = mm2px(Vec(inputPosX+6,inputPosY-1)); + smallLetterDisplay->box.size = Vec(20, 20); + smallLetterDisplay->value = inputlookup[inputindex]; + addChild(smallLetterDisplay); + //module->smallLetterDisplays[i] = smallLetterDisplay; } } @@ -510,6 +523,8 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { module->onCreate(); } MyTextFieldCookie* textField; + SmallLetterDisplay* smallLetterDisplay; + }; Model *modelComputerscareILoveCookies = Model::create<ComputerscareILoveCookies, ComputerscareILoveCookiesWidget>("computerscare", "computerscare-i-love-cookies", "I Love Cookies", SEQUENCER_TAG);