Documentation
¶
Index ¶
- Constants
- Variables
- func UnitRegister(unit UnitConfig)
- func UnitReset()
- type App
- type Bitmap
- type Bus
- type Channel
- type Color
- type CompoundError
- type Config
- type ConfigFunc
- type Display
- type Error
- type Event
- type EventHandler
- type EventHandlerFunc
- type EventId
- type EventNS
- type FilePoll
- type FilePollFlags
- type FilePollFunc
- type FlagNS
- type Flags
- type FontFace
- type FontFlags
- type FontManager
- type GPIO
- type GPIOEdge
- type GPIOMode
- type GPIOPin
- type GPIOPull
- type GPIOState
- type I2C
- type InputDevice
- type InputDeviceType
- type InputManager
- type KeyCode
- type KeyState
- type LIRC
- type LIRCEvent
- type LIRCMode
- type LIRCType
- type Logger
- type MainCommandFunc
- type MainTestFunc
- type NewFunc
- type PWM
- type Platform
- type PlatformType
- type Point
- type Publisher
- type RPCEvent
- type RPCEventType
- type RPCFlag
- type RPCServiceDiscovery
- type RPCServiceRecord
- type RPCServiceRegister
- type SPI
- type SPIMode
- type Size
- type Surface
- type SurfaceCallback
- type SurfaceFlags
- type SurfaceManager
- type Timer
- type Unit
- type UnitConfig
- type UnitType
Constants ¶
const ( // SurfaceLayer SURFACE_LAYER_BACKGROUND uint16 = 0x0000 SURFACE_LAYER_DEFAULT uint16 = 0x0001 SURFACE_LAYER_MAX uint16 = 0xFFFE SURFACE_LAYER_CURSOR uint16 = 0xFFFF )
Variables ¶
var ( ZeroPoint = Point{0, 0} ZeroSize = Size{0, 0} )
var ( ColorRed = Color{1.0, 0.0, 0.0, 1.0} ColorGreen = Color{0.0, 1.0, 0.0, 1.0} ColorBlue = Color{0.0, 0.0, 1.0, 1.0} ColorWhite = Color{1.0, 1.0, 1.0, 1.0} ColorBlack = Color{0.0, 0.0, 0.0, 1.0} ColorPurple = Color{1.0, 0.0, 1.0, 1.0} ColorCyan = Color{0.0, 1.0, 1.0, 1.0} ColorYellow = Color{1.0, 1.0, 0.0, 1.0} ColorDarkGrey = Color{0.25, 0.25, 0.25, 1.0} ColorLightGrey = Color{0.75, 0.75, 0.75, 1.0} ColorMidGrey = Color{0.5, 0.5, 0.5, 1.0} ColorTransparent = Color{} )
Standard Colors
Functions ¶
func UnitRegister ¶
func UnitRegister(unit UnitConfig)
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) }
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 Color ¶ added in v2.0.5
type Color struct {
R, G, B, A float32
}
Color including opacity
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 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) WithPrefix ¶
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
EventHandlerFunc is the handler for an emitted event, which should cancel when context.Done() signal is received
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 )
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_NONE FilePollFlags = (1 << iota) FILEPOLL_FLAG_READ FILEPOLL_FLAG_WRITE )
type FilePollFunc ¶ added in v2.0.5
type FilePollFunc func(uintptr, FilePollFlags)
FilePollFunc is the handler for file polling
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 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
func (FontFlags) StringFlag ¶ added in v2.0.5
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 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 GPIOPin ¶ added in v2.0.2
type GPIOPin uint8
GPIOPin is the logical GPIO pin
const ( // Invalid pin constant GPIO_PIN_NONE GPIOPin = 0xFF )
type GPIOPull ¶ added in v2.0.2
type GPIOPull uint8
GPIOPull is the GPIO Pin resistor configuration (pull up/down or floating)
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() string Type() InputDeviceType }
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 InputManager ¶ added in v2.0.5
type InputManager interface { // Open an input device OpenDevice(bus uint, exclusive bool) (InputDevice, error) // Close an input device CloseDevice(InputDevice) error // Implements gopi.Unit Unit }
InputManager manages all input devices
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 )
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 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 // 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 ¶
MainCommandFunc is the main handler for command line tool
type MainTestFunc ¶ added in v2.0.2
MainTestFunc is the main handler for a testing tool
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 // Implements gopi.Unit Unit }
type PlatformType ¶ added in v2.0.2
type PlatformType uint
const ( PLATFORM_NONE PlatformType = 0 PLATFORM_DARWIN PlatformType = (1 << iota) >> 1 PLATFORM_RPI PLATFORM_LINUX PLATFORM_MIN = PLATFORM_DARWIN PLATFORM_MAX = PLATFORM_LINUX )
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 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 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 }
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
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 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 )
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(SurfaceManager) 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
type UnitConfig ¶
type UnitConfig struct { Name string // Unique name of the unit Type UnitType // Unit type Requires []string // Unit dependencies Config ConfigFunc New NewFunc // 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 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_SERVICE UNIT_RPC_CLIENT UNIT_MAX = UNIT_PLATFORM )