diff options
| author | Christian Kolset <ckolset@colostate.edu> | 2026-08-07 16:12:36 -0600 |
|---|---|---|
| committer | Christian Kolset <ckolset@colostate.edu> | 2026-08-07 16:23:20 -0600 |
| commit | 03e301ac1d8d0785017b6428f4c3bed33b81efcd (patch) | |
| tree | c288456db0dd77eb356a01550a4c70c4390192ae /api_layers | |
| parent | f0e070f8bdf42ab2b60d318bbd7f65afbfabaab2 (diff) | |
Removed serial commands feature.main
Diffstat (limited to 'api_layers')
| -rw-r--r-- | api_layers/firmware/esp32_stringPot/esp32_stringPot.ino | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/api_layers/firmware/esp32_stringPot/esp32_stringPot.ino b/api_layers/firmware/esp32_stringPot/esp32_stringPot.ino index 9edda7b..3fde958 100644 --- a/api_layers/firmware/esp32_stringPot/esp32_stringPot.ino +++ b/api_layers/firmware/esp32_stringPot/esp32_stringPot.ino @@ -8,6 +8,14 @@ Required library: esp32 by Espressif Systems + Calibration: + 1. Flash board with calibrationMODE = true. + 2. Set to position #1 and record actual position (measuredRange[0]) and + output position (readingRange[0]). + 3. Move to position #2 and record actual position (measuredRange[1]) + and output position (readingRange[1]). + 4. Flash board with calibrationMODE = false. + ───────────────────────────────────────────────────────────────────────── */ @@ -31,7 +39,6 @@ float butter_b0, butter_b1, butter_b2, butter_a1, butter_a2; float butter_z1 = 0.0, butter_z2 = 0.0; void setup() { - Serial.begin(115200); while (!Serial) { @@ -39,15 +46,13 @@ void setup() { } analogReadResolution(12); + computeButterworthCoeffs(butterworth_cutoffHz, butterworth_sampleHz); if (calibrationMODE == false){ computeCalibrationParameters(measuredRange, readingRange); } - computeButterworthCoeffs(butterworth_cutoffHz, butterworth_sampleHz); } void loop() { - handleSerialCommands(); - unsigned long currentTime = micros(); if (currentTime - lastSampleTime >= sampleInterval) { @@ -100,21 +105,3 @@ float butterworthLowPass(float newSample) { butter_z2 = butter_b2 * newSample - butter_a2 * output; return output; } - -void handleSerialCommands() { - // "C:<cutoffHz>\n" sets Butterworth cutoff frequency, e.g. "C:15.0\n" - if (Serial.available() > 0) { - String line = Serial.readStringUntil('\n'); - line.trim(); - - if (line.startsWith("C:")) { - float newCutoff = line.substring(2).toFloat(); - if (newCutoff > 0.0 && newCutoff < butterworth_sampleHz / 2.0) { - butterworth_cutoffHz = newCutoff; - computeButterworthCoeffs(butterworth_cutoffHz, butterworth_sampleHz); - butter_z1 = 0.0; - butter_z2 = 0.0; - } - } - } -} |
