-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialWidget.cpp
More file actions
44 lines (39 loc) · 1.07 KB
/
DialWidget.cpp
File metadata and controls
44 lines (39 loc) · 1.07 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
/*
*DialWidget.cpp
*Created By: Jacob Regan
*Date of Creation: 4/23/12
*Date of last edit: 4/25/12
*/
#include "WProgram.h"
#include "DialWidget.h"
#include "WidgetShield.h"
//Sets x, y, and inital angle
DialWidget::DialWidget(uint16_t x, uint16_t y, uint16_t angle) : Widget(x,y,DIAL_WIDGET_TYPE)
{
this->x = x;
this->y = y;
this->angle = angle;
}
//sets new angle and sends command to redraw the needle
void DialWidget::redrawNeedle(uint16_t angle){
// only sets new angle and sends command if the angle has indeed changed
// this saves on draw time
if(angle != this->angle){
//set new angle
this->angle = angle;
//define stat array
char send[4];
//set id to first index
send[0] = id;
send[1] = 0x02;
//next two indices are reserved for the new angle
WidgetShield::Instance()->uint16ToCharArray(angle,send+2);
// send the widget command.
WidgetShield::Instance()->sendWidgetCommand(send, 4);
}
}
// set needle to position 0 for the inital draw
void DialWidget::initGraphics(){
WidgetShield::Instance()->moveWidget(this, x, y);
redrawNeedle(angle);
}