altsensortesting press 2 for mm
This commit is contained in:
@@ -111,13 +111,14 @@ static void printBoundaries() {
|
|||||||
|
|
||||||
// ── State ────────────────────────────────────────────────────
|
// ── State ────────────────────────────────────────────────────
|
||||||
bool sampling = false;
|
bool sampling = false;
|
||||||
|
bool rawMode = false;
|
||||||
|
|
||||||
// ═════════════════════════════════════════════════════════════
|
// ═════════════════════════════════════════════════════════════
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(2000000);
|
Serial.begin(2000000);
|
||||||
pinMode(OOR_PIN, INPUT);
|
pinMode(OOR_PIN, INPUT);
|
||||||
setupADC();
|
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() {
|
void loop() {
|
||||||
@@ -128,10 +129,16 @@ void loop() {
|
|||||||
|
|
||||||
if (cmd.charAt(0) == '1') {
|
if (cmd.charAt(0) == '1') {
|
||||||
sampling = true;
|
sampling = true;
|
||||||
|
rawMode = false;
|
||||||
resetTracking();
|
resetTracking();
|
||||||
Serial.println(F("Sampling started."));
|
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') {
|
} else if (cmd.charAt(0) == '0') {
|
||||||
sampling = false;
|
sampling = false;
|
||||||
|
rawMode = false;
|
||||||
Serial.println(F("Sampling stopped."));
|
Serial.println(F("Sampling stopped."));
|
||||||
printBoundaries();
|
printBoundaries();
|
||||||
}
|
}
|
||||||
@@ -153,6 +160,16 @@ void loop() {
|
|||||||
|
|
||||||
if (!ready) return; // nothing new — come back next iteration
|
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)
|
// All values here are in-range (OOR filtered in ISR)
|
||||||
trackLowest(val);
|
trackLowest(val);
|
||||||
trackHighest(val);
|
trackHighest(val);
|
||||||
|
|||||||
Reference in New Issue
Block a user