diff options
| author | Linus Nielsen Feltzing <linus@haxx.se> | 2005-09-06 13:43:26 +0000 |
|---|---|---|
| committer | Linus Nielsen Feltzing <linus@haxx.se> | 2005-09-06 13:43:26 +0000 |
| commit | ff73f0dcbf49ddac923a1eae9b8e0e2d34c613a8 (patch) | |
| tree | 6ed4830f2134137d31b263a86c4c9891c76bec48 | |
| parent | fbaf503d0d5506d4b4867e3b9bd468bb1bae381b (diff) | |
| download | rockbox-ff73f0dcbf49ddac923a1eae9b8e0e2d34c613a8.zip rockbox-ff73f0dcbf49ddac923a1eae9b8e0e2d34c613a8.tar.gz rockbox-ff73f0dcbf49ddac923a1eae9b8e0e2d34c613a8.tar.bz2 rockbox-ff73f0dcbf49ddac923a1eae9b8e0e2d34c613a8.tar.xz | |
Changed WPS enum conditional functionality, displaying the last part in the list if the tag has no value. Also added enum support for battery (5 steps) and volume (10 steps).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7476 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/wps-display.c | 35 | ||||
| -rw-r--r-- | firmware/export/id3.h | 2 |
2 files changed, 30 insertions, 7 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index 9cb9e96..1aa21b7 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c @@ -617,7 +617,10 @@ static char* get_tag(struct mp3entry* cid3, return buf; case 'c': /* File Codec */ - *intval = id3->codectype; + if(id3->codectype == AFMT_UNKNOWN) + *intval = AFMT_NUM_CODECS; + else + *intval = id3->codectype; return id3_get_codec(id3); } break; @@ -697,6 +700,7 @@ static char* get_tag(struct mp3entry* cid3, case 'v': /* volume */ *flags |= WPS_REFRESH_DYNAMIC; snprintf(buf, buf_size, "%d%%", global_settings.volume); + *intval = global_settings.volume / 10 + 1; return buf; } @@ -752,9 +756,15 @@ static char* get_tag(struct mp3entry* cid3, { int l = battery_level(); if (l > -1) + { snprintf(buf, buf_size, "%d%%", l); + *intval = l / 20 + 1; + } else + { + *intval = 6; return "?%"; + } return buf; } @@ -857,6 +867,7 @@ static const char* skip_conditional(const char* fmt, int num) { int level = 1; int count = num; + const char *last_alternative = NULL; while (*fmt) { @@ -867,6 +878,7 @@ static const char* skip_conditional(const char* fmt, int num) case '|': if(1 == level) { + last_alternative = fmt; if(num) { count--; if(count == 0) @@ -879,10 +891,18 @@ static const char* skip_conditional(const char* fmt, int num) case '>': if (0 == --level) { - if (num) - fmt--; - - return fmt; + /* We're just skipping to the end */ + if(num == 0) + return fmt; + + /* If we are parsing an enum, we'll return the selected + item. If there weren't enough items in the enum, we'll + return the last one found. */ + if(count && last_alternative) + { + return last_alternative; + } + return fmt - 1; } continue; @@ -1069,9 +1089,10 @@ static void format_display(char* buf, if ('<' == *fmt) fmt++; - /* No value, so skip to else part */ + /* No value, so skip to else part, using a sufficiently high + value to "hit" the last part of the conditional */ if ((!value) || (!strlen(value))) - fmt = skip_conditional(fmt, 1); + fmt = skip_conditional(fmt, 1000); else if(intval > 1) /* enum */ fmt = skip_conditional(fmt, intval - 1); diff --git a/firmware/export/id3.h b/firmware/export/id3.h index d407b7b..6c65071 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h @@ -40,6 +40,8 @@ enum { AFMT_WAVPACK, /* WavPack */ /* New formats must be added to the end of this list */ + + AFMT_NUM_CODECS }; struct mp3entry { |