fix(pkg/rgbled): use action maps to turn on/off led colors
This commit is contained in:
@ -5,23 +5,12 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type LED struct {
|
||||
LEDID string `json:"led_id" xml:"led_id"`
|
||||
LEDName string `json:"led_name" xml:"led_name"`
|
||||
LEDLocation string `json:"led_location" xml:"led_location"`
|
||||
GPIONumber *GPIO `json:"gpio_number" xml:"gpio_number"`
|
||||
LEDEnabled bool `json:"led_enabled" xml:"led_enabled"`
|
||||
LEDColor *LEDColor `json:"led_color" xml:"led_color"`
|
||||
DeviceID string `json:"device_id" xml:"device_id"`
|
||||
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
|
||||
}
|
||||
|
||||
type RGBLED struct {
|
||||
RGBLEDID string `json:"rgbled_id" xml:"rgbled_id"`
|
||||
RGBLEDName string `json:"rgbled_name" xml:"rgbled_name"`
|
||||
RGBLEDLocation string `json:"rgbled_location" xml:"rgb_location"`
|
||||
BaseColorsToGPIO map[BaseColor]*GPIO `json:"color_to_gpio" xml:"color_to_gpio"`
|
||||
ActionMapping map[LEDOption]LEDColor `json:"action_mapping" xml:"action_mapping"`
|
||||
BaseColorsToGPIO map[BaseColor]*GPIO `json:"base_colors_to_gpio" xml:"base_colors_to_gpio"`
|
||||
ActionMapping map[LEDAction]LEDColor `json:"action_mapping" xml:"action_mapping"`
|
||||
RGBLEDEnabled bool `json:"rgbled_enabled" xml:"rgb_enabled"`
|
||||
DeviceID string `json:"device_id" xml:"device_id"`
|
||||
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
|
||||
@ -48,7 +37,7 @@ const (
|
||||
LEDColorWhite LEDColor = "white"
|
||||
)
|
||||
|
||||
func StrintToLEDColor(color string) (LEDColor, error) {
|
||||
func StringToLEDColor(color string) (LEDColor, error) {
|
||||
switch color {
|
||||
case "blue":
|
||||
return LEDColorBlue, nil
|
||||
@ -71,20 +60,20 @@ func StrintToLEDColor(color string) (LEDColor, error) {
|
||||
}
|
||||
}
|
||||
|
||||
type LEDOption string
|
||||
type LEDAction string
|
||||
|
||||
const (
|
||||
LEDError LEDOption = "error"
|
||||
LEDWarn = "warn"
|
||||
LEDOk = "ok"
|
||||
LEDSync = "sync"
|
||||
LEDLogfile = "logfile"
|
||||
LEDActionError LEDAction = "error"
|
||||
LEDActionWarn = "warn"
|
||||
LEDActionRun = "run"
|
||||
LEDActionSync = "sync"
|
||||
LEDActionLogfile = "logfile"
|
||||
)
|
||||
|
||||
var DefaultActionMapping = map[LEDOption]LEDColor{
|
||||
LEDError: LEDColorRed,
|
||||
LEDWarn: LEDColorYellow,
|
||||
LEDOk: LEDColorGreen,
|
||||
LEDSync: LEDColorTurquoise,
|
||||
LEDLogfile: LEDColorBlue,
|
||||
var DefaultActionMapping = map[LEDAction]LEDColor{
|
||||
LEDActionError: LEDColorRed,
|
||||
LEDActionWarn: LEDColorYellow,
|
||||
LEDActionRun: LEDColorGreen,
|
||||
LEDActionSync: LEDColorTurquoise,
|
||||
LEDActionLogfile: LEDColorBlue,
|
||||
}
|
||||
|
Reference in New Issue
Block a user