Commit 12a167a3f142c93db8e17152e3df673a24c86ec7

Con Kolivas 2011-09-04T13:57:40

Implement menus to change temperature limits.

diff --git a/adl.c b/adl.c
index 997a2c0..9792f3c 100644
--- a/adl.c
+++ b/adl.c
@@ -720,10 +720,12 @@ void change_autosettings(int gpu)
 {
 	struct gpu_adl *ga = &gpus[gpu].adl;
 	char input;
+	int val;
 
 	wlogprint("Target temperature: %d\n", ga->targettemp);
 	wlogprint("Overheat temperature: %d\n", ga->overtemp);
-	wlogprint("Toggle [F]an auto [G]PU auto, change [T]arget [O]verheat\n");
+	wlogprint("Hysteresis differece: %d\n", opt_hysteresis);
+	wlogprint("Toggle [F]an auto [G]PU auto\nChange [T]arget [O]verheat [H]ysteresis\n");
 	wlogprint("Or press any other key to continue\n");
 	input = getch();
 	if (!strncasecmp(&input, "f", 1)) {
@@ -740,6 +742,25 @@ void change_autosettings(int gpu)
 			wlogprint("Resetting GPU engine clock to startup settings\n");
 			set_defaultengine(gpu);
 		}
+	} else if (!strncasecmp(&input, "t", 1)) {
+		val = curses_int("Enter target temperature for this GPU in °C (0-100)");
+		if (val < 0 || val > 100)
+			wlogprint("Invalid temperature");
+		else
+			ga->targettemp = val;
+	} else if (!strncasecmp(&input, "o", 1)) {
+		wlogprint("Enter oveheat temperature for this GPU in °C (%d-100)", ga->targettemp);
+		val = curses_int("");
+		if (val <= ga->targettemp || val > 100)
+			wlogprint("Invalid temperature");
+		else
+			ga->overtemp = val;
+	} else if (!strncasecmp(&input, "h", 1)) {
+		val = curses_int("Enter hysteresis temperature difference (0-10)");
+		if (val < 1 || val > 10)
+			wlogprint("Invalid value");
+		else
+			opt_hysteresis = val;
 	}
 }
 
diff --git a/main.c b/main.c
index ef8e664..df145b7 100644
--- a/main.c
+++ b/main.c
@@ -1253,7 +1253,7 @@ static struct opt_table opt_config_table[] = {
 #endif
 #ifdef HAVE_ADL
 	OPT_WITH_ARG("--temp-hysteresis",
-		     set_int_0_to_10, opt_show_intval, &opt_hysteresis,
+		     set_int_1_to_10, opt_show_intval, &opt_hysteresis,
 		     "Set how much the temperature can fluctuate outside limits when automanaging speeds"),
 	OPT_WITH_ARG("--temp-overheat",
 		     set_int_0_to_100, opt_show_intval, &opt_overheattemp,