gregorg / KISS_OSD

Kiss OSD open-sourced from Felix code
5 stars 2 forks source link

Timer doesn't display properly >65s and incorrectly counts 0m60s #6

Closed ikura closed 8 years ago

ikura commented 8 years ago

Using a uint16_t for time (in milliseconds) you overflow at 65.535s. And you need to compare seconds >= 60 instead of > 60. I corrected the code in two places (sorry for copy & paste, not easy to push a change right now) as per below.

static unsigned long start_time = 0;
static unsigned long time = 0;
static unsigned long total_time = 0;
void print_time(unsigned long time, char *time_str) {
    uint16_t seconds = time / 1000;
    uint8_t mills = time % 1000;
    uint8_t minutes = seconds / 60;
    if (seconds >= 60) {
gregorg commented 8 years ago

Thank you ikura ! I've applied your patch.