p kj
/
LPC824-BlynkWeatherstation
Microduino
Fork of Io_moon by
Diff: Blynk_v0_3_7/Blynk/utility/BlynkUtility.h
- Revision:
- 0:740c1eb2df13
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Blynk_v0_3_7/Blynk/utility/BlynkUtility.h Thu Jun 23 11:16:14 2016 +0000 @@ -0,0 +1,35 @@ +/** + * @file BlynkUtility.h + * @author Volodymyr Shymanskyy + * @license This project is released under the MIT License (MIT) + * @copyright Copyright (c) 2015 Volodymyr Shymanskyy + * @date Jun 2015 + * @brief Utility functions + * + */ + +#ifndef BlynkUtility_h +#define BlynkUtility_h + +template<class T> +const T& BlynkMin(const T& a, const T& b) +{ + return (b < a) ? b : a; +} + +template<class T> +const T& BlynkMax(const T& a, const T& b) +{ + return (b < a) ? a : b; +} + +template <unsigned WSIZE, typename T> +void BlynkAverageSample (T& avg, const T& input) { + avg -= avg/WSIZE; + const T add = input/WSIZE; + // Fix for shorter delays + avg += (add > 0) ? add : -1; +} + +#endif +