fix(pkg/daemon): turn on/off info lights
This commit is contained in:
parent
3436d6c91f
commit
13fcb9776d
@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-flucky/flucky/pkg/config"
|
"github.com/go-flucky/flucky/pkg/config"
|
||||||
"github.com/go-flucky/flucky/pkg/logfile"
|
"github.com/go-flucky/flucky/pkg/logfile"
|
||||||
|
"github.com/go-flucky/flucky/pkg/rgbled"
|
||||||
"github.com/go-flucky/flucky/pkg/sensor"
|
"github.com/go-flucky/flucky/pkg/sensor"
|
||||||
"github.com/go-flucky/flucky/pkg/types"
|
"github.com/go-flucky/flucky/pkg/types"
|
||||||
)
|
)
|
||||||
@ -29,20 +30,36 @@ func Start(cnf *config.Configuration, compression bool) error {
|
|||||||
|
|
||||||
temperatures := make([]*types.Temperature, 0)
|
temperatures := make([]*types.Temperature, 0)
|
||||||
|
|
||||||
ticker := time.Tick(time.Second * 60)
|
ticker := time.Tick(time.Second * 300)
|
||||||
|
|
||||||
|
rgbLEDs := cnf.GetRGBLEDs(config.ENABLED)
|
||||||
|
err := rgbled.Green(rgbLEDs)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Can not turn on blue info light: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker:
|
case <-ticker:
|
||||||
|
err := rgbled.Blue(rgbLEDs)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Can not turn on yellow info light: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("Write measured values into logfile")
|
log.Printf("Write measured values into logfile")
|
||||||
|
|
||||||
log.Printf("%v new measured temperature values", len(temperatures))
|
log.Printf("%v new measured temperature values", len(temperatures))
|
||||||
err := logfile.WriteTemperatures(temperatures, cnf.Device.TemperatureLogfile, compression)
|
err = logfile.WriteTemperatures(temperatures, cnf.Device.TemperatureLogfile, compression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Can not save temperatures: %v", err)
|
return fmt.Errorf("Can not save temperatures: %v", err)
|
||||||
}
|
}
|
||||||
temperatures = make([]*types.Temperature, 0)
|
temperatures = make([]*types.Temperature, 0)
|
||||||
|
|
||||||
|
err = rgbled.Green(rgbLEDs)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Can not turn on green info light: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
case temperature, more := <-temperatureChannel:
|
case temperature, more := <-temperatureChannel:
|
||||||
if more {
|
if more {
|
||||||
temperatures = append(temperatures, temperature)
|
temperatures = append(temperatures, temperature)
|
||||||
@ -55,6 +72,11 @@ func Start(cnf *config.Configuration, compression bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case killSignal := <-interrupt:
|
case killSignal := <-interrupt:
|
||||||
|
err := rgbled.Red(rgbLEDs)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Can not turn on info light: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
//close(humidityChannel)
|
//close(humidityChannel)
|
||||||
close(temperatureChannel)
|
close(temperatureChannel)
|
||||||
return fmt.Errorf("Daemon was interruped by system signal %v", killSignal)
|
return fmt.Errorf("Daemon was interruped by system signal %v", killSignal)
|
||||||
|
Loading…
Reference in New Issue
Block a user