1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-09-19 13:33:25 +01:00

Add a bit of tools + make unselectable menu objects

+ fix compile error
+ move back to top of menus
This commit is contained in:
Such Meme, Many Skill 2019-11-21 20:54:18 +01:00
parent 7b0faabf38
commit be79d64deb
5 changed files with 71 additions and 25 deletions

View file

@ -24,11 +24,11 @@ int makemenu(menu_item menu[], int menuamount){
gfx_con_setpos(0, 31); gfx_con_setpos(0, 31);
if (currentpos == 1){ if (currentpos == 1){
while (currentpos < menuamount && menu[currentpos - 1].property < 0) while (currentpos < menuamount && menu[currentpos - 1].property < 1)
currentpos++; currentpos++;
} }
if (currentpos == menuamount){ if (currentpos == menuamount){
while (currentpos > 1 && menu[currentpos - 1].property < 0) while (currentpos > 1 && menu[currentpos - 1].property < 1)
currentpos--; currentpos--;
} }
@ -46,13 +46,13 @@ int makemenu(menu_item menu[], int menuamount){
if (res & BTN_VOL_UP && currentpos > 1){ if (res & BTN_VOL_UP && currentpos > 1){
currentpos--; currentpos--;
while(menu[currentpos - 1].property < 0 && currentpos > 1) while(menu[currentpos - 1].property < 1 && currentpos > 1)
currentpos--; currentpos--;
} }
else if (res & BTN_VOL_DOWN && currentpos < menuamount){ else if (res & BTN_VOL_DOWN && currentpos < menuamount){
currentpos++; currentpos++;
while(menu[currentpos - 1].property < 0 && currentpos < menuamount) while(menu[currentpos - 1].property < 1 && currentpos < menuamount)
currentpos++; currentpos++;
} }

View file

@ -1,4 +1,6 @@
#pragma once #pragma once
#include "te.h"
int makemenu(menu_item menu[], int menuamount); int makemenu(menu_item menu[], int menuamount);
int message(char* message, u32 color); int message(char* message, u32 color);
void clearscreen();

View file

@ -3,25 +3,33 @@
#include "te.h" #include "te.h"
#include "gfx.h" #include "gfx.h"
#include "../utils/util.h" #include "../utils/util.h"
#include "tools.h"
extern bool sd_mount(); extern bool sd_mount();
extern void sd_unmount(); extern void sd_unmount();
bool sd_mounted = false; bool sd_mounted = false;
menu_item mainmenu[MAINMENU_AMOUNT] = { menu_item mainmenu[MAINMENU_AMOUNT] = {
{"[SD:/] SD CARD", COLOR_GREEN, 1, 0}, {"[SD:/] SD CARD", COLOR_GREEN, 1, 1},
{"[EMMC:/] ?\n", COLOR_GREEN, 2, 0}, {"[EMMC:/] ?", COLOR_GREEN, 2, 1},
{"Mount/Unmount SD", COLOR_WHITE, 3, 0}, {"\nMount/Unmount SD", COLOR_WHITE, 3, 1},
{"Tools\n", COLOR_VIOLET, 4, 0}, {"Tools", COLOR_VIOLET, 4, 1},
{"Credits", COLOR_WHITE, 5, 0}, {"\nCredits", COLOR_WHITE, 5, 1},
{"Exit", COLOR_WHITE, 6, 0} {"Exit", COLOR_WHITE, 6, 1}
}; };
menu_item shutdownmenu[4] = { menu_item shutdownmenu[5] = {
{"Reboot to RCM", COLOR_VIOLET, 1, 0}, {"-- EXIT --\n", COLOR_ORANGE, -1, 0},
{"Reboot normally", COLOR_ORANGE, 2, 0}, {"Back", COLOR_WHITE, 1, 1},
{"Power off\n", COLOR_BLUE, 3, 0}, {"\nReboot to RCM", COLOR_VIOLET, 2, 1},
{"Back", COLOR_WHITE, 4, 0} {"Reboot normally", COLOR_ORANGE, 3, 1},
{"Power off", COLOR_BLUE, 4, 1}
};
menu_item toolsmenu[3] = {
{"-- TOOLS --\n", COLOR_VIOLET, -1, 0},
{"Back", COLOR_WHITE, 1, 1},
{"\nDisplay Console Info", COLOR_GREEN, 2, 1}
}; };
void fillmainmenu(){ void fillmainmenu(){
@ -37,12 +45,12 @@ void fillmainmenu(){
break; break;
case 3: case 3:
if (sd_mounted){ if (sd_mounted){
mainmenu[i].property = 1; mainmenu[i].property = 2;
strcpy(mainmenu[i].name, "Unmount SD"); strcpy(mainmenu[i].name, "\nUnmount SD");
} }
else { else {
mainmenu[i].property = 0; mainmenu[i].property = 1;
strcpy(mainmenu[i].name, "Mount SD"); strcpy(mainmenu[i].name, "\nMount SD");
} }
break; break;
} }
@ -67,17 +75,24 @@ void te_main(){
sd_mounted = sd_mount(); sd_mounted = sd_mount();
} }
if (res == 4){
res = makemenu(toolsmenu, 3);
if (res == 2)
displayinfo();
}
if (res == 5) if (res == 5)
message(CREDITS_MESSAGE, COLOR_WHITE); message(CREDITS_MESSAGE, COLOR_WHITE);
if (res == 6){ if (res == 6){
res = makemenu(shutdownmenu, 4); res = makemenu(shutdownmenu, 5);
if (res == 1) if (res == 2)
reboot_rcm(); reboot_rcm();
else if (res == 2)
reboot_normal();
else if (res == 3) else if (res == 3)
power_off(); reboot_normal();
else if (res == 4)
power_off(); //todo declock bpmp
} }
} }
} }

View file

@ -0,0 +1,26 @@
#include "tools.h"
#include "gfx.h"
#include "../libs/fatfs/ff.h"
#include "../gfx/gfx.h"
#include "../utils/btn.h"
void displayinfo(){
clearscreen();
FATFS *fs;
DWORD fre_clust, fre_sect, tot_sect;
int res;
gfx_printf("Getting storage info: please wait...");
res = f_getfree("sd:", &fre_clust, &fs);
gfx_printf("\nResult getfree: %d\n\n", res);
tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * fs->csize;
gfx_printf("%d KiB total\n%d KiB free\n\nPress any key to continue", tot_sect / 2, fre_sect / 2);
btn_wait();
}

View file

@ -0,0 +1,3 @@
#pragma once
void displayinfo();