Commit d2e14c38861a7a69a64ce769daa1b4914201da6e

Kano 2013-12-23T08:57:01

drillbit fix temp display to fit in standard space

diff --git a/driver-drillbit.c b/driver-drillbit.c
index 8050e6a..9345946 100644
--- a/driver-drillbit.c
+++ b/driver-drillbit.c
@@ -426,15 +426,27 @@ static void drillbit_updatetemps(struct thr_info *thr)
 static void drillbit_get_statline_before(char *buf, size_t bufsiz, struct cgpu_info *drillbit)
 {
 	struct drillbit_info *info = drillbit->device_data;
-
-	tailsprintf(buf, bufsiz, "%c%-2d", info->product[0], info->num_chips);
-
-	if ((info->capabilities & CAP_TEMP) && info->temp != 0) {
-		tailsprintf(buf, bufsiz, " %d.%dC (%d.%dC)", info->temp/10, info->temp%10,
-			    info->max_temp/10, info->max_temp%10);
+	int temp, max_temp, space = 0;
+
+	temp = (int)(info->temp);
+
+	tailsprintf(buf, bufsiz, "%c%d", info->product[0], info->num_chips);
+	if (info->num_chips < 10)
+		space++;
+
+	if ((info->capabilities & CAP_TEMP) && temp != 0) {
+		if (temp > 999) // Fixed display space
+			temp = 999;
+		max_temp = (int)(info->max_temp);
+		if (max_temp > 999) // Fixed display space
+			max_temp = 999;
+		if (max_temp < 100)
+			space++;
+		tailsprintf(buf, bufsiz, " %2d max%d.%d%*s",
+					 temp / 10, max_temp / 10, max_temp % 10, space, "");
 	} else {
 		// Space out to the same width as if there was a temp field in place
-		tailsprintf(buf, bufsiz, "		  ");
+		tailsprintf(buf, bufsiz, "           %*s", space, "");
 	}
 
 	tailsprintf(buf, bufsiz, " | ");