-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightpoint.cpp
67 lines (58 loc) · 1.39 KB
/
lightpoint.cpp
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
#include "Arduino.h"
#include "lightpoint.h"
#include "setup.h"
void Lightpoint::init()
{
registerButton(_button, this);
}
Lightpoint::Lightpoint(uint8_t id, uint8_t nvSlot, uint8_t board, uint8_t relay, uint8_t button):Relay(id, nvSlot, board, relay, ONOFFLIGHT)
{
_button = button;
init();
saveState(0);
}
Lightpoint::Lightpoint(uint8_t id, unsigned char *initData): Relay(id,initData)
{
_button = initData[_offset++];
init();
}
Lightpoint::~Lightpoint()
{
}
uint8_t Lightpoint::saveConfig(unsigned char *initData)
{
uint8_t offset = Relay::saveConfig(initData);
initData[offset++]=_button;
return offset;
}
void Lightpoint::printInfo()
{
Relay::printInfo();
Serial.print(F("\tbutton # "));
Serial.println(_button);
}
void Lightpoint::press(uint8_t button, uint8_t previousState)
{
// If previousState was PRESSED, ignore this
if((previousState == RELEASED) && button == _button)
{
setOn(!relayState());
}
saveState(0);
}
void Lightpoint::printDefinition(uint8_t first)
{
{
char buffer[40];
sprintf(buffer,"define lightpoint %d %d %d %d %d",getId(), getNVSlot(), getBoard(), getRelay(), _button);
Serial.println(buffer);
}
Relay::printDefinition(0);
};
bool Lightpoint::isType(enum DeviceType type)
{
if(type == ONOFFLIGHT)
return true;
else
return Relay::isType(type);
}