fix(pkg/rgbled): use action maps to turn on/off led colors

This commit is contained in:
2019-06-24 22:57:29 +02:00
parent 02fa0cc931
commit c8a1dd2935
9 changed files with 284 additions and 157 deletions

View File

@ -184,10 +184,16 @@ func PrintRGBLEDs(cnf *config.Configuration, w io.Writer) {
tw := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0)
// headline
fmt.Fprintln(tw, "name\tlocation\tblue\tgreen\tred\tenabled")
fmt.Fprintln(tw, "name\tlocation\tblue\tgreen\tred\tenabled\taction")
for _, rgbled := range cnf.RGBLEDs {
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%v\t%v\n", rgbled.RGBLEDName, rgbled.RGBLEDLocation, *rgbled.BaseColorsToGPIO[types.BaseColorBlue], *rgbled.BaseColorsToGPIO[types.BaseColorGreen], *rgbled.BaseColorsToGPIO[types.BaseColorRed], rgbled.RGBLEDEnabled)
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%v\t%v\t", rgbled.RGBLEDName, rgbled.RGBLEDLocation, *rgbled.BaseColorsToGPIO[types.BaseColorBlue], *rgbled.BaseColorsToGPIO[types.BaseColorGreen], *rgbled.BaseColorsToGPIO[types.BaseColorRed], rgbled.RGBLEDEnabled)
for action, color := range rgbled.ActionMapping {
fmt.Fprintf(tw, "%v=%v,", action, color)
}
fmt.Fprintf(tw, "\n")
}
tw.Flush()