diff --git a/source/main.c b/source/main.c index 6649edc..5bbdc49 100644 --- a/source/main.c +++ b/source/main.c @@ -162,5 +162,6 @@ void ipl_main() gfx_con_init(); display_backlight_pwm_init(); + sd_mount(); meme_main(); } diff --git a/source/meme/main.c b/source/meme/main.c index ed2937a..1fcfceb 100644 --- a/source/meme/main.c +++ b/source/meme/main.c @@ -4,10 +4,40 @@ #include "../utils/btn.h" #include "utils.h" #include "main.h" +#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) void meme_main(){ utils_gfx_init(); static const u32 colors[7] = {COLOR_RED, COLOR_ORANGE, COLOR_YELLOW, COLOR_GREEN, COLOR_BLUE, COLOR_VIOLET, COLOR_DEFAULT}; - gfx_printf("%k%pHello World!\n%k%pHi denn i think i did it\n%p%kAnother test", colors[1], colors[0], colors[2], colors[5], colors[6], colors[3]); + gfx_printf("%k%pHello World!\n%k%pHi denn i think i did it\n%p%kAnother test\n", colors[1], colors[0], colors[2], colors[5], colors[6], colors[3]); + + sdmmc_storage_t storage; + sdmmc_t sdmmc; + + sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4); + sdmmc_storage_set_mmc_partition(&storage, 1); + + //f_rename("sd:/yeet.txt", "sd:/yote.txt"); + + char *itemsinfolder[250]; + unsigned int muhbits[250]; + int folderamount = 0; + folderamount = readfolder(itemsinfolder, muhbits); + + int i = 0; + gfx_printf("%d", folderamount); + while(i < folderamount){ + gfx_printf("\n%s", itemsinfolder[i]); + if (muhbits[i] & OPTION1) gfx_printf(" "); + else gfx_printf(" "); + i++; + } + utils_waitforpower(); } \ No newline at end of file diff --git a/source/meme/utils.c b/source/meme/utils.c index f65242f..0a49f15 100644 --- a/source/meme/utils.c +++ b/source/meme/utils.c @@ -1,8 +1,18 @@ +#include +#include +#include #include "../gfx/di.h" #include "../gfx/gfx.h" #include "../utils/btn.h" #include "../utils/util.h" #include "utils.h" +#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) void utils_gfx_init(){ display_backlight_brightness(100, 1000); @@ -18,4 +28,24 @@ void utils_waitforpower(){ reboot_normal(); else power_off(); +} + +int readfolder(char *items[], unsigned int *muhbits){ + DIR dir; + FILINFO fno; + char path[100] = "sd:/"; + + if (f_opendir(&dir, path)) { + gfx_printf("\nFailed to open %s", path); + } + + int i = 0; + 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++; + } + return i; } \ No newline at end of file diff --git a/source/meme/utils.h b/source/meme/utils.h index 3f0e01c..fb09b48 100644 --- a/source/meme/utils.h +++ b/source/meme/utils.h @@ -1,4 +1,5 @@ #pragma once void utils_gfx_init(); -void utils_waitforpower(); \ No newline at end of file +void utils_waitforpower(); +int readfolder(char *items[], unsigned int *muhbits); \ No newline at end of file