[sky9x / gruvin9x] Files in SD Manager sorted alphabetically
[sky9x / gruvin9x] Format function added into SD Manager
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@
|
|||||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
||||||
|
|
||||||
|
|
||||||
#define _USE_MKFS 0 /* 0:Disable or 1:Enable */
|
#define _USE_MKFS 1 /* 0:Disable or 1:Enable */
|
||||||
/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
|
/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+85
-3
@@ -572,7 +572,7 @@ void menuProcSd(uint8_t event)
|
|||||||
switch(event) {
|
switch(event) {
|
||||||
case EVT_ENTRY:
|
case EVT_ENTRY:
|
||||||
f_chdir("/");
|
f_chdir("/");
|
||||||
reusableBuffer.sd.offset = 255;
|
reusableBuffer.sd.offset = 65535;
|
||||||
break;
|
break;
|
||||||
#if defined(ROTARY_ENCODERS)
|
#if defined(ROTARY_ENCODERS)
|
||||||
case EVT_KEY_FIRST(BTN_REa):
|
case EVT_KEY_FIRST(BTN_REa):
|
||||||
@@ -605,7 +605,11 @@ void menuProcSd(uint8_t event)
|
|||||||
#endif
|
#endif
|
||||||
case EVT_KEY_LONG(KEY_MENU):
|
case EVT_KEY_LONG(KEY_MENU):
|
||||||
killEvents(event);
|
killEvents(event);
|
||||||
if (m_posVert > 0) {
|
if (m_posVert == 0) {
|
||||||
|
s_menu[s_menu_count++] = STR_SD_INFO;
|
||||||
|
s_menu[s_menu_count++] = STR_SD_FORMAT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
#if defined(PCBARM)
|
#if defined(PCBARM)
|
||||||
uint8_t index = m_posVert-1-s_pgOfs;
|
uint8_t index = m_posVert-1-s_pgOfs;
|
||||||
char * line = reusableBuffer.sd.lines[index];
|
char * line = reusableBuffer.sd.lines[index];
|
||||||
@@ -620,6 +624,75 @@ void menuProcSd(uint8_t event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SD_ALPHABETICAL_ORDER
|
||||||
|
#ifdef SD_ALPHABETICAL_ORDER
|
||||||
|
if (reusableBuffer.sd.offset != s_pgOfs) {
|
||||||
|
char hidden_line[SD_SCREEN_FILE_LENGTH+1] = "";
|
||||||
|
uint8_t hidden_flag = 0;
|
||||||
|
|
||||||
|
if (s_pgOfs == 0) {
|
||||||
|
reusableBuffer.sd.offset = 0;
|
||||||
|
}
|
||||||
|
else if (s_pgOfs >= reusableBuffer.sd.count-7) {
|
||||||
|
reusableBuffer.sd.offset = s_pgOfs+1;
|
||||||
|
}
|
||||||
|
else if (s_pgOfs > reusableBuffer.sd.offset) {
|
||||||
|
memcpy(hidden_line, reusableBuffer.sd.lines[0], sizeof(hidden_line));
|
||||||
|
hidden_flag = reusableBuffer.sd.flags[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
memcpy(hidden_line, reusableBuffer.sd.lines[6], sizeof(hidden_line));
|
||||||
|
hidden_flag = reusableBuffer.sd.flags[6];
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(reusableBuffer.sd.lines, 0, sizeof(reusableBuffer.sd.lines));
|
||||||
|
reusableBuffer.sd.count = 0;
|
||||||
|
|
||||||
|
FRESULT res = f_opendir(&dir, "."); /* Open the directory */
|
||||||
|
if (res == FR_OK) {
|
||||||
|
for (;;) {
|
||||||
|
res = f_readdir(&dir, &fno); /* Read a directory item */
|
||||||
|
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
|
||||||
|
if (fno.fname[0] == '.' && fno.fname[1] == '\0') continue; /* Ignore dot entry */
|
||||||
|
#if _USE_LFN
|
||||||
|
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||||
|
#else
|
||||||
|
fn = fno.fname;
|
||||||
|
#endif
|
||||||
|
reusableBuffer.sd.count++;
|
||||||
|
|
||||||
|
bool isdir = (fno.fattrib & AM_DIR);
|
||||||
|
|
||||||
|
for (uint8_t i=0; i<7; i++) {
|
||||||
|
if (s_pgOfs >= reusableBuffer.sd.offset) {
|
||||||
|
char *line = reusableBuffer.sd.lines[i];
|
||||||
|
if ((!hidden_line[0] || (!isdir && hidden_flag) || (strcmp(hidden_line, fn) < 0)) && (line[0] == '\0' || (isdir&&!reusableBuffer.sd.flags[i]) || strcmp(fn, line) < 0)) {
|
||||||
|
if (i < 7-1) {
|
||||||
|
memmove(reusableBuffer.sd.lines[i+1], line, sizeof(reusableBuffer.sd.lines[i]) * (7-1-i));
|
||||||
|
memmove(&reusableBuffer.sd.flags[i+1], &reusableBuffer.sd.flags[i], sizeof(reusableBuffer.sd.flags[i]) * (7-1-i));
|
||||||
|
}
|
||||||
|
strncpy(line, fn, SD_SCREEN_FILE_LENGTH);
|
||||||
|
reusableBuffer.sd.flags[i] = isdir;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char *line = reusableBuffer.sd.lines[6-i];
|
||||||
|
if ((!hidden_line[0] || (isdir && !hidden_flag) || (strcmp(hidden_line, fn) > 0)) && (line[0] == '\0' || (!isdir&&reusableBuffer.sd.flags[6-i]) || strcmp(fn, line) > 0)) {
|
||||||
|
if (i < 7-1) {
|
||||||
|
memmove(reusableBuffer.sd.lines, reusableBuffer.sd.lines[1], sizeof(reusableBuffer.sd.lines[0]) * (6-i));
|
||||||
|
memmove(&reusableBuffer.sd.flags, &reusableBuffer.sd.flags[1], sizeof(reusableBuffer.sd.flags[0]) * (6-i));
|
||||||
|
}
|
||||||
|
strncpy(line, fn, SD_SCREEN_FILE_LENGTH);
|
||||||
|
reusableBuffer.sd.flags[6-i] = isdir;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (reusableBuffer.sd.offset != s_pgOfs) {
|
if (reusableBuffer.sd.offset != s_pgOfs) {
|
||||||
memset(reusableBuffer.sd.lines, 0, sizeof(reusableBuffer.sd.lines));
|
memset(reusableBuffer.sd.lines, 0, sizeof(reusableBuffer.sd.lines));
|
||||||
memset(reusableBuffer.sd.flags, 0, sizeof(reusableBuffer.sd.flags));
|
memset(reusableBuffer.sd.flags, 0, sizeof(reusableBuffer.sd.flags));
|
||||||
@@ -652,6 +725,9 @@ void menuProcSd(uint8_t event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
reusableBuffer.sd.offset = s_pgOfs;
|
||||||
|
|
||||||
for (uint8_t i=0; i<7; i++) {
|
for (uint8_t i=0; i<7; i++) {
|
||||||
uint8_t y = FH+i*FH;
|
uint8_t y = FH+i*FH;
|
||||||
@@ -666,7 +742,13 @@ void menuProcSd(uint8_t event)
|
|||||||
const char * result = displayMenu(_event);
|
const char * result = displayMenu(_event);
|
||||||
if (result) {
|
if (result) {
|
||||||
uint8_t index = m_posVert-1-s_pgOfs;
|
uint8_t index = m_posVert-1-s_pgOfs;
|
||||||
if (result == STR_DELETE_FILE) {
|
if (result == STR_SD_FORMAT) {
|
||||||
|
f_mkfs(0, 0, 0);
|
||||||
|
f_mount(0, &g_FATFS_Obj);
|
||||||
|
f_chdir("/");
|
||||||
|
reusableBuffer.sd.offset = -1;
|
||||||
|
}
|
||||||
|
else if (result == STR_DELETE_FILE) {
|
||||||
f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
|
f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
|
||||||
strcat_P(lfn, PSTR("/"));
|
strcat_P(lfn, PSTR("/"));
|
||||||
strcat(lfn, reusableBuffer.sd.lines[index]);
|
strcat(lfn, reusableBuffer.sd.lines[index]);
|
||||||
|
|||||||
@@ -287,6 +287,8 @@ namespace simu {
|
|||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
FATFS g_FATFS_Obj;
|
||||||
|
|
||||||
FRESULT f_stat (const TCHAR*, FILINFO*)
|
FRESULT f_stat (const TCHAR*, FILINFO*)
|
||||||
{
|
{
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
@@ -362,6 +364,12 @@ FRESULT f_readdir (DIR * rep, FILINFO * fil)
|
|||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FRESULT f_mkfs (unsigned char, unsigned char, unsigned int)
|
||||||
|
{
|
||||||
|
printf("Format SD...\n"); fflush(stdout);
|
||||||
|
return FR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
FRESULT f_mkdir (const TCHAR*)
|
FRESULT f_mkdir (const TCHAR*)
|
||||||
{
|
{
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
|
|||||||
@@ -357,6 +357,8 @@ const pm_char STR_PLAY_FILE[] PROGMEM = TR_PLAY_FILE;
|
|||||||
const pm_char STR_DELETE_FILE[] PROGMEM = TR_DELETE_FILE;
|
const pm_char STR_DELETE_FILE[] PROGMEM = TR_DELETE_FILE;
|
||||||
const pm_char STR_COPY_FILE[] PROGMEM = TR_COPY_FILE;
|
const pm_char STR_COPY_FILE[] PROGMEM = TR_COPY_FILE;
|
||||||
const pm_char STR_RENAME_FILE[] PROGMEM = TR_RENAME_FILE;
|
const pm_char STR_RENAME_FILE[] PROGMEM = TR_RENAME_FILE;
|
||||||
|
const pm_char STR_SD_INFO[] PROGMEM = TR_SD_INFO;
|
||||||
|
const pm_char STR_SD_FORMAT[] PROGMEM = TR_SD_FORMAT;
|
||||||
const pm_char STR_REMOVED[] PROGMEM = TR_REMOVED;
|
const pm_char STR_REMOVED[] PROGMEM = TR_REMOVED;
|
||||||
const pm_char STR_NA[] PROGMEM = TR_NA;
|
const pm_char STR_NA[] PROGMEM = TR_NA;
|
||||||
|
|
||||||
|
|||||||
@@ -439,6 +439,8 @@ extern const pm_char STR_DELETE_FILE[];
|
|||||||
extern const pm_char STR_COPY_FILE[];
|
extern const pm_char STR_COPY_FILE[];
|
||||||
extern const pm_char STR_RENAME_FILE[];
|
extern const pm_char STR_RENAME_FILE[];
|
||||||
extern const pm_char STR_REMOVED[];
|
extern const pm_char STR_REMOVED[];
|
||||||
|
extern const pm_char STR_SD_INFO[];
|
||||||
|
extern const pm_char STR_SD_FORMAT[];
|
||||||
extern const pm_char STR_NA[];
|
extern const pm_char STR_NA[];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -429,4 +429,6 @@
|
|||||||
#define TR_COPY_FILE "Kop\204rovat"
|
#define TR_COPY_FILE "Kop\204rovat"
|
||||||
#define TR_RENAME_FILE "P\206ejmenovat"
|
#define TR_RENAME_FILE "P\206ejmenovat"
|
||||||
#define TR_REMOVED " odstran\203n"
|
#define TR_REMOVED " odstran\203n"
|
||||||
|
#define TR_SD_INFO "Infos"
|
||||||
|
#define TR_SD_FORMAT "Format"
|
||||||
#define TR_NA "[X]"
|
#define TR_NA "[X]"
|
||||||
|
|||||||
@@ -429,4 +429,6 @@
|
|||||||
#define TR_COPY_FILE "Copy"
|
#define TR_COPY_FILE "Copy"
|
||||||
#define TR_RENAME_FILE "Rename"
|
#define TR_RENAME_FILE "Rename"
|
||||||
#define TR_REMOVED " removed"
|
#define TR_REMOVED " removed"
|
||||||
|
#define TR_SD_INFO "Infos"
|
||||||
|
#define TR_SD_FORMAT "Format"
|
||||||
#define TR_NA "N/A"
|
#define TR_NA "N/A"
|
||||||
|
|||||||
@@ -435,4 +435,6 @@
|
|||||||
#define TR_COPY_FILE "Copy"
|
#define TR_COPY_FILE "Copy"
|
||||||
#define TR_RENAME_FILE "Rename"
|
#define TR_RENAME_FILE "Rename"
|
||||||
#define TR_REMOVED " removed"
|
#define TR_REMOVED " removed"
|
||||||
|
#define TR_SD_INFO "Infos"
|
||||||
|
#define TR_SD_FORMAT "Format"
|
||||||
#define TR_NA "N/A"
|
#define TR_NA "N/A"
|
||||||
|
|||||||
@@ -428,4 +428,6 @@
|
|||||||
#define TR_COPY_FILE "Copier"
|
#define TR_COPY_FILE "Copier"
|
||||||
#define TR_RENAME_FILE "Renommer"
|
#define TR_RENAME_FILE "Renommer"
|
||||||
#define TR_REMOVED " supprim\200"
|
#define TR_REMOVED " supprim\200"
|
||||||
|
#define TR_SD_INFO "Infos"
|
||||||
|
#define TR_SD_FORMAT "Formatter"
|
||||||
#define TR_NA "N/D"
|
#define TR_NA "N/D"
|
||||||
|
|||||||
@@ -429,4 +429,6 @@
|
|||||||
#define TR_COPY_FILE "Copia"
|
#define TR_COPY_FILE "Copia"
|
||||||
#define TR_RENAME_FILE "Rinomomina"
|
#define TR_RENAME_FILE "Rinomomina"
|
||||||
#define TR_REMOVED " rimosso"
|
#define TR_REMOVED " rimosso"
|
||||||
|
#define TR_SD_INFO "Infos"
|
||||||
|
#define TR_SD_FORMAT "Format"
|
||||||
#define TR_NA "N/A"
|
#define TR_NA "N/A"
|
||||||
|
|||||||
@@ -427,4 +427,6 @@
|
|||||||
#define TR_COPY_FILE "Kopia"
|
#define TR_COPY_FILE "Kopia"
|
||||||
#define TR_RENAME_FILE "Byt namn"
|
#define TR_RENAME_FILE "Byt namn"
|
||||||
#define TR_REMOVED " raderad"
|
#define TR_REMOVED " raderad"
|
||||||
|
#define TR_SD_INFO "Infos"
|
||||||
|
#define TR_SD_FORMAT "Format"
|
||||||
#define TR_NA "N/A"
|
#define TR_NA "N/A"
|
||||||
|
|||||||
Reference in New Issue
Block a user