Skip to content

Commit 0f26a02

Browse files
committed
still WIP, but kinda working better
1 parent 2b76a3c commit 0f26a02

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

include/ParameterManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,17 +663,17 @@ class ParameterManager {
663663
continue;
664664
float v = p->getLastModulatedNormalValue();
665665
int pos = constrain((float)columns * v, 0, columns-1);
666-
line[pos] = '0' + i;
666+
line[pos] = '0' + (i % '9');
667667
}
668668

669-
for (uint_fast8_t i = 0 ; i < this->available_inputs->size() ; i++) {
669+
/*for (uint_fast8_t i = 0 ; i < this->available_inputs->size() ; i++) {
670670
BaseParameterInput *p = this->available_inputs->get(i);
671671
//if (strcmp(p->label,"None")==0)
672672
// continue;
673673
float v = p->get_normal_value_unipolar();
674674
int pos = constrain((float)(columns * v), 0, columns-1);
675675
line[pos] = 'A' + i;
676-
}
676+
}*/
677677

678678
Serial.printf(line);
679679

include/parameter_inputs/ThresholdToggleParameterInput.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class ThresholdToggleParameterInput : public VoltageParameterInput {
2929
virtual void read() override {
3030
//Serial.printf("ThresholdToggleParameterInput::read() %s\n", this->name);
3131
float readValue = this->voltage_source->get_voltage_normal();
32+
if (inverted) {
33+
readValue = 1.0f - readValue;
34+
}
35+
36+
if (this->debug) Serial.printf("ThresholdToggleParameterInput::read() %s readValue %f\n", this->name, readValue);
3237

3338
if (firstRun || this->is_significant_change(readValue, this->lastValue)) {
3439
this->lastValue = readValue;

include/parameters/Parameter.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,12 +892,18 @@ class DataParameterBase : public FloatParameter {
892892
float constrained_value = this->constrainNormal(value);
893893
this->lastModulatedNormalValue = constrained_value;
894894
//this->lastOutputNormalValue = this->lastModulatedNormalValue; // = value;
895-
if (debug && Serial) Serial.printf("%s#setTargetValueFromNormal(%3.3f) got modulated value %3.3f, ", this->label, value, constrained_value);
895+
if (debug && Serial) {
896+
Serial.printf("%s#setTargetValueFromNormal(%3.3f) got modulated value %3.3f, ", this->label, value, constrained_value);
897+
Serial.flush();
898+
}
896899

897900
float slewed_value = constrained_value;
898901
if (slewing || lastModulatedNormalValue!=lastOutputNormalValue) {
899902
slewed_value = this->get_slewed_value(constrained_value);
900-
if (this->debug && Serial) Serial.printf("%s:\tslewed from\t%3.3f\tto %3.3f\n", this->label, constrained_value, slewed_value);
903+
if (this->debug && Serial) {
904+
Serial.printf("%s:\tslewed from\t%3.3f\tto %3.3f\n", this->label, constrained_value, slewed_value);
905+
Serial.flush();
906+
}
901907
}
902908

903909
//float slewed_value = this->get_slewed_value(constrained_value);

include/voltage_sources/PicoSDKADCVoltageSource.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ class ComputerCardVoltageSource : public WorkshopVoltageSourceBase {
149149
int adcReading = channel < 3 ? sw->KnobVal((ComputerCard::Knob)channel) :
150150
channel==3 ? sw->SwitchVal() : sw->CVIn(channel-4);
151151

152+
if (channel > 3) {
153+
//adcReading *= 2; // scale up the CV inputs to match the 0-5V range of the knobs
154+
// todo: fix this properly?
155+
adcReading += 2047; // 0-5V range
156+
}
157+
152158
float voltageFromAdc = this->adcread_to_voltage(adcReading);
153159

154160
if (this->debug) {
@@ -162,13 +168,16 @@ class ComputerCardVoltageSource : public WorkshopVoltageSourceBase {
162168
Serial.println(voltageCorrected);
163169
}
164170

165-
if (this->debug) Serial.printf("in WorkshopVoltageSource#fetch_current_voltage() finishing (and returning %f)\n", voltageCorrected);
171+
if (this->debug) Serial.printf("in WorkshopVoltageSource#fetch_current_voltage() finishing!! (and returning %f)\n", voltageCorrected);
166172

167173
return maximum_input_voltage - voltageCorrected;
168174
}
169175

170176
virtual float adcread_to_voltage(int16_t adcReading) {
171177
float voltageFromAdc = float(adcReading) * (maximum_input_voltage / 4095.0); // 12 bit ADC, 0-4095
178+
if (this->debug) {
179+
Serial.printf("ComputerCardVoltageSource channel %i read ADC voltageFromAdc %i, converted to voltageFromAdc %3.3f\t :", channel, adcReading, voltageFromAdc); Serial_flush();
180+
}
172181
return voltageFromAdc;
173182
}
174183

0 commit comments

Comments
 (0)