gopi

package module
v2.0.30 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: BSD-2-Clause Imports: 14 Imported by: 33

README

GOPI Go Language Application Framework

CircleCI

This repository contains an application framework for the Go language, which will allow you to develop applications which utilize a number of features of your computer. It's targetted at the Raspberry Pi presently. The following features are intended to be supported:

  • The GPIO, I2C and SPI interfaces
  • Display and display surfaces, bitmaps and vector graphics
  • GPU acceleration for 2D graphics
  • Font loading and rendering in bitmap and vector forms
  • Input devices like the mouse, keyboard and touchscreen
  • Infrared transmission and receiving, for example for remote controls
  • Network microservices, announcement and discovery

It would also be great to support the following features in the future:

  • Image and video encoding/decoding, including utilizing hardware acceleration
  • Connected cameras
  • 3D graphics
  • Audio devices
  • User interface widgets and layout
  • Building for Darwin (Macintosh) targets

Documentation

Please read the documentation at gopi.mutablelogic.com for all the relevant information about requirements, getting started and contributing.

Contributing and License

This repository is released under the Apache License. Please see the LICENSE file in the root of the repository for a copy of this license and for a list of the conditions for redistribution and use.

I welcome contributions, feature requests and issues. In order to contribute, please fork and send pull requests. Feel free to contact me for feature requests and bugs by filing issues here.

Documentation

Index

Constants

View Source
const (
	// SurfaceLayer
	SURFACE_LAYER_BACKGROUND uint16 = 0x0000
	SURFACE_LAYER_DEFAULT    uint16 = 0x0001
	SURFACE_LAYER_MAX        uint16 = 0xFFFE
	SURFACE_LAYER_CURSOR     uint16 = 0xFFFF
)

Variables

View Source
var (
	ZeroPoint = Point{0, 0}
	ZeroSize  = Size{0, 0}
)
View Source
var (
	ColorRed         = color.RGBA{0xFF, 0x00, 0x00, 0xFF}
	ColorGreen       = color.RGBA{0x00, 0xFF, 0x00, 0xFF}
	ColorBlue        = color.RGBA{0x00, 0x00, 0xFF, 0xFF}
	ColorWhite       = color.White
	ColorBlack       = color.Black
	ColorPurple      = color.RGBA{0xFF, 0x00, 0xFF, 0xFF}
	ColorCyan        = color.RGBA{0x00, 0xFF, 0xFF, 0xFF}
	ColorYellow      = color.RGBA{0xFF, 0xFF, 0x00, 0xFF}
	ColorDarkGrey    = color.RGBA{0x40, 0x40, 0x40, 0xFF}
	ColorLightGrey   = color.RGBA{0xBF, 0xBF, 0xBF, 0xFF}
	ColorMidGrey     = color.RGBA{0x80, 0x80, 0x80, 0xFF}
	ColorTransparent = color.Transparent
)

Standard Colors

Functions

func UnitRegister

func UnitRegister(unit UnitConfig)

func UnitReset added in v2.0.2

func UnitReset()

Types

type App

type App interface {

	// Run the application and return the return code
	Run() int

	// WaitForSignal stalls the application until a signal is returned,
	// context is cancelled or deadline exceeded
	WaitForSignal(context.Context, ...os.Signal) error // Wait for interrupt signal with context

	// Flags returns the set of key/value configuration parameters
	Flags() Flags

	// Emit events
	Emit(Event)

	// Return unit instances
	UnitInstance(string) Unit // Return singular unit for name
	Log() Logger              // Return logger unit
	Timer() Timer             // Return timer unit
	Bus() Bus                 // Return event bus unit
	Platform() Platform       // Return hardware platform unit
	Display() Display         // Return display
	Surfaces() SurfaceManager // Return surface manager
	Input() InputManager      // Return input manager
	Fonts() FontManager       // Return font manager
	GPIO() GPIO               // Return GPIO interface
	I2C() I2C                 // Return I2C interface
	SPI() SPI                 // Return SPI interface
	LIRC() LIRC               // Return LIRC interface
}

App encapsulates the lifecycle of a running application which is created through the 'app' package and run by calling the Run method. A running application has access to unit instances (for example, logger, timer and event bus).

type Bitmap added in v2.0.5

type Bitmap interface {
	Type() SurfaceFlags
	Size() Size

	// Clear bitmap
	ClearToColor(color.Color)

	// Set Pixel
	Pixel(color.Color, Point)

	// Draw line
	Line(color.Color, Point, Point)

	// Outline circle with centre and radius
	CircleOutline(color.Color, Point, float32)

	// Paint a rune
	Rune(color.Color, Point, rune, FontFace, FontSize)

	// Implements image.Image and draw.Image
	draw.Image
}

Bitmap defines a rectangular bitmap which can be used by the GPU

type Bus

type Bus interface {
	Unit

	// Emit an event on the bus
	Emit(Event)

	// NewHandler registers an event handler for an event name
	NewHandler(EventHandler) error

	// DefaultHandler registers a default handler for an event namespace
	DefaultHandler(EventNS, EventHandlerFunc) error
}

Bus unit - handles events

type Channel added in v2.0.2

type Channel uint

Channel is an arbitary communication channel

type CompoundError added in v2.0.2

type CompoundError struct {
	// contains filtered or unexported fields
}

CompoundError represents a set of errors

func NewCompoundError added in v2.0.2

func NewCompoundError(errs ...error) *CompoundError

func (*CompoundError) Add added in v2.0.2

func (this *CompoundError) Add(err error) error

func (*CompoundError) Error added in v2.0.2

func (this *CompoundError) Error() string

func (*CompoundError) ErrorOrSelf added in v2.0.2

func (this *CompoundError) ErrorOrSelf() error

func (*CompoundError) Is added in v2.0.2

func (this *CompoundError) Is(other error) bool

type Config

type Config interface {
	Name() string             // Returns name of the unit
	New(Logger) (Unit, error) // Opens the driver from configuration, or returns error
}

Unit configuration interface

type ConfigFunc

type ConfigFunc func(App) error

type DebugApp added in v2.0.16

type DebugApp interface {

	// Testing
	T() *testing.T

	// Implements App
	App
}

DebugApp is an application with additional context

type Display added in v2.0.2

type Display interface {
	// Return display number
	DisplayId() uint

	// Return name of the display
	Name() string

	// Return display size for nominated display number, or (0,0) if display does not exist
	Size() (uint32, uint32)

	// Return the PPI (pixels-per-inch) for the display, or return zero if unknown
	PixelsPerInch() uint32

	// Implements gopi.Unit
	Unit
}

Display implements a pixel-based display device. Displays are always numbered from zero onwards

type Error

type Error uint

Error represents a gopi error

const (
	ErrNone               Error = iota // No error condition
	ErrNotImplemented                  // Method or feature not implemented
	ErrBadParameter                    // Error with parameter passed to method
	ErrNotFound                        // Missing object
	ErrHelp                            // Help requested from command line
	ErrInternalAppError                // Internal application error
	ErrSignalCaught                    // Signal caught
	ErrUnexpectedResponse              // Unexpected Response
	ErrDuplicateItem                   // Duplicate Item
	ErrOutOfOrder                      // Out of order
	ErrMax                = ErrDuplicateItem
)

