2019-11-21 15:02:45 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "te.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
#include "../utils/util.h"
|
|
|
|
|
|
|
|
extern bool sd_mount();
|
|
|
|
extern void sd_unmount();
|
2019-11-21 16:34:47 +00:00
|
|
|
bool sd_mounted = false;
|
2019-11-21 15:02:45 +00:00
|
|
|
|
|
|
|
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}
|
|
|
|
};
|
|
|
|
|
|
|
|
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}
|
|
|
|
};
|
|
|
|
|
|
|
|
void fillmainmenu(){
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAINMENU_AMOUNT; i++){
|
|
|
|
switch (i + 1) {
|
|
|
|
case 1:
|
2019-11-21 16:34:47 +00:00
|
|
|
if (sd_mounted)
|
2019-11-21 15:02:45 +00:00
|
|
|
mainmenu[i].property = 1;
|
|
|
|
else
|
|
|
|
mainmenu[i].property = -1;
|
|
|
|
break;
|
|
|
|
case 3:
|
2019-11-21 16:34:47 +00:00
|
|
|
if (sd_mounted){
|
2019-11-21 15:02:45 +00:00
|
|
|
mainmenu[i].property = 1;
|
2019-11-21 16:34:47 +00:00
|
|
|
strcpy(mainmenu[i].name, "Unmount SD");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mainmenu[i].property = 0;
|
|
|
|
strcpy(mainmenu[i].name, "Mount SD");
|
|
|
|
}
|
2019-11-21 15:02:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void te_main(){
|
|
|
|
int res;
|
|
|
|
|
2019-11-21 16:34:47 +00:00
|
|
|
sd_mounted = sd_mount();
|
|
|
|
|
2019-11-21 15:02:45 +00:00
|
|
|
while (1){
|
|
|
|
fillmainmenu();
|
2019-11-21 16:34:47 +00:00
|
|
|
res = makemenu(mainmenu, MAINMENU_AMOUNT);
|
|
|
|
|
|
|
|
if (res == 3){
|
|
|
|
if (sd_mounted){
|
|
|
|
sd_mounted = false;
|
|
|
|
sd_unmount();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sd_mounted = sd_mount();
|
|
|
|
}
|
2019-11-21 15:02:45 +00:00
|
|
|
|
|
|
|
if (res == 5)
|
2019-11-21 16:34:47 +00:00
|
|
|
message(CREDITS_MESSAGE, COLOR_WHITE);
|
2019-11-21 15:02:45 +00:00
|
|
|
|
|
|
|
if (res == 6){
|
|
|
|
res = makemenu(shutdownmenu, 4);
|
|
|
|
if (res == 1)
|
|
|
|
reboot_rcm();
|
|
|
|
else if (res == 2)
|
|
|
|
reboot_normal();
|
|
|
|
else if (res == 3)
|
|
|
|
power_off();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|