diff --git a/source/tegraexplorer/gfx.c b/source/tegraexplorer/gfx.c index c75f4f7..2abdd8c 100644 --- a/source/tegraexplorer/gfx.c +++ b/source/tegraexplorer/gfx.c @@ -24,11 +24,11 @@ int makemenu(menu_item menu[], int menuamount){ gfx_con_setpos(0, 31); if (currentpos == 1){ - while (currentpos < menuamount && menu[currentpos - 1].property < 0) + while (currentpos < menuamount && menu[currentpos - 1].property < 1) currentpos++; } if (currentpos == menuamount){ - while (currentpos > 1 && menu[currentpos - 1].property < 0) + while (currentpos > 1 && menu[currentpos - 1].property < 1) currentpos--; } @@ -46,13 +46,13 @@ int makemenu(menu_item menu[], int menuamount){ if (res & BTN_VOL_UP && currentpos > 1){ currentpos--; - while(menu[currentpos - 1].property < 0 && currentpos > 1) + while(menu[currentpos - 1].property < 1 && currentpos > 1) currentpos--; } else if (res & BTN_VOL_DOWN && currentpos < menuamount){ currentpos++; - while(menu[currentpos - 1].property < 0 && currentpos < menuamount) + while(menu[currentpos - 1].property < 1 && currentpos < menuamount) currentpos++; } diff --git a/source/tegraexplorer/gfx.h b/source/tegraexplorer/gfx.h index bdae328..32fecab 100644 --- a/source/tegraexplorer/gfx.h +++ b/source/tegraexplorer/gfx.h @@ -1,4 +1,6 @@ #pragma once +#include "te.h" int makemenu(menu_item menu[], int menuamount); -int message(char* message, u32 color); \ No newline at end of file +int message(char* message, u32 color); +void clearscreen(); \ No newline at end of file diff --git a/source/tegraexplorer/te.c b/source/tegraexplorer/te.c index e210a2a..784fb1b 100644 --- a/source/tegraexplorer/te.c +++ b/source/tegraexplorer/te.c @@ -3,25 +3,33 @@ #include "te.h" #include "gfx.h" #include "../utils/util.h" +#include "tools.h" extern bool sd_mount(); extern void sd_unmount(); bool sd_mounted = false; menu_item mainmenu[MAINMENU_AMOUNT] = { - {"[SD:/] SD CARD", COLOR_GREEN, 1, 0}, - {"[EMMC:/] ?\n", COLOR_GREEN, 2, 0}, - {"Mount/Unmount SD", COLOR_WHITE, 3, 0}, - {"Tools\n", COLOR_VIOLET, 4, 0}, - {"Credits", COLOR_WHITE, 5, 0}, - {"Exit", COLOR_WHITE, 6, 0} + {"[SD:/] SD CARD", COLOR_GREEN, 1, 1}, + {"[EMMC:/] ?", COLOR_GREEN, 2, 1}, + {"\nMount/Unmount SD", COLOR_WHITE, 3, 1}, + {"Tools", COLOR_VIOLET, 4, 1}, + {"\nCredits", COLOR_WHITE, 5, 1}, + {"Exit", COLOR_WHITE, 6, 1} }; -menu_item shutdownmenu[4] = { - {"Reboot to RCM", COLOR_VIOLET, 1, 0}, - {"Reboot normally", COLOR_ORANGE, 2, 0}, - {"Power off\n", COLOR_BLUE, 3, 0}, - {"Back", COLOR_WHITE, 4, 0} +menu_item shutdownmenu[5] = { + {"-- EXIT --\n", COLOR_ORANGE, -1, 0}, + {"Back", COLOR_WHITE, 1, 1}, + {"\nReboot to RCM", COLOR_VIOLET, 2, 1}, + {"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(){ @@ -37,12 +45,12 @@ void fillmainmenu(){ break; case 3: if (sd_mounted){ - mainmenu[i].property = 1; - strcpy(mainmenu[i].name, "Unmount SD"); + mainmenu[i].property = 2; + strcpy(mainmenu[i].name, "\nUnmount SD"); } else { - mainmenu[i].property = 0; - strcpy(mainmenu[i].name, "Mount SD"); + mainmenu[i].property = 1; + strcpy(mainmenu[i].name, "\nMount SD"); } break; } @@ -67,17 +75,24 @@ void te_main(){ sd_mounted = sd_mount(); } + if (res == 4){ + res = makemenu(toolsmenu, 3); + + if (res == 2) + displayinfo(); + } + if (res == 5) message(CREDITS_MESSAGE, COLOR_WHITE); if (res == 6){ - res = makemenu(shutdownmenu, 4); - if (res == 1) + res = makemenu(shutdownmenu, 5); + if (res == 2) reboot_rcm(); - else if (res == 2) - reboot_normal(); else if (res == 3) - power_off(); + reboot_normal(); + else if (res == 4) + power_off(); //todo declock bpmp } } } \ No newline at end of file diff --git a/source/tegraexplorer/tools.c b/source/tegraexplorer/tools.c new file mode 100644 index 0000000..cd5f91b --- /dev/null +++ b/source/tegraexplorer/tools.c @@ -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(); +} \ No newline at end of file diff --git a/source/tegraexplorer/tools.h b/source/tegraexplorer/tools.h new file mode 100644 index 0000000..8c23809 --- /dev/null +++ b/source/tegraexplorer/tools.h @@ -0,0 +1,3 @@ +#pragma once + +void displayinfo(); \ No newline at end of file