altsensortesting press 2 for mm
This commit is contained in:
@@ -111,13 +111,14 @@ static void printBoundaries() {
|
||||
|
||||
// ── State ────────────────────────────────────────────────────
|
||||
bool sampling = false;
|
||||
bool rawMode = false;
|
||||
|
||||
// ═════════════════════════════════════════════════════════════
|
||||
void setup() {
|
||||
Serial.begin(2000000);
|
||||
pinMode(OOR_PIN, INPUT);
|
||||
setupADC();
|
||||
Serial.println(F("Send '1' to start sampling, '0' to stop and print bounds."));
|
||||
Serial.println(F("Send '1' to start sampling, '0' to stop and print bounds, '2' for raw ADC output."));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -128,10 +129,16 @@ void loop() {
|
||||
|
||||
if (cmd.charAt(0) == '1') {
|
||||
sampling = true;
|
||||
rawMode = false;
|
||||
resetTracking();
|
||||
Serial.println(F("Sampling started."));
|
||||
} else if (cmd.charAt(0) == '2') {
|
||||
sampling = true;
|
||||
rawMode = true;
|
||||
Serial.println(F("Raw ADC output started."));
|
||||
} else if (cmd.charAt(0) == '0') {
|
||||
sampling = false;
|
||||
rawMode = false;
|
||||
Serial.println(F("Sampling stopped."));
|
||||
printBoundaries();
|
||||
}
|
||||
@@ -153,6 +160,16 @@ void loop() {
|
||||
|
||||
if (!ready) return; // nothing new — come back next iteration
|
||||
|
||||
if (rawMode) {
|
||||
long mm_x100 = map(val, 178, 895, 1600, 2600);
|
||||
Serial.print(mm_x100 / 100);
|
||||
Serial.print('.');
|
||||
long frac = mm_x100 % 100;
|
||||
if (frac < 10) Serial.print('0');
|
||||
Serial.println(frac);
|
||||
return;
|
||||
}
|
||||
|
||||
// All values here are in-range (OOR filtered in ISR)
|
||||
trackLowest(val);
|
||||
trackHighest(val);
|
||||
|
||||
Reference in New Issue
Block a user