-
Notifications
You must be signed in to change notification settings - Fork 1
/
smartvase.ino
300 lines (265 loc) · 7.7 KB
/
smartvase.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
#include "WiFly.h"
#include "Credentials.h"
#include <SMARTGPU.h> //include the SMARTGPU library!
#include <string.h>
SMARTGPU lcd; //create our object called LCD
//Variables para controlar cuándo han terminado de ejecutarse los procesos de Gmail, Traffic y Weather
boolean bConnectedW = false;
boolean bConnectedGm = false;
boolean bConnectedGs = false;
boolean bConnectedT = false;
boolean bFinishedW = false;
boolean bFinishedGm = false;
boolean bFinishedGs = false;
boolean bFinishedT = false;
//Variables para controlar el lugar de la pantalla donde se ha pulsado
int iOp = 0; //zona donde se ha marcado en pantalla {1,2,3}
int touch[2];
char valN = '0'; //número de mails leído
long initTime; //Momento de tiempo en el que el programa comienza
int nTimes=1; //Variable para controlar cuándo se tiene que ejecutar la comprobación de correo
float tiempo; //Variable que almacena el tiempo que ha pasado desde que comenzó el programa
void setup()
{
Serial.begin(9600);
initWifly();
initLCD(lcd);
while (!bFinishedGm){
nMessages();
}
bFinishedGm = false;
initTime=millis();
//pinMode(A6, INPUT);
pinMode(40, OUTPUT);
pinMode(41, OUTPUT);
pinMode(42, OUTPUT);
pinMode(43, OUTPUT);
}
void loop()
{
//wait for a touch on screen to do something
while(lcd.touchScreen(touch)==0){
tiempo = millis()-initTime;
if ((tiempo/1000) > (18000*nTimes)){
Serial.println("Comprobar correo");
while (!bFinishedGm){
nMessages();
}
bFinishedGm = false;
}
}
initTouch();
actionTouch();
}
//*******************************************************************************************************************
//Convert String to char*
//*******************************************************************************************************************
char * stringToChar(String sCadena)
{
char *track;
char tracklngth[sCadena.length() + 1];
sCadena.toCharArray(tracklngth, sCadena.length() + 1);
track = tracklngth;
return track;
}
//*******************************************************************************************************************
//inicializa el touch del menu
//*******************************************************************************************************************
void initTouch(){
//obtain icon number
if((touch[XCOORD]>26)&&(touch[XCOORD]<98)&&(touch[YCOORD]>94)&&(touch[YCOORD]<166)){
iOp=1;
}else if((touch[XCOORD]>129)&&(touch[XCOORD]<201)&&(touch[YCOORD]>94)&&(touch[YCOORD]<166)){
iOp=2;
}else if((touch[XCOORD]>224)&&(touch[XCOORD]<296)&&(touch[YCOORD]>94)&&(touch[YCOORD]<166)){
iOp=3;
}
}
//*******************************************************************************************************************
//inicializa la Wifly
//*******************************************************************************************************************
void initWifly(){
WiFly.begin();
Serial.println("Wifi connecting");
if (!WiFly.join(ssid, passphrase)) {
//if (!WiFly.join(ssid)) {
while (1) {
Serial.println("Wifi not connected");
// Hang on failure.
}
}
Serial.println("Wifi connected");
}
//*******************************************************************************************************************
//inicializa el LCD
//*******************************************************************************************************************
void initLCD(SMARTGPU lcd){
lcd.init(); //configure the serial and pinout of arduino board for SMARTGPU support
lcd.start(); //initialize the SMARTGPU processor
//lcd.imageSD(0,0,"MENU");
}
//*******************************************************************************************************************
//Realiza la acción adecuada en función de lo seleccionado en pantalla
//*******************************************************************************************************************
void actionTouch(){
switch (iOp){
//GMAIL
case 1:
switch (valN){
case '0':
lcd.imageSD(0,0,"MGmail");
while (!bFinishedGs){
Subjects();
}
bFinishedGs = false;
delay(5000);
lcd.imageSD(0,0,"MENU");
break;
case '1':
lcd.imageSD(0,0,"MENU");
while (!bFinishedGs){
Subjects();
}
bFinishedGs = false;
delay(5000);
lcd.imageSD(0,0,"MENU1M");
break;
case '2':
lcd.imageSD(0,0,"M2MG");
while (!bFinishedGs){
Subjects();
}
bFinishedGs = false;
delay(5000);
lcd.imageSD(0,0,"MENU2M");
break;
case '3':
lcd.imageSD(0,0,"M3MG");
while (!bFinishedGs){
Subjects();
}
bFinishedGs = false;
delay(5000);
lcd.imageSD(0,0,"MENU3M");
break;
default:
lcd.imageSD(0,0,"MnMG");
while (!bFinishedGs){
Subjects();
}
bFinishedGs = false;
delay(5000);
lcd.imageSD(0,0,"MENUnM");
break;
}
iOp=0;
//initTouch();
break;
//WEATHER
case 2:
switch (valN){
case '0':
lcd.imageSD(0,0,"MWeather");
while (!bFinishedW){
Weather();
}
bFinishedW = false;
delay(5000);
lcd.imageSD(0,0,"MENU");
break;
case '1':
Serial.println("M1MW");
lcd.imageSD(0,0,"M1MW");
while (!bFinishedW){
Weather();
}
bFinishedW = false;
delay(5000);
lcd.imageSD(0,0,"MENU1M");
break;
case '2':
lcd.imageSD(0,0,"M2MW");
while (!bFinishedW){
Weather();
}
bFinishedW = false;
delay(5000);
lcd.imageSD(0,0,"MENU2M");
break;
case '3':
lcd.imageSD(0,0,"M3MW");
while (!bFinishedW){
Weather();
}
bFinishedW = false;
delay(5000);
lcd.imageSD(0,0,"MENU3M");
break;
default:
lcd.imageSD(0,0,"MnMW");
while (!bFinishedW){
Weather();
}
bFinishedW = false;
delay(5000);
lcd.imageSD(0,0,"MENUnM");
break;
}
iOp=0;
//initTouch();
break;
//TRAFFIC
case 3:
switch (valN){
case '0':
lcd.imageSD(0,0,"MTraffic");
while (!bFinishedT){
Traffic();
}
bFinishedT = false;
delay(5000);
lcd.imageSD(0,0,"MENU");
break;
case '1':
lcd.imageSD(0,0,"M1MT");
while (!bFinishedT){
Traffic();
}
bFinishedT = false;
delay(5000);
lcd.imageSD(0,0,"MENU1M");
break;
case '2':
lcd.imageSD(0,0,"M2MT");
while (!bFinishedT){
Traffic();
}
bFinishedT = false;
delay(5000);
lcd.imageSD(0,0,"MENU2M");
break;
case '3':
lcd.imageSD(0,0,"M3MT");
while (!bFinishedT){
Traffic();
}
bFinishedT = false;
delay(5000);
lcd.imageSD(0,0,"MENU3M");
break;
default:
lcd.imageSD(0,0,"MnMT");
lcd.imageSD(0,0,"TSim");
//while (!bFinishedT){
// Traffic();
//}
bFinishedT = false;
delay(5000);
lcd.imageSD(0,0,"MENUnM");
break;
}
iOp=0;
//initTouch();
break;
}
}