func (Error) Error

func (this Error) Error() string

func (Error) WithPrefix

func (this Error) WithPrefix(prefix string) error

type Event

type Event interface {
	Source() Unit       // Source of the event
	Name() string       // Name of the event
	NS() EventNS        // Namespace for the event
	Value() interface{} // Any value associated with the event
}

Event emitted on the event bus

var (
	NullEvent Event
)

type EventHandler

type EventHandler struct {
	// The name of the event
	Name string

	// The handler function for the event
	Handler EventHandlerFunc

	// The namespace of the event, usually 0
	EventNS EventNS

	// The timeout value for the handler, usually 0
	Timeout time.Duration
}

EventHandler defines how an emitted event is handled in the application

type EventHandlerFunc added in v2.0.2

type EventHandlerFunc func(context.Context, App, Event)

EventHandlerFunc is the handler for an emitted event, which should cancel when context.Done() signal is received

type EventId added in v2.0.2

type EventId uint

EventId is a unique ID for each event

type EventNS

type EventNS uint

EventNS is the namespace in which events are emitted, usually EVENT_NS_DEFAULT

const (
	EVENT_NS_DEFAULT EventNS = iota // Default event namespace
	EVENT_NS_MAX             = EVENT_NS_DEFAULT
)

func (EventNS) String added in v2.0.2

func (v EventNS) String() string

type FSEvent added in v2.0.16

type FSEvent interface {
	// Root path being watched
	Root() string

	// Path the event is concerned with, under the root path
	Path() string

	// Whether the event concerns a folder
	IsFolder() bool

	// The event flags
	Flags() FSEventFlags

	// The unique inode number for the event path, or zero
	Inode() uint64

	// Implements gopi.Event
	Event
}

type FSEventFlags added in v2.0.16

type FSEventFlags uint

File system event flags

const (
	FSEVENT_FLAG_ATTRIB  FSEventFlags = (1 << iota) // Attributes changed
	FSEVENT_FLAG_CREATE                             // File created
	FSEVENT_FLAG_DELETE                             // File deleted
	FSEVENT_FLAG_MODIFY                             // File modified
	FSEVENT_FLAG_MOVE                               // File moved
	FSEVENT_FLAG_UNMOUNT                            // Watched filesystem was unmounted
	FSEVENT_FLAG_ALL                  = FSEVENT_FLAG_ATTRIB | FSEVENT_FLAG_CREATE | FSEVENT_FLAG_DELETE | FSEVENT_FLAG_MODIFY | FSEVENT_FLAG_MOVE | FSEVENT_FLAG_UNMOUNT
	FSEVENT_FLAG_NONE    FSEventFlags = 0
	FSEVENT_FLAG_MIN     FSEventFlags = FSEVENT_FLAG_ATTRIB
	FSEVENT_FLAG_MAX     FSEventFlags = FSEVENT_FLAG_UNMOUNT
)

func (FSEventFlags) String added in v2.0.16

func (f FSEventFlags) String() string

func (FSEventFlags) StringFlag added in v2.0.16

func (f FSEventFlags) StringFlag() string

type FSEventFunc added in v2.0.16

type FSEventFunc func(uint32, FSEvent)

FSEventFunc is the handler for filesystem events

type FSEvents added in v2.0.16

type FSEvents interface {
	// Watch for events and call handler when events are generated
	Watch(string, FSEventFlags, FSEventFunc) (uint32, error)

	// Unwatch stops watching for file events
	Unwatch(uint32) error

	// Implements gopi.Unit
	Unit
}

FSEvents emits events when watched files and folders are changed

type FilePoll added in v2.0.5

type FilePoll interface {
	// Watch for events and call handler with file descriptor
	Watch(uintptr, FilePollFlags, FilePollFunc) error

	// Unwatch stops watching for file events
	Unwatch(uintptr) error

	// Implements gopi.Unit
	Unit
}

FilePoll emits READ and WRITE events for files

type FilePollFlags added in v2.0.5

type FilePollFlags uint

READ and WRITE flags

const (
	FILEPOLL_FLAG_READ  FilePollFlags = (1 << iota) // File descriptor ready for reading
	FILEPOLL_FLAG_WRITE                             // File descriptor ready for writing
	FILEPOLL_FLAG_NONE  FilePollFlags = 0
	FILEPOLL_FLAG_MIN   FilePollFlags = FILEPOLL_FLAG_READ
	FILEPOLL_FLAG_MAX   FilePollFlags = FILEPOLL_FLAG_WRITE
)

func (FilePollFlags) String added in v2.0.16

func (f FilePollFlags) String() string

func (FilePollFlags) StringFlag added in v2.0.16

func (f FilePollFlags) StringFlag() string

type FilePollFunc added in v2.0.5

type FilePollFunc func(uintptr, FilePollFlags)

FilePollFunc is the handler for file polling

type FlagNS added in v2.0.2

type FlagNS uint

FlagNS is the namespace for a flag

const (
	FLAG_NS_DEFAULT FlagNS = iota
	FLAG_NS_VERSION
	FLAG_NS_SERVICE
)

func (FlagNS) String added in v2.0.2

func (v FlagNS) String() string

type Flags

type Flags interface {
	Name() string                                       // Return name of tool
	Parse([]string) error                               // Parse command-line flags
	Parsed() bool                                       // Returns true if Parsed() has been called
	Args() []string                                     // Return command-line arguments
	HasFlag(string, FlagNS) bool                        // HasFlag returns true if a flag exists
	Visit(FlagNS, func(name string, value interface{})) // Visit all flags in a namespace

	Usage(io.Writer)   // Write out usage for the application
	Version(io.Writer) // Write out version for the application

	// Define flags in default namespace
	FlagBool(name string, value bool, usage string) *bool
	FlagString(name, value, usage string) *string
	FlagDuration(name string, value time.Duration, usage string) *time.Duration
	FlagInt(name string, value int, usage string) *int
	FlagUint(name string, value uint, usage string) *uint
	FlagFloat64(name string, value float64, usage string) *float64

	// Get flag values
	GetBool(string, FlagNS) bool
	GetString(string, FlagNS) string
	GetDuration(string, FlagNS) time.Duration
	GetInt(string, FlagNS) int
	GetUint(string, FlagNS) uint
	GetFloat64(string, FlagNS) float64

	// Set flag values
	SetBool(string, FlagNS, bool)
	SetString(string, FlagNS, string)
	SetDuration(string, FlagNS, time.Duration)
	SetInt(string, FlagNS, int)
	SetUint(string, FlagNS, uint)
	SetFloat64(string, FlagNS, float64)
}

Flags encapsulates a set of key/value pairs in several namespaces with parsing of command-line flags in the default namespace

type FontFace added in v2.0.5

