-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextField.cpp
More file actions
71 lines (51 loc) · 1.77 KB
/
TextField.cpp
File metadata and controls
71 lines (51 loc) · 1.77 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
#include "TextField.h"
#include <LiquidCrystal_I2C.h>
extern LiquidCrystal_I2C lcd; // 1602 LCD Setup
TextField::TextField(String _text, int _column, int _row)
{
this->cursors = false;
this->text = _text;
this->row = _row;
this->column = _column;
}
//--------------------------------------------P R I N T F I E L D--------------------------------------------
void TextField::printField()
{
lcd.setCursor(column, row); // move to the specified location on the screen
lcd.print(text); // print the text
if (cursors == true)
{
printCursors();
}
else
{
removeCursors();
}
}
//--------------------------------------------S E L E C T F I E L D--------------------------------------------
void TextField::selectField()
{
cursors = true;
}
//------------------------------------------D E S E L E C T F I E L D------------------------------------------
void TextField::deselectField()
{
cursors = false;
}
//---------------------------------------------I S S E L E C T E D---------------------------------------------
bool TextField::isSelected()
{
return cursors; // if the cursors are on then it is selected
}
//-------------------------------------------P R I N T C U R S O R S-------------------------------------------
void TextField::printCursors()
{
lcd.setCursor((column - 1), row);
lcd.print(">");
}
//-------------------------------------------R E M O V E C U R S O R S-------------------------------------------
void TextField::removeCursors()
{
lcd.setCursor((column - 1), row);
lcd.print(" ");
}