forked from blynkkk/blynk-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlynkWidgets.h
47 lines (40 loc) · 946 Bytes
/
BlynkWidgets.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @file BlynkWidgets.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Mar 2015
* @brief
*/
#include <WidgetLED.h>
#include <WidgetLCD.h>
#include <WidgetTerminal.h>
#include <WidgetTimeInput.h>
#include <WidgetMap.h>
// Cannot auto-include as these have library dependencies
//#include <WidgetRTC.h>
template<class T>
class VPinWriteOnChange {
T prev;
const int vpin;
public:
VPinWriteOnChange(int v)
: vpin(v)
{}
VPinWriteOnChange<T>& operator= (const T& value) {
update(value);
return *this;
}
void set(const T& value) {
prev = value;
}
void update(const T& value) {
if (value != prev) {
prev = value;
report();
}
}
void report() {
Blynk.virtualWrite(vpin, prev);
}
};