type FontFace interface {

	// Get Face Name (from the filename)
	Name() string

	// Get Face Index
	Index() uint

	// Get Number of faces within the file
	NumFaces() uint

	// Number of glyphs for the face
	NumGlyphs() uint

	// Return name of font family
	Family() string

	// Return style name of font face
	Style() string

	// Return properties for face
	Flags() FontFlags
}

Abstract font face interface

type FontFlags added in v2.0.5

type FontFlags uint16

Font flags

const (
	FONT_FLAGS_NONE             FontFlags = 0x0000
	FONT_FLAGS_STYLE_ITALIC     FontFlags = 0x0001
	FONT_FLAGS_STYLE_BOLD       FontFlags = 0x0002
	FONT_FLAGS_STYLE_BOLDITALIC FontFlags = 0x0003
	FONT_FLAGS_STYLE_REGULAR    FontFlags = 0x0004
	FONT_FLAGS_STYLE_ANY        FontFlags = 0x0007
)

func (FontFlags) String added in v2.0.5

func (f FontFlags) String() string

func (FontFlags) StringFlag added in v2.0.5

func (f FontFlags) StringFlag() string

type FontManager added in v2.0.5

type FontManager interface {

	// Open a font face - first face at index 0 is loaded
	OpenFace(path string) (FontFace, error)

	// Open a font face - indexed within file of several faces
	OpenFaceAtIndex(path string, index uint) (FontFace, error)

	// Open font faces at path, checking to see if individual files should
	// be opened through a callback function
	OpenFacesAtPath(path string, callback func(manager FontManager, path string, info os.FileInfo) bool) error

	// Destroy a font face
	DestroyFace(FontFace) error

	// Return an array of font families which are loaded
	Families() []string

	// Return open face for filepath
	FaceForPath(path string) FontFace

	// Return faces in a family and/or with a particular set of attributes
	Faces(family string, flags FontFlags) []FontFace

	// Implements gopi.Unit
	Unit
}

FontManager for font management

type FontSize added in v2.0.17

type FontSize struct {
	Size float32
	Unit FontSizeUnit
}

Font flags

type FontSizeUnit added in v2.0.17

type FontSizeUnit uint

Font flags

const (
	FONT_SIZE_PIXELS FontSizeUnit = iota
	FONT_SIZE_POINTS
)

type GPIO added in v2.0.2

type GPIO interface {
	// Return number of physical pins, or 0 if if cannot be returned
	// or nothing is known about physical pins
	NumberOfPhysicalPins() uint

	// Return array of available logical pins or nil if nothing is
	// known about pins
	Pins() []GPIOPin

	// Return logical pin for physical pin number. Returns
	// GPIO_PIN_NONE where there is no logical pin at that position
	// or we don't now about the physical pins
	PhysicalPin(uint) GPIOPin

	// Return physical pin number for logical pin. Returns 0 where there
	// is no physical pin for this logical pin, or we don't know anything
	// about the layout
	PhysicalPinForPin(GPIOPin) uint

	// Read pin state
	ReadPin(GPIOPin) GPIOState

	// Write pin state
	WritePin(GPIOPin, GPIOState)

	// Get pin mode
	GetPinMode(GPIOPin) GPIOMode

	// Set pin mode
	SetPinMode(GPIOPin, GPIOMode)

	// Set pull mode to pull down or pull up - will
	// return ErrNotImplemented if not supported
	SetPullMode(GPIOPin, GPIOPull) error

	// Start watching for rising and/or falling edge,
	// or stop watching when GPIO_EDGE_NONE is passed.
	// Will return ErrNotImplemented if not supported
	Watch(GPIOPin, GPIOEdge) error

	// Implements gopi.Unit
	Unit
}

GPIO implements the GPIO interface for simple input and output

type GPIOEdge added in v2.0.2

type GPIOEdge uint8

GPIOEdge is a rising or falling edge

const (
	GPIO_EDGE_NONE GPIOEdge = iota
	GPIO_EDGE_RISING
	GPIO_EDGE_FALLING
	GPIO_EDGE_BOTH
)

func (GPIOEdge) String added in v2.0.2

func (e GPIOEdge) String() string

type GPIOMode added in v2.0.2

type GPIOMode uint8

GPIOMode is the GPIO Pin mode

const (
	// Set pin mode and/or function
	GPIO_INPUT GPIOMode = iota
	GPIO_OUTPUT
	GPIO_ALT5
	GPIO_ALT4
	GPIO_ALT0
	GPIO_ALT1
	GPIO_ALT2
	GPIO_ALT3
	GPIO_NONE
)

func (GPIOMode) String added in v2.0.2

func (m GPIOMode) String() string

type GPIOPin added in v2.0.2

type GPIOPin uint8

GPIOPin is the logical GPIO pin

const (
	// Invalid pin constant
	GPIO_PIN_NONE GPIOPin = 0xFF
)

func (GPIOPin) String added in v2.0.2

func (p GPIOPin) String() string

type GPIOPull added in v2.0.2

type GPIOPull uint8

GPIOPull is the GPIO Pin resistor configuration (pull up/down or floating)

const (
	GPIO_PULL_OFF GPIOPull = iota
	GPIO_PULL_DOWN
	GPIO_PULL_UP
)

func (GPIOPull) String added in v2.0.2

func (p GPIOPull) String() string

type GPIOState added in v2.0.2

type GPIOState uint8

GPIOState is the GPIO Pin state

const (
	GPIO_LOW GPIOState = iota
	GPIO_HIGH
)

func (GPIOState) String added in v2.0.2

func (s GPIOState) String() string

type I2C added in v2.0.2

type I2C interface {

	// Set current slave address
	SetSlave(uint8) error

	// Get current slave address
	GetSlave() uint8

	// Return true if a slave was detected at a particular address
	DetectSlave(uint8) (bool, error)

	// Read Byte (8-bits), Word (16-bits) & Block ([]byte) from registers
	ReadUint8(reg uint8) (uint8, error)
	ReadInt8(reg uint8) (int8, error)
	ReadUint16(reg uint8) (uint16, error)
	ReadInt16(reg uint8) (int16, error)
	ReadBlock(reg, length uint8) ([]byte, error)

	// Write Byte (8-bits) & Word (16-bits) to registers
	WriteUint8(reg, value uint8) error
	WriteInt8(reg uint8, value int8) error
	WriteUint16(reg uint8, value uint16) error
	WriteInt16(reg uint8, value int16) error

	// Implements gopi.Unit
	Unit
}

I2C implements the I2C interface for sensors, etc.

type InputDevice added in v2.0.5

type InputDevice interface {
	// Name returns the name of the device
	Name() string

	// Id returns a unique ID for the device
	Id() uint

	// Returns the file descriptor for the device, or zero
	Fd() uintptr

	// Type returns the type of input device
	Type() InputDeviceType

	// KeyState indicates keyboard state when a modififer key is pressed or locked
	KeyState() KeyState

	// Position returns the absolute position for the device
	// (if mouse, joystick or touchscreen)
	Position() Point

	// SetPosition sets the absolute position for the device
	SetPosition(Point)

	// Matches returns true if a device has specific capabilities or name
	Matches(name string, flags InputDeviceType) bool
}

