Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathGLCDTextBox.cpp
More file actions
Latest commit
99 lines (73 loc) · 2.89 KB
/
Copy pathGLCDTextBox.cpp
File metadata and controls
99 lines (73 loc) · 2.89 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
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
89
90
91
92
93
94
95
96
97
98
99
/*
Project: 1Sheeld Library
File: GLCDTextBox.h
Version: 7.0
Compiler: Arduino avr-gcc 4.3.2
Author: Integreight
Date: 2015.7
*/
#defineFROM_ONESHEELD_LIBRARY
#include"OneSheeld.h"
#include"GLCDTextBox.h"
GLCDTextBox::GLCDTextBox(int x , int y, char * _dataString): ShapeClass(GLCD_TEXTBOX_TYPE,x,y)
{
dataString = NULL;
dataStringLength = strlen(_dataString)+1;
dataMalloced=false;
if(dataStringLength!=0)
{
dataString = (char *) malloc(sizeof(char)*(dataStringLength));
memcpy(dataString,_dataString,dataStringLength);
dataMalloced=true;
}
}
voidGLCDTextBox::draw()
{
byte xPositionArray[2] ;
xPositionArray[1] = (xposition >> 8) & 0xFF;
xPositionArray[0] = xposition & 0xFF;
byte yPositionArray[2] ;
yPositionArray[1] = (yposition >> 8) & 0xFF;
yPositionArray[0] = yposition & 0xFF;
byte shapeIdArray[2] ;
shapeIdArray[1] = (shapeID >> 8) & 0xFF;
shapeIdArray[0] = shapeID & 0xFF;
byte functionId = SHAPE_DRAW;
OneSheeld.sendShieldFrame(GLCD_ID,0,GLCD_TEXTBOX_TYPE,5,newFunctionArg(1,&functionId),newFunctionArg(2,shapeIdArray)
,newFunctionArg(2,xPositionArray)
,newFunctionArg(2,yPositionArray)
,newFunctionArg(strlen(dataString),(byte *)dataString));
}
voidGLCDTextBox::setFont(byte fontType)
{
byte shapeIdArray[2] ;
shapeIdArray[1] = (shapeID >> 8) & 0xFF;
shapeIdArray[0] = shapeID & 0xFF;
byte functionId = GLCD_TEXTBOX_SET_FONT;
OneSheeld.sendShieldFrame(GLCD_ID,0,GLCD_TEXTBOX_TYPE,3,newFunctionArg(1,&functionId),newFunctionArg(2,shapeIdArray)
,newFunctionArg(1,&fontType));
}
voidGLCDTextBox::setSize(byte size)
{
byte shapeIdArray[2] ;
shapeIdArray[1] = (shapeID >> 8) & 0xFF;
shapeIdArray[0] = shapeID & 0xFF;
byte functionId = GLCD_TEXTBOX_SET_SIZE;
OneSheeld.sendShieldFrame(GLCD_ID,0,GLCD_TEXTBOX_TYPE,3,newFunctionArg(1,&functionId),newFunctionArg(2,shapeIdArray)
,newFunctionArg(1,&size));
}
voidGLCDTextBox::setText(char * _dataString)
{
dataString = _dataString;
byte shapeIdArray[2] ;
shapeIdArray[1] = (shapeID >> 8) & 0xFF;
shapeIdArray[0] = shapeID & 0xFF;
byte functionId = GLCD_TEXTBOX_TEXT;
OneSheeld.sendShieldFrame(GLCD_ID,0,GLCD_TEXTBOX_TYPE,3,newFunctionArg(1,&functionId),newFunctionArg(2,shapeIdArray)
,newFunctionArg(strlen(dataString),(byte *)dataString));
}
GLCDTextBox::~GLCDTextBox()
{
if(dataMalloced)
free(dataString);
}