Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc. http://www.blynk.cc/
Dependents: Blynk_RBL_BLE_Nano Blynk_MicroBit Blynk_Serial Blynk_RBL_BLE_Nano
utility/BlynkUtility.h
- Committer:
- vshymanskyy
- Date:
- 2018-01-26
- Revision:
- 22:e1d3971fd902
- Parent:
- 18:c328c1a97f90
File content as of revision 22:e1d3971fd902:
/** * @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 if (add > 0) avg += add; else avg -= 1; } class BlynkHelperAutoInc { public: BlynkHelperAutoInc(uint8_t& counter) : c(counter) { ++c; } ~BlynkHelperAutoInc() { --c; } private: uint8_t& c; }; #define BlynkBitSet(value, bit) ((value) |= (1UL << (bit))) #define BlynkBitClear(value, bit) ((value) &= ~(1UL << (bit))) #define BlynkBitRead(value, bit) (((value) >> (bit)) & 0x01) #define BlynkBitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) #endif