InputDevice represents a keyboard, mouse, touchscreen, etc.

type InputDeviceType added in v2.0.5

type InputDeviceType uint8

InputDeviceType is one or more of keyboard, mouse, touchscreen, etc

const (
	INPUT_TYPE_NONE        InputDeviceType = 0x00
	INPUT_TYPE_KEYBOARD    InputDeviceType = 0x01
	INPUT_TYPE_MOUSE       InputDeviceType = 0x02
	INPUT_TYPE_TOUCHSCREEN InputDeviceType = 0x04
	INPUT_TYPE_JOYSTICK    InputDeviceType = 0x08
	INPUT_TYPE_REMOTE      InputDeviceType = 0x10
	INPUT_TYPE_ANY         InputDeviceType = 0xFF
)

Types of input device

func (InputDeviceType) String added in v2.0.5

func (t InputDeviceType) String() string

type InputEvent added in v2.0.16

type InputEvent interface {
	// Return device which is emitting the event
	Device() InputDevice

	// Type of event
	Type() InputEventType

	// KeyCode returned when a key press event
	KeyCode() KeyCode

	// KeyState returned when a key press event
	KeyState() KeyState

	// ScanCode returned when a key press event
	ScanCode() uint32

	// Abs returns absolute input position
	Abs() Point

	// Rel returns relative input position
	Rel() Point

	// Implements gopi.Event
	Event
}

type InputEventType added in v2.0.16

type InputEventType uint16

Type of input event

const (
	INPUT_EVENT_NONE          InputEventType = 0x0000
	INPUT_EVENT_KEYPRESS      InputEventType = 0x0001
	INPUT_EVENT_KEYRELEASE    InputEventType = 0x0002
	INPUT_EVENT_KEYREPEAT     InputEventType = 0x0003
	INPUT_EVENT_ABSPOSITION   InputEventType = 0x0004
	INPUT_EVENT_RELPOSITION   InputEventType = 0x0005
	INPUT_EVENT_TOUCHPRESS    InputEventType = 0x0006
	INPUT_EVENT_TOUCHRELEASE  InputEventType = 0x0007
	INPUT_EVENT_TOUCHPOSITION InputEventType = 0x0008
)

Input events

func (InputEventType) String added in v2.0.16

func (e InputEventType) String() string

type InputManager added in v2.0.5

type InputManager interface {

	// Open Devices by name and/or type and return a list of opened devices
	OpenDevicesByNameType(name string, flags InputDeviceType, exclusive bool) ([]InputDevice, error)

	// Open an input device, and 'grab' exclusively
	OpenDevice(bus uint, exclusive bool) (InputDevice, error)

	// Close an input device
	CloseDevice(InputDevice) error

	// Implements gopi.Unit
	Unit
}

InputManager manages all input devices

type KeyAction added in v2.0.16

type KeyAction uint32

Key Code

const (
	KEYACTION_KEY_UP KeyAction = iota
	KEYACTION_KEY_DOWN
	KEYACTION_KEY_REPEAT
	KEYACTION_NONE
)

Key actions

func (KeyAction) String added in v2.0.16

func (k KeyAction) String() string

type KeyCode added in v2.0.5

type KeyCode uint16

Key Code

