From 8f10cbfac5489c1be3bb456f88ab419e2da24458 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Sat, 31 May 2014 20:14:08 +0800 Subject: [PATCH] Total uptime length Conflicts: sgminer.c --- sgminer.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sgminer.c b/sgminer.c index f3eee709..6dc63065 100644 --- a/sgminer.c +++ b/sgminer.c @@ -2361,6 +2361,30 @@ static bool shared_strategy(void) wprintw(win, "%s", tmp42); \ } while (0) +/* Must be called with curses mutex lock held and curses_active */ +static void curses_print_uptime(void) +{ + struct timeval now, tv; + unsigned int days, hours; + div_t d; + + cgtime(&now); + timersub(&now, &total_tv_start, &tv); + d = div(tv.tv_sec, 86400); + days = d.quot; + d = div(d.rem, 3600); + hours = d.quot; + d = div(d.rem, 60); + cg_wprintw(statuswin, " - [%u day%c %02d:%02d:%02d]" + , days + , (days == 1) ? ' ' : 's' + , hours + , d.quot + , d.rem + ); +} + + /* Must be called with curses mutex lock held and curses_active */ static void curses_print_status(void) { @@ -2369,6 +2393,7 @@ static void curses_print_status(void) wattron(statuswin, A_BOLD); cg_mvwprintw(statuswin, line, 0, PACKAGE " " VERSION " - Started: %s", datestamp); + curses_print_uptime(); wattroff(statuswin, A_BOLD); mvwhline(statuswin, ++line, 0, '-', 80);