benjamin

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2023 License: GPL-2.0 Imports: 4 Imported by: 0

README

benjamin

Benjamin, a Button panel UI

Supported devices

Devices supported by benjamin, are:

  • Elgato Stream Deck (original)
  • Elgato Stream Deck V2 (original)
  • Elgato Stream Deck Mini
  • Elgato Stream Deck MK.2
  • Elgato Stream Deck XL
  • Elgato Stream Deck XL V2
  • Elgato Stream Deck +
  • Inifinitton iButton

Peripherals supported by benjamin:

  • Buttons (with display)
  • Displays
  • Encoders

License

Copyright (C) 2023 Wijnand Modderman-Lenstra.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Documentation

Overview

Package Benjamin, a Button panel UI

This package contains drivers and user interface logic for interacting with button panels, such as the popular Elgate Stream Decks.

Supported devices

Devices supported by benjamin, are:

Elgato Stream Deck (original)
Elgato Stream Deck V2 (original)
Elgato Stream Deck Mini
Elgato Stream Deck MK.2
Elgato Stream Deck XL
Elgato Stream Deck XL V2
Elgato Stream Deck +
Inifinitton iButton

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseEvent

type BaseEvent struct {
	On Device
	At time.Time
}

func (BaseEvent) Device

func (b BaseEvent) Device() Device

func (BaseEvent) Time

func (b BaseEvent) Time() time.Time

type Button

type Button interface {
	Peripheral
	Drawable

	// Position on the key matrix.
	Position() image.Point
}

type ButtonPress

type ButtonPress struct {
	BaseEvent
	Button
}

func (ButtonPress) String

func (event ButtonPress) String() string

type ButtonRelease

type ButtonRelease struct {
	BaseEvent
	After time.Duration
	Button
}

func (ButtonRelease) String

func (event ButtonRelease) String() string

type Device

type Device interface {
	Manufacturer() string
	Product() string
	Serial() string

	Open() error
	Close() error
	Reset() error

	// Clear all displays and buttons to black.
	Clear() error

	Events() <-chan Event

	Surface
}

type Display

type Display interface {
	Peripheral
	Drawable
}

type DisplayLongPress

type DisplayLongPress struct {
	BaseEvent
	Display
	Position image.Point
}

func (DisplayLongPress) String

func (event DisplayLongPress) String() string

type DisplayPress

type DisplayPress struct {
	BaseEvent
	Display
	Position image.Point
}

func (DisplayPress) String

func (event DisplayPress) String() string

type DisplaySwipe

type DisplaySwipe struct {
	BaseEvent
	Display
	From, To image.Point
}

func (DisplaySwipe) String

func (event DisplaySwipe) String() string

type Drawable

type Drawable interface {
	Size() image.Point
	SetImage(image.Image) error
}

type Encoder

type Encoder interface {
	Peripheral

	// Display linked to the encoder, returns nil if the encoder has no display.
	Display() Display
}

Encoder is a rotary encoder.

type EncoderChange

type EncoderChange struct {
	BaseEvent
	Encoder
	Change int
	Bits   int
}

func (EncoderChange) String

func (event EncoderChange) String() string

type EncoderPress

type EncoderPress struct {
	BaseEvent
	Encoder
}

func (EncoderPress) String

func (event EncoderPress) String() string

type EncoderRelease

type EncoderRelease struct {
	BaseEvent
	Encoder
	After time.Duration
}

func (EncoderRelease) String

func (event EncoderRelease) String() string

type Error

type Error struct {
	BaseEvent
	Error error
}

func (Error) String

func (event Error) String() string

type Event

type Event struct {
	// Type of event.
	Type EventType

	// Peripheral the event was generated with.
	Peripheral Peripheral

	// Data associated with the event.
	Data EventData
}

Event from user interaction.

func NewButtonPress

func NewButtonPress(device Device, key Button) Event

func NewButtonRelease

func NewButtonRelease(device Device, key Button, after time.Duration) Event

func NewDisplayLongPress

func NewDisplayLongPress(device Device, display Display, at image.Point) Event

func NewDisplayPress

func NewDisplayPress(device Device, display Display, at image.Point) Event

func NewDisplaySwipe

func NewDisplaySwipe(device Device, display Display, from, to image.Point) Event

func NewEncoderChange

func NewEncoderChange(device Device, encoder Encoder, change, bits int) Event

func NewEncoderPress

func NewEncoderPress(device Device, encoder Encoder) Event

func NewEncoderRelease

func NewEncoderRelease(device Device, encoder Encoder, after time.Duration) Event

func NewError

func NewError(device Device, err error) Event

func (Event) String

func (e Event) String() string

type EventData

type EventData interface {
	// Device the event was on.
	Device() Device

	// Time of event.
	Time() time.Time

	// Stringer interface
	fmt.Stringer
}

type EventHandler

type EventHandler interface {
	Handle(Event)
}

type EventHandlerFunc

type EventHandlerFunc func(Event)

func (EventHandlerFunc) Handle

func (f EventHandlerFunc) Handle(event Event)

type EventType

type EventType int
const (
	TypeError EventType = iota
	TypeButtonPress
	TypeButtonRelease
	TypeDisplayPress
	TypeDisplayLongPress
	TypeDisplaySwipe
	TypeEncoderChange
	TypeEncoderPress
	TypeEncoderRelease
	TypeMax
)

func (EventType) String

func (t EventType) String() string

type Peripheral

type Peripheral interface {
	// Surface the pheripheral is connected to.
	Surface() Surface

	// Index of the pheripheral.
	Index() int
}

type Route

type Route struct {
	Peripheral Peripheral
	EventHandler
}

type Router

type Router map[EventType][]Route

func (Router) Handle

func (r Router) Handle(e Event)

func (Router) On

func (r Router) On(p Peripheral, t EventType, h EventHandler)

func (Router) Run

func (r Router) Run(d Device)

type Screen added in v1.0.1

type Screen interface {
	Peripheral
	Drawable
}

type Surface

type Surface interface {
	Display(int) Display
	Displays() int
	DisplayArea() Screen

	Encoder(int) Encoder
	Encoders() int

	Button(int) Button
	ButtonAt(image.Point) Button
	Buttons() int
	ButtonLayout() image.Point
	ButtonArea() Screen

	SetBrightness(float64) error
}

type USBDevice added in v1.0.1

type USBDevice interface {
	DeviceInfo() hid.DeviceInfo
}

Directories

Path Synopsis
cmd
all
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL