1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +00:00

Add some testing features

This commit is contained in:
Such Meme, Many Skill 2019-12-03 10:06:11 +01:00
parent 65f38ba459
commit 57714daa87
7 changed files with 84 additions and 14 deletions

View file

@ -11,8 +11,8 @@
fs_entry fileobjects[500]; fs_entry fileobjects[500];
char rootpath[10] = ""; char rootpath[10] = "";
char currentpath[255] = ""; char currentpath[300] = "";
char clipboard[255] = ""; char clipboard[300] = "";
u8 clipboardhelper = 0; u8 clipboardhelper = 0;
extern const char sizevalues[4][3]; extern const char sizevalues[4][3];
extern int launch_payload(char *path); extern int launch_payload(char *path);
@ -28,6 +28,38 @@ menu_item explfilemenu[8] = {
{"\nLaunch Payload", COLOR_ORANGE, PAYLOAD, 1} {"\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 *getnextloc(char *current, char *add){
char *ret; char *ret;
size_t size = strlen(current) + strlen(add) + 1; 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; size_t size = strlen(name) + 1;
fileobjects[spot].property = 0; fileobjects[spot].property = 0;
if (fileobjects[spot].name != NULL){
free(fileobjects[spot].name);
fileobjects[spot].name = NULL;
}
fileobjects[spot].name = (char*) malloc (size); fileobjects[spot].name = (char*) malloc (size);
strlcpy(fileobjects[spot].name, name, size); strlcpy(fileobjects[spot].name, name, size);
@ -86,6 +123,7 @@ void addobject(char* name, int spot, bool isfol, bool isarc){
int sizes = 0; int sizes = 0;
FILINFO fno; FILINFO fno;
f_stat(getnextloc(currentpath, name), &fno); f_stat(getnextloc(currentpath, name), &fno);
size = fno.fsize; size = fno.fsize;
while (size > 1024){ while (size > 1024){
@ -127,7 +165,7 @@ void filemenu(const char *startpath){
int amount, res, tempint; int amount, res, tempint;
char temp[100]; char temp[100];
strcpy(rootpath, startpath); strcpy(rootpath, startpath);
strcpy(currentpath, startpath); writecurpath(startpath);
amount = readfolder(currentpath); amount = readfolder(currentpath);
while (1){ while (1){
@ -137,7 +175,7 @@ void filemenu(const char *startpath){
if (!strcmp(rootpath, currentpath)) if (!strcmp(rootpath, currentpath))
break; break;
else { else {
strcpy(currentpath, getprevloc(currentpath)); writecurpath(getprevloc(currentpath));
amount = readfolder(currentpath); amount = readfolder(currentpath);
} }
} }
@ -150,7 +188,7 @@ void filemenu(const char *startpath){
} }
else { else {
if (fileobjects[res - 1].property & ISDIR){ if (fileobjects[res - 1].property & ISDIR){
strcpy(currentpath, getnextloc(currentpath, fileobjects[res - 1].name)); writecurpath(getnextloc(currentpath, fileobjects[res - 1].name));
amount = readfolder(currentpath); amount = readfolder(currentpath);
} }
else { else {
@ -172,8 +210,10 @@ void filemenu(const char *startpath){
switch (res){ switch (res){
case COPY: case COPY:
writeclipboard(getnextloc(currentpath, fileobjects[res - 1].name), false, false);
break;
case MOVE: case MOVE:
strcpy(clipboard, getnextloc(currentpath, fileobjects[res - 1].name)); writeclipboard(getnextloc(currentpath, fileobjects[res - 1].name), true, false);
break; break;
case DELETE: case DELETE:
msleep(100); msleep(100);

View file

@ -9,6 +9,8 @@
#define ISKB (1 << 5) #define ISKB (1 << 5)
#define ISB (1 << 4) #define ISB (1 << 4)
#define OPERATION (1 << 1)
/* Bit table for property: /* Bit table for property:
0000 0001: Directory bit 0000 0001: Directory bit
0000 0010: Archive bit 0000 0010: Archive bit

View file

@ -16,7 +16,7 @@ const char fixedoptions[3][50] = {
}; };
const char sizevalues[4][3] = { const char sizevalues[4][3] = {
" B", "B ",
"KB", "KB",
"MB", "MB",
"GB" "GB"

View file

@ -30,10 +30,11 @@ menu_item shutdownmenu[7] = {
{"Reboot to Atmosphere", COLOR_GREEN, AMS, -1} {"Reboot to Atmosphere", COLOR_GREEN, AMS, -1}
}; };
menu_item toolsmenu[3] = { menu_item toolsmenu[4] = {
{"-- TOOLS --\n", COLOR_VIOLET, -1, 0}, {"-- TOOLS --\n", COLOR_VIOLET, -1, 0},
{"Back", COLOR_WHITE, -1, 1}, {"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(){ void fillmainmenu(){
@ -87,10 +88,13 @@ void te_main(){
break; break;
case TOOLS: case TOOLS:
res = makemenu(toolsmenu, 3); res = makemenu(toolsmenu, 4);
if (res == DISPLAY_INFO) if (res == DISPLAY_INFO)
displayinfo(); displayinfo();
if (res == DISPLAY_GPIO)
displaygpio();
break; break;

View file

@ -29,7 +29,8 @@ enum shutdownmenu_return {
}; };
enum toolsmenu_return { enum toolsmenu_return {
DISPLAY_INFO = 1 DISPLAY_INFO = 1,
DISPLAY_GPIO
}; };
//menu_item mainmenu[MAINMENU_AMOUNT]; //menu_item mainmenu[MAINMENU_AMOUNT];

View file

@ -3,6 +3,8 @@
#include "../libs/fatfs/ff.h" #include "../libs/fatfs/ff.h"
#include "../gfx/gfx.h" #include "../gfx/gfx.h"
#include "../utils/btn.h" #include "../utils/btn.h"
#include "../soc/gpio.h"
#include "../utils/util.h"
void displayinfo(){ void displayinfo(){
clearscreen(); clearscreen();
@ -19,8 +21,28 @@ void displayinfo(){
tot_sect = (fs->n_fatent - 2) * fs->csize; tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * 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(); 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;
}
} }

View file

@ -1,3 +1,4 @@
#pragma once #pragma once
void displayinfo(); void displayinfo();
void displaygpio();