const (
	KEYCODE_NONE             KeyCode = 0x0000
	KEYCODE_ESC              KeyCode = 0x0001
	KEYCODE_1                KeyCode = 0x0002
	KEYCODE_2                KeyCode = 0x0003
	KEYCODE_3                KeyCode = 0x0004
	KEYCODE_4                KeyCode = 0x0005
	KEYCODE_5                KeyCode = 0x0006
	KEYCODE_6                KeyCode = 0x0007
	KEYCODE_7                KeyCode = 0x0008
	KEYCODE_8                KeyCode = 0x0009
	KEYCODE_9                KeyCode = 0x000A
	KEYCODE_0                KeyCode = 0x000B
	KEYCODE_MINUS            KeyCode = 0x000C
	KEYCODE_EQUAL            KeyCode = 0x000D
	KEYCODE_BACKSPACE        KeyCode = 0x000E
	KEYCODE_TAB              KeyCode = 0x000F
	KEYCODE_Q                KeyCode = 0x0010
	KEYCODE_W                KeyCode = 0x0011
	KEYCODE_E                KeyCode = 0x0012
	KEYCODE_R                KeyCode = 0x0013
	KEYCODE_T                KeyCode = 0x0014
	KEYCODE_Y                KeyCode = 0x0015
	KEYCODE_U                KeyCode = 0x0016
	KEYCODE_I                KeyCode = 0x0017
	KEYCODE_O                KeyCode = 0x0018
	KEYCODE_P                KeyCode = 0x0019
	KEYCODE_LEFTBRACE        KeyCode = 0x001A
	KEYCODE_RIGHTBRACE       KeyCode = 0x001B
	KEYCODE_ENTER            KeyCode = 0x001C
	KEYCODE_LEFTCTRL         KeyCode = 0x001D
	KEYCODE_A                KeyCode = 0x001E
	KEYCODE_S                KeyCode = 0x001F
	KEYCODE_D                KeyCode = 0x0020
	KEYCODE_F                KeyCode = 0x0021
	KEYCODE_G                KeyCode = 0x0022
	KEYCODE_H                KeyCode = 0x0023
	KEYCODE_J                KeyCode = 0x0024
	KEYCODE_K                KeyCode = 0x0025
	KEYCODE_L                KeyCode = 0x0026
	KEYCODE_SEMICOLON        KeyCode = 0x0027
	KEYCODE_APOSTROPHE       KeyCode = 0x0028
	KEYCODE_GRAVE            KeyCode = 0x0029
	KEYCODE_LEFTSHIFT        KeyCode = 0x002A
	KEYCODE_BACKSLASH        KeyCode = 0x002B
	KEYCODE_Z                KeyCode = 0x002C
	KEYCODE_X                KeyCode = 0x002D
	KEYCODE_C                KeyCode = 0x002E
	KEYCODE_V                KeyCode = 0x002F
	KEYCODE_B                KeyCode = 0x0030
	KEYCODE_N                KeyCode = 0x0031
	KEYCODE_M                KeyCode = 0x0032
	KEYCODE_COMMA            KeyCode = 0x0033
	KEYCODE_DOT              KeyCode = 0x0034
	KEYCODE_SLASH            KeyCode = 0x0035
	KEYCODE_RIGHTSHIFT       KeyCode = 0x0036
	KEYCODE_KPASTERISK       KeyCode = 0x0037
	KEYCODE_LEFTALT          KeyCode = 0x0038
	KEYCODE_SPACE            KeyCode = 0x0039
	KEYCODE_CAPSLOCK         KeyCode = 0x003A
	KEYCODE_F1               KeyCode = 0x003B
	KEYCODE_F2               KeyCode = 0x003C
	KEYCODE_F3               KeyCode = 0x003D
	KEYCODE_F4               KeyCode = 0x003E
	KEYCODE_F5               KeyCode = 0x003F
	KEYCODE_F6               KeyCode = 0x0040
	KEYCODE_F7               KeyCode = 0x0041
	KEYCODE_F8               KeyCode = 0x0042
	KEYCODE_F9               KeyCode = 0x0043
	KEYCODE_F10              KeyCode = 0x0044
	KEYCODE_NUMLOCK          KeyCode = 0x0045
	KEYCODE_SCROLLLOCK       KeyCode = 0x0046
	KEYCODE_KP7              KeyCode = 0x0047
	KEYCODE_KP8              KeyCode = 0x0048
	KEYCODE_KP9              KeyCode = 0x0049
	KEYCODE_KPMINUS          KeyCode = 0x004A
	KEYCODE_KP4              KeyCode = 0x004B
	KEYCODE_KP5              KeyCode = 0x004C
	KEYCODE_KP6              KeyCode = 0x004D
	KEYCODE_KPPLUS           KeyCode = 0x004E
	KEYCODE_KP1              KeyCode = 0x004F
	KEYCODE_KP2              KeyCode = 0x0050
	KEYCODE_KP3              KeyCode = 0x0051
	KEYCODE_KP0              KeyCode = 0x0052
	KEYCODE_KPDOT            KeyCode = 0x0053
	KEYCODE_F11              KeyCode = 0x0057
	KEYCODE_F12              KeyCode = 0x0058
	KEYCODE_KPENTER          KeyCode = 0x0060
	KEYCODE_RIGHTCTRL        KeyCode = 0x0061
	KEYCODE_KPSLASH          KeyCode = 0x0062
	KEYCODE_SYSRQ            KeyCode = 0x0063
	KEYCODE_RIGHTALT         KeyCode = 0x0064
	KEYCODE_LINEFEED         KeyCode = 0x0065
	KEYCODE_HOME             KeyCode = 0x0066
	KEYCODE_UP               KeyCode = 0x0067
	KEYCODE_PAGEUP           KeyCode = 0x0068
	KEYCODE_LEFT             KeyCode = 0x0069
	KEYCODE_RIGHT            KeyCode = 0x006A
	KEYCODE_END              KeyCode = 0x006B
	KEYCODE_DOWN             KeyCode = 0x006C
	KEYCODE_PAGEDOWN         KeyCode = 0x006D
	KEYCODE_INSERT           KeyCode = 0x006E
	KEYCODE_DELETE           KeyCode = 0x006F
	KEYCODE_MACRO            KeyCode = 0x0070
	KEYCODE_MUTE             KeyCode = 0x0071
	KEYCODE_VOLUMEDOWN       KeyCode = 0x0072
	KEYCODE_VOLUMEUP         KeyCode = 0x0073
	KEYCODE_POWER            KeyCode = 0x0074
	KEYCODE_KPEQUAL          KeyCode = 0x0075
	KEYCODE_KPPLUSMINUS      KeyCode = 0x0076
	KEYCODE_KPCOMMA          KeyCode = 0x0079
	KEYCODE_LEFTMETA         KeyCode = 0x007D
	KEYCODE_RIGHTMETA        KeyCode = 0x007E
	KEYCODE_SLEEP            KeyCode = 0x008E
	KEYCODE_WAKEUP           KeyCode = 0x008F
	KEYCODE_KPLEFTPAREN      KeyCode = 0x00B3
	KEYCODE_KPRIGHTPAREN     KeyCode = 0x00B4
	KEYCODE_F13              KeyCode = 0x00B7
	KEYCODE_F14              KeyCode = 0x00B8
	KEYCODE_F15              KeyCode = 0x00B9
	KEYCODE_F16              KeyCode = 0x00BA
	KEYCODE_F17              KeyCode = 0x00BB
	KEYCODE_F18              KeyCode = 0x00BC
	KEYCODE_F19              KeyCode = 0x00BD
	KEYCODE_F20              KeyCode = 0x00BE
	KEYCODE_F21              KeyCode = 0x00BF
	KEYCODE_F22              KeyCode = 0x00C0
	KEYCODE_F23              KeyCode = 0x00C1
	KEYCODE_F24              KeyCode = 0x00C2
	KEYCODE_CLOSE            KeyCode = 0x00CE
	KEYCODE_PLAY             KeyCode = 0x00CF
	KEYCODE_PRINT            KeyCode = 0x00D2
	KEYCODE_SEARCH           KeyCode = 0x00D9
	KEYCODE_CANCEL           KeyCode = 0x00DF
	KEYCODE_BRIGHTNESS_DOWN  KeyCode = 0x00E0
	KEYCODE_BRIGHTNESS_UP    KeyCode = 0x00E1
	KEYCODE_BRIGHTNESS_CYCLE KeyCode = 0x00F3
	KEYCODE_BRIGHTNESS_AUTO  KeyCode = 0x00F4
	KEYCODE_MAX              KeyCode = 0x02FF
)
const (
	KEYCODE_BTN0      KeyCode = 0x0100
	KEYCODE_BTN1      KeyCode = 0x0101
	KEYCODE_BTN2      KeyCode = 0x0102
	KEYCODE_BTN3      KeyCode = 0x0103
	KEYCODE_BTN4      KeyCode = 0x0104
	KEYCODE_BTN5      KeyCode = 0x0105
	KEYCODE_BTN6      KeyCode = 0x0106
	KEYCODE_BTN7      KeyCode = 0x0107
	KEYCODE_BTN8      KeyCode = 0x0108
	KEYCODE_BTN9      KeyCode = 0x0109
	KEYCODE_BTNLEFT   KeyCode = 0x0110
	KEYCODE_BTNRIGHT  KeyCode = 0x0111
	KEYCODE_BTNMIDDLE KeyCode = 0x0112
	KEYCODE_BTNSIDE   KeyCode = 0x0113
	KEYCODE_BTNEXTRA  KeyCode = 0x0114
	KEYCODE_BTNTOUCH  KeyCode = 0x014A
)

func (KeyCode) String added in v2.0.5

func (k KeyCode) String() string

type KeyState added in v2.0.5

type KeyState uint16

Key State

const (
	KEYSTATE_NONE       KeyState = 0x0000
	KEYSTATE_SCROLLLOCK KeyState = 0x0001 // Scroll Lock
	KEYSTATE_NUMLOCK    KeyState = 0x0002 // Num Lock
	KEYSTATE_CAPSLOCK   KeyState = 0x0004 // Caps Lock
	KEYSTATE_LEFTSHIFT  KeyState = 0x0010 // Left Shift
	KEYSTATE_RIGHTSHIFT KeyState = 0x0020 // Right Shift
	KEYSTATE_SHIFT      KeyState = 0x0030 // Either Shift
	KEYSTATE_LEFTALT    KeyState = 0x0040 // Left Alt
	KEYSTATE_RIGHTALT   KeyState = 0x0080 // Right Alt
	KEYSTATE_ALT        KeyState = 0x00C0 // Either Alt
	KEYSTATE_LEFTMETA   KeyState = 0x0100 // Left Meta/Command
	KEYSTATE_RIGHTMETA  KeyState = 0x0200 // Right Meta/Command
	KEYSTATE_META       KeyState = 0x0300 // Either Meta/Command
	KEYSTATE_LEFTCTRL   KeyState = 0x0400 // Left Control
	KEYSTATE_RIGHTCTRL  KeyState = 0x0800 // Right Control
	KEYSTATE_CTRL       KeyState = 0x0C00 // Either Control

	KEYSTATE_MASK KeyState = 0x0CFF // Bitmask
	KEYSTATE_MIN  KeyState = KEYSTATE_SCROLLLOCK
	KEYSTATE_MAX  KeyState = KEYSTATE_CTRL // Maximum
)

