Monitors, weather, radiation, UV index, Natural Gas levels
Fork of WeatherMeters by
RainGauge.h@1:a197f86e143a, 2014-06-10 (annotated)
- Committer:
- sunilaluri6
- Date:
- Tue Jun 10 00:11:28 2014 +0000
- Revision:
- 1:a197f86e143a
- Parent:
- 0:457832d52954
Rev1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AdamGreen | 0:457832d52954 | 1 | /* Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/) |
AdamGreen | 0:457832d52954 | 2 | |
AdamGreen | 0:457832d52954 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
AdamGreen | 0:457832d52954 | 4 | you may not use this file except in compliance with the License. |
AdamGreen | 0:457832d52954 | 5 | You may obtain a copy of the License at |
AdamGreen | 0:457832d52954 | 6 | |
AdamGreen | 0:457832d52954 | 7 | http://www.apache.org/licenses/LICENSE-2.0 |
AdamGreen | 0:457832d52954 | 8 | |
AdamGreen | 0:457832d52954 | 9 | Unless required by applicable law or agreed to in writing, software |
AdamGreen | 0:457832d52954 | 10 | distributed under the License is distributed on an "AS IS" BASIS, |
AdamGreen | 0:457832d52954 | 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AdamGreen | 0:457832d52954 | 12 | See the License for the specific language governing permissions and |
AdamGreen | 0:457832d52954 | 13 | limitations under the License. |
AdamGreen | 0:457832d52954 | 14 | */ |
AdamGreen | 0:457832d52954 | 15 | /* Header file for class to interface with the rain gauge sensor of the Sparkfun Weather Meters: |
AdamGreen | 0:457832d52954 | 16 | http://www.sparkfun.com/products/8942 |
AdamGreen | 0:457832d52954 | 17 | */ |
AdamGreen | 0:457832d52954 | 18 | #ifndef _RAIN_GAUGE_H_ |
AdamGreen | 0:457832d52954 | 19 | #define _RAIN_GAUGE_H_ |
AdamGreen | 0:457832d52954 | 20 | |
AdamGreen | 0:457832d52954 | 21 | #include "DebouncedFallingEdgeCounter.h" |
AdamGreen | 0:457832d52954 | 22 | |
AdamGreen | 0:457832d52954 | 23 | |
AdamGreen | 0:457832d52954 | 24 | #define MILLIMETERS_OF_RAIN_PER_COUNT 0.2794f |
AdamGreen | 0:457832d52954 | 25 | |
AdamGreen | 0:457832d52954 | 26 | |
AdamGreen | 0:457832d52954 | 27 | namespace AFP |
AdamGreen | 0:457832d52954 | 28 | { |
AdamGreen | 0:457832d52954 | 29 | |
AdamGreen | 0:457832d52954 | 30 | class CRainGauge : protected CDebouncedFallingEdgeCounter |
AdamGreen | 0:457832d52954 | 31 | { |
AdamGreen | 0:457832d52954 | 32 | public: |
AdamGreen | 0:457832d52954 | 33 | CRainGauge(PinName RainGaugePin, unsigned int IgnoreTimeForDebounceInMicroSeconds = 1000) |
AdamGreen | 0:457832d52954 | 34 | : CDebouncedFallingEdgeCounter(RainGaugePin, IgnoreTimeForDebounceInMicroSeconds) |
AdamGreen | 0:457832d52954 | 35 | { |
AdamGreen | 0:457832d52954 | 36 | } |
AdamGreen | 0:457832d52954 | 37 | |
AdamGreen | 0:457832d52954 | 38 | void Reset() |
AdamGreen | 0:457832d52954 | 39 | { |
AdamGreen | 0:457832d52954 | 40 | ZeroCount(); |
AdamGreen | 0:457832d52954 | 41 | } |
AdamGreen | 0:457832d52954 | 42 | |
AdamGreen | 0:457832d52954 | 43 | float GetRainfall() |
AdamGreen | 0:457832d52954 | 44 | { |
AdamGreen | 0:457832d52954 | 45 | return (float)GetCount() * MILLIMETERS_OF_RAIN_PER_COUNT; |
AdamGreen | 0:457832d52954 | 46 | } |
AdamGreen | 0:457832d52954 | 47 | }; |
AdamGreen | 0:457832d52954 | 48 | |
AdamGreen | 0:457832d52954 | 49 | } // namespace AFP |
AdamGreen | 0:457832d52954 | 50 | using namespace AFP; |
AdamGreen | 0:457832d52954 | 51 | |
AdamGreen | 0:457832d52954 | 52 | #endif // _RAIN_GAUGE_H_ |