diff options
-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 | |||
1082 | desc: in the peak meter menu | 1082 | desc: in the peak meter menu |
1083 | eng: "Maximum of range" | 1083 | eng: "Maximum of range" |
1084 | new: | 1084 | new: |
1085 | |||
1086 | id: LANG_RECORDING | 1085 | id: LANG_RECORDING |
1087 | desc: in the main menu | 1086 | desc: in the main menu |
1088 | eng: "Recording" | 1087 | eng: "Recording" |
@@ -1142,3 +1141,14 @@ id: LANG_RECORDING_SETTINGS | |||
1142 | desc: in the main menu | 1141 | desc: in the main menu |
1143 | eng: "Recording settings" | 1142 | eng: "Recording settings" |
1144 | new: | 1143 | new: |
1144 | |||
1145 | id: LANG_DISK_STAT | ||
1146 | desc: disk size info | ||
1147 | eng: "Disk: %d.%dGB" | ||
1148 | new: | ||
1149 | |||
1150 | id: LANG_DISK_FREE_STAT | ||
1151 | desc: disk size info | ||
1152 | eng: "Free: %d.%dGB" | ||
1153 | new: | ||
1154 | |||
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 @@ | |||
38 | #include "powermgmt.h" | 38 | #include "powermgmt.h" |
39 | #include "sound_menu.h" | 39 | #include "sound_menu.h" |
40 | #include "status.h" | 40 | #include "status.h" |
41 | #include "fat.h" | ||
41 | 42 | ||
42 | #include "lang.h" | 43 | #include "lang.h" |
43 | 44 | ||
@@ -158,60 +159,87 @@ bool show_info(void) | |||
158 | int integer, decimal; | 159 | int integer, decimal; |
159 | bool done = false; | 160 | bool done = false; |
160 | int key; | 161 | int key; |
161 | int state=0; | 162 | int state = 1; |
162 | 163 | ||
163 | while(!done) | 164 | while(!done) |
164 | { | 165 | { |
166 | int y=0; | ||
165 | lcd_clear_display(); | 167 | lcd_clear_display(); |
166 | lcd_puts(0, 0, str(LANG_ROCKBOX_INFO)); | 168 | #ifdef HAVE_LCD_BITMAP |
167 | 169 | lcd_puts(0, y++, str(LANG_ROCKBOX_INFO)); | |
168 | integer = buflen / 1000; | 170 | y++; |
169 | decimal = buflen % 1000; | 171 | state = 3; |
172 | #endif | ||
173 | |||
174 | if (state & 1) { | ||
175 | integer = buflen / 1000; | ||
176 | decimal = buflen % 1000; | ||
170 | #ifdef HAVE_LCD_CHARCELLS | 177 | #ifdef HAVE_LCD_CHARCELLS |
171 | snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_PLAYER), integer, decimal); | 178 | snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_PLAYER), |
172 | lcd_puts(0, 0, s); | 179 | integer, decimal); |
173 | #else | 180 | #else |
174 | snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_RECORDER), integer, | 181 | snprintf(s, sizeof(s), str(LANG_BUFFER_STAT_RECORDER), |
175 | decimal); | 182 | integer, decimal); |
176 | lcd_puts(0, 2, s); | ||
177 | #endif | 183 | #endif |
178 | 184 | lcd_puts(0, y++, s); | |
185 | |||
179 | #ifdef HAVE_LCD_CHARCELLS | 186 | #ifdef HAVE_LCD_CHARCELLS |
180 | snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_PLAYER), | 187 | snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_PLAYER), |
181 | battery_level(), battery_level_safe() ? "" : "!"); | 188 | battery_level(), battery_level_safe() ? "" : "!"); |
182 | lcd_puts(0, 1, s); | ||
183 | #else | 189 | #else |
184 | #ifdef HAVE_CHARGE_CTRL | 190 | #ifdef HAVE_CHARGE_CTRL |
185 | if (charger_enabled) | 191 | if (charger_enabled) |
186 | snprintf(s, sizeof(s), str(LANG_BATTERY_CHARGE)); | 192 | snprintf(s, sizeof(s), str(LANG_BATTERY_CHARGE)); |
187 | else | 193 | else |
194 | snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_RECORDER), | ||
195 | battery_level(), battery_level_safe() ? "" : " !!"); | ||
196 | #else | ||
188 | snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_RECORDER), | 197 | snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_RECORDER), |
189 | battery_level(), battery_level_safe() ? "" : " !!"); | 198 | battery_level(), battery_level_safe() ? "" : " !!"); |
190 | lcd_puts(0, 3, s); | ||
191 | #else | ||
192 | snprintf(s, sizeof(s), str(LANG_BATTERY_LEVEL_RECORDER), | ||
193 | battery_level(), battery_level_safe() ? "" : " !!"); | ||
194 | lcd_puts(0, 3, s); | ||
195 | #endif | 199 | #endif |
196 | #endif | 200 | #endif |
197 | 201 | lcd_puts(0, y++, s); | |
202 | } | ||
203 | |||
204 | if (state & 2) { | ||
205 | unsigned int size, free; | ||
206 | fat_size( &size, &free ); | ||
207 | |||
208 | size /= 1024; | ||
209 | integer = size / 1024; | ||
210 | decimal = size % 1024 / 100; | ||
211 | snprintf(s, sizeof s, str(LANG_DISK_STAT), integer, decimal); | ||
212 | lcd_puts(0, y++, s); | ||
213 | |||
214 | free /= 1024; | ||
215 | integer = free / 1024; | ||
216 | decimal = free % 1024 / 100; | ||
217 | snprintf(s, sizeof s, str(LANG_DISK_FREE_STAT), integer, decimal); | ||
218 | lcd_puts(0, y++, s); | ||
219 | } | ||
198 | lcd_update(); | 220 | lcd_update(); |
199 | 221 | ||
200 | /* Wait for a key to be pushed */ | 222 | /* Wait for a key to be pushed */ |
201 | key = button_get_w_tmo(HZ/2); | 223 | key = button_get_w_tmo(HZ*5); |
202 | if(key) { | 224 | switch(key) { |
203 | switch(state) { | 225 | #ifdef HAVE_PLAYER_KEYPAD |
204 | case 0: | 226 | case BUTTON_STOP | BUTTON_REL: |
205 | /* first, a non-release event */ | 227 | #else |
206 | if(!(key&BUTTON_REL)) | 228 | case BUTTON_LEFT | BUTTON_REL: |
207 | state++; | 229 | case BUTTON_OFF | BUTTON_REL: |
230 | #endif | ||
231 | done = true; | ||
208 | break; | 232 | break; |
209 | case 1: | 233 | |
210 | /* then a release-event */ | 234 | #ifdef HAVE_PLAYER_KEYPAD |
211 | if(key&BUTTON_REL) | 235 | case BUTTON_LEFT: |
212 | done = true; | 236 | case BUTTON_RIGHT: |
237 | if (state == 1) | ||
238 | state = 2; | ||
239 | else | ||
240 | state = 1; | ||
213 | break; | 241 | break; |
214 | } | 242 | #endif |
215 | } | 243 | } |
216 | } | 244 | } |
217 | 245 | ||
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) | |||
223 | return fat_bpb.startsector; | 223 | return fat_bpb.startsector; |
224 | } | 224 | } |
225 | 225 | ||
226 | void fat_size(unsigned int* size, unsigned int* free) | ||
227 | { | ||
228 | if (size) | ||
229 | *size = fat_bpb.dataclusters * fat_bpb.bpb_secperclus / 2; | ||
230 | if (free) | ||
231 | *free = fat_bpb.fsinfo.freecount * fat_bpb.bpb_secperclus / 2; | ||
232 | } | ||
233 | |||
226 | int fat_mount(int startsector) | 234 | int fat_mount(int startsector) |
227 | { | 235 | { |
228 | unsigned char buf[SECTOR_SIZE]; | 236 | 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 | |||
67 | 67 | ||
68 | 68 | ||
69 | extern int fat_mount(int startsector); | 69 | extern int fat_mount(int startsector); |
70 | extern void fat_size(unsigned int* size, unsigned int* free); | ||
70 | 71 | ||
71 | extern int fat_create_dir(unsigned int currdir, char *name); | 72 | extern int fat_create_dir(unsigned int currdir, char *name); |
72 | extern int fat_startsector(void); | 73 | 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 @@ | |||
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <string.h> | 22 | #include <string.h> |
23 | #include <sys/stat.h> | 23 | #include <sys/stat.h> |
24 | #include <sys/vfs.h> | ||
24 | #include <dirent.h> | 25 | #include <dirent.h> |
25 | 26 | ||
26 | #include <fcntl.h> | 27 | #include <fcntl.h> |
@@ -107,3 +108,23 @@ int x11_open(char *name, int opts) | |||
107 | } | 108 | } |
108 | return open(name, opts); | 109 | return open(name, opts); |
109 | } | 110 | } |
111 | |||
112 | void fat_size(unsigned int* size, unsigned int* free) | ||
113 | { | ||
114 | struct statfs fs; | ||
115 | |||
116 | if (!statfs(".", &fs)) { | ||
117 | DEBUGF("statfs: bsize=%d blocks=%d free=%d\n", | ||
118 | fs.f_bsize, fs.f_blocks, fs.f_bfree); | ||
119 | if (size) | ||
120 | *size = fs.f_blocks * (fs.f_bsize / 1024); | ||
121 | if (free) | ||
122 | *free = fs.f_bfree * (fs.f_bsize / 1024); | ||
123 | } | ||
124 | else { | ||
125 | if (size) | ||
126 | *size = 0; | ||
127 | if (free) | ||
128 | *free = 0; | ||
129 | } | ||
130 | } | ||