Key state

func (KeyState) String added in v2.0.16

func (s KeyState) String() string

func (KeyState) StringFlag added in v2.0.16

func (s KeyState) StringFlag() string

type LIRC added in v2.0.2

type LIRC interface {
	// Get receive and send modes
	RcvMode() LIRCMode
	SendMode() LIRCMode
	SetRcvMode(mode LIRCMode) error
	SetSendMode(mode LIRCMode) error

	// Receive parameters
	RcvDutyCycle() uint32
	RcvResolutionMicros() uint32

	// Receive parameters
	SetRcvTimeout(micros uint32) error
	SetRcvTimeoutReports(enable bool) error
	SetRcvCarrierHz(value uint32) error
	SetRcvCarrierRangeHz(min uint32, max uint32) error

	// Send parameters
	SendDutyCycle() uint32
	SetSendCarrierHz(value uint32) error
	SetSendDutyCycle(value uint32) error

	// Send Pulse Mode, values are in milliseconds
	PulseSend(values []uint32) error

	// Implements gopi.Unit
	Unit
}

LIRC implements the IR send & receive interface

type LIRCEvent added in v2.0.5

type LIRCEvent interface {
	Type() LIRCType // Type of event
	Mode() LIRCMode // Mode of receiving data

	// Implements gopi.Event methods
	Event
}

LIRCEvent emitted on the event bus

type LIRCMode added in v2.0.2

type LIRCMode uint32

LIRCMode is the LIRC Mode

const (
	LIRC_MODE_NONE     LIRCMode = 0x00000000
	LIRC_MODE_RAW      LIRCMode = 0x00000001
	LIRC_MODE_PULSE    LIRCMode = 0x00000002 // send only
	LIRC_MODE_MODE2    LIRCMode = 0x00000004 // rcv only
	LIRC_MODE_LIRCCODE LIRCMode = 0x00000010 // rcv only
	LIRC_MODE_MAX      LIRCMode = LIRC_MODE_LIRCCODE
)

func (LIRCMode) String added in v2.0.2

func (m LIRCMode) String() string

type LIRCType added in v2.0.2

type LIRCType uint32

LIRCType is the LIRC Type

const (
	LIRC_TYPE_SPACE     LIRCType = 0x00000000
	LIRC_TYPE_PULSE     LIRCType = 0x01000000
	LIRC_TYPE_FREQUENCY LIRCType = 0x02000000
	LIRC_TYPE_TIMEOUT   LIRCType = 0x03000000
	LIRC_TYPE_MAX       LIRCType = LIRC_TYPE_TIMEOUT
)

func (LIRCType) String added in v2.0.2

func (t LIRCType) String() string

type Logger

type Logger interface {
	Unit

	// Name returns the name of the logger
	Name() string

	// Clone returns a new logger with a different name
	Clone(string) Logger

	// Error logs an error, and returns an error with the name prefixed
	Error(error) error

	// Warn outputs informational message with warning severity
	Warn(args ...interface{})

	// Info outputs informational message
	Info(args ...interface{})

	// Debug will log a debug message when debugging is on
	Debug(args ...interface{})

	// IsDebug returns true if debugging is enabled
	IsDebug() bool
}

Abstract logging interface

type MainCommandFunc

type MainCommandFunc func(App, []string) error

MainCommandFunc is the main handler for command line tool

type MainTestFunc added in v2.0.2

type MainTestFunc func(App, *testing.T)

MainTestFunc is the main handler for a testing tool

type NewFunc added in v2.0.2

type NewFunc func(App) (Unit, error)

type PWM added in v2.0.2

type PWM interface {
	// Return array of pins which are enabled for PWM
	Pins() []GPIOPin

	// Period
	Period(GPIOPin) (time.Duration, error)
	SetPeriod(time.Duration, ...GPIOPin) error

	// Duty Cycle between 0.0 and 1.0 (0.0 is always off, 1.0 is always on)
	DutyCycle(GPIOPin) (float32, error)
	SetDutyCycle(float32, ...GPIOPin) error

	// Implements gopi.Unit
	Unit
}

PWM implements the PWM interface for actuators, motors, etc.

type Platform added in v2.0.2

type Platform interface {

	// Product returns product name
	Product() string

	// Type returns flags identifying platform type
	Type() PlatformType

	// SerialNumber returns unique serial number for host
	SerialNumber() string

	// Uptime returns uptime for host
	Uptime() time.Duration

	// LoadAverages returns 1, 5 and 15 minute load averages
	LoadAverages() (float64, float64, float64)

	// NumberOfDisplays returns the number of possible displays for this host
	NumberOfDisplays() uint

	// AttachedDisplays returns array of displays which are actually attached
	AttachedDisplays() []uint

	// Implements gopi.Unit
	Unit
}

type PlatformType added in v2.0.2

type PlatformType uint32
const (
	PLATFORM_NONE PlatformType = 0
	// OS
	PLATFORM_DARWIN PlatformType = (1 << iota) >> 1
	PLATFORM_RPI
	PLATFORM_LINUX
	// CPU
	PLATFORM_X86_32
	PLATFORM_X86_64
	PLATFORM_BCM2835_ARM6
	PLATFORM_BCM2836_ARM7
	PLATFORM_BCM2837_ARM8
	PLATFORM_BCM2838_ARM8
	// MIN AND MAX
	PLATFORM_MIN = PLATFORM_DARWIN
	PLATFORM_MAX = PLATFORM_BCM2838_ARM8
)

func (PlatformType) FlagString added in v2.0.2

func (p PlatformType) FlagString() string

func (PlatformType) String added in v2.0.2

func (p PlatformType) String() string

type Point added in v2.0.5

type Point struct {
	X, Y float32
}

func (Point) Equals added in v2.0.5

func (p1 Point) Equals(p2 Point) bool

func (Point) String added in v2.0.5

func (p Point) String() string

type PubSub added in v2.0.27

type PubSub interface {
	Unit

	// Emit sends values to be received by handlers
	Emit(value interface{})

	// Subscribe and handle messages which are emitted
	Subscribe() <-chan interface{}

	// Unsubscribe from a channel
	Unsubscribe(<-chan interface{})
}

Publisher/Subscriber interface for arbitary messages

type Publisher added in v2.0.2

