1
0
Fork 0
forked from len0rd/rockbox

Added disk space to Info menu item. (Players press + to see it.)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2837 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-11-12 11:32:26 +00:00
parent 8a727cecdb
commit 6fb512aba5
5 changed files with 105 additions and 37 deletions

View file

@ -1082,7 +1082,6 @@ id: LANG_PM_MAX
desc: in the peak meter menu
eng: "Maximum of range"
new:
id: LANG_RECORDING
desc: in the main menu
eng: "Recording"
@ -1142,3 +1141,14 @@ id: LANG_RECORDING_SETTINGS
desc: in the main menu
eng: "Recording settings"
new:
id: LANG_DISK_STAT
desc: disk size info
eng: "Disk: %d.%dGB"
new:
id: LANG_DISK_FREE_STAT
desc: disk size info
eng: "Free: %d.%dGB"
new:

View file

@ -38,6 +38,7 @@
#include "powermgmt.h"
#include "sound_menu.h"
#include "status.h"
#include "fat.h"
#include "lang.h"
@ -158,60 +159,87 @@ bool show_info(void)
int integer, decimal;
bool done = false;
int key;
int state=0;
int state = 1;
while(!done)
{
int y=0;
lcd_clear_display();
lcd_puts(0, 0, str(LANG_ROCKBOX_INFO));
integer = buflen / 1000;
decimal = buflen % 1000;
#ifdef HAVE_LCD_CHARCELLS
snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_PLAYER), integer, decimal);
lcd_puts(0, 0, s);
#else
snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_RECORDER), integer,
decimal);
lcd_puts(0, 2, s);
#ifdef HAVE_LCD_BITMAP
lcd_puts(0, y++, str(LANG_ROCKBOX_INFO));
y++;
state = 3;
#endif
if (state & 1) {
integer = buflen / 1000;
decimal = buflen % 1000;
#ifdef HAVE_LCD_CHARCELLS
snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_PLAYER),
battery_level(), battery_level_safe() ? "" : "!");
lcd_puts(0, 1, s);
snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_PLAYER),
integer, decimal);
#else
snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_RECORDER),
integer, decimal);
#endif
lcd_puts(0, y++, s);
#ifdef HAVE_LCD_CHARCELLS
snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_PLAYER),
battery_level(), battery_level_safe() ? "" : "!");
#else
#ifdef HAVE_CHARGE_CTRL
if (charger_enabled)
snprintf(s, sizeof(s), str(LANG_BATTERY_CHARGE));
else
if (charger_enabled)
snprintf(s, sizeof(s), str(LANG_BATTERY_CHARGE));
else
snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_RECORDER),
battery_level(), battery_level_safe() ? "" : " !!");
#else
snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_RECORDER),
battery_level(), battery_level_safe() ? "" : " !!");
lcd_puts(0, 3, s);
#else
snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_RECORDER),
battery_level(), battery_level_safe() ? "" : " !!");
lcd_puts(0, 3, s);
#endif
#endif
lcd_puts(0, y++, s);
}
if (state & 2) {
unsigned int size, free;
fat_size( &size, &free );
size /= 1024;
integer = size / 1024;
decimal = size % 1024 / 100;
snprintf(s, sizeof s, str(LANG_DISK_STAT), integer, decimal);
lcd_puts(0, y++, s);
free /= 1024;
integer = free / 1024;
decimal = free % 1024 / 100;
snprintf(s, sizeof s, str(LANG_DISK_FREE_STAT), integer, decimal);
lcd_puts(0, y++, s);
}
lcd_update();
/* Wait for a key to be pushed */
key = button_get_w_tmo(HZ/2);
if(key) {
switch(state) {
case 0:
/* first, a non-release event */
if(!(key&BUTTON_REL))
state++;
key = button_get_w_tmo(HZ*5);
switch(key) {
#ifdef HAVE_PLAYER_KEYPAD
case BUTTON_STOP | BUTTON_REL:
#else
case BUTTON_LEFT | BUTTON_REL:
case BUTTON_OFF | BUTTON_REL:
#endif
done = true;
break;
case 1:
/* then a release-event */
if(key&BUTTON_REL)
done = true;
#ifdef HAVE_PLAYER_KEYPAD
case BUTTON_LEFT:
case BUTTON_RIGHT:
if (state == 1)
state = 2;
else
state = 1;
break;
}
#endif
}
}

View file

@ -223,6 +223,14 @@ int fat_startsector(void)
return fat_bpb.startsector;
}
void fat_size(unsigned int* size, unsigned int* free)
{
if (size)
*size = fat_bpb.dataclusters * fat_bpb.bpb_secperclus / 2;
if (free)
*free = fat_bpb.fsinfo.freecount * fat_bpb.bpb_secperclus / 2;
}
int fat_mount(int startsector)
{
unsigned char buf[SECTOR_SIZE];

View file

@ -67,6 +67,7 @@ struct fat_dir
extern int fat_mount(int startsector);
extern void fat_size(unsigned int* size, unsigned int* free);
extern int fat_create_dir(unsigned int currdir, char *name);
extern int fat_startsector(void);

View file

@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <dirent.h>
#include <fcntl.h>
@ -107,3 +108,23 @@ int x11_open(char *name, int opts)
}
return open(name, opts);
}
void fat_size(unsigned int* size, unsigned int* free)
{
struct statfs fs;
if (!statfs(".", &fs)) {
DEBUGF("statfs: bsize=%d blocks=%d free=%d\n",
fs.f_bsize, fs.f_blocks, fs.f_bfree);
if (size)
*size = fs.f_blocks * (fs.f_bsize / 1024);
if (free)
*free = fs.f_bfree * (fs.f_bsize / 1024);
}
else {
if (size)
*size = 0;
if (free)
*free = 0;
}
}