An API for interacting with the Adafruit flow meter.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FlowMeter.h Source File

FlowMeter.h

00001 #ifndef FLOW_METER_H
00002 #define FLOW_METER_H
00003 
00004 #include "mbed.h"
00005 
00006 class FlowMeter {
00007 public:
00008     /*
00009      * Makes a FlowMeter object with the pin as output to the mbed.
00010      */
00011     FlowMeter(PinName out);
00012 
00013     /*
00014      * Utility functions for converting pulses to volumetric measures.
00015      */
00016     static float pulses_to_fl_oz(int pulses);
00017     static float pulses_to_ml(int pulses);
00018 
00019     /*
00020      * Reads the number of pulses.
00021      *
00022      * @return number of pulses recorded.
00023      */
00024     long get_pulse_count(void);
00025 
00026     /*
00027      * Convenience functions to get volumetric measures without
00028      * called a conversion function.
00029      */
00030     float get_fl_oz(void);
00031     float get_ml(void);
00032 
00033     /*
00034      * Resets the pulse count.
00035      */
00036     void reset(void);
00037 
00038 private:
00039     void handle_pulse_irq(void);
00040     volatile long _pulses;
00041     InterruptIn _pin;
00042 
00043 
00044 };
00045 
00046 #endif