Browse Source

Colour bad conditions in red

Luke Dashjr 12 years ago
parent
commit
34ffd0a539
1 changed files with 32 additions and 5 deletions
  1. 32 5
      miner.c

+ 32 - 5
miner.c

@@ -2725,7 +2725,7 @@ void get_statline3(char *buf, struct cgpu_info *cgpu, bool for_curses, bool opt_
 #ifdef HAVE_CURSES
 #ifdef HAVE_CURSES
 	if (for_curses)
 	if (for_curses)
 	{
 	{
-		const char *cHrStatsOpt[] = {"DEAD ", "SICK ", "OFF  ", "REST ", " ERR ", "WAIT ", cHr};
+		const char *cHrStatsOpt[] = {"\2DEAD \1", "\2SICK \1", "OFF  ", "\2REST \1", " \2ERR \1", "\2WAIT \1", cHr};
 		int cHrStatsI = (sizeof(cHrStatsOpt) / sizeof(*cHrStatsOpt)) - 1;
 		int cHrStatsI = (sizeof(cHrStatsOpt) / sizeof(*cHrStatsOpt)) - 1;
 		bool all_dead = true, all_off = true;
 		bool all_dead = true, all_off = true;
 		for (struct cgpu_info *proc = cgpu; proc; proc = proc->next_proc)
 		for (struct cgpu_info *proc = cgpu; proc; proc = proc->next_proc)
@@ -2803,6 +2803,8 @@ static void text_print_status(int thr_id)
 }
 }
 
 
 #ifdef HAVE_CURSES
 #ifdef HAVE_CURSES
+static int attr_bad = A_BOLD;
+
 #ifdef USE_UNICODE
 #ifdef USE_UNICODE
 static
 static
 void bfg_waddstr(WINDOW *win, const char *s)
 void bfg_waddstr(WINDOW *win, const char *s)
@@ -2825,6 +2827,14 @@ next:
 			default:
 			default:
 				++p;
 				++p;
 				goto next;
 				goto next;
+			case '\1':
+				PREP_ADDCH;
+				wattroff(win, attr_bad);
+				goto next;
+			case '\2':
+				PREP_ADDCH;
+				wattron(win, attr_bad);
+				goto next;
 			case '|':
 			case '|':
 				PREP_ADDCH;
 				PREP_ADDCH;
 				wadd_wch(win, WACS_VLINE);
 				wadd_wch(win, WACS_VLINE);
@@ -6638,6 +6648,7 @@ static void hashmeter(int thr_id, struct timeval *diff,
 		struct cgpu_info *proc;
 		struct cgpu_info *proc;
 		int i, working_devs = 0, working_procs = 0;
 		int i, working_devs = 0, working_procs = 0;
 		int divx;
 		int divx;
+		bool bad = false;
 		
 		
 		// Find the highest temperature of all processors
 		// Find the highest temperature of all processors
 		for (i = 0; i < total_devices; ++i)
 		for (i = 0; i < total_devices; ++i)
@@ -6647,26 +6658,38 @@ static void hashmeter(int thr_id, struct timeval *diff,
 			if (proc->temp > temp)
 			if (proc->temp > temp)
 				temp = proc->temp;
 				temp = proc->temp;
 			
 			
-			if (likely(proc->status == LIFE_WELL && proc->deven == DEV_ENABLED && proc->rolling > .1))
+			if (unlikely(proc->deven == DEV_DISABLED || proc->rolling < .1))
+				;  // Just need to block it off from both conditions
+			else
+			if (likely(proc->status == LIFE_WELL && proc->deven == DEV_ENABLED))
 			{
 			{
 				++working_procs;
 				++working_procs;
 				if (proc->device == proc)
 				if (proc->device == proc)
 					++working_devs;
 					++working_devs;
 			}
 			}
+			else
+				bad = true;
 		}
 		}
 		
 		
 		if (working_devs == working_procs)
 		if (working_devs == working_procs)
-			sprintf(statusline, "%d        ", working_devs);
+			sprintf(statusline, "%s%d        ", bad ? "\2" : "", working_devs);
 		else
 		else
-			sprintf(statusline, "%d/%d     ", working_devs, working_procs);
+			sprintf(statusline, "%s%d/%d     ", bad ? "\2" : "", working_devs, working_procs);
 		
 		
 		divx = 7;
 		divx = 7;
 		if (opt_show_procs && !opt_compact)
 		if (opt_show_procs && !opt_compact)
 			++divx;
 			++divx;
 		
 		
+		if (bad)
+		{
+			++divx;
+			statusline[divx] = '\1';
+			++divx;
+		}
+		
 		temperature_column_tail(&statusline[divx], true, &temp);
 		temperature_column_tail(&statusline[divx], true, &temp);
 		
 		
-		format_statline(&statusline[15],
+		format_statline(statusline,
 		                cHr, aHr,
 		                cHr, aHr,
 		                uHr,
 		                uHr,
 		                total_accepted,
 		                total_accepted,
@@ -9066,7 +9089,11 @@ void enable_curses(void) {
 	mainwin = initscr();
 	mainwin = initscr();
 	start_color();
 	start_color();
 	if (has_colors() && ERR != init_pair(1, COLOR_WHITE, COLOR_BLUE))
 	if (has_colors() && ERR != init_pair(1, COLOR_WHITE, COLOR_BLUE))
+	{
 		menu_attr = COLOR_PAIR(1);
 		menu_attr = COLOR_PAIR(1);
+		if (ERR != init_pair(2, COLOR_RED, COLOR_BLACK))
+			attr_bad |= COLOR_PAIR(2);
+	}
 	keypad(mainwin, true);
 	keypad(mainwin, true);
 	getmaxyx(mainwin, y, x);
 	getmaxyx(mainwin, y, x);
 	statuswin = newwin(logstart, x, 0, 0);
 	statuswin = newwin(logstart, x, 0, 0);