An API for interacting with the Adafruit flow meter.
FlowMeter.h@0:195a3c58c944, 2016-04-28 (annotated)
- Committer:
- krbng4180
- Date:
- Thu Apr 28 19:53:59 2016 +0000
- Revision:
- 0:195a3c58c944
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
krbng4180 | 0:195a3c58c944 | 1 | #ifndef FLOW_METER_H |
krbng4180 | 0:195a3c58c944 | 2 | #define FLOW_METER_H |
krbng4180 | 0:195a3c58c944 | 3 | |
krbng4180 | 0:195a3c58c944 | 4 | #include "mbed.h" |
krbng4180 | 0:195a3c58c944 | 5 | |
krbng4180 | 0:195a3c58c944 | 6 | class FlowMeter { |
krbng4180 | 0:195a3c58c944 | 7 | public: |
krbng4180 | 0:195a3c58c944 | 8 | /* |
krbng4180 | 0:195a3c58c944 | 9 | * Makes a FlowMeter object with the pin as output to the mbed. |
krbng4180 | 0:195a3c58c944 | 10 | */ |
krbng4180 | 0:195a3c58c944 | 11 | FlowMeter(PinName out); |
krbng4180 | 0:195a3c58c944 | 12 | |
krbng4180 | 0:195a3c58c944 | 13 | /* |
krbng4180 | 0:195a3c58c944 | 14 | * Utility functions for converting pulses to volumetric measures. |
krbng4180 | 0:195a3c58c944 | 15 | */ |
krbng4180 | 0:195a3c58c944 | 16 | static float pulses_to_fl_oz(int pulses); |
krbng4180 | 0:195a3c58c944 | 17 | static float pulses_to_ml(int pulses); |
krbng4180 | 0:195a3c58c944 | 18 | |
krbng4180 | 0:195a3c58c944 | 19 | /* |
krbng4180 | 0:195a3c58c944 | 20 | * Reads the number of pulses. |
krbng4180 | 0:195a3c58c944 | 21 | * |
krbng4180 | 0:195a3c58c944 | 22 | * @return number of pulses recorded. |
krbng4180 | 0:195a3c58c944 | 23 | */ |
krbng4180 | 0:195a3c58c944 | 24 | long get_pulse_count(void); |
krbng4180 | 0:195a3c58c944 | 25 | |
krbng4180 | 0:195a3c58c944 | 26 | /* |
krbng4180 | 0:195a3c58c944 | 27 | * Convenience functions to get volumetric measures without |
krbng4180 | 0:195a3c58c944 | 28 | * called a conversion function. |
krbng4180 | 0:195a3c58c944 | 29 | */ |
krbng4180 | 0:195a3c58c944 | 30 | float get_fl_oz(void); |
krbng4180 | 0:195a3c58c944 | 31 | float get_ml(void); |
krbng4180 | 0:195a3c58c944 | 32 | |
krbng4180 | 0:195a3c58c944 | 33 | /* |
krbng4180 | 0:195a3c58c944 | 34 | * Resets the pulse count. |
krbng4180 | 0:195a3c58c944 | 35 | */ |
krbng4180 | 0:195a3c58c944 | 36 | void reset(void); |
krbng4180 | 0:195a3c58c944 | 37 | |
krbng4180 | 0:195a3c58c944 | 38 | private: |
krbng4180 | 0:195a3c58c944 | 39 | void handle_pulse_irq(void); |
krbng4180 | 0:195a3c58c944 | 40 | volatile long _pulses; |
krbng4180 | 0:195a3c58c944 | 41 | InterruptIn _pin; |
krbng4180 | 0:195a3c58c944 | 42 | |
krbng4180 | 0:195a3c58c944 | 43 | |
krbng4180 | 0:195a3c58c944 | 44 | }; |
krbng4180 | 0:195a3c58c944 | 45 | |
krbng4180 | 0:195a3c58c944 | 46 | #endif |