|
|
|
@ -72,13 +72,14 @@ enum buttonStates enterButton = OPEN; |
|
|
|
|
enum buttonStates downButton = OPEN; |
|
|
|
|
|
|
|
|
|
enum screenStates screenState = BOOT_UP; |
|
|
|
|
float pressureValue = 0.0; |
|
|
|
|
double pressureValue = 0.0; |
|
|
|
|
int pressureSetPoint = 0; |
|
|
|
|
//float initialPressure = 0.0;
|
|
|
|
|
//float runningPressure = 0.0;
|
|
|
|
|
float sampledPressure = 0.0; |
|
|
|
|
double initialPressure = 0.0; |
|
|
|
|
//double runningPressure = 0.0;
|
|
|
|
|
double sampledPressure = 0.0; |
|
|
|
|
double runningRateInv = 0.0; |
|
|
|
|
|
|
|
|
|
int debounceValue(float value) { |
|
|
|
|
int debounceValue(double value) { |
|
|
|
|
static int prevValue = (int) value; |
|
|
|
|
|
|
|
|
|
if (abs(prevValue - value) > 0.4) { |
|
|
|
@ -135,6 +136,8 @@ void logData() { |
|
|
|
|
#endif |
|
|
|
|
Serial.print(", sampled: "); |
|
|
|
|
Serial.print(sampledPressure); |
|
|
|
|
Serial.print(", rate (inv): "); |
|
|
|
|
Serial.print(runningRateInv); |
|
|
|
|
Serial.print(", setpoint: "); |
|
|
|
|
Serial.print(pressureSetPoint); |
|
|
|
|
Serial.print(", state: "); |
|
|
|
@ -151,6 +154,7 @@ void runUI() { |
|
|
|
|
static unsigned long timer = millis(); |
|
|
|
|
|
|
|
|
|
static unsigned long startTime = millis(); |
|
|
|
|
static unsigned long stopTime = millis(); |
|
|
|
|
static bool isInflating = false; |
|
|
|
|
static bool isDeflating = false; |
|
|
|
|
|
|
|
|
@ -249,7 +253,7 @@ void runUI() { |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case INIT_RUN: |
|
|
|
|
//initialPressure = pressureValue;
|
|
|
|
|
initialPressure = pressureValue; |
|
|
|
|
startTime = millis(); |
|
|
|
|
timer = millis(); |
|
|
|
|
screenState = BEGIN_RUN; |
|
|
|
@ -284,6 +288,7 @@ void runUI() { |
|
|
|
|
setSoleniod(SOLENOID_STOP); |
|
|
|
|
screenState = MEASURING; |
|
|
|
|
timer = millis(); |
|
|
|
|
stopTime = millis(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
@ -292,6 +297,22 @@ void runUI() { |
|
|
|
|
if (millis() >= timer + 3000) { |
|
|
|
|
sampledPressure = pressureValue; |
|
|
|
|
|
|
|
|
|
runningRateInv = (stopTime - startTime) / (sampledPressure - initialPressure); |
|
|
|
|
|
|
|
|
|
Serial.print("stopTime: "); |
|
|
|
|
Serial.print(stopTime); |
|
|
|
|
Serial.print(", startTime: "); |
|
|
|
|
Serial.print(startTime); |
|
|
|
|
Serial.print(", sampledPressure: "); |
|
|
|
|
Serial.print(sampledPressure); |
|
|
|
|
Serial.print(", initialPressure: "); |
|
|
|
|
Serial.print(initialPressure); |
|
|
|
|
Serial.print(", rate: "); |
|
|
|
|
Serial.print(runningRateInv); |
|
|
|
|
Serial.println(""); |
|
|
|
|
|
|
|
|
|
initialPressure = sampledPressure; |
|
|
|
|
|
|
|
|
|
if (isInflating && (int) sampledPressure >= pressureSetPoint) { |
|
|
|
|
screenState = SAY_DONE; |
|
|
|
|
nextState = PRESSURE; |
|
|
|
@ -303,6 +324,7 @@ void runUI() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
timer = millis(); |
|
|
|
|
startTime = millis(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (millis() < timer + 500) { |
|
|
|
@ -323,14 +345,17 @@ void runUI() { |
|
|
|
|
|
|
|
|
|
case RUNNING: |
|
|
|
|
if (enterButton == PRESSED) { |
|
|
|
|
setSoleniod(SOLENOID_STOP); |
|
|
|
|
screenState = SAY_CANCEL; |
|
|
|
|
nextState = PRESSURE; |
|
|
|
|
timer = millis(); |
|
|
|
|
} else if (upButton == PRESSED) { |
|
|
|
|
setSoleniod(SOLENOID_STOP); |
|
|
|
|
screenState = SAY_CANCEL; |
|
|
|
|
nextState = PRESSURE; |
|
|
|
|
timer = millis(); |
|
|
|
|
} else if (downButton == PRESSED) { |
|
|
|
|
setSoleniod(SOLENOID_STOP); |
|
|
|
|
screenState = SAY_CANCEL; |
|
|
|
|
nextState = PRESSURE; |
|
|
|
|
timer = millis(); |
|
|
|
@ -339,9 +364,11 @@ void runUI() { |
|
|
|
|
if (isInflating && millis() >= timer + 20000) { |
|
|
|
|
screenState = MEASURING; |
|
|
|
|
timer = millis(); |
|
|
|
|
stopTime = millis(); |
|
|
|
|
} else if (isDeflating && millis() >= timer + 10000) { |
|
|
|
|
screenState = MEASURING; |
|
|
|
|
timer = millis(); |
|
|
|
|
stopTime = millis(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isInflating) { |
|
|
|
|