diff --git a/source/tegraexplorer/fs.c b/source/tegraexplorer/fs.c index 54ae19e..c8a0c3a 100644 --- a/source/tegraexplorer/fs.c +++ b/source/tegraexplorer/fs.c @@ -11,8 +11,8 @@ fs_entry fileobjects[500]; char rootpath[10] = ""; -char currentpath[255] = ""; -char clipboard[255] = ""; +char currentpath[300] = ""; +char clipboard[300] = ""; u8 clipboardhelper = 0; extern const char sizevalues[4][3]; extern int launch_payload(char *path); @@ -28,6 +28,38 @@ menu_item explfilemenu[8] = { {"\nLaunch Payload", COLOR_ORANGE, PAYLOAD, 1} }; +void writecurpath(const char *in){ + /* + if (currentpath != NULL) + free(currentpath); + + size_t len = strlen(in) + 1; + currentpath = (char*) malloc (len); + strcpy(currentpath, in); + */ + strcpy(currentpath, in); +} + +void writeclipboard(const char *in, bool operation, bool folder){ + //if (clipboard != NULL) + // free(clipboard); + + clipboardhelper = 0; + + if (operation) + clipboardhelper |= (OPERATION); + + if (folder) + clipboardhelper |= (ISDIR); + + /* + size_t len = strlen(in) + 1; + clipboard = (char*) malloc (len); + strcpy(clipboard, in); + */ + strcpy(clipboard, in); +} + char *getnextloc(char *current, char *add){ char *ret; size_t size = strlen(current) + strlen(add) + 1; @@ -76,6 +108,11 @@ void addobject(char* name, int spot, bool isfol, bool isarc){ size_t size = strlen(name) + 1; fileobjects[spot].property = 0; + if (fileobjects[spot].name != NULL){ + free(fileobjects[spot].name); + fileobjects[spot].name = NULL; + } + fileobjects[spot].name = (char*) malloc (size); strlcpy(fileobjects[spot].name, name, size); @@ -86,6 +123,7 @@ void addobject(char* name, int spot, bool isfol, bool isarc){ int sizes = 0; FILINFO fno; f_stat(getnextloc(currentpath, name), &fno); + size = fno.fsize; while (size > 1024){ @@ -127,7 +165,7 @@ void filemenu(const char *startpath){ int amount, res, tempint; char temp[100]; strcpy(rootpath, startpath); - strcpy(currentpath, startpath); + writecurpath(startpath); amount = readfolder(currentpath); while (1){ @@ -137,7 +175,7 @@ void filemenu(const char *startpath){ if (!strcmp(rootpath, currentpath)) break; else { - strcpy(currentpath, getprevloc(currentpath)); + writecurpath(getprevloc(currentpath)); amount = readfolder(currentpath); } } @@ -150,7 +188,7 @@ void filemenu(const char *startpath){ } else { if (fileobjects[res - 1].property & ISDIR){ - strcpy(currentpath, getnextloc(currentpath, fileobjects[res - 1].name)); + writecurpath(getnextloc(currentpath, fileobjects[res - 1].name)); amount = readfolder(currentpath); } else { @@ -172,8 +210,10 @@ void filemenu(const char *startpath){ switch (res){ case COPY: + writeclipboard(getnextloc(currentpath, fileobjects[res - 1].name), false, false); + break; case MOVE: - strcpy(clipboard, getnextloc(currentpath, fileobjects[res - 1].name)); + writeclipboard(getnextloc(currentpath, fileobjects[res - 1].name), true, false); break; case DELETE: msleep(100); diff --git a/source/tegraexplorer/fs.h b/source/tegraexplorer/fs.h index 9a2cfb5..5a2b5f0 100644 --- a/source/tegraexplorer/fs.h +++ b/source/tegraexplorer/fs.h @@ -9,6 +9,8 @@ #define ISKB (1 << 5) #define ISB (1 << 4) +#define OPERATION (1 << 1) + /* Bit table for property: 0000 0001: Directory bit 0000 0010: Archive bit diff --git a/source/tegraexplorer/gfx.c b/source/tegraexplorer/gfx.c index 2fee26c..fd1aa1a 100644 --- a/source/tegraexplorer/gfx.c +++ b/source/tegraexplorer/gfx.c @@ -16,7 +16,7 @@ const char fixedoptions[3][50] = { }; const char sizevalues[4][3] = { - " B", + "B ", "KB", "MB", "GB" diff --git a/source/tegraexplorer/te.c b/source/tegraexplorer/te.c index 1cd4495..bd6a89d 100644 --- a/source/tegraexplorer/te.c +++ b/source/tegraexplorer/te.c @@ -30,10 +30,11 @@ menu_item shutdownmenu[7] = { {"Reboot to Atmosphere", COLOR_GREEN, AMS, -1} }; -menu_item toolsmenu[3] = { +menu_item toolsmenu[4] = { {"-- TOOLS --\n", COLOR_VIOLET, -1, 0}, {"Back", COLOR_WHITE, -1, 1}, - {"\nDisplay Console Info", COLOR_GREEN, DISPLAY_INFO, 1} + {"\nDisplay Console Info", COLOR_GREEN, DISPLAY_INFO, 1}, + {"Display GPIO pins [DEV]", COLOR_RED, DISPLAY_GPIO, 1} }; void fillmainmenu(){ @@ -87,10 +88,13 @@ void te_main(){ break; case TOOLS: - res = makemenu(toolsmenu, 3); + res = makemenu(toolsmenu, 4); if (res == DISPLAY_INFO) displayinfo(); + + if (res == DISPLAY_GPIO) + displaygpio(); break; diff --git a/source/tegraexplorer/te.h b/source/tegraexplorer/te.h index 2e362cf..9997b97 100644 --- a/source/tegraexplorer/te.h +++ b/source/tegraexplorer/te.h @@ -29,7 +29,8 @@ enum shutdownmenu_return { }; enum toolsmenu_return { - DISPLAY_INFO = 1 + DISPLAY_INFO = 1, + DISPLAY_GPIO }; //menu_item mainmenu[MAINMENU_AMOUNT]; diff --git a/source/tegraexplorer/tools.c b/source/tegraexplorer/tools.c index cd5f91b..ef94b8b 100644 --- a/source/tegraexplorer/tools.c +++ b/source/tegraexplorer/tools.c @@ -3,6 +3,8 @@ #include "../libs/fatfs/ff.h" #include "../gfx/gfx.h" #include "../utils/btn.h" +#include "../soc/gpio.h" +#include "../utils/util.h" void displayinfo(){ clearscreen(); @@ -19,8 +21,28 @@ void displayinfo(){ 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); - + gfx_printf("%d KiB total\n%d KiB free\n\nPress any key to continue\n", tot_sect / 2, fre_sect / 2); btn_wait(); +} + +void displaygpio(){ + int res; + clearscreen(); + gfx_printf("Updates gpio pins ever 50ms:\nPress power to exit"); + msleep(200); + while (1){ + msleep(10); + gfx_con_setpos(0, 63); + + for (int i = 0; i <= 30; i++){ + gfx_printf("\nPort %d: ", i); + for (int i2 = 7; i2 >= 0; i2--) + gfx_printf("%d", gpio_read(i, (1 << i2))); + } + + res = btn_read(); + if (res & BTN_POWER) + break; + } } \ No newline at end of file diff --git a/source/tegraexplorer/tools.h b/source/tegraexplorer/tools.h index 8c23809..3117f23 100644 --- a/source/tegraexplorer/tools.h +++ b/source/tegraexplorer/tools.h @@ -1,3 +1,4 @@ #pragma once -void displayinfo(); \ No newline at end of file +void displayinfo(); +void displaygpio(); \ No newline at end of file