I have a code for a time bar for my mp3-player used on a QVGA color touch screen.
My problem is, when I do the calculation to determine how long I'm in the song, it wont give me any number but 0.
Every variable here is a unsigned long.
I have tested the code, and after I divide 'percent' with 'startsize' I get this bug.
I init the mmc with 'startsize' and transfer the number to 'filesize' afterwards.
Code: Select all
unsigned long percent;
percent = startsize-filesize;
percent *= 2; // Works fine, providing number larger than 0
percent = percent/(startsize/100); // does not work. Only result is zero, no matter for how long time the song is playing.
.....more code.....
And by the way, I have splitted my project in more files so filesize is in another file which is included in the main file. Shouldn't have any affect on the code.
Regards,
Simon H.A.