-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLightWidget.cpp
More file actions
48 lines (42 loc) · 1.08 KB
/
LightWidget.cpp
File metadata and controls
48 lines (42 loc) · 1.08 KB
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
/*
*LightWidget.cpp
*Created By: Jacob Regan
*Date of Creation: 4/23/12
*Date of last edit: 4/25/12
*/
#include "WProgram.h"
#include "LightWidget.h"
#include "WidgetShield.h"
// sets x, y, and status of the widget
LightWidget::LightWidget(uint16_t x, uint16_t y, char status) : Widget(x,y,LIGHT_WIDGET_TYPE)
{
this->x = x;
this->y = y;
this->status = status;
}
//toggles the status of the widget to be 'on' or 'off'
void LightWidget::changeStatus(){
//checks if the status is off
if(status == 0x00){
char command = 0x02;
//if it is then turn it on and send on command to shield
status = 0x01;
char send[3];
send[0] = id;
send[1] = 0x02;
send[2] = status;
WidgetShield::Instance()->sendWidgetCommand(send, 3);
}else{
char command = 0x02;
//else it must be on so turn it off and send off command to shield
status = 0x00;
char send[3] = {id, command, status};
WidgetShield::Instance()->sendWidgetCommand(send, 3);
}
}
char LightWidget::getStatus(){
return (this->status);
}
void LightWidget::initGraphics(){
WidgetShield::Instance()->moveWidget(this, x, y);
}