-
Notifications
You must be signed in to change notification settings - Fork 16
/
_lcd.ino
296 lines (284 loc) · 6 KB
/
_lcd.ino
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*
Demonstrates the use a 16x2 LCD display. The LiquidCrystal library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface.
The circuit:
* LCD RS pin to digital pin 13
* LCD En pin to digital pin 12
* LCD D4 pin to digital pin 11
* LCD D5 pin to digital pin 10
* LCD D6 pin to digital pin 09
* LCD D7 pin to digital pin 08
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
// RS EN D4 D5 D6 D7
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
// make some custom characters
byte armsUpDn[8] = {
0b00000,
0b00100,
0b01110,
0b00100,
0b00000,
0b01110,
0b00000,
0b00000
};
void Setup_LCD()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// create a new character
lcd.createChar(1, armsUpDn);
// startup LOGO
lcd.setCursor(4,0);
lcd.print("CNCProVN");
lcd.setCursor(3,1);
lcd.print("Plasma THC");
delay(100);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("www.cncprovn.com");
lcd.setCursor(5,1);
lcd.print("v:02.0");
delay(100);
lcd.clear();
}
void doLCD()
{
if (show >= 2)
{
show = 0;
switch (menu)
{
case 0:
doLCDDefault();
break;
case 1:
doLCDMenu();
break;
case 11:
doLCDMenuSetup();
break;
case 111:
doLCDDelayTime();
break;
case 112:
doLCDHysreresis();
break;
case 113:
doLCDStartVoltage();
break;
case 114:
doLCDLoadDefault();
break;
case 12:
doLCDTest();
break;
default:
doLCDDefault();
}
}
}
void doLCDDefault()
{
if (encoderVal < 0) encoderVal = 0;
else if (encoderVal > 250) encoderVal = 250;
SetV = encoderVal;
if (SetV != oldValue)
{
SaveData(_SetV, SetV);
oldValue = SetV;
}
lcd.setCursor(0,0);
lcd.print("SetV: ");
lcd.print(SetV);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("ArcV: ");
lcd.print(ArcV / 10);
lcd.print(" ");
}
//Main menu
void doLCDMenu()
{
if (encoderVal < 0) encoderVal = 2;
pos = encoderVal % 3;
switch (pos)
{
case 0:
lcd.setCursor(0,0);
lcd.print("> Exit ");
lcd.setCursor(0,1);
lcd.print(" Setup ");
break;
case 1:
lcd.setCursor(0,0);
lcd.print("> Setup ");
lcd.setCursor(0,1);
lcd.print(" Test ");
break;
case 2:
lcd.setCursor(0,0);
lcd.print("> Test ");
lcd.setCursor(0,1);
lcd.print(" Exit ");
break;
}
}
// Setup
void doLCDMenuSetup()
{
if (encoderVal < 0) encoderVal = 4;
pos = abs(encoderVal % 5);
switch (pos)
{
case 0:
lcd.setCursor(0,0);
lcd.print(">> Exit ");
lcd.setCursor(0,1);
lcd.print(" Delay Time ");
break;
case 1:
lcd.setCursor(0,0);
lcd.print(">> Delay Time ");
lcd.setCursor(0,1);
lcd.print(" Hysreresis ");
break;
case 2:
lcd.setCursor(0,0);
lcd.print(">> Hysreresis ");
lcd.setCursor(0,1);
lcd.print(" Start Voltage");
break;
case 3:
lcd.setCursor(0,0);
lcd.print(">> Start Voltage");
lcd.setCursor(0,1);
lcd.print(" Load Default ");
break;
case 4:
lcd.setCursor(0,0);
lcd.print(">> Load Default ");
lcd.setCursor(0,1);
lcd.print(" Exit ");
break;
}
}
// Test
void doLCDTest()
{
if (encoderVal < 0) encoderVal = 2;
pos = abs(encoderVal % 3);
switch (pos)
{
case 0:
lcd.setCursor(0,0);
lcd.print("Test > Exit ");
lcd.setCursor(0,1);
lcd.print(" Torch Up ");
bitWrite(PORTC, 3, 0);
bitWrite(PORTC, 4, 0);
bitWrite(PORTC, 5, 0);
break;
case 1:
lcd.setCursor(0,0);
lcd.print("Test > Torch Up ");
lcd.setCursor(0,1);
lcd.print(" Torch Dn ");
bitWrite(PORTC, 3, 0);
bitWrite(PORTC, 4, 1);
bitWrite(PORTC, 5, 1);
break;
case 2:
lcd.setCursor(0,0);
lcd.print("Test > Torch Dn ");
lcd.setCursor(0,1);
lcd.print(" Exit ");
bitWrite(PORTC, 3, 1);
bitWrite(PORTC, 4, 0);
bitWrite(PORTC, 5, 1);
break;
}
}
void doLCDDelayTime()
{
if (encoderVal < 1) encoderVal = 1;
else if (encoderVal > 200) encoderVal = 200;
DT = encoderVal;
if (DT != oldValue)
{
SaveData(_DT, DT);
oldValue = DT;
LCDtime = 0;
}
double x = DT / 10.00;
lcd.setCursor(0,0);
lcd.print("Set > Delay Time");
lcd.setCursor(0,1);
lcd.print(" : ");
lcd.print(x, 1);
lcd.print(" s ");
}
void doLCDHysreresis()
{
if (encoderVal < 1) encoderVal = 1;
else if (encoderVal > 99) encoderVal = 99;
HyS = encoderVal;
if (HyS != oldValue)
{
SaveData(_HyS, HyS);
oldValue = HyS;
LCDtime = 0;
}
double x = HyS / 10.00;
lcd.setCursor(0,0);
lcd.print("Set > Hysreresis");
lcd.setCursor(0,1);
lcd.print(" :");
lcd.write(1);
lcd.print(x, 1);
lcd.print(" V ");
}
void doLCDStartVoltage()
{
if (encoderVal < 50) encoderVal = 50;
else if (encoderVal > 250) encoderVal = 250;
StV = encoderVal;
if (StV != oldValue)
{
SaveData(_StV, StV);
oldValue = StV;
LCDtime = 0;
}
lcd.setCursor(0,0);
lcd.print("Set > Start Volt");
lcd.setCursor(0,1);
lcd.print(" : ");
lcd.print(StV);
lcd.print(" V ");
}
void doLCDLoadDefault()
{
Default();
for (byte i = 0; i < 100; i++)
{
lcd.setCursor(0,0);
lcd.print(" Default ");
lcd.setCursor(0,1);
lcd.print("Load ");
lcd.print(i);
lcd.print(" ");
lcd.print("%");
lcd.print(" ");
delay(10);
}
lcd.setCursor(0,1);
lcd.print(" DONE ");
delay(1000);
menu = 11;
}