Skip to content

Commit af2b9a6

Browse files
authored
Merge pull request n0xa#112 from n0xa/color
Minor UI fixes, Color Themes
2 parents 703602c + 2d585a7 commit af2b9a6

File tree

2 files changed

+135
-8
lines changed

2 files changed

+135
-8
lines changed

localization.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@
9292
#define TXT_ORANGE "Orange"
9393
#define TXT_GREENYELLOW "Green Yellow"
9494
#define TXT_PINK "Pink"
95-
#define TXT_COLOR "Color"
95+
#define TXT_COLOR "Custom Colors"
9696
#define TXT_SET_FGCOLOR "MAIN COLOR"
9797
#define TXT_SET_BGCOLOR "BACKGROUND COLOR"
98+
#define TXT_THEME "Color Theme"
9899
#endif
99100

100101
#if defined(LANGUAGE_PT_BR)
@@ -191,7 +192,8 @@
191192
#define TXT_ORANGE "Alaranjado"
192193
#define TXT_GREENYELLOW "Verde Amarelo"
193194
#define TXT_PINK "Rosa"
194-
#define TXT_COLOR "Cor"
195+
#define TXT_COLOR "Mudar Cores"
195196
#define TXT_SET_FGCOLOR "COR PRINCIPAL"
196197
#define TXT_SET_BGCOLOR "COR DE FUNDO"
198+
#define TXT_THEME "Tema De Cores"
197199
#endif

m5stick-nemo.ino

+131-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// github.com/n0xa | IG: @4x0nn
33

44
// -=-=-=-=-=-=- Uncomment the platform you're building for -=-=-=-=-=-=-
5-
// #define STICK_C_PLUS
5+
#define STICK_C_PLUS
66
// #define STICK_C_PLUS2
77
// #define STICK_C
88
// #define CARDPUTER
@@ -13,8 +13,8 @@
1313
// #define LANGUAGE_PT_BR
1414

1515
// -- DEPRECATED - THESE ARE NOW EEPROM DEFINED -- //
16-
uint16_t BGCOLOR=0x0000;
17-
uint16_t FGCOLOR=0x07E0;
16+
uint16_t BGCOLOR=0x0001; // placeholder
17+
uint16_t FGCOLOR=0xFFF1; // placeholder
1818

1919
#ifndef NEMO_VERSION
2020
#define NEMO_VERSION "dev"
@@ -197,7 +197,8 @@ uint16_t FGCOLOR=0x07E0;
197197
// 19 - NEMO Portal
198198
// 20 - Attack menu
199199
// 21 - Deauth Attack
200-
// 22 - Color Settings
200+
// 22 - Custom Color Settings
201+
// 23 - Pre-defined color themes
201202
// .. - ..
202203
// 97 - Mount/UnMount SD Card on M5Stick devices, if SDCARD is declared
203204

