2019-08-14 23:24:58 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2019-08-14 20:29:04 +01:00
|
|
|
#include "../gfx/di.h"
|
|
|
|
#include "../gfx/gfx.h"
|
|
|
|
#include "../utils/btn.h"
|
|
|
|
#include "../utils/util.h"
|
|
|
|
#include "utils.h"
|
2019-08-14 23:24:58 +01:00
|
|
|
#include "../libs/fatfs/ff.h"
|
|
|
|
#include "../storage/sdmmc.h"
|
|
|
|
|
|
|
|
#define OPTION1 (1 << 0)
|
|
|
|
#define OPTION2 (1 << 1)
|
|
|
|
#define OPTION3 (1 << 2)
|
|
|
|
#define OPTION4 (1 << 3)
|
2019-08-14 20:29:04 +01:00
|
|
|
|
|
|
|
void utils_gfx_init(){
|
|
|
|
display_backlight_brightness(100, 1000);
|
|
|
|
gfx_clear_grey(0x1B);
|
|
|
|
gfx_con_setpos(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void utils_waitforpower(){
|
|
|
|
u32 btn = btn_wait();
|
|
|
|
if (btn & BTN_VOL_UP)
|
|
|
|
reboot_rcm();
|
|
|
|
else if (btn & BTN_VOL_DOWN)
|
|
|
|
reboot_normal();
|
|
|
|
else
|
|
|
|
power_off();
|
2019-08-14 23:24:58 +01:00
|
|
|
}
|
|
|
|
|
2019-08-14 23:42:41 +01:00
|
|
|
int readfolder(char *items[], unsigned int *muhbits, const char path[]){
|
2019-08-14 23:24:58 +01:00
|
|
|
DIR dir;
|
|
|
|
FILINFO fno;
|
2019-08-14 23:42:41 +01:00
|
|
|
int i = 0;
|
2019-08-14 23:24:58 +01:00
|
|
|
|
|
|
|
if (f_opendir(&dir, path)) {
|
|
|
|
gfx_printf("\nFailed to open %s", path);
|
|
|
|
}
|
2019-08-14 23:42:41 +01:00
|
|
|
else{
|
|
|
|
while (!f_readdir(&dir, &fno) && fno.fname[0]){
|
|
|
|
size_t size = strlen(fno.fname) + 1;
|
|
|
|
items[i] = (char*) malloc (size);
|
|
|
|
strlcpy(items[i], fno.fname, size);
|
|
|
|
if (fno.fattrib & AM_DIR) muhbits[i] |= (OPTION1);
|
|
|
|
i++;
|
|
|
|
}
|
2019-08-14 23:24:58 +01:00
|
|
|
}
|
|
|
|
return i;
|
2019-08-14 20:29:04 +01:00
|
|
|
}
|