type Publisher interface {
	// Emit sends values to be received by handlers
	Emit(queue uint, value interface{})

	// Subscribe and handle messages which are emitted
	Subscribe(queue uint, callback func(value interface{})) Channel

	// Unsubscribe from a channel
	Unsubscribe(Channel)
}

Publisher interface for Emit/Receive mechanism for arbitary messages

type RPCClientConn added in v2.0.13

type RPCClientConn interface {
	// Return connection information, or nil if not connected
	Addr() string

	// Return service names supported by connection
	Services() ([]string, error)

	// Mutex locking to ensure one request at a time
	Lock()
	Unlock()

	// Implements gopi.Unit
	Unit
}

RPCClientConn implements a single client connection for communicating with an RPC server

type RPCClientPool added in v2.0.12

type RPCClientPool interface {
	// Lookup service records by parameter - returns records
	// which match either a service name up to max number of
	// records (or zero for unlimited). Will wait for new records
	// and block until cancelled
	Lookup(ctx context.Context, addr string, max uint) ([]RPCServiceRecord, error)

	// Connect to service by service record
	Connect(RPCServiceRecord, RPCFlag) (RPCClientConn, error)

	// Connect to service by address and port
	ConnectAddr(net.IP, uint16) (RPCClientConn, error)

	// Connect to service by unix socket
	ConnectFifo(string) (RPCClientConn, error)

	// Disconnect from service
	Disconnect(RPCClientConn) error

	// Create a client stub for a connection given a service name
	CreateStub(string, RPCClientConn) RPCClientStub

	// Implements gopi.Unit
	Unit
}

RPCClientPool represents a pool of clients and connections to remove services

type RPCClientStub added in v2.0.24

type RPCClientStub interface {
	// Return the connection associated with the client
	Conn() RPCClientConn

	// Implements gopi.Unit
	Unit
}

type RPCEvent added in v2.0.2

type RPCEvent interface {
	// Type of event
	Type() RPCEventType

	// Service record associated with event
	Service() RPCServiceRecord

	// Time-to-live value for event
	TTL() time.Duration

	// Implements gopi.Event
	Event
}

RPCEvent is emitted on service discovery and server events

type RPCEventType added in v2.0.2

type RPCEventType uint // RPCEventType is an enumeration of event types
const (
	RPC_EVENT_NONE            RPCEventType = iota
	RPC_EVENT_SERVER_STARTED               // RPC Server started
	RPC_EVENT_SERVER_STOPPED               // RPC Server stopped
	RPC_EVENT_SERVICE_ADDED                // Service instance lookup (new)
	RPC_EVENT_SERVICE_UPDATED              // Service instance lookup (updated)
	RPC_EVENT_SERVICE_REMOVED              // Service instance lookup (removed)
	RPC_EVENT_SERVICE_EXPIRED              // Service instance lookup (expired)
	RPC_EVENT_SERVICE_NAME                 // Service name discovered
	RPC_EVENT_SERVICE_RECORD               // Service record lookup
	RPC_EVENT_CLIENT_CONNECTED
	RPC_EVENT_CLIENT_DISCONNECTED
	RPC_EVENT_MAX = RPC_EVENT_CLIENT_DISCONNECTED
)

func (RPCEventType) String added in v2.0.2

func (t RPCEventType) String() string

type RPCFlag added in v2.0.2

type RPCFlag uint // RPCFlag is a set of flags modifying behavior
const (
	RPC_FLAG_NONE          RPCFlag = 0
	RPC_FLAG_INET_UDP      RPCFlag = (1 << iota) >> 1 // Use UDP protocol (TCP assumed otherwise)
	RPC_FLAG_INET_V4                                  // Use V4 addressing
	RPC_FLAG_INET_V6                                  // Use V6 addressing
	RPC_FLAG_SERVICE_FIRST                            // Use first service
	RPC_FLAG_SERVICE_ANY                              // Use any service
	RPC_FLAG_MIN           = RPC_FLAG_INET_UDP
	RPC_FLAG_MAX           = RPC_FLAG_SERVICE_ANY
)

func (RPCFlag) FlagString added in v2.0.2

func (v RPCFlag) FlagString() string

func (RPCFlag) String added in v2.0.2

func (f RPCFlag) String() string

type RPCServer added in v2.0.6

type RPCServer interface {
	// Start an RPC server in currently running thread.
	// The method will not return until Stop is called
	// which needs to be done in a different thread
	Start() error

	// Stop RPC server. If halt is true then it immediately
	// ends the server without waiting for current requests to
	// be served
	Stop(halt bool) error

	// Return address the server is bound to, or nil if
	// the server is not running
	Addr() net.Addr

	// Implements gopi.Unit
	Unit
}

RPCServer serves requests for one or more services

type RPCService added in v2.0.9

type RPCService interface {
	// CancelRequests is called by the server to gracefully end any
	// on-going streaming requests, but before the service is shutdown
	CancelRequests() error

	// Implements gopi.Unit
	Unit
}

RPCService is a driver which implements all the necessary methods to handle remote calls

type RPCServiceDiscovery added in v2.0.2

type RPCServiceDiscovery interface {
	// Lookup service instances by name
	Lookup(ctx context.Context, service string) ([]RPCServiceRecord, error)

	// Return list of service names
	EnumerateServices(ctx context.Context) ([]string, error)

	// Implements gopi.Unit
	Unit
}

RPCServiceDiscovery will lookup services and classes of service

type RPCServiceRecord added in v2.0.2

type RPCServiceRecord struct {
	Name    string
	Service string
	Host    string
	Port    uint16
	Addrs   []net.IP
	Txt     []string
}

RPCServiceRecord defines a service which can be registered or discovered on the network

func (RPCServiceRecord) String added in v2.0.2

func (this RPCServiceRecord) String() string

type RPCServiceRegister added in v2.0.2

type RPCServiceRegister interface {
	// Register service record, and de-register when deadline is exceeded
	Register(ctx context.Context, record RPCServiceRecord) error

	// Implements gopi.Unit
	Unit
}

RPCServiceRegister will register services

type RunFunc added in v2.0.14

type RunFunc func(App, Unit) error

type SPI added in v2.0.2

type SPI interface {
	// Get SPI mode
	Mode() SPIMode
	// Get SPI speed
	MaxSpeedHz() uint32
	// Get Bits Per Word
	BitsPerWord() uint8
	// Set SPI mode
	SetMode(SPIMode) error
	// Set SPI speed
	SetMaxSpeedHz(uint32) error
	// Set Bits Per Word
	SetBitsPerWord(uint8) error

	// Read/Write
	Transfer(send []byte) ([]byte, error)

	// Read
	Read(len uint32) ([]byte, error)

	// Write
	Write(send []byte) error

	// Implements gopi.Unit
	Unit
}

SPI implements the SPI interface for sensors, etc.

type SPIMode added in v2.0.2

type SPIMode uint8

SPIMode is the SPI Mode

