-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplay.cpp
150 lines (121 loc) · 2.67 KB
/
display.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// display.cpp /////////////////////////////////////////////////////////////////
// wrapper for messages printed to the lcd /////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//#include <std_files>
//#include "Headers.h"
//#include "Source.c"
//#include "Headers.hpp"
//#include "Source.cpp"
#include "display.h"
#ifdef PRESEASON
#include <iostream>
#endif
Display::Display()
{
for(int cy = 0; cy != 16; ++cy)
{ lineOne[cy] = clear_character;
lineTwo[cy] = clear_character;
}
}
Display::Display(String line_one, String line_two)
{
for(int cy = 0; cy != 16; ++cy)
{ lineOne[cy] = (line_one.c_str())[cy];
}
for(int cy = 0; cy != 16; ++cy)
{ lineTwo[cy] = (line_two.c_str())[cy];
}
}
String Display::getLine(short line_number)
{
String output = " ";
if(line_number == 1)
{
for(int cy = 0; cy != 16; ++cy)
{ output[cy] = lineOne[cy];
}
//output[0] = 'y';
}
else if(line_number == 2)
{ for(int cy = 0; cy != 16; ++cy)
{ output[cy] = lineTwo[cy];
}
}
else
{ print("line number inaccessible");
String output = "error";
}
//print("getLine is returning");
//print(output);
return output;
}
void Display::clearLine(short line_number)
{ if((line_number == 2)||(line_number ==1))
{
for(int cy = 0; cy != 16; ++cy)
{ if(line_number == 1)
{ lineOne[cy] = clear_character;
}
else if(line_number == 2)
{ lineTwo[cy] = clear_character;
}
}
}
}
void Display::clearDisplay()
{ this->clearLine(1);
this->clearLine(2);
}
void Display::printToLine(short line_number, short startPoint, String input)
{
//#ifdef PRESEASON
if(line_number == 1)
{
for(int cy = 0; cy != 16; ++cy)
{ if((cy >= startPoint)&&(cy < (startPoint+input.length()) ))
{ lineOne[cy] = input[cy - startPoint];
}
}
}
else if(line_number == 2)
{ for(int cy = 0; cy != 16; ++cy)
{ if((cy >= startPoint)&&(cy < (startPoint+input.length()) ))
{ lineTwo[cy] = input[cy - startPoint];
}
}
}
else
{ print("error printing to line");
print("line number inaccessible");
}
//#else
//#endif
}
String getStringAtInt(int input)
{
String output;
#ifdef PRESEASON
output = std::to_string(input);
#else
output = String(input);
#endif
return output;
}
void Display::printToLine(short line_number, short startPoint, int input)
{
printToLine(line_number, startPoint, getStringAtInt(input));
}
#ifdef PRESEASON
void Display::printContents()
{
for(int cy = 0; cy != 16; ++cy)
{ std::cout << lineOne[cy] << ", ";
} std::cout << std::endl;
for(int cy = 0; cy != 16; ++cy)
{ std::cout << lineTwo[cy] << ", ";
} std::cout << std::endl;
}
#endif
Display::~Display()
{
}