commit 46c87711ddfd78567af2de1cd6e9f40eae7d11f9
parent bd2d5b4b414765adb32b2c70598e1d11f2309089
Author: Adam M <aemalone@gmail.com>
Date: Sun, 2 Dec 2018 21:09:16 -0600
show accurate display values in cookies
Diffstat:
3 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp
@@ -321,14 +321,16 @@ void onCreate () override
this->smallLetterDisplays[i]->doubleblink = value;
}
std::string getDisplayString(int index) {
- std::string lhs = std::to_string(this->absoluteStep[index]);
- std::string rhs = std::to_string(this->numSteps[index]);
+ std::string lhs = std::to_string(this->newABS[index].readHead);
+ std::string rhs = std::to_string(this->newABS[index].numTokens);
+ std::string thisVal = this->newABS[index].getWorkingStepDisplay();
+
padTo(lhs, 3,' ');
padTo(rhs, 3,' ');
- std::string val = lhs + "/" + rhs + "\n" + knobandinputlookup[this->absoluteSequences[index][this->absoluteStep[index]]];
+ std::string val = lhs + "/" + rhs + "\n" + thisVal.substr(0,4);
return val;
}
float mapKnobValue(float rawValue, int rowIndex) {
@@ -422,8 +424,6 @@ void ComputerscareILoveCookies::step() {
}
activeKnobIndex[i] = newABS[i].peekWorkingStep();
-
-
//outputs[TRG_OUTPUT + i].value = params[KNOB_PARAM + activeKnob].value;
// how to handle a randomization input here?
@@ -442,11 +442,11 @@ void ComputerscareILoveCookies::step() {
else if(activeKnobIndex[i] < 78) {
outputs[TRG_OUTPUT + i].value = newABS[i].exactFloats[activeKnobIndex[i] - 52];
}
- else if(activeKnobIndex[i] <104) {
+ else if(activeKnobIndex[i] < 104) {
outputs[TRG_OUTPUT + i].value = 2.22;
}
else {
- outputs[TRG_OUTPUT+i].value = otherOutputValues[activeKnobIndex[i]-104];
+ outputs[TRG_OUTPUT+i].value = otherOutputValues[activeKnobIndex[i] - 104];
}
if(inputs[CLOCK_INPUT + i].active) {
outputs[FIRST_STEP_OUTPUT + i].value = (currentTriggerIsHigh && atFirstStep) ? 10.f : 0.0f;
diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp
@@ -224,8 +224,6 @@ std::vector<Token> interleaveExpand(std::vector<std::vector<Token>> blocks) {
indices.push_back(0);
lengths.push_back(blocks[i].size());
}
- printf("interleaveExpand lengths:");
- //printVector(lengths);
while(outerLength && ((!allAtZero && steps < 6000 ) || steps == 0)) {
if(lengths[outerIndex]) {
output.push_back(blocks[outerIndex][indices[outerIndex]]);
@@ -383,6 +381,7 @@ AbsoluteSequence::AbsoluteSequence(std::string expr, std::string lookup) {
exactFloats = p.exactFloats;
randomTokens=p.randomVector;
tokenStack = p.tokenStack;
+ numTokens = tokenStack.size();
indexSequence = getIndicesFromTokenStack(tokenStack);
workingIndexSequence = duplicateIntVector(indexSequence);;
readHead = -1 ;
@@ -420,6 +419,16 @@ void AbsoluteSequence::incrementAndCheck() {
randomizeIndex(readHead);
}
}
+std::string AbsoluteSequence::getWorkingStepDisplay() {
+ int stepIndex = peekWorkingStep();
+ if(stepIndex < 52) {
+ std::string str(1,knobandinputlookup[stepIndex]);
+ return str;
+ }
+ else {
+ return std::to_string(exactFloats[stepIndex - 52]);
+ }
+}
std::vector<int> getIndicesFromTokenStack(std::vector<Token> tokens) {
std::vector<int> output;
@@ -500,7 +509,6 @@ void Parser::setForInterleave(Token t) {
}
void Parser::ParseExactValue(Token t) {
- int currentSize;
if(t.type=="LeftAngle") {
t=skipAndPeekToken();
std::string num="";
@@ -642,7 +650,6 @@ void Token::print() {
}
std::vector<Token> tokenizeString(std::string input) {
std::vector<Token> stack;
- int stringIndex=0;
for(unsigned int i = 0; i < input.length(); i++) {
std::string token(1,input[i]);
if(token=="(") stack.push_back(Token("LeftParen",token));
diff --git a/src/dtpulse.hpp b/src/dtpulse.hpp
@@ -61,7 +61,9 @@ class AbsoluteSequence {
std::vector<std::vector<int>> randomIndexes;
std::vector<std::vector<Token>> randomTokens;
std::vector<Token> tokenStack;
+
int readHead;
+ int numTokens;
void print();
void skipStep();
int peekStep();
@@ -70,6 +72,7 @@ class AbsoluteSequence {
void incrementAndCheck();
int getReadHead();
int getCurrentAddressAtReadHead();
+ std::string getWorkingStepDisplay();
};
bool is_digits(const std::string &str);
void padTo(std::string &str, const size_t num, const char paddingChar );