Monitors, weather, radiation, UV index, Natural Gas levels
Fork of WeatherMeters by
Diff: WeatherMeters.cpp
- Revision:
- 0:457832d52954
diff -r 000000000000 -r 457832d52954 WeatherMeters.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WeatherMeters.cpp Sat Feb 25 03:23:51 2012 +0000 @@ -0,0 +1,59 @@ +/* Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +/* Implementation of class to interface with Sparkfun Weather Meters: + http://www.sparkfun.com/products/8942 +*/ +#include <mbed.h> +#include "WeatherMeters.h" + + +CWeatherMeters::CWeatherMeters(PinName AnemometerPin, + PinName RainGaugePin, + PinName WindVanePin, + float WindVaneSeriesResistance) : m_Anemometer(AnemometerPin), + m_RainGauge(RainGaugePin), + m_WindVane(WindVanePin, WindVaneSeriesResistance) +{ +} + + +void CWeatherMeters::GetMeasurements(SMeasurements* pMeasurements) +{ + pMeasurements->WindDirectionString = m_WindVane.GetWindDirectionAsString(); + pMeasurements->WindDirectionAngle = m_WindVane.GetWindDirectionAsAngle(); + pMeasurements->WindSpeed = m_Anemometer.GetCurrentWindSpeed(); + pMeasurements->MaximumWindSpeed = m_Anemometer.GetMaximumWindSpeed(); + pMeasurements->Rainfall = m_RainGauge.GetRainfall(); +} + + +void CWeatherMeters::Reset() +{ + ResetRainfall(); + ResetMaximumWindSpeed(); +} + + +void CWeatherMeters::ResetRainfall() +{ + m_RainGauge.Reset(); +} + + +void CWeatherMeters::ResetMaximumWindSpeed() +{ + m_Anemometer.ResetMaximumWindSpeed(); +} +