const (
	SPI_MODE_CPHA SPIMode = 0x01
	SPI_MODE_CPOL SPIMode = 0x02
	SPI_MODE_0    SPIMode = 0x00
	SPI_MODE_1    SPIMode = (0x00 | SPI_MODE_CPHA)
	SPI_MODE_2    SPIMode = (SPI_MODE_CPOL | 0x00)
	SPI_MODE_3    SPIMode = (SPI_MODE_CPOL | SPI_MODE_CPHA)
	SPI_MODE_NONE SPIMode = 0xFF
)

func (SPIMode) String added in v2.0.2

func (m SPIMode) String() string

type Size added in v2.0.5

type Size struct {
	W, H float32
}

func (Size) String added in v2.0.5

func (s Size) String() string

type StubFunc added in v2.0.24

type StubFunc func(RPCClientConn) (RPCClientStub, error)

type Surface added in v2.0.5

type Surface interface {
	Type() SurfaceFlags
	Size() Size
	Origin() Point
	Opacity() float32
	Layer() uint16
	Bitmap() Bitmap
}

Surface defines an on-screen rectanglar surface

type SurfaceCallback added in v2.0.5

type SurfaceCallback func() error

SurfaceCallback

type SurfaceFlags added in v2.0.5

type SurfaceFlags uint16

SurfaceFlags are flags associated with surface

const (
	// SurfaceFlags - surface binding
	SURFACE_FLAG_NONE       SurfaceFlags = 0x0000
	SURFACE_FLAG_BITMAP     SurfaceFlags = 0x0001 // Bitmap
	SURFACE_FLAG_OPENGL     SurfaceFlags = 0x0002
	SURFACE_FLAG_OPENGL_ES  SurfaceFlags = 0x0003
	SURFACE_FLAG_OPENGL_ES2 SurfaceFlags = 0x0004
	SURFACE_FLAG_OPENVG     SurfaceFlags = 0x0005 // 2D Vector
	SURFACE_FLAG_TYPEMASK   SurfaceFlags = 0x000F
	// SurfaceFlags - surface configuration
	SURFACE_FLAG_RGBA32     SurfaceFlags = 0x0000 // 4 bytes per pixel
	SURFACE_FLAG_RGB888     SurfaceFlags = 0x0010 // 3 bytes per pixel
	SURFACE_FLAG_RGB565     SurfaceFlags = 0x0020 // 2 bytes per pixel
	SURFACE_FLAG_CONFIGMASK SurfaceFlags = 0x00F0
	// SurfaceFlags - modifiers
	SURFACE_FLAG_ALPHA_FROM_SOURCE SurfaceFlags = 0x0100
	SURFACE_FLAG_MODMASK           SurfaceFlags = 0x0F00
)

func (SurfaceFlags) Config added in v2.0.5

func (f SurfaceFlags) Config() SurfaceFlags

Config returns the configuration of the surface

func (SurfaceFlags) ConfigString added in v2.0.5

func (f SurfaceFlags) ConfigString() string

func (SurfaceFlags) Mod added in v2.0.5

func (f SurfaceFlags) Mod() SurfaceFlags

Mod returns surface modifiers

func (SurfaceFlags) ModString added in v2.0.5

func (f SurfaceFlags) ModString() string

func (SurfaceFlags) String added in v2.0.5

func (f SurfaceFlags) String() string

func (SurfaceFlags) Type added in v2.0.5

func (f SurfaceFlags) Type() SurfaceFlags

Type returns the type of the surface

func (SurfaceFlags) TypeString added in v2.0.5

func (f SurfaceFlags) TypeString() string

type SurfaceManager added in v2.0.5

type SurfaceManager interface {
	// Return the display associated with the surface manager
	Display() Display

	// Return the name of the surface manager
	Name() string

	// Return capabilities for the GPU
	Types() []SurfaceFlags

	// Do CreateSurface, updates and drawing within this method
	Do(SurfaceCallback) error

	// Create and destroy surfaces
	CreateSurfaceWithBitmap(Bitmap, SurfaceFlags, float32, uint16, Point, Size) (Surface, error)
	CreateSurface(SurfaceFlags, float32, uint16, Point, Size) (Surface, error)
	CreateBackground(SurfaceFlags, float32) (Surface, error)
	DestroySurface(Surface) error

	// Create and destroy bitmaps
	CreateBitmap(SurfaceFlags, Size) (Bitmap, error)
	CreateSnapshot(SurfaceFlags) (Bitmap, error)
	DestroyBitmap(Bitmap) error

	// Implements gopi.Unit
	Unit
}

SurfaceManager allows you to open, close and move surfaces around an open display

type Timer

type Timer interface {
	Unit

	NewTicker(time.Duration) EventId // Create periodic event at interval
	NewTimer(time.Duration) EventId  // Create one-shot event after interval
	Cancel(EventId) error            // Cancel events
}

Timer unit - sends out messages on the event bus

type Unit

type Unit interface {
	Close() error   // Close closes the driver and frees the underlying resources
	String() string // String returns a string representation of the unit
}

Unit interface

func New

func New(config Config, log Logger) (Unit, error)

type UnitConfig

type UnitConfig struct {
	Name     string     // Unique name of the unit
	Type     UnitType   // Unit type
	Requires []string   // Unit dependencies
	Pri      uint       // Priority when more than one unit of the same type
	Config   ConfigFunc // ConfigFunc is called to add configuration to the app
	New      NewFunc    // NewFunc is called to create a unit instance
	Run      RunFunc    // RunFunc is called once all unit instances have been created
	Stub     StubFunc   // StubFunc is called on RPC Clients to create a client stub
	// contains filtered or unexported fields
}

func UnitWithDependencies added in v2.0.2

func UnitWithDependencies(unitNames ...string) ([]*UnitConfig, error)

UnitWithDependencies returns units with all dependencies satisfied in reverse order of when they need to be configured and initialized

func UnitsByName

func UnitsByName(unitName string) []*UnitConfig

func UnitsByPri added in v2.0.17

func UnitsByPri(units []*UnitConfig) []*UnitConfig

UnitsByPri returns all units if all 'Pri' fields are set to zero, or will return the highest numbered 'Pri' unit otherwise

func UnitsByType

func UnitsByType(unitType UnitType) []*UnitConfig

func (UnitConfig) String

func (u UnitConfig) String() string

type UnitType

type UnitType uint
const (
	UNIT_NONE UnitType = iota
	UNIT_LOGGER
	UNIT_TIMER
	UNIT_BUS
	UNIT_PLATFORM
	UNIT_DISPLAY
	UNIT_I2C
	UNIT_LIRC
	UNIT_GPIO
	UNIT_SPI
	UNIT_FONT_MANAGER
	UNIT_SURFACE_MANAGER
	UNIT_INPUT_MANAGER
	UNIT_RPC_DISCOVERY
	UNIT_RPC_REGISTER
	UNIT_RPC_SERVER
	UNIT_RPC_SERVICE
	UNIT_RPC_CLIENT
	UNIT_RPC_CLIENTPOOL
	UNIT_MAX = UNIT_PLATFORM
)

func (UnitType) String

func (v UnitType) String() string

Jump to

Keyboard shortcuts

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