p kj
/
LPC824-BlynkWeatherstation
Microduino
Fork of Io_moon by
Blynk_v0_3_7/Blynk/utility/BlynkUtility.h@1:e34100dd6532, 2016-06-24 (annotated)
- Committer:
- lixianyu
- Date:
- Fri Jun 24 02:06:43 2016 +0000
- Revision:
- 1:e34100dd6532
- Parent:
- 0:740c1eb2df13
?Arduino??????????0~255??????LPC824????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lixianyu | 0:740c1eb2df13 | 1 | /** |
lixianyu | 0:740c1eb2df13 | 2 | * @file BlynkUtility.h |
lixianyu | 0:740c1eb2df13 | 3 | * @author Volodymyr Shymanskyy |
lixianyu | 0:740c1eb2df13 | 4 | * @license This project is released under the MIT License (MIT) |
lixianyu | 0:740c1eb2df13 | 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy |
lixianyu | 0:740c1eb2df13 | 6 | * @date Jun 2015 |
lixianyu | 0:740c1eb2df13 | 7 | * @brief Utility functions |
lixianyu | 0:740c1eb2df13 | 8 | * |
lixianyu | 0:740c1eb2df13 | 9 | */ |
lixianyu | 0:740c1eb2df13 | 10 | |
lixianyu | 0:740c1eb2df13 | 11 | #ifndef BlynkUtility_h |
lixianyu | 0:740c1eb2df13 | 12 | #define BlynkUtility_h |
lixianyu | 0:740c1eb2df13 | 13 | |
lixianyu | 0:740c1eb2df13 | 14 | template<class T> |
lixianyu | 0:740c1eb2df13 | 15 | const T& BlynkMin(const T& a, const T& b) |
lixianyu | 0:740c1eb2df13 | 16 | { |
lixianyu | 0:740c1eb2df13 | 17 | return (b < a) ? b : a; |
lixianyu | 0:740c1eb2df13 | 18 | } |
lixianyu | 0:740c1eb2df13 | 19 | |
lixianyu | 0:740c1eb2df13 | 20 | template<class T> |
lixianyu | 0:740c1eb2df13 | 21 | const T& BlynkMax(const T& a, const T& b) |
lixianyu | 0:740c1eb2df13 | 22 | { |
lixianyu | 0:740c1eb2df13 | 23 | return (b < a) ? a : b; |
lixianyu | 0:740c1eb2df13 | 24 | } |
lixianyu | 0:740c1eb2df13 | 25 | |
lixianyu | 0:740c1eb2df13 | 26 | template <unsigned WSIZE, typename T> |
lixianyu | 0:740c1eb2df13 | 27 | void BlynkAverageSample (T& avg, const T& input) { |
lixianyu | 0:740c1eb2df13 | 28 | avg -= avg/WSIZE; |
lixianyu | 0:740c1eb2df13 | 29 | const T add = input/WSIZE; |
lixianyu | 0:740c1eb2df13 | 30 | // Fix for shorter delays |
lixianyu | 0:740c1eb2df13 | 31 | avg += (add > 0) ? add : -1; |
lixianyu | 0:740c1eb2df13 | 32 | } |
lixianyu | 0:740c1eb2df13 | 33 | |
lixianyu | 0:740c1eb2df13 | 34 | #endif |
lixianyu | 0:740c1eb2df13 | 35 |