From 892ea5aa1fc80ea69bab8e2059c2936e4fa3d394 Mon Sep 17 00:00:00 2001 From: Nicholas Thompson Date: Wed, 27 Feb 2019 23:26:50 +0200 Subject: [PATCH] Updated cli to use led map --- cmd/invertercli/invertercli.go | 11 ++++------- mk2if/mk2interface.go | 6 ++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/invertercli/invertercli.go b/cmd/invertercli/invertercli.go index d57f479..e1fe897 100644 --- a/cmd/invertercli/invertercli.go +++ b/cmd/invertercli/invertercli.go @@ -74,14 +74,11 @@ func PrintInfo(info *mk2if.Mk2Info) { out += fmt.Sprintf("Out Volt: %.2fV Out Cur: %.2fA Out Freq %.2fHz\n", info.OutVoltage, info.OutCurrent, info.OutFrequency) out += fmt.Sprintf("In Power %.2fW Out Power %.2fW\n", info.InVoltage*info.InCurrent, info.OutVoltage*info.OutCurrent) out += fmt.Sprintf("Charge State: %.2f%%\n", info.ChargeState*100) - out += "LEDs on:" - for _, v := range info.LedListOn { - out += " " + mk2if.LedNames[v] - } - out += "\nLEDs blink:" - for _, v := range info.LedListBlink { - out += " " + mk2if.LedNames[v] + out += "LEDs state:" + for k, v := range info.LEDs { + out += fmt.Sprintf(" %s %s", mk2if.LedNames[k], mk2if.StateNames[v]) } + out += "\nErrors:" for _, v := range info.Errors { out += " " + v.Error() diff --git a/mk2if/mk2interface.go b/mk2if/mk2interface.go index 87bd69c..8e662c9 100644 --- a/mk2if/mk2interface.go +++ b/mk2if/mk2interface.go @@ -34,6 +34,12 @@ const ( LedBlink ) +var StateNames = map[LEDstate]string{ + LedOff: "off", + LedOn: "on", + LedBlink: "blink", +} + type Mk2Info struct { // Will be marked as false if an error is detected. Valid bool