diff options
-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 9cb9e9601f..1aa21b72f5 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -617,7 +617,10 @@ static char* get_tag(struct mp3entry* cid3, | |||
617 | return buf; | 617 | return buf; |
618 | 618 | ||
619 | case 'c': /* File Codec */ | 619 | case 'c': /* File Codec */ |
620 | *intval = id3->codectype; | 620 | if(id3->codectype == AFMT_UNKNOWN) |
621 | *intval = AFMT_NUM_CODECS; | ||
622 | else | ||
623 | *intval = id3->codectype; | ||
621 | return id3_get_codec(id3); | 624 | return id3_get_codec(id3); |
622 | } | 625 | } |
623 | break; | 626 | break; |
@@ -697,6 +700,7 @@ static char* get_tag(struct mp3entry* cid3, | |||
697 | case 'v': /* volume */ | 700 | case 'v': /* volume */ |
698 | *flags |= WPS_REFRESH_DYNAMIC; | 701 | *flags |= WPS_REFRESH_DYNAMIC; |
699 | snprintf(buf, buf_size, "%d%%", global_settings.volume); | 702 | snprintf(buf, buf_size, "%d%%", global_settings.volume); |
703 | *intval = global_settings.volume / 10 + 1; | ||
700 | return buf; | 704 | return buf; |
701 | 705 | ||
702 | } | 706 | } |
@@ -752,9 +756,15 @@ static char* get_tag(struct mp3entry* cid3, | |||
752 | { | 756 | { |
753 | int l = battery_level(); | 757 | int l = battery_level(); |
754 | if (l > -1) | 758 | if (l > -1) |
759 | { | ||
755 | snprintf(buf, buf_size, "%d%%", l); | 760 | snprintf(buf, buf_size, "%d%%", l); |
761 | *intval = l / 20 + 1; | ||
762 | } | ||
756 | else | 763 | else |
764 | { | ||
765 | *intval = 6; | ||
757 | return "?%"; | 766 | return "?%"; |
767 | } | ||
758 | return buf; | 768 | return buf; |
759 | } | 769 | } |
760 | 770 | ||
@@ -857,6 +867,7 @@ static const char* skip_conditional(const char* fmt, int num) | |||
857 | { | 867 | { |
858 | int level = 1; | 868 | int level = 1; |
859 | int count = num; | 869 | int count = num; |
870 | const char *last_alternative = NULL; | ||
860 | 871 | ||
861 | while (*fmt) | 872 | while (*fmt) |
862 | { | 873 | { |
@@ -867,6 +878,7 @@ static const char* skip_conditional(const char* fmt, int num) | |||
867 | 878 | ||
868 | case '|': | 879 | case '|': |
869 | if(1 == level) { | 880 | if(1 == level) { |
881 | last_alternative = fmt; | ||
870 | if(num) { | 882 | if(num) { |
871 | count--; | 883 | count--; |
872 | if(count == 0) | 884 | if(count == 0) |
@@ -879,10 +891,18 @@ static const char* skip_conditional(const char* fmt, int num) | |||
879 | case '>': | 891 | case '>': |
880 | if (0 == --level) | 892 | if (0 == --level) |
881 | { | 893 | { |
882 | if (num) | 894 | /* We're just skipping to the end */ |
883 | fmt--; | 895 | if(num == 0) |
884 | 896 | return fmt; | |
885 | return fmt; | 897 | |
898 | /* If we are parsing an enum, we'll return the selected | ||
899 | item. If there weren't enough items in the enum, we'll | ||
900 | return the last one found. */ | ||
901 | if(count && last_alternative) | ||
902 | { | ||
903 | return last_alternative; | ||
904 | } | ||
905 | return fmt - 1; | ||
886 | } | 906 | } |
887 | continue; | 907 | continue; |
888 | 908 | ||
@@ -1069,9 +1089,10 @@ static void format_display(char* buf, | |||
1069 | if ('<' == *fmt) | 1089 | if ('<' == *fmt) |
1070 | fmt++; | 1090 | fmt++; |
1071 | 1091 | ||
1072 | /* No value, so skip to else part */ | 1092 | /* No value, so skip to else part, using a sufficiently high |
1093 | value to "hit" the last part of the conditional */ | ||
1073 | if ((!value) || (!strlen(value))) | 1094 | if ((!value) || (!strlen(value))) |
1074 | fmt = skip_conditional(fmt, 1); | 1095 | fmt = skip_conditional(fmt, 1000); |
1075 | else | 1096 | else |
1076 | if(intval > 1) /* enum */ | 1097 | if(intval > 1) /* enum */ |
1077 | fmt = skip_conditional(fmt, intval - 1); | 1098 | fmt = skip_conditional(fmt, intval - 1); |
diff --git a/firmware/export/id3.h b/firmware/export/id3.h index d407b7b7cf..6c6507159a 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h | |||
@@ -40,6 +40,8 @@ enum { | |||
40 | AFMT_WAVPACK, /* WavPack */ | 40 | AFMT_WAVPACK, /* WavPack */ |
41 | 41 | ||
42 | /* New formats must be added to the end of this list */ | 42 | /* New formats must be added to the end of this list */ |
43 | |||
44 | AFMT_NUM_CODECS | ||
43 | }; | 45 | }; |
44 | 46 | ||
45 | struct mp3entry { | 47 | struct mp3entry { |