diff --git a/apps/wps.c b/apps/wps.c index 031c20b9f7..a4d7292c64 100644 --- a/apps/wps.c +++ b/apps/wps.c @@ -95,11 +95,6 @@ static void draw_screen(struct mp3entry* id3) lcd_puts(0, l++, id3->album?id3->album:""); lcd_puts(0, l++, id3->artist?id3->artist:""); - snprintf(buffer,sizeof(buffer), "Time: %d:%02d", - id3->length / 60000, - id3->length % 60000 / 1000 ); - lcd_puts(0, l++, buffer); - snprintf(buffer,sizeof(buffer), "%d kbits", id3->bitrate); lcd_puts(0, l++, buffer); @@ -124,6 +119,7 @@ void wps_show(void) struct mp3entry* id3 = mpeg_current_track(); int lastlength=0, lastsize=0, lastrate=0; int lastartist=0, lastalbum=0, lasttitle=0; + char buffer[32]; while ( 1 ) { int i; @@ -144,7 +140,17 @@ void wps_show(void) lasttitle = id3->title[0]; } - for ( i=0;i<20;i++ ) { +#ifdef HAVE_LCD_BITMAP + snprintf(buffer,sizeof(buffer), "Time: %d:%02d / %d:%02d", + id3->elapsed / 60000, + id3->elapsed % 60000 / 1000, + id3->length / 60000, + id3->length % 60000 / 1000 ); + lcd_puts(0, 6, buffer); + lcd_update(); +#endif + + for ( i=0;i<5;i++ ) { switch ( button_get(false) ) { case BUTTON_ON: return; @@ -194,7 +200,7 @@ void wps_show(void) mpeg_stop(); break; } - sleep(HZ/20); + sleep(HZ/10); } } } diff --git a/firmware/id3.h b/firmware/id3.h index 4729d5355f..1f8aef6310 100644 --- a/firmware/id3.h +++ b/firmware/id3.h @@ -33,6 +33,7 @@ struct mp3entry { int id3v1len; int filesize; /* in bytes */ int length; /* song length */ + int elapsed; /* ms played */ /* these following two fields are used for local buffering */ char id3v2buf[300]; diff --git a/firmware/mpeg.c b/firmware/mpeg.c index d130a8b572..ab99fa744c 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -150,6 +150,7 @@ static struct { int mempos; } id3tags[MAX_ID3_TAGS]; static int last_tag = 0; +static int last_dma_tick = 0; static void create_fliptable(void) { @@ -228,6 +229,8 @@ static void dma_tick(void) start_dma(); } } + id3tags[0].id3.elapsed += (current_tick - last_dma_tick) * 1000 / HZ; + last_dma_tick = current_tick; } static void bitswap(unsigned short *data, int length) @@ -387,6 +390,7 @@ static void mpeg_thread(void) mp3info(&(id3tags[0].id3), ev.data); id3tags[0].mempos = mp3buf_write; last_tag=1; + id3tags[0].id3.elapsed = 0; /* Make it read more data */ filling = true;