Skip to content

Commit

Permalink
readme update, some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kybernetyk committed May 5, 2011
1 parent c9ecb52 commit c9f1c95
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
30 changes: 28 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
A simple fan speed control demon for Linux on an Apple Mac Book Pro.
A simple fan speed control demon for Linux + Apple Mac Book Pro (5,5).
License: GPL3
(C) Leon Szpilewski

My Macbook Pro 5,5 runs pretty hot til the fan on linux kicks in.
My Macbook Pro 5,5 runs pretty hot till the fan on linux kicks in.
This is an attempt to create a demon that will fix this behavior.

The fan speed formula is for now a simple logarithmic function and
seems a little too sensitive in the early mid ranges.

I'm planning to replace all that ugly math with a highly over-
engineered goal oriented system - but for now the math stuff
works pretty well ;)

Compatibility can only be ensured with MBP 5,5 13" models yet.
I heard rumors of the bigger MBPs (15/17") having more than one
fan built in. But as I don't have access to those models I can't
verify that. You are however welocome to fork the code and build
in support for your model.


How To Build
============

The demon is written in Go and requires the newest Go weekly.
Though the code isn't that complicated and it should work with any
newer Go version. To build the project just type:

> gomake

To run the demon (which isn't a demon yet):
> sudo ./mbpfand


11 changes: 10 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ package main
const (
g_sensors_base_dir = "/sys/devices/platform/applesmc.768/"

//temperature sensors
g_cpu_die_sensor = "temp5_input"

//fan control
g_fan_sensor = "fan1_input"
g_fan_max = "fan1_max"
g_fan_out = "fan1_min" //write to ths to set the fan RPM
)

const (
g_min_temp = 40.0 //what we wish our temp would always be in a world full of rainbow shitting unicorns
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
)

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
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func calc_fan_speed(temp float64) float64 {
return x
}

//check temp, set speed
func DoWork() {
f := GetAverageTemp()
fmt.Println("Average temperature:", f)
Expand All @@ -26,6 +27,7 @@ func DoWork() {
SetFanSpeed(rpm)
}

//turns seconds into nanoseconds ... for all the folks who hate zeros
func seconds(n int64) int64 {
return 1000000000 * n
}
Expand All @@ -34,7 +36,7 @@ func main() {
g_max_fan_speed = readSensor(g_fan_max)
fmt.Println("Max Fan Speed for this system:", g_max_fan_speed)

ticker := time.NewTicker(seconds(10))
ticker := time.NewTicker(seconds(g_job_fire_time))
L:
for {
select {
Expand All @@ -43,7 +45,7 @@ L:
break L
}
case <-ticker.C:
go DoWork()
DoWork()
}
}
}

0 comments on commit c9f1c95

Please sign in to comment.