forked from justcallmekoko/ESP32Marauder
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMenuFunctions.cpp
More file actions
3835 lines (3391 loc) · 151 KB
/
MenuFunctions.cpp
File metadata and controls
3835 lines (3391 loc) · 151 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
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "MenuFunctions.h"
#include "lang_var.h"
#ifdef HAS_SCREEN
extern const unsigned char menu_icons[][66];
void MenuFunctions::buttonNotSelected(int b, int x) {
if (x == -1)
x = b;
// Ensure b is within valid button index range
b = (x - menu_start_index) % BUTTON_SCREEN_LIMIT;
#ifdef HAS_MINI_SCREEN
display_obj.tft.setFreeFont(NULL);
display_obj.key[b].drawButton(false, current_menu->list->get(x).name);
#endif
uint16_t color = this->getColor(current_menu->list->get(x).color);
#ifdef HAS_FULL_SCREEN
display_obj.tft.setFreeFont(MENU_FONT);
display_obj.key[b].drawButton(false, current_menu->list->get(x).name);
if ((current_menu->list->get(x).name != text09) && (current_menu->list->get(x).icon != 255))
display_obj.tft.drawXBitmap(0,
KEY_Y + (b * (KEY_H + KEY_SPACING_Y)) - (ICON_H / 2),
menu_icons[current_menu->list->get(x).icon],
ICON_W,
ICON_H,
TFT_BLACK,
color);
display_obj.tft.setFreeFont(NULL);
#endif
}
void MenuFunctions::buttonSelected(int b, int x) {
if (x == -1)
x = b;
// Ensure b is within valid button index range
b = (x - menu_start_index) % BUTTON_SCREEN_LIMIT;
uint16_t color = this->getColor(current_menu->list->get(x).color);
#ifdef HAS_MINI_SCREEN
display_obj.tft.setFreeFont(NULL);
display_obj.key[b].drawButton(true, current_menu->list->get(x).name);
#endif
#ifdef HAS_FULL_SCREEN
display_obj.tft.setFreeFont(MENU_FONT);
display_obj.key[b].drawButton(true, current_menu->list->get(x).name);
if ((current_menu->list->get(x).name != text09) && (current_menu->list->get(x).icon != 255))
display_obj.tft.drawXBitmap(0,
KEY_Y + (b * (KEY_H + KEY_SPACING_Y)) - (ICON_H / 2),
menu_icons[current_menu->list->get(x).icon],
ICON_W,
ICON_H,
TFT_BLACK,
color);
display_obj.tft.setFreeFont(NULL);
#endif
}
void MenuFunctions::displayMenuButtons() {
#ifdef HAS_ILI9341
// Draw lines to show each menu button
for (int i = 0; i < 3; i++) {
// Draw horizontal line on left
display_obj.tft.drawLine(0,
TFT_HEIGHT / 3 * (i),
(TFT_WIDTH / 12) / 2,
TFT_HEIGHT / 3 * (i),
TFT_FARTGRAY);
// Draw horizontal line on right
display_obj.tft.drawLine(TFT_WIDTH - 1 - ((TFT_WIDTH / 12) / 2),
TFT_HEIGHT / 3 * (i),
TFT_WIDTH,
TFT_HEIGHT / 3 * (i),
TFT_FARTGRAY);
// Draw vertical line on left
display_obj.tft.drawLine(0,
(TFT_HEIGHT / 3 * (i)) - ((TFT_WIDTH / 12) / 2),
0,
(TFT_HEIGHT / 3 * (i)) + ((TFT_WIDTH / 12) / 2),
TFT_FARTGRAY);
// Draw vertical line on right
display_obj.tft.drawLine(TFT_WIDTH - 1,
(TFT_HEIGHT / 3 * (i)) - ((TFT_WIDTH / 12) / 2),
TFT_WIDTH - 1,
(TFT_HEIGHT / 3 * (i)) + ((TFT_WIDTH / 12) / 2),
TFT_FARTGRAY);
}
#endif
}
// Function to check menu input
void MenuFunctions::main(uint32_t currentTime)
{
// Some function exited and we need to go back to normal
if (display_obj.exit_draw) {
if (wifi_scan_obj.currentScanMode != WIFI_CONNECTED)
wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF;
display_obj.exit_draw = false;
this->orientDisplay();
}
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == WIFI_CONNECTED) ||
(wifi_scan_obj.currentScanMode == OTA_UPDATE) ||
(wifi_scan_obj.currentScanMode == ESP_UPDATE) ||
(wifi_scan_obj.currentScanMode == SHOW_INFO) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_GPS_DATA) ||
(wifi_scan_obj.currentScanMode == GPS_POI) ||
(wifi_scan_obj.currentScanMode == GPS_TRACKER) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_GPS_NMEA)) {
if (wifi_scan_obj.orient_display) {
this->orientDisplay();
wifi_scan_obj.orient_display = false;
}
}
if (currentTime != 0) {
if (currentTime - initTime >= BANNER_TIME) {
this->initTime = millis();
if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) &&
(wifi_scan_obj.currentScanMode != LV_ADD_SSID))
this->updateStatusBar();
// Do channel analyzer stuff
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_ANALYZER)){
#ifdef HAS_SCREEN
this->setGraphScale(this->graphScaleCheck(wifi_scan_obj._analyzer_values));
this->drawGraph(wifi_scan_obj._analyzer_values);
#endif
}
if (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ACT) {
#ifdef HAS_SCREEN
this->setGraphScale(this->graphScaleCheckSmall(wifi_scan_obj.channel_activity));
this->drawGraphSmall(wifi_scan_obj.channel_activity);
#endif
}
}
}
boolean pressed = false;
// This is code from bodmer's keypad example
uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
// Get the display buffer out of the way
if ((wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF ) &&
(wifi_scan_obj.currentScanMode != WIFI_CONNECTED) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_AP_SPAM) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_CSA) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_QUIET) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_AUTH) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_DEAUTH) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_DEAUTH_MANUAL) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_DEAUTH_TARGETED) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_BAD_MSG_TARGETED) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_BAD_MSG) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_SLEEP) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_SLEEP_TARGETED) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_MIMIC) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_FUNNY_BEACON) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_RICK_ROLL))
display_obj.displayBuffer();
int pre_getTouch = millis();
#ifdef HAS_ILI9341
if (!this->disable_touch)
pressed = display_obj.updateTouch(&t_x, &t_y);
#endif
// Brightness gesture: hold top or bottom zone 1.5s to enter brightness mode
#ifdef HAS_ILI9341
if (pressed && (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF ||
wifi_scan_obj.currentScanMode == WIFI_CONNECTED)) {
uint16_t zoneUp = TFT_HEIGHT * 25 / 100;
uint16_t zoneDown = TFT_HEIGHT * 75 / 100;
if (t_y < zoneUp || t_y >= zoneDown) {
uint32_t hold_start = millis();
uint16_t hx, hy;
bool held = false;
while (display_obj.updateTouch(&hx, &hy)) {
if (millis() - hold_start >= 1500) {
held = true;
break;
}
delay(10);
}
if (held) {
// Wait for release before entering brightness mode
while (display_obj.updateTouch(&hx, &hy)) delay(10);
this->brightnessMode();
return;
}
}
}
#endif
// POI button interception during wardrive — full width bottom bar
#ifdef HAS_ILI9341
if (pressed &&
(wifi_scan_obj.currentScanMode == WIFI_SCAN_WAR_DRIVE ||
wifi_scan_obj.currentScanMode == WIFI_SCAN_STATION_WAR_DRIVE)) {
if (t_y >= 270) {
wifi_scan_obj.tagPOI(nullptr);
// Brief green flash
display_obj.tft.fillRect(0, 270, 240, 50, TFT_GREEN);
display_obj.tft.setTextSize(2);
display_obj.tft.setTextColor(TFT_BLACK, TFT_GREEN);
String poiFlash = "POI (" + String(wifi_scan_obj.poiCount) + ")";
int16_t flashWidth = poiFlash.length() * 12;
display_obj.tft.setCursor((240 - flashWidth) / 2, 287);
display_obj.tft.print(poiFlash);
delay(200);
x = -1;
y = -1;
return;
}
}
#endif
// This is if there are scans/attacks going on
#ifdef HAS_ILI9341
if ((wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF) &&
(pressed) &&
(wifi_scan_obj.currentScanMode != WIFI_CONNECTED) &&
(wifi_scan_obj.currentScanMode != OTA_UPDATE) &&
(wifi_scan_obj.currentScanMode != ESP_UPDATE) &&
(wifi_scan_obj.currentScanMode != SHOW_INFO) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_GPS_DATA) &&
(wifi_scan_obj.currentScanMode != GPS_POI) &&
(wifi_scan_obj.currentScanMode != GPS_TRACKER) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_GPS_NMEA))
{
// Stop the current scan
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_SAE_COMMIT) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DETECT_FOLLOW) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_STATION_WAR_DRIVE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_STATION) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_WAR_DRIVE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EVIL_PORTAL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_TARGET_AP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_TARGET_AP_FULL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP_STA) ||
(wifi_scan_obj.currentScanMode == WIFI_PING_SCAN) ||
(wifi_scan_obj.currentScanMode == WIFI_ARP_SCAN) ||
(wifi_scan_obj.currentScanMode == WIFI_PORT_SCAN_ALL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SSH) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_TELNET) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DNS) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SMTP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_HTTP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_HTTPS) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_RDP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PWN) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PINESCAN) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_MULTISSID) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ESPRESSIF) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ALL) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_BEACON_SPAM) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_AP_SPAM) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_CSA) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_QUIET) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_AUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_DEAUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_DEAUTH_MANUAL) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_DEAUTH_TARGETED) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_BAD_MSG_TARGETED) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_BAD_MSG) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_SLEEP) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_SLEEP_TARGETED) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_SAE_COMMIT) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_MIMIC) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_FUNNY_BEACON) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_RICK_ROLL) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_BEACON_LIST) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_ALL) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_RAYBAN) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_AIRTAG) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_AIRTAG_MON) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLIPPER) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLOCK) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLOCK_WARDRIVE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE_TWO) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SOUR_APPLE) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SWIFTPAIR_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SPAM_ALL) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SAMSUNG_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_GOOGLE_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_FLIPPER_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_SPOOF_AIRTAG) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_WAR_DRIVE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_WAR_DRIVE_CONT) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SKIMMERS) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_ANALYZER))
{
wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
// If we don't do this, the text and button coordinates will be off
display_obj.init();
// Take us back to the menu
changeMenu(current_menu, true);
}
x = -1;
y = -1;
return;
}
#endif
#ifdef HAS_BUTTONS
#if (C_BTN >= 0) && !defined(MARAUDER_CARDPUTER)
bool c_btn_press = c_btn.justPressed();
#elif defined(MARAUDER_CARDPUTER)
bool c_btn_press = this->isKeyPressed('(');
#endif
#ifndef HAS_ILI9341
if ((c_btn_press) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_OFF) &&
(wifi_scan_obj.currentScanMode != WIFI_CONNECTED) &&
(wifi_scan_obj.currentScanMode != OTA_UPDATE) &&
(wifi_scan_obj.currentScanMode != ESP_UPDATE) &&
(wifi_scan_obj.currentScanMode != SHOW_INFO) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_GPS_DATA) &&
(wifi_scan_obj.currentScanMode != GPS_POI) &&
(wifi_scan_obj.currentScanMode != GPS_TRACKER) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_GPS_NMEA))
{
// Stop the current scan
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SAE_COMMIT) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DETECT_FOLLOW) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_STATION_WAR_DRIVE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_RAW_CAPTURE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_STATION) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_WAR_DRIVE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EVIL_PORTAL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SIG_STREN) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_TARGET_AP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_TARGET_AP_FULL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP_STA) ||
(wifi_scan_obj.currentScanMode == WIFI_PING_SCAN) ||
(wifi_scan_obj.currentScanMode == WIFI_ARP_SCAN) ||
(wifi_scan_obj.currentScanMode == WIFI_PORT_SCAN_ALL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SSH) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_TELNET) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DNS) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SMTP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_HTTP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_HTTPS) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_RDP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PWN) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PINESCAN) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_MULTISSID) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ESPRESSIF) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ALL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DEAUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_BEACON_SPAM) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_AP_SPAM) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_CSA) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_QUIET) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_AUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_DEAUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_DEAUTH_MANUAL) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_DEAUTH_TARGETED) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_BAD_MSG_TARGETED) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_BAD_MSG) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_SLEEP) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_SLEEP_TARGETED) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_SAE_COMMIT) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_MIMIC) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_FUNNY_BEACON) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_RICK_ROLL) ||
(wifi_scan_obj.currentScanMode == WIFI_ATTACK_BEACON_LIST) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_ALL) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_RAYBAN) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_AIRTAG) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_AIRTAG_MON) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLIPPER) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLOCK) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLOCK_WARDRIVE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE_TWO) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SOUR_APPLE) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SWIFTPAIR_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SPAM_ALL) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SAMSUNG_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_GOOGLE_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_FLIPPER_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_SPOOF_AIRTAG) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_WAR_DRIVE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_WAR_DRIVE_CONT) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SKIMMERS) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ACTIVE_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ACTIVE_LIST_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ACT) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PACKET_RATE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_ANALYZER))
{
wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
// If we don't do this, the text and button coordinates will be off
display_obj.init();
// Take us back to the menu
changeMenu(current_menu);
}
x = -1;
y = -1;
return;
}
#endif
#endif
// Check if any key coordinate boxes contain the touch coordinates
// This is for when on a menu
// Make sure to add certain scanning functions here or else
// menu items will be selected while scans and attacks are running
#ifdef HAS_ILI9341
if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_AP_SPAM) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_CSA) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_QUIET) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_AUTH) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_DEAUTH) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_DEAUTH_MANUAL) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_DEAUTH_TARGETED) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_BAD_MSG_TARGETED) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_BAD_MSG) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_SLEEP) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_SLEEP_TARGETED) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_SAE_COMMIT) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_MIMIC) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_PACKET_RATE) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_RAW_CAPTURE) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_CHAN_ANALYZER) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_CHAN_ACT) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_SIG_STREN) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_AP) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_PROBE) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_DEAUTH) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_FUNNY_BEACON) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_EAPOL) &&
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_RICK_ROLL))
{
// Need this to set all keys to false
/*for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++) {
if (pressed && display_obj.key[b].contains(t_x, t_y)) {
display_obj.key[b].press(true); // tell the button it is pressed
} else {
display_obj.key[b].press(false); // tell the button it is NOT pressed
}
}*/
// Detect up, down, select
uint8_t menu_button = display_obj.menuButton(&t_x, &t_y, pressed);
if (menu_button > -1) {
if (menu_button == UP_BUTTON) {
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == WIFI_CONNECTED) ||
(wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
if (current_menu->selected > 0) {
current_menu->selected--;
// Page up
if (current_menu->selected < this->menu_start_index) {
this->buildButtons(current_menu, current_menu->selected);
this->displayCurrentMenu(current_menu->selected);
}
this->buttonSelected(current_menu->selected - this->menu_start_index, current_menu->selected);
if (!current_menu->list->get(current_menu->selected + 1).selected)
this->buttonNotSelected(current_menu->selected + 1 - this->menu_start_index, current_menu->selected + 1);
}
// Loop to end
else {
current_menu->selected = current_menu->list->size() - 1;
if (current_menu->selected >= BUTTON_SCREEN_LIMIT) {
this->buildButtons(current_menu, current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
this->displayCurrentMenu(current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
}
this->buttonSelected(current_menu->selected, current_menu->selected);
if (!current_menu->list->get(0).selected)
this->buttonNotSelected(0, this->menu_start_index);
}
}
else if ((wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PACKET_RATE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_RAW_CAPTURE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DEAUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SIG_STREN)) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.set_channel < 14)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel + 1);
else
wifi_scan_obj.changeChannel(1);
#else
if (wifi_scan_obj.dual_band_channel_index < DUAL_BAND_CHANNELS - 1)
wifi_scan_obj.dual_band_channel_index++;
else
wifi_scan_obj.dual_band_channel_index = 0;
wifi_scan_obj.changeChannel(wifi_scan_obj.dual_band_channels[wifi_scan_obj.dual_band_channel_index]);
#endif
}
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ACT) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.activity_page < MAX_CHANNEL / CHAN_PER_PAGE) {
wifi_scan_obj.activity_page++;
}
#else
if (wifi_scan_obj.activity_page < DUAL_BAND_CHANNELS / CHAN_PER_PAGE) {
wifi_scan_obj.activity_page++;
}
#endif
wifi_scan_obj.drawChannelLine();
}
}
if (menu_button == DOWN_BUTTON) {
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == WIFI_CONNECTED) ||
(wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
if (current_menu->selected < current_menu->list->size() - 1) {
current_menu->selected++;
// Page down
if (current_menu->selected - this->menu_start_index >= BUTTON_SCREEN_LIMIT) {
this->buildButtons(current_menu, current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
this->displayCurrentMenu(current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
}
else
this->buttonSelected(current_menu->selected - this->menu_start_index, current_menu->selected);
if (!current_menu->list->get(current_menu->selected - 1).selected)
this->buttonNotSelected(current_menu->selected - 1 - this->menu_start_index, current_menu->selected - 1);
}
// Loop to beginning
else {
if (current_menu->selected >= BUTTON_SCREEN_LIMIT) {
current_menu->selected = 0;
this->buildButtons(current_menu);
this->displayCurrentMenu();
this->buttonSelected(current_menu->selected);
}
else {
current_menu->selected = 0;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->list->size() - 1).selected)
this->buttonNotSelected(current_menu->list->size() - 1);
}
}
}
else if ((wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PACKET_RATE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_RAW_CAPTURE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DEAUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SIG_STREN)) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.set_channel > 1)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel - 1);
else
wifi_scan_obj.changeChannel(14);
#else
if (wifi_scan_obj.dual_band_channel_index > 0)
wifi_scan_obj.dual_band_channel_index--;
else
wifi_scan_obj.dual_band_channel_index = DUAL_BAND_CHANNELS - 1;
wifi_scan_obj.changeChannel(wifi_scan_obj.dual_band_channels[wifi_scan_obj.dual_band_channel_index]);
#endif
}
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ACT) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.activity_page > 1) {
wifi_scan_obj.activity_page--;
}
#else
if (wifi_scan_obj.activity_page > 0) {
wifi_scan_obj.activity_page--;
}
#endif
wifi_scan_obj.drawChannelLine();
}
}
if(menu_button == SELECT_BUTTON) {
current_menu->list->get(current_menu->selected).callable();
}
else {
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == WIFI_CONNECTED))
this->displayMenuButtons();
}
}
// Check if any key has changed state
/*for (uint8_t b = 0; b < current_menu->list->size(); b++) {
display_obj.tft.setFreeFont(MENU_FONT);
if (display_obj.key[b].justPressed()) {
display_obj.key[b].drawButton(true, current_menu->list->get(b).name);
if (current_menu->list->get(b).name != text09)
display_obj.tft.drawXBitmap(0,
KEY_Y + b * (KEY_H + KEY_SPACING_Y) - (ICON_H / 2),
menu_icons[current_menu->list->get(b).icon],
ICON_W,
ICON_H,
this->getColor(current_menu->list->get(b).color),
TFT_BLACK);
}
// If button was just release, execute the button's function
if ((display_obj.key[b].justReleased()) && (!pressed))
{
display_obj.key[b].drawButton(false, current_menu->list->get(b).name);
current_menu->list->get(b).callable();
}
// This
else if ((display_obj.key[b].justReleased()) && (pressed)) {
display_obj.key[b].drawButton(false, current_menu->list->get(b).name);
if (current_menu->list->get(b).name != text09)
display_obj.tft.drawXBitmap(0,
KEY_Y + b * (KEY_H + KEY_SPACING_Y) - (ICON_H / 2),
menu_icons[current_menu->list->get(b).icon],
ICON_W,
ICON_H,
TFT_BLACK,
this->getColor(current_menu->list->get(b).color));
}
display_obj.tft.setFreeFont(NULL);
}*/
}
x = -1;
y = -1;
#endif
// Menu navigation and paging
#ifdef HAS_BUTTONS
// Don't do this for touch screens
#if !(defined(MARAUDER_V6) || defined(MARAUDER_V6_1) || defined(MARAUDER_CYD_MICRO) || defined(MARAUDER_CYD_GUITION) || defined(MARAUDER_CYD_2USB) || defined(MARAUDER_CYD_3_5_INCH))
#if !defined(MARAUDER_M5STICKC) || defined(MARAUDER_M5STICKCP2)
#if (U_BTN >= 0 || defined(MARAUDER_CARDPUTER))
#if (U_BTN >= 0)
if (u_btn.justPressed()) {
#elif defined(MARAUDER_CARDPUTER)
if (this->isKeyPressed(';')) {
#endif
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == WIFI_CONNECTED) ||
(wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
if (current_menu->selected > 0) {
current_menu->selected--;
// Page up
if (current_menu->selected < this->menu_start_index) {
this->buildButtons(current_menu, current_menu->selected);
this->displayCurrentMenu(current_menu->selected);
}
this->buttonSelected(current_menu->selected - this->menu_start_index, current_menu->selected);
if (!current_menu->list->get(current_menu->selected + 1).selected)
this->buttonNotSelected(current_menu->selected + 1 - this->menu_start_index, current_menu->selected + 1);
}
// Loop to end
else {
current_menu->selected = current_menu->list->size() - 1;
if (current_menu->selected >= BUTTON_SCREEN_LIMIT) {
this->buildButtons(current_menu, current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
this->displayCurrentMenu(current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
}
this->buttonSelected(current_menu->selected, current_menu->selected);
if (!current_menu->list->get(0).selected)
this->buttonNotSelected(0, this->menu_start_index);
}
}
else if ((wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PACKET_RATE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_RAW_CAPTURE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DEAUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SIG_STREN)) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.set_channel < 14)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel + 1);
else
wifi_scan_obj.changeChannel(1);
#else
if (wifi_scan_obj.dual_band_channel_index < DUAL_BAND_CHANNELS - 1)
wifi_scan_obj.dual_band_channel_index++;
else
wifi_scan_obj.dual_band_channel_index = 0;
wifi_scan_obj.changeChannel(wifi_scan_obj.dual_band_channels[wifi_scan_obj.dual_band_channel_index]);
#endif
}
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ACT) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.activity_page < MAX_CHANNEL / CHAN_PER_PAGE) {
wifi_scan_obj.activity_page++;
}
#else
if (wifi_scan_obj.activity_page < DUAL_BAND_CHANNELS / CHAN_PER_PAGE) {
wifi_scan_obj.activity_page++;
}
#endif
wifi_scan_obj.drawChannelLine();
}
}
#endif
#endif
#if (D_BTN >= 0 || defined(MARAUDER_CARDPUTER))
#if (D_BTN >= 0)
if (d_btn.justPressed()){
#elif defined(MARAUDER_CARDPUTER)
if (this->isKeyPressed('.')){
#endif
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
(wifi_scan_obj.currentScanMode == WIFI_CONNECTED) ||
(wifi_scan_obj.currentScanMode == OTA_UPDATE)) {
if (current_menu->selected < current_menu->list->size() - 1) {
current_menu->selected++;
// Page down
if (current_menu->selected - this->menu_start_index >= BUTTON_SCREEN_LIMIT) {
this->buildButtons(current_menu, current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
this->displayCurrentMenu(current_menu->selected + 1 - BUTTON_SCREEN_LIMIT);
}
else
this->buttonSelected(current_menu->selected - this->menu_start_index, current_menu->selected);
if (!current_menu->list->get(current_menu->selected - 1).selected)
this->buttonNotSelected(current_menu->selected - 1 - this->menu_start_index, current_menu->selected - 1);
}
// Loop to beginning
else {
if (current_menu->selected >= BUTTON_SCREEN_LIMIT) {
current_menu->selected = 0;
this->buildButtons(current_menu);
this->displayCurrentMenu();
this->buttonSelected(current_menu->selected);
}
else {
current_menu->selected = 0;
this->buttonSelected(current_menu->selected);
if (!current_menu->list->get(current_menu->list->size() - 1).selected)
this->buttonNotSelected(current_menu->list->size() - 1);
}
}
}
else if ((wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PACKET_RATE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_RAW_CAPTURE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_AP) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_PROBE) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_DEAUTH) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_SIG_STREN)) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.set_channel > 1)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel - 1);
else
wifi_scan_obj.changeChannel(14);
#else
if (wifi_scan_obj.dual_band_channel_index > 0)
wifi_scan_obj.dual_band_channel_index--;
else
wifi_scan_obj.dual_band_channel_index = DUAL_BAND_CHANNELS - 1;
wifi_scan_obj.changeChannel(wifi_scan_obj.dual_band_channels[wifi_scan_obj.dual_band_channel_index]);
#endif
}
else if (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ACT) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.activity_page > 1) {
wifi_scan_obj.activity_page--;
}
#else
if (wifi_scan_obj.activity_page > 0) {
wifi_scan_obj.activity_page--;
}
#endif
wifi_scan_obj.drawChannelLine();
}
}
#endif
#if (R_BTN >= 0 || defined(MARAUDER_CARDPUTER))
#if (R_BTN >= 0)
if (r_btn.justPressed()) {
#elif defined(MARAUDER_CARDPUTER)
if (this->isKeyPressed('/')) {
#endif
if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.set_channel < 14)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel + 1);
else
wifi_scan_obj.changeChannel(1);
#else
if (wifi_scan_obj.dual_band_channel_index < DUAL_BAND_CHANNELS - 1)
wifi_scan_obj.dual_band_channel_index++;
else
wifi_scan_obj.dual_band_channel_index = 0;
wifi_scan_obj.changeChannel(wifi_scan_obj.dual_band_channels[wifi_scan_obj.dual_band_channel_index]);
#endif
}
}
#endif
#if (L_BTN >= 0 || defined(MARAUDER_CARDPUTER))
#if (L_BTN >= 0)
if (l_btn.justPressed()) {
#elif defined(MARAUDER_CARDPUTER)
if (this->isKeyPressed(',')) {
#endif
if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) {
#ifndef HAS_DUAL_BAND
if (wifi_scan_obj.set_channel > 1)
wifi_scan_obj.changeChannel(wifi_scan_obj.set_channel - 1);
else
wifi_scan_obj.changeChannel(14);
#else
if (wifi_scan_obj.dual_band_channel_index > 0)
wifi_scan_obj.dual_band_channel_index--;
else
wifi_scan_obj.dual_band_channel_index = DUAL_BAND_CHANNELS - 1;
wifi_scan_obj.changeChannel(wifi_scan_obj.dual_band_channels[wifi_scan_obj.dual_band_channel_index]);
#endif
}
}
#endif
if(c_btn_press){
current_menu->list->get(current_menu->selected).callable();
}
#endif
#endif
}
#if BATTERY_ANALOG_ON == 1
byte battery_analog_array[10];
byte battery_count = 0;
byte battery_analog_last = 101;
#define BATTERY_CHECK 50
uint16_t battery_analog = 0;
void MenuFunctions::battery(bool initial)
{
if (BATTERY_ANALOG_ON) {
uint8_t n = 0;
byte battery_analog_sample[10];
byte deviation;
if (battery_count == BATTERY_CHECK - 5) digitalWrite(BATTERY_PIN, HIGH);
else if (battery_count == 5) digitalWrite(BATTERY_PIN, LOW);
if (battery_count == 0) {
battery_analog = 0;
for (n = 9; n > 0; n--)battery_analog_array[n] = battery_analog_array[n - 1];
for (n = 0; n < 10; n++) {
battery_analog_sample[n] = map((analogRead(ANALOG_PIN) * 5), 2400, 4200, 0, 100);
if (battery_analog_sample[n] > 100) battery_analog_sample[n] = 100;
else if (battery_analog_sample[n] < 0) battery_analog_sample[n] = 0;
battery_analog += battery_analog_sample[n];
}
battery_analog = battery_analog / 10;
for (n = 0; n < 10; n++) {
deviation = abs(battery_analog - battery_analog_sample[n]);
if (deviation >= 10) battery_analog_sample[n] = battery_analog;
}
battery_analog = 0;
for (n = 0; n < 10; n++) battery_analog += battery_analog_sample[n];
battery_analog = battery_analog / 10;
battery_analog_array[0] = battery_analog;
if (battery_analog_array[9] > 0 ) {
battery_analog = 0;
for (n = 0; n < 10; n++) battery_analog += battery_analog_array[n];
battery_analog = battery_analog / 10;
}
battery_count ++;
}
else if (battery_count < BATTERY_CHECK) battery_count++;
else if (battery_count >= BATTERY_CHECK) battery_count = 0;
if (battery_analog_last != battery_analog) {
battery_analog_last = battery_analog;
MenuFunctions::battery2();
}
}
}
void MenuFunctions::battery2(bool initial)
{
uint16_t the_color;
if ( digitalRead(CHARGING_PIN) == 1) the_color = TFT_BLUE;
else if (battery_analog < 20) the_color = TFT_RED;
else if (battery_analog < 40) the_color = TFT_YELLOW;
else the_color = TFT_GREEN;
display_obj.tft.setTextColor(the_color, STATUSBAR_COLOR);
display_obj.tft.fillRect(186, 0, 50, STATUS_BAR_WIDTH, STATUSBAR_COLOR);
display_obj.tft.drawXBitmap(186,
0,
menu_icons[STATUS_BAT],
16,
16,
STATUSBAR_COLOR,
the_color);
display_obj.tft.drawString((String) battery_analog + "%", 204, 0, 2);
}
#else
void MenuFunctions::battery(bool initial)
{
#ifdef HAS_BATTERY
uint16_t the_color;
if (battery_obj.i2c_supported)
{
// Could use int compare maybe idk
if (((String)battery_obj.battery_level != "25") && ((String)battery_obj.battery_level != "0"))
the_color = TFT_GREEN;
else
the_color = TFT_RED;
if ((battery_obj.battery_level != battery_obj.old_level) || (initial)) {
battery_obj.old_level = battery_obj.battery_level;
display_obj.tft.fillRect(204, 0, SCREEN_WIDTH, STATUS_BAR_WIDTH, STATUSBAR_COLOR);
}
display_obj.tft.setCursor(0, 1);
/*if (!this->disable_touch) {
display_obj.tft.drawXBitmap(186,
0,
menu_icons[STATUS_BAT],
16,
16,
STATUSBAR_COLOR,
the_color);
}*/
display_obj.tft.drawString((String)battery_obj.battery_level + "%", 204, 0, 2);
}
#endif
}
void MenuFunctions::battery2(bool initial)
{
MenuFunctions::battery(initial);
}
#endif
void MenuFunctions::updateStatusBar()
{
display_obj.tft.setTextSize(1);
bool status_changed = false;
#if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) || defined(MARAUDER_CARDPUTER) || defined(MARAUDER_MINI_V3)
display_obj.tft.setFreeFont(NULL);
#endif
uint16_t the_color;
#ifdef HAS_GPS
if (this->old_gps_sat_count != gps_obj.getNumSats()) {
this->old_gps_sat_count = gps_obj.getNumSats();
display_obj.tft.fillRect(0, 0, TFT_WIDTH, STATUS_BAR_WIDTH, STATUSBAR_COLOR);
status_changed = true;