Documentation
¶
Index ¶
- Constants
- Variables
- func NotifyEnablers(listeners []interface{}, enabled bool)
- func ToBool(raw any) (bool, bool)
- func ToFloat(raw any) (float64, bool)
- func ToInt(raw any) (int, bool)
- func ToString(raw any) (string, bool)
- func ToStringArray(raw any) ([]string, bool)
- type BaseButton
- type Button
- type ButtonContext
- type ButtonFactory
- type ConnectionConfig
- type ConnectionConfigProvider
- type ConnectionFactory
- type ConnectionManager
- type Device
- type Enabler
- type Factory
- type FlashingButton
- type GC
- func (gc *GC) DrawDoubleLineToggleTextButton(text1, text2 string, activeLine int) image.Image
- func (gc *GC) DrawIconButton(icon image.Image) image.Image
- func (gc *GC) DrawIconLabelButton(icon image.Image, label string) image.Image
- func (gc *GC) DrawNoButton() image.Image
- func (gc *GC) DrawSingleLineTextButton(text string) image.Image
- func (gc *GC) LoadFontAsset(name string, points float64) font.Face
- func (gc *GC) LoadFontFaceFromReader(r io.Reader, points float64) (font.Face, error)
- func (gc *GC) LoadIconAsset(name string) image.Image
- func (gc *GC) LoadIconFromFile(filename string) (image.Image, error)
- func (gc *GC) LoadIconFromReader(r io.Reader) (image.Image, error)
- func (gc *GC) Pixels() int
- func (gc *GC) Reset()
- func (gc *GC) SetBackground(background color.Color)
- func (gc *GC) SetFont(filename string)
- func (gc *GC) SetFontSize(points float64)
- func (gc *GC) SetForeground(foreground color.Color)
- func (gc *GC) SwapColors()
- type GraphicContext
- type HamDeck
- func (d *HamDeck) Attach(index int, button Button)
- func (d *HamDeck) AttachPage(id string) error
- func (d *HamDeck) CloseUnusedFactories()
- func (d *HamDeck) Detach(index int)
- func (d *HamDeck) GetConnection(name string, connectionType string) (ConnectionConfig, bool)
- func (d *HamDeck) ReadConfig(r io.Reader) error
- func (d *HamDeck) Redraw(index int, redrawImages bool)
- func (d *HamDeck) RedrawAll(redrawImages bool)
- func (d *HamDeck) RegisterFactory(factory ButtonFactory)
- func (d *HamDeck) Run(stop <-chan struct{}) error
- type Key
- type LongpressHandler
- type Page
- type PageButton
- type PageSwitcher
Constants ¶
View Source
const ( ConfigDefaultFilename = "hamdeck.json" ConfigMainKey = "hamdeck" ConfigConnections = "connections" ConfigStartPageID = "start_page" ConfigPages = "pages" ConfigButtons = "buttons" ConfigType = "type" ConfigIndex = "index" ConfigConnection = "connection" )
View Source
const ( ConfigPage = "page" ConfigLabel = "label" )
View Source
const FlashingInterval = 500 * time.Millisecond
View Source
const LegacyConnectionName = ""
View Source
const LongpressDuration = 1 * time.Second
View Source
const (
PageButtonType = "hamdeck.Page"
)
Variables ¶
View Source
var ( Black = color.Black White = color.White DisabledGray = color.RGBA{54, 60, 62, 255} Red = color.RGBA{255, 0, 0, 255} Green = color.RGBA{0, 255, 0, 255} Blue = color.RGBA{0, 0, 255, 255} Yellow = color.RGBA{255, 255, 0, 255} Magenta = color.RGBA{255, 0, 255, 255} Cyan = color.RGBA{0, 255, 255, 255} DarkGreen = color.RGBA{0, 150, 0, 255} Orange = color.RGBA{255, 165, 0, 255} )
View Source
var ( DefaultBackground = Black DefaultForeground = White DefaultFont = "DejaVuSans.ttf" DefaultFontSize = 24.0 )
Functions ¶
func NotifyEnablers ¶
func NotifyEnablers(listeners []interface{}, enabled bool)
func ToStringArray ¶
Types ¶
type BaseButton ¶
type BaseButton struct {
// contains filtered or unexported fields
}
func (*BaseButton) Attached ¶
func (b *BaseButton) Attached(ctx ButtonContext)
func (*BaseButton) Detached ¶
func (b *BaseButton) Detached()
func (*BaseButton) Invalidate ¶
func (b *BaseButton) Invalidate(redrawImages bool)
type Button ¶
type Button interface { Image(GraphicContext, bool) image.Image Pressed() Released() Attached(ButtonContext) Detached() }
type ButtonContext ¶
type ButtonContext interface {
Invalidate(bool)
}
type ButtonFactory ¶
type ConnectionConfig ¶ added in v0.4.0
type ConnectionConfigProvider ¶ added in v0.4.0
type ConnectionConfigProvider interface {
GetConnection(string, string) (ConnectionConfig, bool)
}
type ConnectionFactory ¶ added in v0.4.0
type ConnectionFactory[T any] func(string, ConnectionConfig) (T, error)
type ConnectionManager ¶ added in v0.4.0
type ConnectionManager[T any] struct { // contains filtered or unexported fields }
func NewConnectionManager ¶ added in v0.4.0
func NewConnectionManager[T any](connectionType string, provider ConnectionConfigProvider, factory ConnectionFactory[T]) *ConnectionManager[T]
func (*ConnectionManager[T]) ForEach ¶ added in v0.4.0
func (m *ConnectionManager[T]) ForEach(f func(T))
func (*ConnectionManager[T]) Get ¶ added in v0.4.0
func (m *ConnectionManager[T]) Get(name string) (T, error)
func (*ConnectionManager[T]) SetLegacy ¶ added in v0.4.0
func (m *ConnectionManager[T]) SetLegacy(legacyConnection T)
type Factory ¶ added in v0.4.0
type Factory struct {
// contains filtered or unexported fields
}
func NewButtonFactory ¶ added in v0.4.0
func NewButtonFactory(pageSwitcher PageSwitcher) *Factory
type FlashingButton ¶
type FlashingButton interface {
Flash(on bool)
}
type GC ¶
type GC struct {
// contains filtered or unexported fields
}
func (*GC) DrawDoubleLineToggleTextButton ¶
func (*GC) DrawIconLabelButton ¶
func (*GC) DrawNoButton ¶
func (*GC) DrawSingleLineTextButton ¶
func (*GC) LoadFontFaceFromReader ¶
func (*GC) SetBackground ¶
func (*GC) SetFontSize ¶
func (*GC) SetForeground ¶
func (*GC) SwapColors ¶
func (gc *GC) SwapColors()
type GraphicContext ¶
type GraphicContext interface { Pixels() int Reset() SetBackground(background color.Color) SetForeground(foreground color.Color) SwapColors() SetFont(filename string) SetFontSize(points float64) DrawNoButton() image.Image DrawSingleLineTextButton(text string) image.Image DrawDoubleLineToggleTextButton(text1, text2 string, activeLine int) image.Image LoadIconFromFile(filename string) (image.Image, error) LoadIconFromReader(r io.Reader) (image.Image, error) LoadIconAsset(name string) image.Image DrawIconButton(icon image.Image) image.Image DrawIconLabelButton(icon image.Image, label string) image.Image }
func NewGraphicContext ¶
func NewGraphicContext(pixels int) GraphicContext
type HamDeck ¶
type HamDeck struct {
// contains filtered or unexported fields
}
func (*HamDeck) AttachPage ¶ added in v0.4.0
func (*HamDeck) CloseUnusedFactories ¶ added in v0.3.0
func (d *HamDeck) CloseUnusedFactories()
func (*HamDeck) GetConnection ¶ added in v0.4.0
func (d *HamDeck) GetConnection(name string, connectionType string) (ConnectionConfig, bool)
func (*HamDeck) RegisterFactory ¶
func (d *HamDeck) RegisterFactory(factory ButtonFactory)
type LongpressHandler ¶
type LongpressHandler struct {
// contains filtered or unexported fields
}
func NewLongpressHandler ¶
func NewLongpressHandler(callback func()) *LongpressHandler
func (*LongpressHandler) Pressed ¶
func (h *LongpressHandler) Pressed()
func (*LongpressHandler) Released ¶
func (h *LongpressHandler) Released()
type PageButton ¶ added in v0.4.0
type PageButton struct { BaseButton // contains filtered or unexported fields }
func NewPageButton ¶ added in v0.4.0
func NewPageButton(pageSwitcher PageSwitcher, id string, label string) *PageButton
func (*PageButton) Image ¶ added in v0.4.0
func (b *PageButton) Image(gc GraphicContext, redrawImages bool) image.Image
func (*PageButton) Pressed ¶ added in v0.4.0
func (b *PageButton) Pressed()
func (*PageButton) Released ¶ added in v0.4.0
func (b *PageButton) Released()
type PageSwitcher ¶ added in v0.4.0
Click to show internal directories.
Click to hide internal directories.