fs: improved file selector

This commit is contained in:
schneider 2011-07-25 00:32:36 +02:00
parent 34b0ba6e58
commit 8daf823d98
1 changed files with 13 additions and 6 deletions

View File

@ -20,11 +20,12 @@ int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, char *ext)
//lcdPrint("OpenDir:"); lcdPrintln(f_get_rc_string(res)); lcdRefresh(); //lcdPrint("OpenDir:"); lcdPrintln(f_get_rc_string(res)); lcdRefresh();
return 0; return 0;
}; };
for(ctr=0;pos<count;ctr++) { ctr=0;
while(1){
res = f_readdir(&dir, &Finfo); res = f_readdir(&dir, &Finfo);
if ((res != FR_OK) || !Finfo.fname[0]) break; if ((res != FR_OK) || !Finfo.fname[0])
if( ctr < skip ) break;
continue;
int len=strlen(Finfo.fname); int len=strlen(Finfo.fname);
int extlen = strlen(ext); int extlen = strlen(ext);
@ -33,7 +34,11 @@ int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, char *ext)
if (Finfo.fattrib & AM_DIR) if (Finfo.fattrib & AM_DIR)
continue; continue;
if( ctr++ < skip )
continue;
strcpy(files[pos++],Finfo.fname); strcpy(files[pos++],Finfo.fname);
if( pos == count )
break;
} }
return pos; return pos;
} }
@ -54,13 +59,15 @@ int selectFile(char *filename, char *extension)
lcdPrintln("Select file:"); lcdPrintln("Select file:");
for(int i=0; i<count; i++){ for(int i=0; i<count; i++){
if( selected == i ) if( selected == i )
lcdPrint(">"); lcdPrint("*");
else
lcdPrint(" ");
lcdPrintln(files[i]); lcdPrintln(files[i]);
} }
lcdRefresh(); lcdRefresh();
key=getInputWait(); key=getInputWait();
if( key==BTN_DOWN ){ if( key==BTN_DOWN ){
if( selected < 6 ){ if( selected < count-1 ){
selected++; selected++;
goto redraw; goto redraw;
}else{ }else{