Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #112 from n0xa/color
Browse files Browse the repository at this point in the history
Minor UI fixes, Color Themes
  • Loading branch information
n0xa committed Feb 24, 2024
2 parents 703602c + 2d585a7 commit af2b9a6
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 8 deletions.
6 changes: 4 additions & 2 deletions localization.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@
#define TXT_ORANGE "Orange"
#define TXT_GREENYELLOW "Green Yellow"
#define TXT_PINK "Pink"
#define TXT_COLOR "Color"
#define TXT_COLOR "Custom Colors"
#define TXT_SET_FGCOLOR "MAIN COLOR"
#define TXT_SET_BGCOLOR "BACKGROUND COLOR"
#define TXT_THEME "Color Theme"
#endif

#if defined(LANGUAGE_PT_BR)
Expand Down Expand Up @@ -191,7 +192,8 @@
#define TXT_ORANGE "Alaranjado"
#define TXT_GREENYELLOW "Verde Amarelo"
#define TXT_PINK "Rosa"
#define TXT_COLOR "Cor"
#define TXT_COLOR "Mudar Cores"
#define TXT_SET_FGCOLOR "COR PRINCIPAL"
#define TXT_SET_BGCOLOR "COR DE FUNDO"
#define TXT_THEME "Tema De Cores"
#endif
137 changes: 131 additions & 6 deletions m5stick-nemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// github.com/n0xa | IG: @4x0nn

// -=-=-=-=-=-=- Uncomment the platform you're building for -=-=-=-=-=-=-
// #define STICK_C_PLUS
#define STICK_C_PLUS
// #define STICK_C_PLUS2
// #define STICK_C
// #define CARDPUTER
Expand All @@ -13,8 +13,8 @@
// #define LANGUAGE_PT_BR

// -- DEPRECATED - THESE ARE NOW EEPROM DEFINED -- //
uint16_t BGCOLOR=0x0000;
uint16_t FGCOLOR=0x07E0;
uint16_t BGCOLOR=0x0001; // placeholder
uint16_t FGCOLOR=0xFFF1; // placeholder

#ifndef NEMO_VERSION
#define NEMO_VERSION "dev"
Expand Down Expand Up @@ -197,7 +197,8 @@ uint16_t FGCOLOR=0x07E0;
// 19 - NEMO Portal
// 20 - Attack menu
// 21 - Deauth Attack
// 22 - Color Settings
// 22 - Custom Color Settings
// 23 - Pre-defined color themes
// .. - ..
// 97 - Mount/UnMount SD Card on M5Stick devices, if SDCARD is declared

