Skip to content

Commit f65ff1b

Browse files
authored
Merge pull request #487 from 0xIO32/fix_initial_delay
Reduce startup delay
2 parents 927e173 + eb94a5e commit f65ff1b

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

internal/controller/controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (f *DefaultFanController) Run(ctx context.Context) error {
209209

210210
ui.Info("Gathering sensor data for %s...", fan.GetId())
211211
// wait a bit to gather monitoring data
212-
time.Sleep(2*time.Second + configuration.CurrentConfig.TempSensorPollingRate*2)
212+
time.Sleep(2*time.Second + configuration.CurrentConfig.TempSensorPollingRate)
213213

214214
fanPwmData, err := f.runInitializationIfNeeded()
215215
if err != nil {
@@ -289,6 +289,14 @@ func (f *DefaultFanController) Run(ctx context.Context) error {
289289
time.Sleep(1 * time.Second)
290290
tick := time.NewTicker(f.updateRate)
291291
defer tick.Stop()
292+
293+
err = f.UpdateFanSpeed()
294+
if err != nil {
295+
ui.ErrorAndNotify("Fan Control Error", "Fan %s: %v", fan.GetId(), err)
296+
f.restoreControlMode()
297+
return nil
298+
}
299+
292300
for {
293301
select {
294302
case <-controllerCtx.Done():

internal/monitor.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package internal
22

33
import (
44
"context"
5+
"time"
6+
57
"github.com/markusressel/fan2go/internal/configuration"
68
"github.com/markusressel/fan2go/internal/sensors"
79
"github.com/markusressel/fan2go/internal/ui"
810
"github.com/markusressel/fan2go/internal/util"
9-
"time"
1011
)
1112

1213
type SensorMonitor interface {
@@ -27,6 +28,12 @@ func NewSensorMonitor(sensor sensors.Sensor, pollingRate time.Duration) SensorMo
2728

2829
func (s sensorMonitor) Run(ctx context.Context) error {
2930
tick := time.NewTicker(s.pollingRate)
31+
32+
err := updateSensor(s.sensor)
33+
if err != nil {
34+
ui.Warning("Error updating sensor: %v", err)
35+
}
36+
3037
for {
3138
select {
3239
case <-ctx.Done():

0 commit comments

Comments
 (0)