-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoice-game-controller.ino
More file actions
539 lines (490 loc) · 25.7 KB
/
Copy pathvoice-game-controller.ino
File metadata and controls
539 lines (490 loc) · 25.7 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
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
#include <Adafruit_SSD1306.h>
#include "VoiceRecognitionV3.h"
#include "Keyboard.h"
// Microphone bitmap
int micBitmapSize = 32;
const unsigned char micBitmap [] PROGMEM = {
0x00, 0x03, 0xe0, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x18, 0x0c, 0x00,
0x00, 0x30, 0x06, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x30, 0x06, 0x00,
0x00, 0x30, 0x06, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x30, 0x06, 0x00,
0x00, 0x30, 0x06, 0x00, 0x03, 0x30, 0x06, 0x60, 0x03, 0x30, 0x06, 0x60, 0x03, 0x30, 0x06, 0x60,
0x03, 0x30, 0x06, 0x60, 0x03, 0x30, 0x06, 0x60, 0x01, 0x98, 0x0c, 0x60, 0x01, 0x9c, 0x1c, 0xc0,
0x01, 0xcf, 0xf8, 0xc0, 0x00, 0xc3, 0xf1, 0x80, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x38, 0x0f, 0x00,
0x00, 0x1f, 0xfc, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0xc0, 0x00,
0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0x80
};
// Jump icon bitmap
const unsigned char jumpBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x40, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x08, 0x80, 0x00, 0x00, 0x00, 0x02, 0x10, 0x08, 0x80,
0x00, 0x00, 0x00, 0x04, 0x08, 0x11, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x11, 0x00, 0x00, 0x00,
0x00, 0x08, 0x04, 0x22, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x22, 0x00, 0x00, 0x00, 0x00, 0x08,
0x04, 0x44, 0x80, 0x00, 0x00, 0x00, 0x08, 0x04, 0x88, 0x80, 0x00, 0x00, 0x00, 0x04, 0x09, 0x08,
0x80, 0x00, 0x00, 0x00, 0x02, 0x11, 0x10, 0x80, 0x00, 0x00, 0x00, 0x01, 0xe2, 0x10, 0x80, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x20, 0x80, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x40, 0x80, 0x00, 0x00, 0x00,
0x07, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x18, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x01,
0x08, 0x80, 0x00, 0x00, 0x01, 0x00, 0x01, 0x08, 0x80, 0x00, 0x00, 0x02, 0x00, 0x01, 0x08, 0x80,
0x00, 0x00, 0x04, 0x1c, 0x01, 0x08, 0x80, 0x00, 0x00, 0x04, 0x22, 0x01, 0x08, 0x80, 0x00, 0x00,
0x04, 0x42, 0x01, 0x00, 0x80, 0x00, 0x00, 0x04, 0x42, 0x01, 0x00, 0x80, 0x00, 0x00, 0x02, 0x22,
0x01, 0x00, 0x80, 0x00, 0x00, 0x02, 0x22, 0x01, 0x00, 0x80, 0x00, 0x00, 0x01, 0x12, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x92, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x80, 0x00, 0x00,
0x00, 0x00, 0x4a, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x32, 0x00, 0x30, 0x00, 0x00, 0x00, 0x04,
0x02, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x02, 0x26, 0x02, 0x00, 0x00, 0x00, 0x04, 0x82, 0x21,
0x01, 0x00, 0x00, 0x00, 0x04, 0x84, 0x20, 0xc1, 0x00, 0x00, 0x00, 0x04, 0x84, 0x20, 0x21, 0x00,
0x00, 0x00, 0x04, 0x84, 0x20, 0x41, 0x00, 0x00, 0x00, 0x04, 0x84, 0x40, 0x81, 0x00, 0x00, 0x00,
0x04, 0x84, 0x41, 0x06, 0x00, 0x00, 0x00, 0x04, 0x84, 0x42, 0x08, 0x00, 0x00, 0x00, 0x04, 0x88,
0x42, 0x10, 0x00, 0x00, 0x00, 0x04, 0x88, 0x84, 0x20, 0x00, 0x00, 0x00, 0x04, 0x08, 0x84, 0x40,
0x00, 0x00, 0x00, 0x04, 0x08, 0x84, 0x80, 0x00, 0x00, 0x00, 0x04, 0x11, 0x03, 0x04, 0x00, 0x00,
0x00, 0x04, 0x11, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x11, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x22, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Shoot icon bitmap
const unsigned char shootBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x80, 0x80, 0x00, 0x00, 0x00, 0x40, 0x11, 0x81,
0x80, 0x00, 0x00, 0x00, 0x70, 0x21, 0x83, 0x00, 0x00, 0x00, 0x00, 0x50, 0x21, 0x87, 0x00, 0x00,
0x00, 0x00, 0x48, 0x61, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x44, 0x41, 0xb3, 0x00, 0x00, 0x08, 0x00,
0x42, 0x41, 0xc6, 0x00, 0x00, 0x0e, 0x00, 0x43, 0x81, 0x86, 0x00, 0x00, 0x07, 0xc0, 0x41, 0x81,
0x0e, 0x00, 0x00, 0x01, 0x38, 0x40, 0x00, 0x0e, 0x00, 0x30, 0x00, 0x87, 0x40, 0x00, 0x0c, 0x1f,
0xe0, 0x00, 0x40, 0xc0, 0x00, 0x1f, 0xf1, 0x80, 0x00, 0x60, 0x00, 0x00, 0x1e, 0x03, 0x80, 0x00,
0x30, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x1c, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0xf0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x1f, 0x80,
0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07,
0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x30, 0x00, 0x00,
0x00, 0x7c, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x70,
0x00, 0x07, 0xff, 0xc0, 0x00, 0x00, 0x3c, 0x00, 0x1f, 0xff, 0xc1, 0x80, 0x0c, 0x1e, 0x00, 0x3f,
0xff, 0xe1, 0xc2, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x23, 0xe7, 0x8f, 0xc7, 0x00, 0x00, 0x00, 0x27,
0xf7, 0xc7, 0xf3, 0x80, 0x00, 0x00, 0x27, 0x3e, 0x76, 0x3d, 0xc0, 0x00, 0x00, 0x2f, 0x1c, 0x3e,
0x1f, 0xe0, 0x00, 0x00, 0x2e, 0x0c, 0x1e, 0x03, 0xf0, 0x00, 0x00, 0x3c, 0x00, 0x06, 0x00, 0x78,
0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Run icon bitmap
const unsigned char runBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x04, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x10, 0x02, 0x00, 0x3f, 0xfe, 0x31, 0x80, 0x10, 0x02,
0x00, 0x00, 0x00, 0x40, 0x40, 0x10, 0x02, 0x00, 0x00, 0x00, 0x80, 0x20, 0x10, 0x02, 0x00, 0x00,
0x03, 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x04, 0x00, 0x0c, 0x10, 0x02, 0x00, 0x00, 0x08, 0x0c,
0x02, 0x08, 0x04, 0x00, 0x0f, 0x10, 0x12, 0x01, 0x84, 0x08, 0x00, 0x00, 0x20, 0x61, 0x00, 0x43,
0xf0, 0x00, 0x00, 0x40, 0x80, 0x80, 0x20, 0x00, 0x3c, 0x00, 0x41, 0x00, 0x40, 0x10, 0x00, 0x42,
0x00, 0x42, 0x00, 0x40, 0x08, 0x01, 0x82, 0x00, 0x3c, 0x00, 0x80, 0x04, 0x02, 0x02, 0x00, 0x00,
0x03, 0x00, 0x02, 0x04, 0x04, 0x00, 0x00, 0x04, 0x00, 0x01, 0x08, 0x08, 0x00, 0x00, 0x08, 0x00,
0x00, 0xf0, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x3f, 0xfc, 0x20, 0x01, 0xe0, 0x00,
0x40, 0x00, 0x00, 0x40, 0x02, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x04, 0x0c, 0x01, 0x00, 0x00,
0x00, 0x80, 0x08, 0x02, 0x06, 0x00, 0x00, 0x01, 0x00, 0x10, 0x01, 0x88, 0x00, 0x00, 0x01, 0x00,
0x20, 0x00, 0x70, 0x00, 0x03, 0xf9, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x02, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x62, 0x00, 0x00, 0x00,
0x00, 0x02, 0x04, 0x81, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x80, 0x80, 0x00, 0x00, 0x00, 0x02,
0x04, 0x80, 0x40, 0x00, 0x00, 0x00, 0x04, 0x08, 0x80, 0x20, 0x00, 0x00, 0x00, 0x04, 0x08, 0x40,
0x20, 0x00, 0x00, 0x00, 0x04, 0x08, 0x20, 0x20, 0x00, 0x00, 0x00, 0x08, 0x08, 0x20, 0x20, 0x00,
0x00, 0x00, 0x30, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x40, 0x10, 0x40, 0x40, 0x00, 0x00, 0x01,
0x80, 0x20, 0x80, 0x80, 0x00, 0x00, 0x06, 0x00, 0x60, 0x81, 0x00, 0x00, 0x00, 0x08, 0x00, 0xc1,
0x02, 0x00, 0x00, 0x00, 0x10, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x20, 0x06, 0x02, 0x04, 0x00,
0x00, 0x00, 0x40, 0x18, 0x04, 0x08, 0x00, 0x00, 0x00, 0x40, 0x20, 0x04, 0x10, 0x00, 0x00, 0x00,
0x40, 0xc0, 0x04, 0x10, 0x00, 0x00, 0x00, 0x43, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x3c, 0x00,
0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Left icon bitmap
const unsigned char leftBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x19, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x80, 0x00,
0x00, 0x00, 0x00, 0x03, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x06, 0x01, 0x80, 0x00, 0x00, 0x00,
0x00, 0x0c, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x18, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x30,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x02, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x60, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x70, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x80,
0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x1c, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x0e, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
0x07, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x81, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc1,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x39, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Right icon bitmap
const unsigned char rightBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x83, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x81,
0xc0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x70, 0x00,
0x7f, 0xff, 0xff, 0xff, 0x80, 0x38, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x40, 0x00,
0x00, 0x00, 0x00, 0x0e, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x03, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0c, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0x00,
0x00, 0x00, 0x00, 0x01, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x06, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x7f, 0xff, 0xff, 0xff, 0x80, 0x18,
0x00, 0x7f, 0xff, 0xff, 0xff, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x60, 0x00, 0x00,
0x00, 0x00, 0x01, 0x80, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x80, 0x00, 0x00, 0x00, 0x00,
0x01, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Up icon bitmap
const unsigned char upBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc3,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x81, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x0e, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x30, 0x00, 0x00, 0x00,
0x00, 0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xe0,
0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x01,
0x80, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x60, 0x00,
0x00, 0x1c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x70,
0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0xc0, 0x00, 0x00,
0x00, 0x03, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc0, 0x07, 0xff, 0x80, 0x00, 0x03, 0xff, 0xe0, 0x07, 0xff, 0x80, 0x00, 0x03, 0xff, 0xe0, 0x00,
0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03,
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00,
0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03,
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00,
0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Down icon bitmap
const unsigned char downBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x07, 0xff, 0xc0, 0x00, 0x01, 0xff, 0xe0,
0x07, 0xff, 0xc0, 0x00, 0x01, 0xff, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x80,
0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x60, 0x00, 0x00,
0x00, 0x07, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1c,
0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x60, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x0e,
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x38, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x01, 0x81, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Game button structure
struct GameButton {
int pin;
int key;
bool isPressed;
};
// Button input mappings
int button1Key = 105;
int button2Key = 101;
int button3Key = 97;
int button4Key = 32;
int button5Key = 176;
int button6Key = 122;
// Game buttons array
const int numButtons = 6;
GameButton gameButtons[numButtons] = {
{4, button1Key, false}, // Button 1
{5, button2Key, false}, // Button 2
{6, button3Key, false}, // Button 3
{7, button4Key, false}, // Button 4
{8, button5Key, false}, // Button 5
{9, button6Key, false} // Button 6
};
// Joystick pins
int xPin = A0;
int yPin = A1;
// Joystick input mapping
int upKey = KEY_UP_ARROW;
int downKey = KEY_DOWN_ARROW;
int leftKey = KEY_LEFT_ARROW;
int rightKey = KEY_RIGHT_ARROW;
// Joystick states
bool upPressed = false;
bool downPressed = false;
bool leftPressed = false;
bool rightPressed = false;
// Adafruit OLED object
int SCREEN_WIDTH = 128;
int SCREEN_HEIGHT = 64;
int SCREEN_ADDRESS = 0x3D;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
// Listening animation settings
int centerX = SCREEN_WIDTH / 2;
int centerY = SCREEN_HEIGHT / 2;
int maxRadius = 31;
int minRadius = 23;
int animationFrames = 12;
int animationFrame = 0;
// Voice command icon settings
int iconSize = 56;
int iconIndex = -1;
bool iconDisplayed = false;
unsigned long iconStartMillis;
const unsigned long iconDuration = 1500;
// Voice recognition module object
VR myVR(10,11);
// Voice recognition buffer
uint8_t buf[64];
// Voice command structure
struct VoiceCommand {
String name;
int key;
unsigned long startMillis;
unsigned long duration;
bool isPressed;
const unsigned char* bitmap;
};
// Voice command input mappings
int jumpCommandKey = 32;
int runCommandKey = 101;
int shootCommandKey = 97;
int upCommandKey = KEY_UP_ARROW;
int downCommandKey = KEY_DOWN_ARROW;
int leftCommandKey = KEY_LEFT_ARROW;
int rightCommandKey = KEY_RIGHT_ARROW;
// Game voice commands
const int numCommands = 7;
VoiceCommand voiceCommands[numCommands] = {
{"Jump", jumpCommandKey, 0, 500, false, jumpBitmap}, // Jump
{"Run", runCommandKey, 0, 500, false, runBitmap}, // Run
{"Shoot", shootCommandKey, 0, 250, false, shootBitmap}, // Shoot
{"Up", upCommandKey, 0, 1000, false, upBitmap}, // Up
{"Down", downCommandKey, 0, 1000, false, downBitmap}, // Down
{"Left", leftCommandKey, 0, 1000, false, leftBitmap}, // Left
{"Right", rightCommandKey, 0, 1000, false, rightBitmap} // Right
};
void setup() {
// Initialize serial communication
Serial.begin(115200);
// Delay
delay(2000);
// Initialize oled display
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
// Initialize button pins
for (int i = 0; i < numButtons; i++) {
pinMode(gameButtons[i].pin, INPUT_PULLUP);
}
// Initialize voice recognition
myVR.begin(9600);
// Clear voice recognizer
if(myVR.clear() == 0){
Serial.println("Recognizer cleared.");
}else{
Serial.println("Voice Recognition Module not found.");
while(1);
}
// Load trained voice records
for (int i = 0; i < numCommands; i++) {
VoiceCommand command = voiceCommands[i];
myVR.load((uint8_t)i);
Serial.println(String(command.name) + " loaded");
}
// Initialize keyboard output
Keyboard.begin();
}
void loop() {
// Process button inputs
processButtons();
// Process joystick inputs
processJoystick();
// Process voice recognizer
processVoice();
// Process display
processDisplay();
}
void processDisplay() {
// Display command icon if active
if (iconIndex > -1) {
if (iconDisplayed == false) {
// Display the selected icon
display.clearDisplay();
display.drawBitmap(
centerX - iconSize/2,
centerY - iconSize/2,
voiceCommands[iconIndex].bitmap,
iconSize,
iconSize,
WHITE
);
iconDisplayed = true;
iconStartMillis = millis();
} else {
unsigned long currentMillis = millis();
if (currentMillis - iconStartMillis >= iconDuration) {
iconIndex = -1;
iconDisplayed = false;
}
}
}
// Display listening animation
else {
// Calculate circle radius
float animationProgress = float(animationFrame) / float(animationFrames - 1);
float animationPhase = animationProgress * 2.0 * PI;
float pulsatingFactor = (cos(animationPhase) + 1.0) / 2.0;
int currentRadius = minRadius + int((maxRadius - minRadius) * pulsatingFactor);
// Display mic and circle
display.clearDisplay();
display.drawBitmap(
centerX - micBitmapSize/2,
centerY - micBitmapSize/2,
micBitmap,
micBitmapSize,
micBitmapSize,
WHITE
);
display.drawCircle(centerX, centerY, currentRadius, SSD1306_WHITE);
// Update frame count
animationFrame = (animationFrame + 1) % animationFrames;
}
// Update display
display.display();
}
void processVoice() {
// Perform voice recognition
int ret = myVR.recognize(buf, 50);
// Process voice record match
if (ret > 0) {
int index = buf[1];
if (voiceCommands[index].isPressed == false) {
Serial.println(String(voiceCommands[index].name) + " command recognized");
Keyboard.press(voiceCommands[index].key);
voiceCommands[index].isPressed = true;
voiceCommands[index].startMillis = millis();
iconIndex = index;
}
}
// Process no voice record match
else {
unsigned long currentMillis = millis();
for (int i = 0; i < numCommands; i++) {
if (voiceCommands[i].isPressed == true && currentMillis - voiceCommands[i].startMillis >= voiceCommands[i].duration) {
Keyboard.release(voiceCommands[i].key);
voiceCommands[i].isPressed = false;
}
}
}
}
void processButtons() {
// Loop through all buttons
for (int i = 0; i < numButtons; i++) {
// Read button digital value - LOW == Pressed
int buttonVal = digitalRead(gameButtons[i].pin);
// Press key on button press
if (buttonVal == LOW && gameButtons[i].isPressed == false) {
Keyboard.press(gameButtons[i].key);
gameButtons[i].isPressed = true;
Serial.println("Button pressed");
}
// Release key on button release
if (buttonVal == HIGH && gameButtons[i].isPressed == true) {
Keyboard.release(gameButtons[i].key);
gameButtons[i].isPressed = false;
Serial.println("Button released");
}
}
}
void processJoystick() {
// Read X and Y analog values
int yValue = analogRead(yPin);
int xValue = analogRead(xPin);
// Map values between 0-100
int xMapped = map(xValue, 0, 1023, 0, 100);
int yMapped = map(yValue, 0, 1023, 0, 100);
// Apply X keyboard inputs
if (xMapped < 30) {
if (leftPressed == false) {
leftPressed = true;
Keyboard.press(leftKey);
Serial.println("Left pressed");
}
} else if (xMapped > 60) {
if (rightPressed == false) {
rightPressed = true;
Keyboard.press(rightKey);
Serial.println("Right pressed");
}
} else {
if (leftPressed == true) {
leftPressed = false;
Keyboard.release(leftKey);
Serial.println("Left released");
}
if (rightPressed == true) {
rightPressed = false;
Keyboard.release(rightKey);
Serial.println("Right released");
}
}
// Apply Y keyboard inputs
if (yMapped < 30) {
if (downPressed == false) {
downPressed = true;
Keyboard.press(downKey);
Serial.println("Down released");
}
} else if (yMapped > 60) {
if (upPressed == false) {
upPressed = true;
Keyboard.press(upKey);
Serial.println("Up pressed");
}
} else {
if (downPressed == true) {
downPressed = false;
Keyboard.release(downKey);
Serial.println("Down released");
}
if (upPressed == true) {
upPressed = false;
Keyboard.release(upKey);
Serial.println("Up released");
}
}
}