@@ -293,7 +294,7 @@ QRCODE qrcodes[] = {
293294
void drawmenu(MENU thismenu[], int size) {
294295
DISP.setTextSize(SMALL_TEXT);
295296
DISP.fillScreen(BGCOLOR);
296-
DISP.setCursor(0, 0);
297+
DISP.setCursor(0, 0, 1);
297298
// scrolling menu
298299
if (cursor < 0) {
299300
cursor = size - 1; // rollover hack for up-arrow on cardputer
@@ -572,7 +573,7 @@ MENU smenu[] = {
572573
{ TXT_SDCARD, 97},
573574
#endif
574575
#endif
575-
{ TXT_COLOR, 22},
576+
{ TXT_THEME, 23},
576577
{ TXT_ABOUT, 10},
577578
{ TXT_REBOOT, 98},
578579
#if defined(USE_EEPROM)
@@ -738,6 +739,9 @@ void color_setup() {
738739
DISP.setCursor(0, 0);
739740
DISP.println(String(TXT_SET_FGCOLOR));
740741
cursor = 0;
742+
#if defined(USE_EEPROM)
743+
cursor=EEPROM.read(4); // get current fg color
744+
#endif
741745
rstOverride = true;
742746
delay(1000);
743747
drawmenu(cmenu, cmenu_size);
@@ -753,8 +757,10 @@ void color_loop() {
753757
}
754758
if (check_select_press()) {
755759
#if defined(USE_EEPROM)
760+
Serial.printf("EEPROM WRITE (4) FGCOLOR: %d\n", cursor);
756761
EEPROM.write(4, cursor);
757762
EEPROM.commit();
763+
cursor=EEPROM.read(5); // get current bg color
758764
#endif
759765
DISP.fillScreen(BGCOLOR);
760766
DISP.setCursor(0, 0);
@@ -772,6 +778,7 @@ void color_loop() {
772778
}
773779
}
774780
#if defined(USE_EEPROM)
781+
Serial.printf("EEPROM WRITE (5) BGCOLOR: %d\n", cursor);
775782
EEPROM.write(5, cursor);
776783
EEPROM.commit();
777784
#endif
@@ -781,6 +788,118 @@ void color_loop() {
781788
}
782789
}
783790

791+
MENU thmenu[] = {
792+
{ TXT_BACK, 0},
793+
{ "Nemo", 1},
794+
{ "Tux", 2},
795+
{ "Bill", 3},
796+
{ "Steve", 4},
797+
{ "Lilac", 5},
798+
{ "Contrast", 6},
799+
{ "NightShift", 7},
800+
{ "Camo", 8},
801+
{ "BubbleGum", 9},
802+
{ TXT_COLOR, 99},
803+
};
804+
int thmenu_size = sizeof(thmenu) / sizeof (MENU);
805+
806+
void theme_setup() {
807+
DISP.fillScreen(BGCOLOR);
808+
DISP.setCursor(0, 0);
809+
DISP.println(String(TXT_THEME));
810+
cursor = 0;
811+
rstOverride = true;
812+
delay(1000);
813+
drawmenu(thmenu, thmenu_size);
814+
}
815+
816+
void theme_loop() {
817+
if (check_next_press()) {
818+
cursor++;
819+
cursor = cursor % thmenu_size;
820+
switch (thmenu[cursor].command){
821+
case 0:
822+
FGCOLOR=11;
823+
BGCOLOR=1;
824+
break;
825+
case 1: // Nemo
826+
FGCOLOR=11;
827+
BGCOLOR=1;
828+
break;
829+
case 2: // Tux
830+
FGCOLOR=8;
831+
BGCOLOR=1;
832+
break;
833+
case 3: // Bill
834+
FGCOLOR=16;
835+
BGCOLOR=10;
836+
break;
837+
case 4: // Steve
838+
FGCOLOR=1;
839+
BGCOLOR=8;
840+
break;
841+
case 5: // Lilac
842+
FGCOLOR=19;
843+
BGCOLOR=6;
844+
break;
845+
case 6: // Contrast
846+
FGCOLOR=16;
847+
BGCOLOR=1;
848+
break;
849+
case 7: // NightShift
850+
FGCOLOR=5;
851+
BGCOLOR=1;
852+
break;
853+
case 8: // Camo
854+
FGCOLOR=1;
855+
BGCOLOR=7;
856+
break;
857+
case 9: // BubbleGum
858+
FGCOLOR=1;
859+
BGCOLOR=19;
860+
break;
861+
case 99:
862+
FGCOLOR=11;
863+
BGCOLOR=1;
864+
break;
865+
}
866+
setcolor(true, FGCOLOR);
867+
setcolor(false, BGCOLOR);
868+
drawmenu(thmenu, thmenu_size);
869+
delay(250);
870+
}
871+
if (check_select_press()) {
872+
switch (thmenu[cursor].command){
873+
case 99:
874+
rstOverride = false;
875+
isSwitching = true;
876+
current_proc = 22;
877+
break;
878+
case 0:
879+
#if defined(USE_EEPROM)
880+
setcolor(true, EEPROM.read(4));
881+
setcolor(false, EEPROM.read(5));
882+
#endif
883+
rstOverride = false;
884+
isSwitching = true;
885+
current_proc = 2;
886+
break;
887+
default:
888+
#if defined(USE_EEPROM)
889+
Serial.printf("EEPROM WRITE (4) FGCOLOR: %d\n", FGCOLOR);
890+
EEPROM.write(4, FGCOLOR);
891+
Serial.printf("EEPROM WRITE (5) BGCOLOR: %d\n", BGCOLOR);
892+
EEPROM.write(5, BGCOLOR);
893+
#endif
894+
rstOverride = false;
895+
isSwitching = true;
896+
current_proc = 2;
897+
}
898+
}
899+
}
900+
901+
902+
784903
int rotation = 1;
785904
#if defined(ROTATION)
786905
/// Rotation MENU ///
@@ -2418,6 +2537,9 @@ void loop() {
24182537
case 22:
24192538
color_setup();
24202539
break;
2540+
case 23:
2541+
theme_setup();
2542+
break;
24212543
}
24222544
}
24232545

@@ -2506,6 +2628,9 @@ void loop() {
25062628
case 22:
25072629
color_loop();
25082630
break;
2631+
case 23:
2632+
theme_loop();
2633+
break;
25092634
#if defined(SDCARD) // SDCARD M5Stick
25102635
#ifndef CARDPUTER // SDCARD M5Stick
25112636
case 97:

0 commit comments

Comments
 (0)