Skip to content

Commit 1921c95

Browse files
give the "percent" meter a bit more precision.
1 parent af6a24b commit 1921c95

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

media/dosamp/dosamp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ static unsigned long display_time_wait_next = 0;
20252025
void display_idle_time(void) {
20262026
unsigned long w,f;
20272027
unsigned char hour,min,sec,centisec;
2028-
unsigned char percent;
2028+
unsigned short percent;
20292029

20302030
/* display time, but not too often. keep the rate limited. */
20312031
time_source->poll(time_source);
@@ -2057,20 +2057,20 @@ void display_idle_time(void) {
20572057
d = wav_data_length;
20582058

20592059
/* it's a percentage from 0 to 99, we don't need high precision for large files */
2060-
while ((m|d) >= 0x100000UL) {
2060+
while ((m|d) >= 0x10000UL) {
20612061
m >>= 4UL;
20622062
d >>= 4UL;
20632063
}
20642064

20652065
/* we don't want divide by zero */
20662066
if (d == 0UL) d = 1UL;
20672067

2068-
percent = (unsigned char)((m * 100UL) / d);
2068+
percent = (unsigned short)((m * 1000UL) / d);
20692069
}
20702070

20712071
printf("\x0D");
2072-
printf("%02u:%02u:%02u.%02u %%%02u %lu/%lu as %lu-Hz %u-ch %u-bit ",
2073-
hour,min,sec,centisec,percent,wav_play_position,wav_data_length,
2072+
printf("%02u:%02u:%02u.%02u %%%02u.%u %lu/%lu as %lu-Hz %u-ch %u-bit ",
2073+
hour,min,sec,centisec,percent/10U,percent%10U,wav_play_position,wav_data_length,
20742074
(unsigned long)play_codec.sample_rate,
20752075
(unsigned int)play_codec.number_of_channels,
20762076
(unsigned int)play_codec.bits_per_sample);

0 commit comments

Comments
 (0)