Skip to content

Commit

Permalink
add build/debug target for fancontrol, fix fancontrol if stratux.conf…
Browse files Browse the repository at this point in the history
… doesn't exist yet on first boot
  • Loading branch information
b3nn0 committed Nov 20, 2021
1 parent 75c473c commit 3d07b46
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
//"args": ["-log_dir", "/tmp/", "-logtostderr", "-replay", "-uatlog", "test-data/cyoung-09062015-noproblem-stratux-uat.log"],
"preLaunchTask": "Build",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Launch Fancontrol",
"type": "go",
"request": "launch",
"mode": "exec",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/fancontrol",
"env": {"CGO_CFLAGS_ALLOW": "-L${workspaceRoot}"},
//"args": ["-log_dir", "/tmp/", "-logtostderr", "-replay", "-uatlog", "test-data/cyoung-09062015-noproblem-stratux-uat.log"],
"preLaunchTask": "Build Fancontrol",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
10 changes: 10 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
"kind": "build",
"isDefault": true
}
},
{
"label": "Build Fancontrol",
"type": "shell",
"command": "make fancontrol debug=true",
"problemMatcher": "$go",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
11 changes: 6 additions & 5 deletions fancontrol_main/fancontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ func (service *Service) Manage() (string, error) {
}

func readSettings() {
myFanControl.PWMDutyMin = defaultPwmDutyMin
myFanControl.TempTarget = defaultTempTarget
myFanControl.PWMFrequency = defaultPwmFrequency
myFanControl.PWMPin = defaultPin
myFanControl.PWMDuty80PStartDelay = PWMDuty80PStartDelay

fd, err := os.Open(configLocation)
if err != nil {
log.Printf("can't read settings %s: %s\n", configLocation, err.Error())
Expand All @@ -325,11 +331,6 @@ func readSettings() {
return
}

myFanControl.PWMDutyMin = defaultPwmDutyMin
myFanControl.TempTarget = defaultTempTarget
myFanControl.PWMFrequency = defaultPwmFrequency
myFanControl.PWMPin = defaultPin

err = json.Unmarshal(buf[0:count], &myFanControl)
if err != nil {
log.Printf("can't read settings %s: %s\n", configLocation, err.Error())
Expand Down

0 comments on commit 3d07b46

Please sign in to comment.