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:
parent
8a727cecdb
commit
6fb512aba5
5 changed files with 105 additions and 37 deletions
|
@ -1082,7 +1082,6 @@ id: LANG_PM_MAX
|
||||||
desc: in the peak meter menu
|
desc: in the peak meter menu
|
||||||
eng: "Maximum of range"
|
eng: "Maximum of range"
|
||||||
new:
|
new:
|
||||||
|
|
||||||
id: LANG_RECORDING
|
id: LANG_RECORDING
|
||||||
desc: in the main menu
|
desc: in the main menu
|
||||||
eng: "Recording"
|
eng: "Recording"
|
||||||
|
@ -1142,3 +1141,14 @@ id: LANG_RECORDING_SETTINGS
|
||||||
desc: in the main menu
|
desc: in the main menu
|
||||||
eng: "Recording settings"
|
eng: "Recording settings"
|
||||||
new:
|
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:
|
||||||
|
|
||||||
|
|
100
apps/main_menu.c
100
apps/main_menu.c
|
@ -38,6 +38,7 @@
|
||||||
#include "powermgmt.h"
|
#include "powermgmt.h"
|
||||||
#include "sound_menu.h"
|
#include "sound_menu.h"
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
|
#include "fat.h"
|
||||||
|
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
|
||||||
|
@ -158,60 +159,87 @@ bool show_info(void)
|
||||||
int integer, decimal;
|
int integer, decimal;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
int key;
|
int key;
|
||||||
int state=0;
|
int state = 1;
|
||||||
|
|
||||||
while(!done)
|
while(!done)
|
||||||
{
|
{
|
||||||
|
int y=0;
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
lcd_puts(0, 0, str(LANG_ROCKBOX_INFO));
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
lcd_puts(0, y++, str(LANG_ROCKBOX_INFO));
|
||||||
integer = buflen / 1000;
|
y++;
|
||||||
decimal = buflen % 1000;
|
state = 3;
|
||||||
#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);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (state & 1) {
|
||||||
|
integer = buflen / 1000;
|
||||||
|
decimal = buflen % 1000;
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_PLAYER),
|
snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_PLAYER),
|
||||||
battery_level(), battery_level_safe() ? "" : "!");
|
integer, decimal);
|
||||||
lcd_puts(0, 1, s);
|
#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
|
#else
|
||||||
#ifdef HAVE_CHARGE_CTRL
|
#ifdef HAVE_CHARGE_CTRL
|
||||||
if (charger_enabled)
|
if (charger_enabled)
|
||||||
snprintf(s, sizeof(s), str(LANG_BATTERY_CHARGE));
|
snprintf(s, sizeof(s), str(LANG_BATTERY_CHARGE));
|
||||||
else
|
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),
|
snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_RECORDER),
|
||||||
battery_level(), battery_level_safe() ? "" : " !!");
|
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
|
||||||
#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();
|
lcd_update();
|
||||||
|
|
||||||
/* Wait for a key to be pushed */
|
/* Wait for a key to be pushed */
|
||||||
key = button_get_w_tmo(HZ/2);
|
key = button_get_w_tmo(HZ*5);
|
||||||
if(key) {
|
switch(key) {
|
||||||
switch(state) {
|
#ifdef HAVE_PLAYER_KEYPAD
|
||||||
case 0:
|
case BUTTON_STOP | BUTTON_REL:
|
||||||
/* first, a non-release event */
|
#else
|
||||||
if(!(key&BUTTON_REL))
|
case BUTTON_LEFT | BUTTON_REL:
|
||||||
state++;
|
case BUTTON_OFF | BUTTON_REL:
|
||||||
|
#endif
|
||||||
|
done = true;
|
||||||
break;
|
break;
|
||||||
case 1:
|
|
||||||
/* then a release-event */
|
#ifdef HAVE_PLAYER_KEYPAD
|
||||||
if(key&BUTTON_REL)
|
case BUTTON_LEFT:
|
||||||
done = true;
|
case BUTTON_RIGHT:
|
||||||
|
if (state == 1)
|
||||||
|
state = 2;
|
||||||
|
else
|
||||||
|
state = 1;
|
||||||
break;
|
break;
|
||||||
}
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,14 @@ int fat_startsector(void)
|
||||||
return fat_bpb.startsector;
|
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)
|
int fat_mount(int startsector)
|
||||||
{
|
{
|
||||||
unsigned char buf[SECTOR_SIZE];
|
unsigned char buf[SECTOR_SIZE];
|
||||||
|
|
|
@ -67,6 +67,7 @@ struct fat_dir
|
||||||
|
|
||||||
|
|
||||||
extern int fat_mount(int startsector);
|
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_create_dir(unsigned int currdir, char *name);
|
||||||
extern int fat_startsector(void);
|
extern int fat_startsector(void);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/vfs.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -107,3 +108,23 @@ int x11_open(char *name, int opts)
|
||||||
}
|
}
|
||||||
return open(name, 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue