-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReader.h
More file actions
36 lines (23 loc) · 703 Bytes
/
Reader.h
File metadata and controls
36 lines (23 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef READER_H
#define READER_H
#include "Arduino.h"
const uint8_t targetPressurePin = A2,
measuredPressurePin = A1;
float getTargetPressureDelta() {
// returns the target pressure delta in PSI
// guaranteed to be in [0, 4.5]
int rawVal = analogRead(targetPressurePin);
float psi = map(rawVal, 0, 634, 0, 4500) / 1000.;
// chop to [0, 4.5]
psi = max(0, psi);
psi = min(4.5, psi);
return psi;
}
float getPressureMeasuredDelta() {
// returns the measured pressure delta in PSI
// no guarantee on bounds of this value
int rawVal = analogRead(measuredPressurePin);
float psi = map(rawVal, 0, 634, 0, 4500) / 1000.;
return psi;
}
#endif