Expand Down Expand Up @@ -293,7 +294,7 @@ QRCODE qrcodes[] = {
void drawmenu(MENU thismenu[], int size) {
DISP.setTextSize(SMALL_TEXT);
DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 0);
DISP.setCursor(0, 0, 1);
// scrolling menu
if (cursor < 0) {
cursor = size - 1; // rollover hack for up-arrow on cardputer
Expand Down Expand Up @@ -572,7 +573,7 @@ MENU smenu[] = {
{ TXT_SDCARD, 97},
#endif
#endif
{ TXT_COLOR, 22},
{ TXT_THEME, 23},
{ TXT_ABOUT, 10},
{ TXT_REBOOT, 98},
#if defined(USE_EEPROM)
Expand Down Expand Up @@ -738,6 +739,9 @@ void color_setup() {
DISP.setCursor(0, 0);
DISP.println(String(TXT_SET_FGCOLOR));
cursor = 0;
#if defined(USE_EEPROM)
cursor=EEPROM.read(4); // get current fg color
#endif
rstOverride = true;
delay(1000);
drawmenu(cmenu, cmenu_size);
Expand All @@ -753,8 +757,10 @@ void color_loop() {
}
if (check_select_press()) {
#if defined(USE_EEPROM)
Serial.printf("EEPROM WRITE (4) FGCOLOR: %d\n", cursor);
EEPROM.write(4, cursor);
EEPROM.commit();
cursor=EEPROM.read(5); // get current bg color
#endif
DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 0);
Expand All @@ -772,6 +778,7 @@ void color_loop() {
}
}
#if defined(USE_EEPROM)
Serial.printf("EEPROM WRITE (5) BGCOLOR: %d\n", cursor);
EEPROM.write(5, cursor);
EEPROM.commit();
#endif
Expand All @@ -781,6 +788,118 @@ void color_loop() {
}
}

MENU thmenu[] = {
{ TXT_BACK, 0},
{ "Nemo", 1},
{ "Tux", 2},
{ "Bill", 3},
{ "Steve", 4},
{ "Lilac", 5},
{ "Contrast", 6},
{ "NightShift", 7},
{ "Camo", 8},
{ "BubbleGum", 9},
{ TXT_COLOR, 99},
};
int thmenu_size = sizeof(thmenu) / sizeof (MENU);

void theme_setup() {
DISP.fillScreen(BGCOLOR);
DISP.setCursor(0, 0);
DISP.println(String(TXT_THEME));
cursor = 0;
rstOverride = true;
delay(1000);
drawmenu(thmenu, thmenu_size);
}

void theme_loop() {
if (check_next_press()) {
cursor++;
cursor = cursor % thmenu_size;
switch (thmenu[cursor].command){
case 0:
FGCOLOR=11;
BGCOLOR=1;
break;
case 1: // Nemo
FGCOLOR=11;
BGCOLOR=1;
break;
case 2: // Tux
FGCOLOR=8;
BGCOLOR=1;
break;
case 3: // Bill
FGCOLOR=16;
BGCOLOR=10;
break;
case 4: // Steve
FGCOLOR=1;
BGCOLOR=8;
break;
case 5: // Lilac
FGCOLOR=19;
BGCOLOR=6;
break;
case 6: // Contrast
FGCOLOR=16;
BGCOLOR=1;
break;
case 7: // NightShift
FGCOLOR=5;
BGCOLOR=1;
break;
case 8: // Camo
FGCOLOR=1;
BGCOLOR=7;
break;
case 9: // BubbleGum
FGCOLOR=1;
BGCOLOR=19;
break;
case 99:
FGCOLOR=11;
BGCOLOR=1;
break;
}
setcolor(true, FGCOLOR);
setcolor(false, BGCOLOR);
drawmenu(thmenu, thmenu_size);
delay(250);
}
if (check_select_press()) {
switch (thmenu[cursor].command){
case 99:
rstOverride = false;
isSwitching = true;
current_proc = 22;
break;
case 0:
#if defined(USE_EEPROM)
setcolor(true, EEPROM.read(4));
setcolor(false, EEPROM.read(5));
#endif
rstOverride = false;
isSwitching = true;
current_proc = 2;
break;
default:
#if defined(USE_EEPROM)
Serial.printf("EEPROM WRITE (4) FGCOLOR: %d\n", FGCOLOR);
EEPROM.write(4, FGCOLOR);
Serial.printf("EEPROM WRITE (5) BGCOLOR: %d\n", BGCOLOR);
EEPROM.write(5, BGCOLOR);
#endif
rstOverride = false;
isSwitching = true;
current_proc = 2;
}
}
}



int rotation = 1;
#if defined(ROTATION)
/// Rotation MENU ///
Expand Down Expand Up @@ -2418,6 +2537,9 @@ void loop() {
case 22:
color_setup();
break;
case 23:
theme_setup();
break;
}
}

Expand Down Expand Up @@ -2506,6 +2628,9 @@ void loop() {
case 22:
color_loop();
break;
case 23:
theme_loop();
break;
#if defined(SDCARD) // SDCARD M5Stick
#ifndef CARDPUTER // SDCARD M5Stick
case 97:
Expand Down

0 comments on commit af2b9a6

Please sign in to comment.