55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package pressure
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/go-flucky/flucky/pkg/types"
|
|
|
|
"github.com/go-flucky/flucky/pkg/cli"
|
|
"github.com/go-flucky/flucky/pkg/config"
|
|
"github.com/go-flucky/flucky/pkg/logfile"
|
|
"github.com/go-flucky/flucky/pkg/rgbled"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var listTemperatureCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: "print air pressures",
|
|
Example: fmt.Sprintf("flucky pressure logs"),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
// read configuration
|
|
cnf, err := config.Read(configFile)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
logfile := logfile.New(cnf.Device.Logfile)
|
|
|
|
rgbLEDs := cnf.GetRGBLEDs(config.ENABLED)
|
|
if err := rgbled.Logfile(rgbLEDs); err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
measuredValues, err := logfile.Read()
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
if err := rgbled.Off(rgbLEDs); err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
measuredValues = types.SelectMeasuredValues(types.MeasuredValueTypePressure, measuredValues)
|
|
|
|
cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout)
|
|
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
pressureCmd.AddCommand(listTemperatureCmd)
|
|
}
|