From ca7cdbd7bc061e11268f1193e2af39aff1cb819b Mon Sep 17 00:00:00 2001 From: jsz Date: Thu, 5 May 2011 16:08:21 +0200 Subject: [PATCH] tweaking the numbers --- Makefile | 2 +- config.go | 13 +++++++++---- main.go | 10 +++++++--- read.go => sensor.go | 0 4 files changed, 17 insertions(+), 8 deletions(-) rename read.go => sensor.go (100%) diff --git a/Makefile b/Makefile index 5cdf76c..1afb487 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include $(GOROOT)/src/Make.inc TARG=mbpfand GOFILES=\ config.go\ - read.go\ + sensor.go\ main.go include $(GOROOT)/src/Make.cmd diff --git a/config.go b/config.go index 137c8b7..2b028be 100644 --- a/config.go +++ b/config.go @@ -19,14 +19,19 @@ const ( ) const ( - g_min_temp = 40.0 //what we wish our temp would always be to set the fan to 0rpm - //chosing 40.0 here will make our fan spin @ 2000rpm @ 50.0C ... - g_min_fan_speed = 2000.0 ) +var g_max_fan_speed float64 = 6200.0 const ( g_job_fire_time = 10.0 //how often the DoWork() function shall be called. time in seconds ) -var g_max_fan_speed float64 = 6200.0 +type ModeType int32 + +const ( + mode_Default = iota + mode_Aggressive +) + +var g_opt_mode ModeType = mode_Default diff --git a/main.go b/main.go index 436babb..bd7b059 100644 --- a/main.go +++ b/main.go @@ -9,9 +9,13 @@ import ( var control_chan chan string = make(chan string) func calc_fan_speed(temp float64) float64 { - x := math.Log10(temp/g_min_temp)/math.Log10(2.0)*g_max_fan_speed - //clipping to min/max will be done by SetFanSpeed() - return x + switch (g_opt_mode) { + case mode_Default: + return math.Log10(temp/40.0) / 0.3 * g_max_fan_speed //quiet but not so cool + case mode_Aggressive: + return math.Log10(temp/30.0) / 0.35 * g_max_fan_speed //cooler but also louder + } + return g_min_fan_speed } //check temp, set speed diff --git a/read.go b/sensor.go similarity index 100% rename from read.go rename to sensor.go