-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOLED_menu.ino
315 lines (294 loc) · 9.41 KB
/
OLED_menu.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Keypad.h>
/////////////////////////////////////////////////////////////
const byte ROWS=6;
const byte COLS=3;
int UD=0; // position of rectangular box
int menu_set=0; // menu item number
int cursor_id=0; // Cursor POS
int temp=0; // value for dash_effect
int x=0; // Initial X value
int y=0; // Initial y value
int z=0; // Initial z value
char keys[ROWS][COLS]=
{
{'M','U','B'},
{'L','O','R'},
{'.','D','0'},
{'1','2','3'},
{'4','5','6'},
{'7','8','9'}
};
byte rowPins[ROWS] = {2,3,4,5,6,7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8,9,10}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
/////////////////////////////////////////////////////////////
#define OLED_RESET -1
#define PAUSE 1000
#define SCREEN_HEIGHT 64
#define SCREEN_WIDTH 128
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
/////////////////////////////////////////////////////////////
void setup()
{
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.fillScreen(0);
display.display();
}
String Main_Menu2[4][5][5]=
{
{{"WIFI","SCAN","ATCK","SERV","NETT"},{5,6,7,8,9},{10,11,12,13,14},{15,16,17,18,19},{20,21,22,23,24}},
{{"RFAT","RFSC","ATCK","BLST","JAMM"},{30,31,32,33,34},{35,36,37,38,39},{40,41,42,43,44},{9,9,9,9,9}},
{{"CARA","PHOB","ATTK","IGNI","KILL"},{25,46,47,48,49},{50,51,52,53,54},{55,56,57,58,59},{9,9,9,9,9}},
{{"BUNY","SYST","ARCH","MEAN","PALD"},{65,66,67,68,69},{70,71,72,73,74},{75,76,77,78,79},{9,9,9,9,9}}
};
/////////////////////////////////////////////////////////////
int cursor_pp=0;
void line_drawer(int c, int f)
{
display.setTextColor(c);
display.setCursor(f,5); //36, 74
display.print("-");
delay(20);
display.display();
display.setCursor(f,20);
display.print("-");
delay(20);
display.display();
display.setCursor(f,35);
display.print("-");
delay(20);
display.display();
display.setCursor(f,50);
display.print("-");
display.display();
}
int cursor_p=0;
int line_p=0;
void dash_drawer(int p,int c, int d)
{
if(temp>0)
{
display.setTextColor(0);
display.setCursor(c,temp); //////////////////// cursor pos 30,68
display.print("-");
display.drawLine(d,8,73,d,0); //////////////////// line pos 35,73
display.display();
}
display.setTextColor(1);
display.setCursor(c,p+5); //////////////////// cursor pos 30,68
display.print("-");
temp=p+5;
display.drawLine(d,8,d,53,1); //////////////////// line pos 35,73
delay(20);
display.display();
}
void line_functions()
{
line_drawer(0,cursor_pp);
dash_drawer(UD,cursor_p,line_p);
line_drawer(1,cursor_pp);
}
void rect_drawup(int p)
{
display.setTextColor(1);
display.setTextSize(1);
display.drawRect(p,3+UD,27,11,1);
display.drawRect(p,18+UD,27,11,0);
display.display();
}
void rect_drawdown(int j)
{
display.setTextColor(1);
display.setTextSize(1);
display.drawRect(j,3+UD,27,11,1);
display.drawRect(j,3+UD-15,27,11,0);
display.display();
}
int array_id=0; // current menu (in 3 Dimension)
int pos1=0;
void up_down(char KEY)
{
if(KEY=='U' && array_id>0)
{
if(UD>0)
{
UD-=15;
rect_drawup(pos1);
if(pos1!=79)
{
line_functions();
}
}
if(cursor_id>0)
{
cursor_id-=1;
}
else
{
}
}
else if(KEY=='D' && array_id>0)
{
if(UD<45)
{
UD+=15;
rect_drawdown(pos1);
if(pos1!=79)
{
line_functions();
}
}
if(cursor_id<=2)
{
cursor_id+=1;
}
else
{
}
}
}
////////////////////////////////////////////////////////
int bp=0;
void blank_space(int k)
{
display.fillRect(k,4,23,56,0); ///43
}
void key_handler(char KEY)
{
if (KEY=='M')
{
display.setTextColor(1);
display.setTextSize(1);
if(array_id==0)
{
menu_handler(x,y,z,array_id);
pos1=3;
bp=43;
cursor_p=30;
line_p=35;
cursor_pp=36;
rect_drawup(pos1);
line_functions();
array_id+=1;
menu_handler(x,y,z,array_id);
}
else if(array_id==1)
{
menu_handler(x,y,z,array_id);
pos1=41;
bp=81;
cursor_p=68;
line_p=73;
cursor_pp=74;
rect_drawup(pos1);
line_functions();
array_id+=1;
menu_handler(x,y,z,array_id);
}
else if(array_id==2)
{
menu_handler(x,y,z,array_id);
pos1=79;
rect_drawup(pos1);
line_functions();
}
Serial.print(array_id);
}
else if(KEY=='U' || KEY=='D')
{
if(pos1!=79)
{
blank_space(bp);
up_down(KEY);
menu_handler(x,y,z,array_id);
}
else
{
up_down(KEY);
}
}
else
{
}
}
////////////////////////////////////////////////////////
int j;
int t2=0;
void menu_handler(int x, int y, int z, int arr)
{
if(arr==0)
{
for(int i=0; i<4; i++)// value of x will change
{
display.setCursor(5,5+(i*15));
display.print(Main_Menu2[i][y][z]);
}
display.display();
}
if(arr==1)
{
j=0;
// display.setTextColor(1);
// display.setTextSize(1);
for(int i=1; i<=5; i++)// value of z will change
{
display.setCursor(43,5+(j*15));
display.print(Main_Menu2[cursor_id][y][i]);
j+=1;
}
display.display();
t2=cursor_id;
}
if(arr==2)
{
j=0;
for(int l=1; l<=5; l++)// value of x will change
{
display.setCursor(81,5+(j*15));
display.print(Main_Menu2[t2][l][cursor_id]);
j+=1;
}
display.display();
}
}
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY)
{
key_handler(key);
}
}
///////////////////////////////////////////////////////
void HIGH_ALERT()
{
display.drawRect(0,0,127,63,1 );
display.display(); // high alert
delay(10);
display.drawRect(0,0,127,63,0 );
display.display();
}
/////////////////////////////////////////////////////
void MEDIUM_ALERT()
{
display.drawRect(0,0,127,63,1 );
display.display(); //medium
delay(100);
display.drawRect(0,0,127,63,0 );
display.display();
delay(750);
}
////////////////////////////////////////////////////
void INFORMATION_ALERT()
{
display.drawRect(0,0,127,63,1);
display.display(); //informational
delay(100);
display.drawRect(0,0,127,63,0 );
display.display();
delay(1500);
}