Skip to content

Commit 5730169

Browse files
authored
Merge pull request #76 from retro-esp32/Feature-Controls-In-HUD
Feature controls in hud
2 parents 3236a1d + 5999ceb commit 5730169

File tree

25 files changed

+1213
-348
lines changed

25 files changed

+1213
-348
lines changed

Assets/retro-esp32/icons/icons.gif

1.02 KB
Loading

Assets/retro-esp32/logos/logo3d.gif

1.5 KB
Loading

Components/odroid-go-handy/odroid-go-common/components/odroid/odroid_hud.c

Lines changed: 185 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
bool INIT = false;
6464
bool SAVED = false;
6565
bool forceConsoleReset;
66+
67+
int32_t VOLUME = 0;
68+
int32_t BRIGHTNESS = 0;
69+
const int32_t BRIGHTNESS_COUNT = 10;
70+
const int32_t BRIGHTNESS_LEVELS[10] = {10,20,30,40,50,60,70,80,90,100};
6671
//}#pragma endregion Globals
6772

6873
//{#pragma region Structs
@@ -79,20 +84,23 @@
7984
int action;
8085
int offset;
8186
} STATES;
82-
STATES WITHSAVE[6] = {
87+
STATES WITHSAVE[5] = {
8388
{"Resume Game",0, 0},
8489
{"Restart Game",1, 10},
8590
{"Reload Game",2, 5},
8691
{"Overwrite Game",4, 25},
87-
{"Delete Save",5, 15},
88-
{"Exit Game",6, 20}
92+
{"Delete Save",5, 15}
8993
};
90-
STATES WITHOUTSAVE[4] = {
94+
STATES WITHOUTSAVE[3] = {
9195
{"Resume Game",0, 0},
9296
{"Restart Game",1, 10},
93-
{"Save Game",3, 25},
94-
{"Exit Game",6, 20}
97+
{"Save Game",3, 25}
9598
};
99+
STATES EXTRAS[3] = {
100+
{"Volume",8, 45},
101+
{"Brightness",9, 50},
102+
{"Quit Game",6, 20}
103+
};
96104
STATES STATE;
97105

98106
// THEME
@@ -140,43 +148,62 @@ const uint16_t FONT_5x7[7][250] = {
140148
{65535,0,0,0,65535,65535,65535,65535,65535,0,0,65535,65535,65535,0,65535,65535,65535,65535,0,65535,65535,65535,65535,65535,65535,0,0,0,0,0,65535,65535,65535,0,65535,0,0,0,65535,65535,65535,65535,65535,65535,0,65535,65535,0,0,65535,0,0,0,65535,65535,65535,65535,65535,65535,65535,0,0,0,65535,65535,0,0,0,65535,0,65535,65535,65535,0,65535,0,0,0,0,0,0,0,0,65535,65535,0,0,0,65535,0,65535,65535,65535,0,0,0,65535,0,0,0,65535,65535,65535,0,0,0,65535,0,0,0,65535,0,65535,0,65535,0,0,0,65535,0,0,65535,0,0,65535,65535,65535,65535,65535,0,65535,65535,65535,0,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,0,65535,65535,65535,0,0,0,0,0,65535,0,65535,65535,65535,0,0,65535,65535,65535,0,65535,0,0,0,0,0,65535,65535,65535,0,0,65535,65535,65535,0,0,0,65535,0,0,0,0,0,0,0,0,0,0,0,0,0,65535,65535,65535,0,0,0,65535,0,0,0,0,65535,0,0,0,0,65535,0,0,65535,0,0,0,0,0,0,0,65535,0,0,65535,0,0,0,0,65535,65535,65535,0,0,65535,65535,65535,0,0,0,0,0,0,0,0,0,0,0},
141149
};
142150

143-
const uint16_t icons[35][5] = {
144-
{0,65535,65535,0,0},
145-
{0,65535,65535,65535,0},
146-
{0,65535,65535,65535,65535},
147-
{0,65535,65535,65535,0},
148-
{0,65535,65535,0,0},
149-
{65535,0,65535,0,0},
150-
{65535,0,65535,65535,0},
151-
{65535,0,65535,65535,65535},
152-
{65535,0,65535,65535,0},
153-
{65535,0,65535,0,0},
154-
{0,65535,65535,0,65535},
155-
{65535,0,0,65535,65535},
156-
{65535,0,0,0,65535},
157-
{65535,65535,0,0,65535},
158-
{65535,0,65535,65535,0},
159-
{0,65535,65535,65535,0},
160-
{65535,0,65535,0,65535},
161-
{65535,65535,0,65535,65535},
162-
{65535,0,65535,0,65535},
163-
{0,65535,65535,65535,0},
164-
{65535,0,0,0,65535},
165-
{0,65535,0,65535,0},
166-
{0,0,65535,0,0},
167-
{0,65535,0,65535,0},
168-
{65535,0,0,0,65535},
169-
{0,0,0,0,0},
170-
{0,0,0,0,65535},
171-
{0,0,0,65535,0},
172-
{65535,0,65535,0,0},
173-
{0,65535,0,0,0},
174-
{0,65535,65535,65535,0},
175-
{65535,0,65535,0,65535},
176-
{65535,0,65535,65535,65535},
177-
{65535,0,0,0,65535},
178-
{0,65535,65535,65535,0},
179-
151+
const uint16_t icons[55][5] = {
152+
{0,65535,65535,0,0},
153+
{0,65535,65535,65535,0},
154+
{0,65535,65535,65535,65535},
155+
{0,65535,65535,65535,0},
156+
{0,65535,65535,0,0},
157+
{65535,0,65535,0,0},
158+
{65535,0,65535,65535,0},
159+
{65535,0,65535,65535,65535},
160+
{65535,0,65535,65535,0},
161+
{65535,0,65535,0,0},
162+
{0,65535,65535,0,65535},
163+
{65535,0,0,65535,65535},
164+
{65535,0,0,0,65535},
165+
{65535,65535,0,0,65535},
166+
{65535,0,65535,65535,0},
167+
{0,65535,65535,65535,0},
168+
{65535,0,65535,0,65535},
169+
{65535,65535,0,65535,65535},
170+
{65535,0,65535,0,65535},
171+
{0,65535,65535,65535,0},
172+
{65535,0,0,0,65535},
173+
{0,65535,0,65535,0},
174+
{0,0,65535,0,0},
175+
{0,65535,0,65535,0},
176+
{65535,0,0,0,65535},
177+
{0,0,0,0,0},
178+
{0,0,0,0,65535},
179+
{0,0,0,65535,0},
180+
{65535,0,65535,0,0},
181+
{0,65535,0,0,0},
182+
{0,65535,65535,65535,0},
183+
{65535,0,65535,0,65535},
184+
{65535,0,65535,65535,65535},
185+
{65535,0,0,0,65535},
186+
{0,65535,65535,65535,0},
187+
{0,65535,0,65535,0},
188+
{65535,65535,65535,65535,65535},
189+
{65535,65535,65535,65535,65535},
190+
{0,65535,65535,65535,0},
191+
{0,0,65535,0,0},
192+
{0,65535,0,65535,0},
193+
{65535,0,65535,0,65535},
194+
{65535,0,0,0,65535},
195+
{0,65535,0,65535,0},
196+
{0,0,65535,0,0},
197+
{0,0,0,65535,0},
198+
{0,65535,0,0,65535},
199+
{0,0,65535,0,65535},
200+
{0,65535,0,0,65535},
201+
{0,0,0,65535,0},
202+
{65535,0,0,0,65535},
203+
{0,0,65535,0,0},
204+
{0,65535,0,65535,0},
205+
{0,0,65535,0,0},
206+
{65535,0,0,0,65535},
180207
};
181208

182209
const uint16_t logo[12][64] = {
@@ -404,42 +431,102 @@ const uint16_t FONT_5x7[7][250] = {
404431
usleep(15000);
405432
}
406433
}
434+
}
435+
436+
void hud_bar(int x, int y, int percent, bool active) {
437+
int w, h;
438+
439+
int i = 0;
440+
for(h = 0; h < 7; h++) {
441+
for(w = 0; w < 100; w++) {
442+
buffer[i] = (w+h)%2 == 0 ? GUI.fg : GUI.bg;
443+
i++;
444+
}
445+
}
446+
ili9341_write_frame_rectangleLE(x, y, 100, 7, buffer);
447+
448+
if(percent > 0) {
449+
i = 0;
450+
for(h = 0; h < 7; h++) {
451+
for(w = 0; w < percent; w++) {
452+
buffer[i] = active ? GUI.hl : GUI.fg;
453+
i++;
454+
}
455+
}
456+
ili9341_write_frame_rectangleLE(x, y, percent, 7, buffer);
457+
}
407458
}
408459

460+
void hud_volume() {
461+
// y=176;
462+
int32_t VOLUME = odroid_settings_Volume_get();
463+
int LIMIT = OPTIONS - 3;
464+
bool active = OPTION == LIMIT ? true : false;
465+
hud_bar((SCREEN.w - 120), 176, VOLUME * 12.5, active);
466+
}
467+
468+
void hud_brightness() {
469+
// y=176;
470+
int LIMIT = OPTIONS - 2;
471+
bool active = OPTION == LIMIT ? true : false;
472+
BRIGHTNESS = odroid_settings_Backlight_get();
473+
474+
hud_bar((SCREEN.w - 120), 196, (BRIGHTNESS_COUNT * BRIGHTNESS)+BRIGHTNESS+1, active);
475+
}
476+
409477
void hud_options() {
410478
x = 16;
411479
y = 28;
412480
w = 5;
413481
h = 5;
414482
i = 0;
415483
int n;
416-
if(OPTIONS == 6) {
417-
for(n = 0; n < OPTIONS; n++) {
484+
if(OPTIONS == 8) {
485+
for(n = 0; n < 5; n++) {
418486
STATE = WITHSAVE[n];
419487
y+=20;
420488
for(int r = 0; r < 5; r++){for(int c = 0; c < 5; c++) {
421489
buffer[i] = icons[r+STATE.offset][c] == WHITE ? OPTION == n ? GUI.hl : GUI.fg : GUI.bg;i++;
422490
}}
423-
if(n == OPTIONS-1) {y = 216;}
424491
ili9341_write_frame_rectangleLE(x, y, w, h, buffer);
425492
hud_text(x+10,y,STATE.label,false,OPTION == n?true:false);
426493
i = 0;
427494
}
428-
STATE = WITHSAVE[OPTION];
429495
} else {
430-
for(n = 0; n < OPTIONS; n++) {
496+
for(n = 0; n < 3; n++) {
431497
STATE = WITHOUTSAVE[n];
432498
y+=20;
433499
for(int r = 0; r < 5; r++){for(int c = 0; c < 5; c++) {
434500
buffer[i] = icons[r+STATE.offset][c] == WHITE ? OPTION == n ? GUI.hl : GUI.fg : GUI.bg;i++;
435501
}}
436-
if(n == OPTIONS-1) {y = 216;}
437502
ili9341_write_frame_rectangleLE(x, y, w, h, buffer);
438503
hud_text(x+10,y,STATE.label,false,OPTION == n?true:false);
439504
i = 0;
440505
}
441-
STATE = WITHOUTSAVE[OPTION];
442506
}
507+
508+
y=156;
509+
for(n = 0; n < 3; n++) {
510+
STATE = EXTRAS[n];
511+
y+=20;
512+
for(int r = 0; r < 5; r++){for(int c = 0; c < 5; c++) {
513+
buffer[i] = icons[r+STATE.offset][c] == WHITE ? OPTION == (n+OPTIONS-3) ? GUI.hl : GUI.fg : GUI.bg;i++;
514+
}}
515+
ili9341_write_frame_rectangleLE(x, y, w, h, buffer);
516+
hud_text(x+10,y,STATE.label,false,OPTION == (n+OPTIONS-3)?true:false);
517+
i = 0;
518+
}
519+
520+
int LIMIT = OPTIONS - 3;
521+
if(OPTION < LIMIT) {
522+
STATE = OPTIONS == 8 ? WITHSAVE[OPTION] : WITHOUTSAVE[OPTION];
523+
} else {
524+
STATE = EXTRAS[OPTION-LIMIT];
525+
}
526+
printf("\n**********\n%s - %d:%d\n**********\n", STATE.label, OPTION, LIMIT);
527+
528+
hud_volume();
529+
hud_brightness();
443530
}
444531
//}#pragma endregion Display
445532

@@ -450,10 +537,10 @@ const uint16_t FONT_5x7[7][250] = {
450537
buffer = (uint16_t *)malloc(size);
451538
if (!buffer) abort();
452539
OPTION = 0;
453-
OPTIONS = SAVED ? 6 : 4;
540+
OPTIONS = SAVED ? 8 : 6;
454541
hud_theme();
455542
GUI = THEMES[USER];
456-
STATE = OPTIONS == 6 ? WITHSAVE[OPTION] : WITHOUTSAVE[OPTION];
543+
STATE = OPTIONS == 8 ? WITHSAVE[OPTION] : WITHOUTSAVE[OPTION];
457544
INIT = true;
458545
}
459546
}
@@ -468,9 +555,9 @@ const uint16_t FONT_5x7[7][250] = {
468555

469556
//{#pragma region Menu
470557
void hud_menu(void) {
471-
int volume = odroid_audio_volume_get();
558+
VOLUME = odroid_audio_volume_get();
472559
#ifdef CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32
473-
volume = 8;
560+
//volume = 8;
474561
#endif
475562
odroid_audio_terminate();
476563
hud_init();
@@ -501,6 +588,49 @@ const uint16_t FONT_5x7[7][250] = {
501588
usleep(200000);
502589
//debounce(ODROID_INPUT_DOWN);
503590
}
591+
/*
592+
LEFT
593+
*/
594+
if(gamepad.values[ODROID_INPUT_LEFT]) {
595+
if(OPTION == OPTIONS - 3) {
596+
if(VOLUME > 0) {
597+
VOLUME--;
598+
odroid_settings_Volume_set(VOLUME);
599+
hud_options();
600+
usleep(200000);
601+
}
602+
}
603+
if(OPTION == OPTIONS - 3 + 1) {
604+
if(BRIGHTNESS > 0) {
605+
BRIGHTNESS--;
606+
odroid_settings_Backlight_set(BRIGHTNESS);
607+
hud_options();
608+
usleep(200000);
609+
}
610+
}
611+
}
612+
613+
/*
614+
RIGHT
615+
*/
616+
if(gamepad.values[ODROID_INPUT_RIGHT]) {
617+
if(OPTION == OPTIONS - 3) {
618+
if(VOLUME < 8) {
619+
VOLUME++;
620+
odroid_settings_Volume_set(VOLUME);
621+
hud_options();
622+
usleep(200000);
623+
}
624+
}
625+
if(OPTION == OPTIONS - 3 + 1) {
626+
if(BRIGHTNESS < (BRIGHTNESS_COUNT-1)) {
627+
BRIGHTNESS++;
628+
odroid_settings_Backlight_set(BRIGHTNESS);
629+
hud_options();
630+
usleep(200000);
631+
}
632+
}
633+
}
504634
/*
505635
BUTTON B
506636
*/
@@ -513,7 +643,7 @@ const uint16_t FONT_5x7[7][250] = {
513643
BUTTON A
514644
*/
515645
if (gamepad.values[ODROID_INPUT_A]) {
516-
odroid_audio_volume_set(volume);
646+
odroid_audio_volume_set(VOLUME);
517647
hud_debug(STATE.label);
518648
ACTION = STATE.action;
519649
switch(ACTION) {

Components/odroid-go-handy/odroid-go-common/components/odroid/odroid_hud.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,7 @@ void hud_menu();
4848
*/
4949
void hud_logo(void);
5050
void hud_progress(char *string, bool bar);
51+
void hud_bar(int x, int y, int percent, bool active);
52+
void hud_volume();
53+
void hud_brightness();
5154
void hud_options();

0 commit comments

Comments
 (0)