commit a77b6ab8713d5f60826058687b89032226485c30
parent c4457595db17525a9619212f32ba1bbcef0c7fc9
Author: Adam M <aemalone@gmail.com>
Date: Tue, 8 Jan 2019 19:12:20 -0600
Add some logic for knowing if laundry is at its final step
Diffstat:
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/ComputerscareLaundrySoup.cpp b/src/ComputerscareLaundrySoup.cpp
@@ -249,6 +249,7 @@ void ComputerscareLaundrySoup::step() {
bool globalGateIn = globalClockTrigger.isHigh();
bool atFirstStep = false;
+ bool atLastStepAfterIncrement = false;
bool clocked = globalClockTrigger.process(inputs[GLOBAL_CLOCK_INPUT].value);
bool currentTriggerIsHigh = false;
bool currentTriggerClocked = false;
@@ -274,14 +275,16 @@ void ComputerscareLaundrySoup::step() {
if(currentTriggerClocked || globalManualClockClicked) {
incrementInternalStep(i);
activeStep[i] = (this->laundrySequences[i].peekWorkingStep() == 1);
-
+ atLastStepAfterIncrement = this->laundrySequences[i].atLastStep();
+ if(atLastStepAfterIncrement) checkIfShouldChange(i);
}
}
else {
if ((inputs[GLOBAL_CLOCK_INPUT].active && clocked) || globalManualClockClicked) {
incrementInternalStep(i);
activeStep[i] = (this->laundrySequences[i].peekWorkingStep() == 1);
-
+ atLastStepAfterIncrement = this->laundrySequences[i].atLastStep();
+ if(atLastStepAfterIncrement) checkIfShouldChange(i);
}
}
@@ -300,7 +303,7 @@ void ComputerscareLaundrySoup::step() {
}
else {
if(atFirstStep && !currentResetActive && !inputs[GLOBAL_RESET_INPUT].active) {
- checkIfShouldChange(i);
+ //checkIfShouldChange(i);
}
}
}
@@ -319,12 +322,13 @@ void ComputerscareLaundrySoup::step() {
void MyTextField::onTextChange() {
std::string value = module->textFields[this->rowIndex]->text;
LaundrySoupSequence lss = LaundrySoupSequence(value);
+
if(!lss.inError && matchParens(value)) {
module->textFields[this->rowIndex]->inError=false;
module->setNextAbsoluteSequence(this->rowIndex);
module->updateDisplayBlink(this->rowIndex);
- whoKnowsLaundry(value);
+ //whoKnowsLaundry(value);
}
else {
module->textFields[this->rowIndex]->inError=true;
diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp
@@ -456,6 +456,9 @@ void LaundrySoupSequence::incrementAndCheck() {
randomizePulseValue(readHead);
}
}
+bool LaundrySoupSequence::atLastStep() {
+ return (readHead == (numSteps -1 ));
+}
void LaundrySoupSequence::randomizePulseValue(int index) {
workingPulseSequence[index] = (rand() % 2);
}
diff --git a/src/dtpulse.hpp b/src/dtpulse.hpp
@@ -110,6 +110,7 @@ class LaundrySoupSequence {
int skipAndPeek();
int peekWorkingStep();
void incrementAndCheck();
+ bool atLastStep();
void randomizePulseValue(int index);
};
bool matchesAny(std::string val, std::vector<std::string> whitelist);