diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-11-12 11:32:26 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-11-12 11:32:26 +0000 |
commit | 6fb512aba58bf221cdfcfc2a3df2148e8527883c (patch) | |
tree | e8ee8149ecf862068b7d70b2ec28ca04678227c6 | |
parent | 8a727cecdbb6f4efcea3a1b98cc1463825bdc499 (diff) |
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
-rw-r--r-- | apps/lang/english.lang | 12 | ||||
-rw-r--r-- | apps/main_menu.c | 98 | ||||
-rw-r--r-- | firmware/drivers/fat.c | 8 | ||||
-rw-r--r-- | firmware/drivers/fat.h | 1 | ||||
-rw-r--r-- | uisimulator/x11/io.c | 21 |
5 files changed, 104 insertions, 36 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 6ded417b2d..b71dca0efc 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -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: + diff --git a/apps/main_menu.c b/apps/main_menu.c index 12bd2274cb..49ad9c9f5b 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c @@ -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_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_BUFFER_STAT_PLAYER), integer, decimal); - lcd_puts(0, 0, s); + snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_PLAYER), + integer, decimal); #else - snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_RECORDER), integer, - decimal); - lcd_puts(0, 2, s); + 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() ? "" : "!"); - lcd_puts(0, 1, s); + 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 } } diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index ad1a7a0c82..38223edc6a 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -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]; diff --git a/firmware/drivers/fat.h b/firmware/drivers/fat.h index b23d8dfa08..8ef2982279 100644 --- a/firmware/drivers/fat.h +++ b/firmware/drivers/fat.h @@ -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); diff --git a/uisimulator/x11/io.c b/uisimulator/x11/io.c index 87ef6ba4b5..2951b1f4a0 100644 --- a/uisimulator/x11/io.c +++ b/uisimulator/x11/io.c @@ -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; + } +} |