Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Blynk_Example_WIZwiki-W7500
Fork of Blynk by
BlynkUtility.h
00001 /** 00002 * @file BlynkUtility.h 00003 * @author Volodymyr Shymanskyy 00004 * @license This project is released under the MIT License (MIT) 00005 * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 00006 * @date Jun 2015 00007 * @brief Utility functions 00008 * 00009 */ 00010 00011 #ifndef BlynkUtility_h 00012 #define BlynkUtility_h 00013 00014 template<class T> 00015 const T& BlynkMin(const T& a, const T& b) 00016 { 00017 return (b < a) ? b : a; 00018 } 00019 00020 template<class T> 00021 const T& BlynkMax(const T& a, const T& b) 00022 { 00023 return (b < a) ? a : b; 00024 } 00025 00026 template <unsigned WSIZE, typename T> 00027 void BlynkAverageSample (T& avg, const T& input) { 00028 avg -= avg/WSIZE; 00029 const T add = input/WSIZE; 00030 // Fix for shorter delays 00031 if (add > 0) 00032 avg += add; 00033 else 00034 avg -= 1; 00035 } 00036 00037 #define BlynkBitSet(value, bit) ((value) |= (1UL << (bit))) 00038 #define BlynkBitClear(value, bit) ((value) &= ~(1UL << (bit))) 00039 #define BlynkBitRead(value, bit) (((value) >> (bit)) & 0x01) 00040 #define BlynkBitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) 00041 00042 #endif
Generated on Tue Jul 12 2022 17:30:45 by
1.7.2
