-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlynkParamPlus.h
88 lines (78 loc) · 1.71 KB
/
BlynkParamPlus.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef BLYNKPARAMSTORE
#define BLYNKPARAMSTORE value
#include <Blynk/BlynkParam.h>
class BlynkParamPlus
: public BlynkParam
{
public:
explicit
BlynkParamPlus()
: BlynkParam(malloc(sizeof(BLYNK_PARAM_PLACEHOLDER_64)), 0, sizeof(BLYNK_PARAM_PLACEHOLDER_64))
{}
BlynkParamPlus operator=(const BlynkParam param);
BlynkParamPlus operator=(int param);
BlynkParamPlus operator=(float param);
BlynkParamPlus operator=(const char* param);
BlynkParamPlus operator=(char* param);
BlynkParamPlus operator+(const BlynkParam param);
private:
void reset();
};
inline void BlynkParamPlus::reset(){
len=0;
*buff = '\0';
}
inline
BlynkParamPlus BlynkParamPlus::operator+(const BlynkParam param)
{
for (int i = 0; param[i] < param.end(); ++i) {
if (param[i].isValid()) {
// Serial.print("Add param[");
// Serial.print(i);
// Serial.print("] = ");
// Serial.println(param[i].asStr());
add(param[i].asStr());
} else {
// Serial.print("param[");
// Serial.print(i);
// Serial.println("] exceeds limit, break");
break;
}
}
return *this;
}
inline
BlynkParamPlus BlynkParamPlus::operator=(const BlynkParam param)
{
this->reset();
return *this + param;
}
inline
BlynkParamPlus BlynkParamPlus::operator=(int param)
{
this->reset();
this->add(param);
return *this;
}
inline
BlynkParamPlus BlynkParamPlus::operator=(float param)
{
this->reset();
this->add(param);
return *this;
}
inline
BlynkParamPlus BlynkParamPlus::operator=(char* param)
{
this->reset();
this->add(param);
return *this;
}
inline
BlynkParamPlus BlynkParamPlus::operator=(const char* param)
{
this->reset();
this->add(param);
return *this;
}
#endif