Blynk example

Dependents:   Blynk_Example_WIZwiki-W7500

Fork of Blynk by Volodymyr Shymanskyy

utility/BlynkUtility.h

Committer:
Volodymyr Shymanskyy
Date:
2016-06-24
Revision:
5:05777a102fdb
Parent:
0:58b20b438383
Child:
7:8879692d4e6c

File content as of revision 5:05777a102fdb:

/**
 * @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;
}

#endif