mirror of
https://github.com/Luzifer/streamdeck.git
synced 2024-12-20 17:51:21 +00:00
Signalize errored displays on streamdeck
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
656a4710f0
commit
fd6ac1e954
2 changed files with 34 additions and 4 deletions
|
@ -235,12 +235,20 @@ func togglePage(page string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
go func(idx int) {
|
go func(idx int) {
|
||||||
var kd = activePage.Keys[idx]
|
var (
|
||||||
if err := callDisplayElement(activePageCtx, idx, kd); err != nil {
|
kd = activePage.Keys[idx]
|
||||||
log.WithFields(log.Fields{
|
keyLogger = log.WithFields(log.Fields{
|
||||||
"key": idx,
|
"key": idx,
|
||||||
"page": activePageName,
|
"page": activePageName,
|
||||||
}).WithError(err).Error("Unable to execute display element")
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
if err := callDisplayElement(activePageCtx, idx, kd); err != nil {
|
||||||
|
keyLogger.WithError(err).Error("Unable to execute display element")
|
||||||
|
|
||||||
|
if err := callErrorDisplayElement(activePageCtx, idx); err != nil {
|
||||||
|
keyLogger.WithError(err).Error("Unable to execute error display element")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}(idx)
|
}(idx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,12 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const errorDisplayElementType = "color"
|
||||||
|
|
||||||
|
var errorDisplayElementAttributes = map[string]interface{}{
|
||||||
|
"rgba": []interface{}{0xff, 0x0, 0x0, 0xff},
|
||||||
|
}
|
||||||
|
|
||||||
type action interface {
|
type action interface {
|
||||||
Execute(attributes map[string]interface{}) error
|
Execute(attributes map[string]interface{}) error
|
||||||
}
|
}
|
||||||
|
@ -80,3 +86,19 @@ func callDisplayElement(ctx context.Context, idx int, kd keyDefinition) error {
|
||||||
|
|
||||||
return inst.(displayElement).Display(ctx, idx, kd.Display.Attributes)
|
return inst.(displayElement).Display(ctx, idx, kd.Display.Attributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func callErrorDisplayElement(ctx context.Context, idx int) error {
|
||||||
|
t, ok := registeredDisplayElements[errorDisplayElementType]
|
||||||
|
if !ok {
|
||||||
|
return errors.Errorf("Unknown display type %q", errorDisplayElementType)
|
||||||
|
}
|
||||||
|
|
||||||
|
var inst interface{}
|
||||||
|
if t.Kind() == reflect.Ptr {
|
||||||
|
inst = reflect.New(t.Elem()).Interface()
|
||||||
|
} else {
|
||||||
|
inst = reflect.New(t).Interface()
|
||||||
|
}
|
||||||
|
|
||||||
|
return inst.(displayElement).Display(ctx, idx, errorDisplayElementAttributes)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue