commit e17f6a1eacc9b15b2c78ed7f4360b297fe14bfce
parent 3c55da2eaaae2a9d0e4e56a723b346148bb5678c
Author: Adam M <[email protected]>
Date: Fri, 21 Dec 2018 23:16:52 -0600
move small letter display to common file, integrate manual buttons for clock and reset in LaundrySoup
Diffstat:
5 files changed, 109 insertions(+), 115 deletions(-)
diff --git a/res/ComputerscareLaundrySoupPanel.svg b/res/ComputerscareLaundrySoupPanel.svg
@@ -35,7 +35,7 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="4.0000001"
- inkscape:cx="101.90912"
+ inkscape:cx="57.159121"
inkscape:cy="365.51563"
inkscape:document-units="mm"
inkscape:current-layer="text1651"
@@ -207,52 +207,6 @@
id="path939"
inkscape:connector-curvature="0" />
</g>
- <g
- aria-label="rst"
- transform="matrix(1.9119826,-0.34464307,0.50786191,1.8921039,-36.890845,-192.32161)"
- style="font-style:normal;font-weight:normal;font-size:1.90312397px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.01258837"
- id="text864">
- <path
- d="m -41.275716,202.9985 c -0.02809,-0.0143 -0.05823,-0.0258 -0.09042,-0.0344 -0.03141,-0.009 -0.06577,-0.0154 -0.10308,-0.0195 -0.132321,-0.0146 -0.228975,0.007 -0.289963,0.0641 -0.06027,0.0567 -0.08086,0.14576 -0.06177,0.26708 l 0.08886,0.56511 -0.235378,-0.026 -0.168693,-1.07274 0.235378,0.026 0.0415,0.11733 c 0.03893,-0.0598 0.08009,-0.0516 0.154062,-0.0742 0.07386,-0.0233 0.167187,-0.0287 0.27999,-0.0162 0.01617,0.002 0.03416,0.005 0.05395,0.009 0.01967,0.003 0.04168,0.008 0.06602,0.0144 z"
- style="stroke-width:0.01482364"
- id="path870"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccccccccccccc" />
- <path
- d="m -40.410807,203.11285 v 0.16169 q -0.07248,-0.0372 -0.15054,-0.0557 -0.07806,-0.0186 -0.161691,-0.0186 -0.127309,0 -0.191428,0.039 -0.06319,0.039 -0.06319,0.11709 0,0.0595 0.04553,0.0939 0.04553,0.0334 0.183064,0.0641 l 0.05854,0.013 q 0.182135,0.039 0.258334,0.11058 0.07713,0.0706 0.07713,0.19793 0,0.14497 -0.115228,0.22953 -0.114299,0.0846 -0.315019,0.0846 -0.08363,0 -0.174701,-0.0167 -0.09014,-0.0158 -0.190498,-0.0483 v -0.17656 q 0.09479,0.0493 0.186781,0.0743 0.092,0.0242 0.182135,0.0242 0.120804,0 0.185852,-0.0409 0.06505,-0.0418 0.06505,-0.11709 0,-0.0697 -0.04739,-0.10686 -0.04646,-0.0372 -0.205366,-0.0716 l -0.05947,-0.0139 q -0.158903,-0.0335 -0.229527,-0.10222 -0.07062,-0.0697 -0.07062,-0.1905 0,-0.14682 0.104077,-0.22674 0.104077,-0.0799 0.295505,-0.0799 0.09478,0 0.178418,0.0139 0.08363,0.0139 0.154257,0.0418 z"
- style="stroke-width:0.01258837"
- id="path872"
- inkscape:connector-curvature="0" />
- <path
- d="m -39.571383,202.62755 -0.03453,0.33682 0.483556,0.002 -0.03123,0.14077 -0.467876,0.008 -0.06611,0.644 c -0.0099,0.0967 -0.0042,0.15873 0.01728,0.18596 0.02211,0.0272 0.0709,0.0403 0.146369,0.0394 l 0.18607,-0.003 -0.01679,0.16312 -0.18607,0.003 c -0.139777,0.002 -0.233377,-0.0247 -0.280802,-0.0801 -0.04736,-0.0558 -0.06343,-0.15786 -0.0482,-0.30618 l 0.06611,-0.64399 -0.132895,0.002 0.01555,-0.15148 0.132895,-0.002 0.03453,-0.33681 z"
- style="stroke-width:0.0138234"
- id="path874"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccccccccccccccccc" />
- </g>
- <g
- aria-label="clk"
- transform="matrix(2.3525877,-0.10292753,0.2449229,1.9213172,39.342343,-189.28658)"
- style="font-style:normal;font-weight:normal;font-size:1.90312397px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.01258837"
- id="text868">
- <path
- d="m -47.023791,202.8756 0.02953,0.23933 c -0.06229,-0.0399 -0.123696,-0.0697 -0.184208,-0.0892 -0.05988,-0.0203 -0.119243,-0.0305 -0.178089,-0.0305 -0.13166,0 -0.227374,0.0529 -0.287143,0.15862 -0.05989,0.10481 -0.0781,0.2523 -0.05464,0.44245 0.02345,0.19016 0.07812,0.33811 0.163998,0.44386 0.08575,0.10481 0.194455,0.15721 0.326112,0.15721 0.05884,0 0.115746,-0.01 0.170717,-0.0291 0.05558,-0.0205 0.08125,0.026 0.133717,-0.0139 l 0.05753,0.16011 c -0.05251,0.0335 -0.108257,0.0585 -0.167252,0.0751 -0.05826,0.0167 -0.12159,0.025 -0.189991,0.025 -0.186089,0 -0.343029,-0.0737 -0.470822,-0.22124 -0.127791,-0.14748 -0.207137,-0.34644 -0.238039,-0.59689 -0.03136,-0.25416 -8.57e-4,-0.45405 0.09151,-0.59967 0.0931,-0.14563 0.235998,-0.21844 0.428707,-0.21844 0.06252,0 0.124597,0.008 0.18623,0.025 0.06153,0.0157 0.12224,0.0398 0.182141,0.0723 z"
- style="stroke-width:0.0167841"
- id="path877"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cccscccsccccscscsccc" />
- <path
- d="m -46.874682,202.76379 0.142911,-0.0353 0.477431,1.633 -0.142911,0.0353 z"
- style="stroke-width:0.01266381"
- id="path879"
- inkscape:connector-curvature="0" />
- <path
- d="m -45.316254,202.73781 h 0.105823 l -0.30408,0.97435 0.684115,-0.51209 0.06147,0.0849 0.0099,0.0299 -0.587562,0.44072 0.393944,0.6319 -0.370906,-0.0255 -0.220701,-0.55448 -0.180998,0.57995 h -0.176676 z"
- style="stroke-width:0.01363125"
- id="path881"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccccccccccc" />
- </g>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:3.52777767px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.07000434"
diff --git a/res/computerscare-invisible-button-frame2.svg b/res/computerscare-invisible-button-frame2.svg
@@ -25,9 +25,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="11.2"
- inkscape:cx="35.06195"
- inkscape:cy="16.512059"
+ inkscape:zoom="7.919596"
+ inkscape:cx="23.746495"
+ inkscape:cy="23.365366"
inkscape:document-units="mm"
inkscape:current-layer="text1460"
showgrid="false"
@@ -45,7 +45,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -59,12 +59,13 @@
style="font-style:normal;font-weight:normal;font-size:6.29599571px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.15739989"
id="text1460">
<rect
- style="fill:#00628d;fill-opacity:1;stroke:none;stroke-width:0.08491325;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#00628d;fill-opacity:0.43809527;stroke:none;stroke-width:0.08150405;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1582"
- width="19.84375"
- height="9.8746281"
- x="0.094494052"
- y="287.07812" />
+ width="18.401733"
+ height="8.8399477"
+ x="1.2024248"
+ y="287.3945"
+ ry="2.0641491" />
</g>
</g>
</svg>
diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp
@@ -142,3 +142,53 @@ struct SmoothKnob : RoundKnob {
setSVG(SVG::load(assetPlugin(plugin, "res/computerscare-medium-knob-effed.svg")));
}
};
+
+
+////////////////////////////////////
+struct SmallLetterDisplay : TransparentWidget {
+
+ std::string value;
+ std::shared_ptr<Font> font;
+ bool active = false;
+ bool blink = false;
+ bool doubleblink = false;
+
+ SmallLetterDisplay() {
+ font = Font::load(assetPlugin(plugin, "res/Oswald-Regular.ttf"));
+ };
+
+ void draw(NVGcontext *vg) override
+ {
+ // Background
+ NVGcolor backgroundColor = COLOR_COMPUTERSCARE_RED;
+ NVGcolor doubleblinkColor = COLOR_COMPUTERSCARE_YELLOW;
+
+
+ if(doubleblink) {
+ nvgBeginPath(vg);
+ nvgRoundedRect(vg, 1.0, -1.0, box.size.x-3, box.size.y-3, 8.0);
+ nvgFillColor(vg, doubleblinkColor);
+ nvgFill(vg);
+ }
+ else {
+ if(blink) {
+ nvgBeginPath(vg);
+ nvgRoundedRect(vg, 1.0, -1.0, box.size.x-3, box.size.y-3, 8.0);
+ nvgFillColor(vg, backgroundColor);
+ nvgFill(vg);
+ }
+ }
+
+ // text
+ nvgFontSize(vg, 19);
+ nvgFontFaceId(vg, font->handle);
+ nvgTextLetterSpacing(vg, 2.5);
+ nvgTextLineHeight(vg, 0.7);
+
+ Vec textPos = Vec(6.0f, 12.0f);
+ NVGcolor textColor = (!blink || doubleblink) ? nvgRGB(0x10, 0x10, 0x00) : COLOR_COMPUTERSCARE_YELLOW;
+ nvgFillColor(vg, textColor);
+ nvgTextBox(vg, textPos.x, textPos.y,80,value.c_str(), NULL);
+
+ }
+};
diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp
@@ -24,54 +24,6 @@ const int numKnobs = numKnobRows * numKnobColumns;
const int numInputs = numInputRows * numInputColumns;
const std::vector<NVGcolor> outlineColorMap = {COLOR_COMPUTERSCARE_RED,COLOR_COMPUTERSCARE_YELLOW,COLOR_COMPUTERSCARE_BLUE};
-////////////////////////////////////
-struct SmallLetterDisplay : TransparentWidget {
-
- std::string value;
- std::shared_ptr<Font> font;
- bool active = false;
- bool blink = false;
- bool doubleblink = false;
-
- SmallLetterDisplay() {
- font = Font::load(assetPlugin(plugin, "res/Oswald-Regular.ttf"));
- };
-
- void draw(NVGcontext *vg) override
- {
- // Background
- NVGcolor backgroundColor = COLOR_COMPUTERSCARE_RED;
- NVGcolor doubleblinkColor = COLOR_COMPUTERSCARE_YELLOW;
-
-
- if(doubleblink) {
- nvgBeginPath(vg);
- nvgRoundedRect(vg, 1.0, -1.0, box.size.x-3, box.size.y-3, 8.0);
- nvgFillColor(vg, doubleblinkColor);
- nvgFill(vg);
- }
- else {
- if(blink) {
- nvgBeginPath(vg);
- nvgRoundedRect(vg, 1.0, -1.0, box.size.x-3, box.size.y-3, 8.0);
- nvgFillColor(vg, backgroundColor);
- nvgFill(vg);
- }
- }
-
- // text
- nvgFontSize(vg, 19);
- nvgFontFaceId(vg, font->handle);
- nvgTextLetterSpacing(vg, 2.5);
- nvgTextLineHeight(vg, 0.7);
-
- Vec textPos = Vec(6.0f, 12.0f);
- NVGcolor textColor = (!blink || doubleblink) ? nvgRGB(0x10, 0x10, 0x00) : COLOR_COMPUTERSCARE_YELLOW;
- nvgFillColor(vg, textColor);
- nvgTextBox(vg, textPos.x, textPos.y,80,value.c_str(), NULL);
-
- }
-};
class MyTextFieldCookie : public LedDisplayTextField {
@@ -156,7 +108,6 @@ struct ComputerscareILoveCookies : Module {
SchmittTrigger globalManualClockTrigger;
SchmittTrigger globalManualResetTrigger;
-
SchmittTrigger clockTriggers[numFields];
SchmittTrigger resetTriggers[numFields];
diff --git a/src/ComputerscareLaundrySoup.cpp b/src/ComputerscareLaundrySoup.cpp
@@ -65,8 +65,11 @@ private:
struct ComputerscareLaundrySoup : Module {
enum ParamIds {
- NUM_PARAMS
- };
+ MANUAL_CLOCK_PARAM,
+ MANUAL_RESET_PARAM,
+ INDIVIDUAL_RESET_PARAM,
+ NUM_PARAMS = INDIVIDUAL_RESET_PARAM + numFields
+ };
enum InputIds {
GLOBAL_CLOCK_INPUT,
GLOBAL_RESET_INPUT,
@@ -87,10 +90,16 @@ struct ComputerscareLaundrySoup : Module {
SchmittTrigger globalClockTrigger;
SchmittTrigger globalResetTriggerInput;
+ SchmittTrigger globalManualClockTrigger;
+ SchmittTrigger globalManualResetTrigger;
+
SchmittTrigger clockTriggers[numFields];
SchmittTrigger resetTriggers[numFields];
MyTextField* textFields[numFields];
+ SmallLetterDisplay* smallLetterDisplays[numFields];
+
+ SchmittTrigger manualResetTriggers[numFields];
std::vector<int> absoluteSequences[numFields];
std::vector<int> nextAbsoluteSequences[numFields];
@@ -194,12 +203,20 @@ void onCreate () override
*/
void incrementInternalStep(int i) {
+
this->absoluteStep[i] +=1;
this->absoluteStep[i] %= this->numSteps[i];
- }
+ this->smallLetterDisplays[i]->value = this->getDisplayString(i);
+ }
+ std::string getDisplayString(int i) {
+ std::string out = std::to_string(this->absoluteStep[i]+1);
+ out += "/" + std::to_string(this->numSteps[i]);
+ out+= "\n";
+ return out;
+ }
void resetOneOfThem(int i) {
- this->absoluteStep[i] = 0;
+ this->absoluteStep[i] = -1;
}
};
@@ -212,9 +229,14 @@ void ComputerscareLaundrySoup::step() {
bool clocked = globalClockTrigger.process(inputs[GLOBAL_CLOCK_INPUT].value);
bool currentTriggerIsHigh = false;
bool currentTriggerClocked = false;
+
+ bool globalManualResetClicked = globalManualResetTrigger.process(params[MANUAL_RESET_PARAM].value);
+ bool globalManualClockClicked = globalManualClockTrigger.process(params[MANUAL_CLOCK_PARAM].value);
+
bool globalResetTriggered = globalResetTriggerInput.process(inputs[GLOBAL_RESET_INPUT].value / 2.f);
bool currentResetActive = false;
bool currentResetTriggered = false;
+ bool currentManualResetClicked;
for(int i = 0; i < numFields; i++) {
activeStep = false;
@@ -223,21 +245,23 @@ void ComputerscareLaundrySoup::step() {
currentTriggerIsHigh = clockTriggers[i].isHigh();
currentTriggerClocked = clockTriggers[i].process(inputs[CLOCK_INPUT + i].value);
+ currentManualResetClicked = manualResetTriggers[i].process(params[INDIVIDUAL_RESET_PARAM + i].value);
+
if(this->numSteps[i] > 0) {
if (inputs[CLOCK_INPUT + i].active) {
- if(currentTriggerClocked) {
+ if(currentTriggerClocked || globalManualClockClicked) {
incrementInternalStep(i);
}
}
else {
- if (inputs[GLOBAL_CLOCK_INPUT].active && clocked) {
+ if ((inputs[GLOBAL_CLOCK_INPUT].active && clocked) || globalManualClockClicked) {
incrementInternalStep(i);
}
}
atFirstStep = (this->absoluteStep[i] == 0);
- if((currentResetActive && currentResetTriggered) || (!currentResetActive && globalResetTriggered)) {
+ if((currentResetActive && currentResetTriggered) || (!currentResetActive && globalResetTriggered) || globalManualResetClicked || currentManualResetClicked) {
checkIfShouldChange(i);
resetOneOfThem(i);
}
@@ -312,6 +336,9 @@ struct ComputerscareLaundrySoupWidget : ModuleWidget {
//global reset input
addInput(Port::create<InPort>(mm2px(Vec(12 , 0)), Port::INPUT, module, ComputerscareLaundrySoup::GLOBAL_RESET_INPUT));
+ addParam(ParamWidget::create<ComputerscareClockButton>(mm2px(Vec(2 , 8)), module, ComputerscareLaundrySoup::MANUAL_CLOCK_PARAM, 0.0, 1.0, 0.0));
+ addParam(ParamWidget::create<ComputerscareResetButton>(mm2px(Vec(12 , 8)), module, ComputerscareLaundrySoup::MANUAL_RESET_PARAM, 0.0, 1.0, 0.0));
+
for(int i = 0; i < numFields; i++) {
//first-step output
addOutput(Port::create<OutPort>(mm2px(Vec(42 , verticalStart + verticalSpacing*i - 11)), Port::OUTPUT, module, ComputerscareLaundrySoup::FIRST_STEP_OUTPUT + i));
@@ -336,8 +363,8 @@ struct ComputerscareLaundrySoupWidget : ModuleWidget {
module->textFields[i] = textField;
//active step display
- NumberDisplayWidget3 *display = new NumberDisplayWidget3();
- display->box.pos = mm2px(Vec(24,verticalStart - 9.2 +verticalSpacing*i));
+ /*NumberDisplayWidget3 *display = new NumberDisplayWidget3();
+ display->box.pos = mm2px(Vec(24,verticalStart - 7.2 +verticalSpacing*i));
display->box.size = Vec(50, 20);
if(&module->numSteps[i]) {
display->value = &module->absoluteStep[i];
@@ -345,11 +372,22 @@ struct ComputerscareLaundrySoupWidget : ModuleWidget {
else {
display->value = 0;
}
- addChild(display);
+ addChild(display);*/
+
+ smallLetterDisplay = new SmallLetterDisplay();
+ smallLetterDisplay->box.pos = mm2px(Vec(20,verticalStart - 9.2 +verticalSpacing*i));
+ smallLetterDisplay->box.size = Vec(60, 30);
+ smallLetterDisplay->value = std::to_string(3);
+ addChild(smallLetterDisplay);
+ module->smallLetterDisplays[i] = smallLetterDisplay;
+
+ addParam(ParamWidget::create<ComputerscareInvisibleButton>(mm2px(Vec(20,verticalStart - 9.2 +verticalSpacing*i)), module, ComputerscareLaundrySoup::INDIVIDUAL_RESET_PARAM + i, 0.0, 1.0, 0.0));
+
}
module->onCreate();
}
MyTextField* textField;
+ SmallLetterDisplay* smallLetterDisplay;
};
Model *modelComputerscareLaundrySoup = Model::create<ComputerscareLaundrySoup, ComputerscareLaundrySoupWidget>("computerscare", "computerscare-laundry-soup", "Laundry Soup", SEQUENCER_TAG);