Documentation
¶
Overview ¶
This file defines a way to register modules, which is a self-contained driver or other piece of code which is created in two phases: a configuration phase, giving the module a way to hook in the configuration into the application configuration, and a creation phase ("new") which reads the configuration and returns the driver (interface gopi.Driver)
Modules are referenced by type (there are several pre-defined types) or by name (where there is no pre-defined type), and can have dependencies on other modules.
Index ¶
- Constants
- Variables
- func CommandLineTool(config AppConfig, main_task MainTask, background_tasks ...BackgroundTask) int
- func CommandLineTool2(config AppConfig, main_task MainTask, background_tasks ...BackgroundTask2) int
- func RPCServerTool(config AppConfig, background_tasks ...BackgroundTask) int
- func RegisterModule(module Module)
- type AppConfig
- type AppInstance
- func (this *AppInstance) Close() error
- func (this *AppInstance) Debug() bool
- func (this *AppInstance) ModuleInstance(name string) Driver
- func (this *AppInstance) Run(main_task MainTask, background_tasks ...BackgroundTask) error
- func (this *AppInstance) Run2(main_task MainTask, background_tasks ...BackgroundTask2) error
- func (this *AppInstance) SendSignal() error
- func (this *AppInstance) Service() string
- func (this *AppInstance) String() string
- func (this *AppInstance) Verbose() bool
- func (this *AppInstance) WaitForSignal()
- func (this *AppInstance) WaitForSignalOrTimeout(timeout time.Duration) bool
- type AppParam
- type BackgroundTask
- type BackgroundTask2
- type Bitmap
- type Color
- type Config
- type Display
- type Driver
- type Event
- type Flags
- func (this *Flags) Args() []string
- func (this *Flags) FlagBool(name string, value bool, usage string) *bool
- func (this *Flags) FlagDuration(name string, value time.Duration, usage string) *time.Duration
- func (this *Flags) FlagFloat64(name string, value float64, usage string) *float64
- func (this *Flags) FlagInt(name string, value int, usage string) *int
- func (this *Flags) FlagString(name string, value string, usage string) *string
- func (this *Flags) FlagUint(name string, value uint, usage string) *uint
- func (this *Flags) Flags() []string
- func (this *Flags) GetBool(name string) (bool, bool)
- func (this *Flags) GetDuration(name string) (time.Duration, bool)
- func (this *Flags) GetFloat64(name string) (float64, bool)
- func (this *Flags) GetInt(name string) (int, bool)
- func (this *Flags) GetParam(key AppParam) interface{}
- func (this *Flags) GetString(name string) (string, bool)
- func (this *Flags) GetUint(name string) (uint, bool)
- func (this *Flags) GetUint16(name string) (uint16, bool)
- func (this *Flags) HasFlag(name string) bool
- func (this *Flags) Name() string
- func (this *Flags) Parse(args []string) error
- func (this *Flags) Parsed() bool
- func (this *Flags) PrintDefaults()
- func (this *Flags) PrintUsage()
- func (this *Flags) PrintVersion()
- func (this *Flags) SetBool(name string, value bool) error
- func (this *Flags) SetDuration(name string, value time.Duration) error
- func (this *Flags) SetFloat64(name string, value float64) error
- func (this *Flags) SetInt(name string, value int) error
- func (this *Flags) SetParam(key AppParam, value interface{})
- func (this *Flags) SetString(name, value string) error
- func (this *Flags) SetUint(name string, value uint) error
- func (this *Flags) SetUsageFunc(usage_func func(flags *Flags))
- func (this *Flags) String() string
- type FontFace
- type FontFlags
- type FontManager
- type GPIO
- type GPIOEdge
- type GPIOEvent
- type GPIOMode
- type GPIOPin
- type GPIOPull
- type GPIOState
- type Hardware
- type I2C
- type InputDevice
- type InputDeviceBus
- type InputDeviceType
- type InputEvent
- type InputEventType
- type InputManager
- type KeyCode
- type KeyState
- type LIRC
- type LIRCEvent
- type LIRCMode
- type LIRCType
- type Layout
- type LayoutDirection
- type Logger
- type MainTask
- type Metric
- type MetricRate
- type MetricType
- type Metrics
- type Module
- type ModuleConfigFunc
- type ModuleNewFunc
- type ModuleRunFunc
- type ModuleType
- type PWM
- type Point
- type Publisher
- type RPCClient
- type RPCClientConn
- type RPCClientPool
- type RPCEvent
- type RPCEventType
- type RPCFlag
- type RPCNewClientFunc
- type RPCServer
- type RPCService
- type RPCServiceDiscovery
- type RPCServiceRecord
- type SPI
- type SPIMode
- type Size
- type Sprite
- type SpriteManager
- type Surface
- type SurfaceFlags
- type SurfaceManager
- type SurfaceManagerBitmapMethods
- type SurfaceManagerCallback
- type SurfaceManagerSurfaceMethods
- type Timer
- type TimerEvent
- type VG
- type VGFillRule
- type VGPaint
- type VGPath
- type VGStrokeCapStyle
- type VGStrokeJoinStyle
- type View
- type ViewAlign
- type ViewDimension
- type ViewDirection
- type ViewDisplay
- type ViewEdge
- type ViewJustify
- type ViewOverflow
- type ViewPositioning
- type ViewWrap
Constants ¶
const ( // SurfaceLayer SURFACE_LAYER_BACKGROUND uint16 = 0x0000 SURFACE_LAYER_DEFAULT uint16 = 0x0001 SURFACE_LAYER_MAX uint16 = 0xFFFE SURFACE_LAYER_CURSOR uint16 = 0xFFFF )
const ( RPC_FLAG_NONE RPCFlag = 0 RPC_FLAG_INET_UDP = (1 << iota) // Use UDP protocol (TCP assumed otherwise) RPC_FLAG_INET_V4 = (1 << iota) // Use V4 addressing RPC_FLAG_INET_V6 = (1 << iota) // Use V6 addressing )
const (
// PARAM_SERVICENAME_DEFAULT is the default service type
PARAM_SERVICENAME_DEFAULT = "gopi"
)
Variables ¶
var ( // Build and version flags GitTag string GitBranch string GitHash string GoBuildTime string )
var ( // ErrNoTasks is an error returned when no tasks are to be run ErrNoTasks = errors.New("No tasks to run") // ErrAppError is a general application error ErrAppError = errors.New("General application error") // ErrHelp is returned when -help was called for on the command line ErrHelp = flag.ErrHelp // ErrNotImplemented is returned when a feature is not supported ErrNotImplemented = errors.New("Feature not implemented") // ErrBadParameter is returned when a supplied parameter is invalid ErrBadParameter = errors.New("Bad Parameter") // ErrUnexpectedResponse is returned when some response wasn't expected ErrUnexpectedResponse = errors.New("Unexpected response") // ErrNotFound is returned when something isn't found ErrNotFound = errors.New("Not found") // ErrOutOfOrder is returned when an operation was executed out of order ErrOutOfOrder = errors.New("Operation out of order") // ErrDeadlineExceeded is returned when a timeout occurred ErrDeadlineExceeded = errors.New("Deadline exceeded") // ErrNotModified is returned when a resource is not modified ErrNotModified = errors.New("Not modified") )
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
var ( // EdgeUndefined is used to set a position as "not defined" or "auto" EdgeUndefined float32 = float32(math.NaN()) // ValueAuto is used to set a value to "auto" ValueAuto float32 = float32(math.NaN()) // BasisAuto is the 'auto' setting for basis BasisAuto float32 = float32(math.NaN()) // TagNone is when there is no tag associated with a view TagNone uint = 0 )
var (
// DONE is the message sent on the channel to indicate task is completed
DONE = struct{}{}
)
Functions ¶
func CommandLineTool ¶
func CommandLineTool(config AppConfig, main_task MainTask, background_tasks ...BackgroundTask) int
CommandLineTool is the basic form of running a command-line application, you generally call this from the main() function
func CommandLineTool2 ¶ added in v1.0.21
func CommandLineTool2(config AppConfig, main_task MainTask, background_tasks ...BackgroundTask2) int
CommandLineTool2 runs multiple background tasks, waits for them all to send a start signl and then runs the main task
func RPCServerTool ¶
func RPCServerTool(config AppConfig, background_tasks ...BackgroundTask) int
RPCServerTool runs a set of RPC Services, you generally call this from the main() function and ensure to import rpc/server and rpc/discovery modules anonymously into your application as well as all your RPC services
func RegisterModule ¶
func RegisterModule(module Module)
RegisterModule registers the Config and New functions for creating a module, there is no return value
Types ¶
type AppConfig ¶
type AppConfig struct { Modules []*Module AppArgs []string AppFlags *Flags Params map[AppParam]interface{} Debug bool Verbose bool }
AppConfig defines how an application should be created
func NewAppConfig ¶
NewAppConfig method will create a new configuration file given the set of modules which should be created, the arguments are either by type or by name
type AppInstance ¶
type AppInstance struct { AppFlags *Flags Logger Logger Hardware Hardware Display Display Graphics SurfaceManager Sprites SpriteManager Input InputManager Fonts FontManager Layout Layout Timer Timer GPIO GPIO I2C I2C SPI SPI PWM PWM LIRC LIRC // background tasks implementation tasks.Tasks // contains filtered or unexported fields }
AppInstance defines the running application instance with modules
func NewAppInstance ¶
func NewAppInstance(config AppConfig) (*AppInstance, error)
NewAppInstance method will create a new application object given an application configuration
func (*AppInstance) Debug ¶
func (this *AppInstance) Debug() bool
Debug returns whether the application has the debug flag set
func (*AppInstance) ModuleInstance ¶
func (this *AppInstance) ModuleInstance(name string) Driver
ModuleInstance returns module instance by name, or returns nil if the module cannot be found. You can use reserved words (ie, logger, layout, etc) for common module types
func (*AppInstance) Run ¶
func (this *AppInstance) Run(main_task MainTask, background_tasks ...BackgroundTask) error
Run all tasks simultaneously, the first task in the list on the main thread and the remaining tasks background tasks.
func (*AppInstance) Run2 ¶ added in v1.0.21
func (this *AppInstance) Run2(main_task MainTask, background_tasks ...BackgroundTask2) error
Run all tasks simultaneously, the first task in the list on the main thread and the remaining tasks background tasks. The main task doesn't start running until received start signals from the background tasks
func (*AppInstance) SendSignal ¶
func (this *AppInstance) SendSignal() error
SendSignal will send the terminate signal, breaking the WaitForSignal block
func (*AppInstance) Service ¶
func (this *AppInstance) Service() string
Service returns the current service name set from configuration
func (*AppInstance) String ¶
func (this *AppInstance) String() string
func (*AppInstance) Verbose ¶
func (this *AppInstance) Verbose() bool
Verbose returns whether the application has the verbose flag set
func (*AppInstance) WaitForSignal ¶
func (this *AppInstance) WaitForSignal()
WaitForSignal blocks until a signal is caught
func (*AppInstance) WaitForSignalOrTimeout ¶
func (this *AppInstance) WaitForSignalOrTimeout(timeout time.Duration) bool
WaitForSignalOrTimeout blocks until a signal is caught or timeout occurs and return true if the signal is caught
type AppParam ¶ added in v1.0.58
type AppParam uint
AppParam is a list of application parameters
const ( // Application paramaters are used to store global constant data // from startup, usually used for storing versions and other // information from time of building PARAM_NONE AppParam = iota PARAM_TIMESTAMP PARAM_EXECNAME PARAM_SERVICENAME PARAM_GOVERSION PARAM_GOBUILDTIME PARAM_GITTAG PARAM_GITBRANCH PARAM_GITHASH PARAM_MAX = PARAM_GITHASH PARAM_MIN = PARAM_TIMESTAMP )
type BackgroundTask ¶
type BackgroundTask func(app *AppInstance, done <-chan struct{}) error
BackgroundTask defines a function which can run as a background task and has a channel which receives a value of gopi.DONE then the background task should complete
type BackgroundTask2 ¶ added in v1.0.21
type BackgroundTask2 func(app *AppInstance, start chan<- struct{}, stop <-chan struct{}) error
type Bitmap ¶
type Bitmap interface { Type() SurfaceFlags Size() Size // Bitmap operations ClearToColor(Color) error FillRectToColor(Color, Point, Size) error PaintPixel(Color, Point) error PaintImage(image.Image, Point, Size) error }
Bitmap defines a rectangular bitmap which can be used by the GPU
type Config ¶
type Config interface { // Opens the driver from configuration, or returns error Open(Logger) (Driver, error) }
Abstract configuration which is used to open and return the concrete driver
type Display ¶
type Display interface { Driver // Return display number Display() 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 }
Display implements a pixel-based display device. Displays are always numbered from zero onwards
type Driver ¶
type Driver interface { // Close closes the driver and frees the underlying resources Close() error }
Abstract driver interface
type Flags ¶
type Flags struct {
// contains filtered or unexported fields
}
func (*Flags) FlagDuration ¶
FlagDuration defines duration flag and return pointer to the flag value
func (*Flags) FlagFloat64 ¶
FlagFloat64 defines float64 flag and return pointer to the flag value
func (*Flags) FlagString ¶
FlagString defines string flag and return pointer to the flag value
func (*Flags) FlagUint ¶
FlagUint defines unsigned integer flag and return pointer to the flag value
func (*Flags) GetBool ¶
GetBool gets boolean value for a flag, and a boolean which indicates if the flag was set
func (*Flags) GetDuration ¶
GetDuration gets duration value for a flag, and a boolean which indicates if the flag was set
func (*Flags) GetFloat64 ¶
GetFloat64 gets float64 value for a flag, and a boolean which indicates if the flag was set
func (*Flags) GetInt ¶
GetInt gets integer value for a flag, and a boolean which indicates if the flag was set
func (*Flags) GetParam ¶ added in v1.0.61
GetParam returns a parameter value as an opaque type, or nil
func (*Flags) GetString ¶
GetString gets string value for a flag, and a boolean which indicates if the flag was set
func (*Flags) GetUint ¶
GetUint gets unsigned integer value for a flag, and a boolean which indicates if the flag was set
func (*Flags) GetUint16 ¶
GetUint16 gets unsigned integer value for a flag, and a boolean which indicates if the flag was set
func (*Flags) PrintDefaults ¶
func (this *Flags) PrintDefaults()
PrintDefaults will output the flags to stderr
func (*Flags) PrintVersion ¶ added in v1.0.59
func (this *Flags) PrintVersion()
func (*Flags) SetDuration ¶
Set a flag duration value
func (*Flags) SetFloat64 ¶
Set a flag float64 value
func (*Flags) SetString ¶
Set a flag string value. The flag must have previously been configured using FlagXX method. Will return an error if the value couldn't be parsed
func (*Flags) SetUsageFunc ¶
SetUsageFunc sets the usage function which prints usage information to stderr
type FontFace ¶
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 FontManager ¶
type FontManager interface { Driver // 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 }
FontManager for font management
type GPIO ¶
type GPIO interface { // Enforces general driver and event publisher Driver Publisher // 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 }
GPIO implements the GPIO interface for simple input and output
type GPIOEvent ¶
type GPIOEvent interface { Event // Pin returns the pin on which the event occurred Pin() GPIOPin // Edge returns whether the pin value is rising or falling // or will return NONE if not defined Edge() GPIOEdge }
GPIOEvent implements an event from the GPIO driver
type GPIOPin ¶
type GPIOPin uint8
Logical GPIO pin
const ( // Invalid pin constant GPIO_PIN_NONE GPIOPin = 0xFF )
type Hardware ¶
type Hardware interface { Driver // Return name of the hardware platform Name() string // Return unique serial number of this hardware SerialNumber() string // Return the number of possible displays for this hardware NumberOfDisplays() uint // Return host uptime UptimeHost() time.Duration // Return load averages LoadAverage() (float64, float64, float64) }
Hardware implements the hardware driver interface, which provides information about the hardware that the software is running on
type I2C ¶
type I2C interface { Driver // 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 }
I2C implements the I2C interface for sensors, etc.
type InputDevice ¶
type InputDevice interface { Driver Publisher // Name of the input device Name() string // Type of device Type() InputDeviceType // Bus interface Bus() InputDeviceBus // Position of cursor (for mouse, joystick and touchscreen devices) Position() Point // Set absolute current cursor position SetPosition(Point) // Get key states (caps lock, shift, scroll lock, num lock, etc) KeyState() KeyState // Set key state (or states) to on or off. Will return error // for key states which are not modifiable SetKeyState(flags KeyState, state bool) error // Returns true if device matches conditions Matches(string, InputDeviceType, InputDeviceBus) bool }
type InputDeviceBus ¶
type InputDeviceBus uint16
Bus type (USB, Bluetooth, etc)
const ( INPUT_BUS_NONE InputDeviceBus = 0x0000 INPUT_BUS_PCI InputDeviceBus = 0x0001 INPUT_BUS_ISAPNP InputDeviceBus = 0x0002 INPUT_BUS_USB InputDeviceBus = 0x0003 INPUT_BUS_HIL InputDeviceBus = 0x0004 INPUT_BUS_BLUETOOTH InputDeviceBus = 0x0005 INPUT_BUS_VIRTUAL InputDeviceBus = 0x0006 INPUT_BUS_ISA InputDeviceBus = 0x0010 INPUT_BUS_I8042 InputDeviceBus = 0x0011 INPUT_BUS_XTKBD InputDeviceBus = 0x0012 INPUT_BUS_RS232 InputDeviceBus = 0x0013 INPUT_BUS_GAMEPORT InputDeviceBus = 0x0014 INPUT_BUS_PARPORT InputDeviceBus = 0x0015 INPUT_BUS_AMIGA InputDeviceBus = 0x0016 INPUT_BUS_ADB InputDeviceBus = 0x0017 INPUT_BUS_I2C InputDeviceBus = 0x0018 INPUT_BUS_HOST InputDeviceBus = 0x0019 INPUT_BUS_GSC InputDeviceBus = 0x001A INPUT_BUS_ATARI InputDeviceBus = 0x001B INPUT_BUS_SPI InputDeviceBus = 0x001C INPUT_BUS_ANY InputDeviceBus = 0xFFFF )
Types of input connection
func (InputDeviceBus) String ¶
func (b InputDeviceBus) String() string
type InputDeviceType ¶
type InputDeviceType uint8
Device type (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 ¶
func (t InputDeviceType) String() string
type InputEvent ¶
type InputEvent interface { Event // Timestamp of event Timestamp() time.Duration // Type of device which has created the event DeviceType() InputDeviceType // Event type EventType() InputEventType // Key or mouse button press or release KeyCode() KeyCode // Modifier key state (caps lock, shift, alt, etc) KeyState() KeyState // Key scancode ScanCode() uint32 // Absolute cursor position Position() Point // Relative change in position Relative() Point // Multi-touch slot identifier Slot() uint }
InputEvent is emitted when an input device changes
type InputEventType ¶
type InputEventType uint16
Event type (button press, button release, etc)
const ( INPUT_EVENT_NONE InputEventType = 0x0000 // Mouse and/or keyboard key/button press events INPUT_EVENT_KEYPRESS InputEventType = 0x0001 INPUT_EVENT_KEYRELEASE InputEventType = 0x0002 INPUT_EVENT_KEYREPEAT InputEventType = 0x0003 // Mouse and/or touchscreen move events INPUT_EVENT_ABSPOSITION InputEventType = 0x0004 INPUT_EVENT_RELPOSITION InputEventType = 0x0005 // Multi-touch events INPUT_EVENT_TOUCHPRESS InputEventType = 0x0006 INPUT_EVENT_TOUCHRELEASE InputEventType = 0x0007 INPUT_EVENT_TOUCHPOSITION InputEventType = 0x0008 )
Input events
func (InputEventType) String ¶
func (e InputEventType) String() string
type InputManager ¶
type InputManager interface { Driver Publisher // Open Devices by name, type and bus and return a list // of newly opened devices OpenDevicesByName(name string, flags InputDeviceType, bus InputDeviceBus) ([]InputDevice, error) // Close Device CloseDevice(device InputDevice) error // Return a list of open devices GetOpenDevices() []InputDevice // Add a device to managed input devices AddDevice(device InputDevice) error }
InputManager allows you to open and close input devices and subscribe to events emitted by devices
type KeyCode ¶
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 KeyState ¶
type KeyState uint16
Key State
const ( KEYSTATE_NONE KeyState = 0x0000 KEYSTATE_MIN KeyState = KEYSTATE_SCROLLLOCK 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_MAX KeyState = KEYSTATE_CTRL // Maximum KEYSTATE_MASK KeyState = 0x0CFF // Bitmask )
Input key state
type LIRC ¶
type LIRC interface { Driver Publisher // Get receive and send modes RcvMode() LIRCMode SendMode() LIRCMode SetRcvMode(mode LIRCMode) error SetSendMode(mode LIRCMode) error // Receive parameters GetRcvResolution() (uint32, error) SetRcvTimeout(micros uint32) error SetRcvTimeoutReports(enable bool) error SetRcvCarrierHz(value uint32) error SetRcvCarrierRangeHz(min uint32, max uint32) error // Send parameters SetSendCarrierHz(value uint32) error SetSendDutyCycle(value uint32) error // Send Pulse Mode, values are in milliseconds PulseSend(values []uint32) error }
LIRC implements the IR send & receive interface
type LIRCEvent ¶
type LIRCEvent interface { Event // The type of message Type() LIRCType // The value Value() uint32 }
LIRCEvent implements an event from the LIRC driver
type Layout ¶
type Layout interface { Driver // Return default view direction Direction() LayoutDirection // Create a root view with a particular tag and view class, // returns a nil object if the view could not be created // due to invalid class or pre-existing tag NewRootView(tag uint, class string) View // Return the root view for a particular tag, returns // a nil object if the view could not be found RootViewForTag(tag uint) View }
Layout defines the methods of calculating layout of views within a rectangular surface (window)
type LayoutDirection ¶
type LayoutDirection uint
LayoutDirection is either left to right, right to left, or inherited from parent
const ( LAYOUT_DIRECTION_NONE LayoutDirection = iota LAYOUT_DIRECTION_LEFTRIGHT LAYOUT_DIRECTION_RIGHTLEFT LAYOUT_DIRECTION_INHERIT = LAYOUT_DIRECTION_NONE )
func (LayoutDirection) String ¶
func (d LayoutDirection) String() string
type Logger ¶
type Logger interface { Driver // Output logging messages Fatal(format string, v ...interface{}) error Error(format string, v ...interface{}) error Warn(format string, v ...interface{}) Info(format string, v ...interface{}) Debug(format string, v ...interface{}) Debug2(format string, v ...interface{}) // Return IsDebug flag IsDebug() bool }
Abstract logging interface
type MainTask ¶
type MainTask func(app *AppInstance, done chan<- struct{}) error
MainTask defines a function which can run as a main task and has a channel which can be written to when the task has completed
type Metric ¶
type Metric interface { // Return the metric rate (store values over a period) Rate() MetricRate // Return the metric type (the units used for the metric) Type() MetricType // Return the name of the metric Name() string // Return the unit for the metric (°C for example) Unit() string // Return the last metric value as a uint UintValue() uint // Return the last metric value as a float64 FloatValue() float64 }
Metric is an abstract method to store values associated with a measurement
type MetricRate ¶
type MetricRate uint
const ( METRIC_RATE_NONE MetricRate = iota METRIC_RATE_MINUTE METRIC_RATE_HOUR METRIC_RATE_DAY )
func (MetricRate) String ¶
func (v MetricRate) String() string
type MetricType ¶
type MetricType uint
const ( METRIC_TYPE_NONE MetricType = iota METRIC_TYPE_PURE // Pure number METRIC_TYPE_CELCIUS // Temperature )
func (MetricType) String ¶ added in v1.0.14
func (t MetricType) String() string
type Metrics ¶
type Metrics interface { Driver // Uptimes for host and for application UptimeHost() time.Duration UptimeApp() time.Duration // Load Average (1, 5 and 15 minutes) LoadAverage() (float64, float64, float64) // Return metric channel which records uint values NewMetricUint(MetricType, MetricRate, string) (chan<- uint, error) // Return metric channel which records float64 values NewMetricFloat64(MetricType, MetricRate, string) (chan<- float64, error) // Return all metrics of a particular type, or METRIC_TYPE_NONE // for all metrics Metrics(MetricType) []Metric }
Metrics returns various metrics for host and custom metrics
type Module ¶
type Module struct { Name string Type ModuleType Config ModuleConfigFunc New ModuleNewFunc Run ModuleRunFunc Requires []string // contains filtered or unexported fields }
Module is a structure which determines details about a module
func AppendModulesByName ¶
Append Modules by name onto the configuration
func ModuleByName ¶
ModuleByName returns a module given the name, or by type if it is using the reserved word. It will return nil if the module is not registered
func ModuleByType ¶
func ModuleByType(t ModuleType) *Module
ModuleByType returns a module given the type. It will return nil if the module is not registered
func ModuleWithDependencies ¶
ModuleWithDependencies returns an array of pointers to modules which satisfy both the module itself and the dependencies. Will return an error with the array as nil if the module was not found or any dependencies are not met, or there are circular dependencies. The ordering of the modules returned is important: dependencies are first, and the module requested is last, so that they can be initialized in the right order when creation is to occur, and vice-versa on application exit
func ModulesByType ¶
func ModulesByType(t ModuleType) []*Module
ModulesByType returns all modules of a given type or an empty array if there are no modules of that type
func (*Module) Identifier ¶
type ModuleConfigFunc ¶
type ModuleConfigFunc func(*AppConfig)
ModuleConfigFunc is the signature for setting up the configuration for creating the app
type ModuleNewFunc ¶
type ModuleNewFunc func(*AppInstance) (Driver, error)
ModuleNewFunc is the signature for creating a new module instance
type ModuleRunFunc ¶
type ModuleRunFunc func(*AppInstance, Driver) error
ModuleRunFunc is the signature for a finalizer just before running the tool
type ModuleType ¶
type ModuleType uint
ModuleType defines the type of module
const ( MODULE_TYPE_NONE ModuleType = iota MODULE_TYPE_OTHER MODULE_TYPE_LOGGER // Logging module MODULE_TYPE_HARDWARE // Hardware capabilities and monitoring MODULE_TYPE_DISPLAY // Displays MODULE_TYPE_GRAPHICS // Graphics (Graphics Manager, Surfaces, Bitmaps) MODULE_TYPE_SPRITES // Sprites Manager MODULE_TYPE_FONTS // Font Manager & Faces MODULE_TYPE_VECTOR // 2D Vector graphics MODULE_TYPE_OPENGL // 3D Graphics MODULE_TYPE_LAYOUT // Flex 2D Rectangular Layout MODULE_TYPE_GPIO // GPIO Hardware interface MODULE_TYPE_I2C // I2C Hardware interface MODULE_TYPE_SPI // SPI Hardware interface MODULE_TYPE_PWM // PWM Hardware interface MODULE_TYPE_INPUT // Input manager & devices MODULE_TYPE_TIMER // Timer module MODULE_TYPE_LIRC // LIRC module MODULE_TYPE_SERVICE // RPC Service MODULE_TYPE_CLIENT // RPC Client MODULE_TYPE_DISCOVERY // RPC Service Discovery MODULE_TYPE_KEYMAP // Key Mapper )
func (ModuleType) String ¶
func (t ModuleType) String() string
type PWM ¶ added in v1.0.27
type PWM interface { Driver // 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 }
PWM implements the PWM interface for actuators, motors, etc.
type Publisher ¶
type Publisher interface { // Subscribe to events emitted. Returns channel on which events // are emitted or nil if this driver does not implement events Subscribe() <-chan Event // Unsubscribe from events emitted Unsubscribe(<-chan Event) }
Publisher is an interface for drivers which accept subscription and unsubscription requests
type RPCClient ¶
type RPCClient interface{}
RPCClient contains the set of RPC methods. Currently anything can be an RPCClient
type RPCClientConn ¶
type RPCClientConn interface { Driver // Mutex lock for the connection Lock() Unlock() // Properties Name() string Addr() string Connected() bool Timeout() time.Duration Services() ([]string, error) }
RPCClientConn implements a single client connection for communicating with an RPC server
type RPCClientPool ¶
type RPCClientPool interface { Driver Publisher // Connect and disconnect Connect(service RPCServiceRecord, flags RPCFlag) (RPCClientConn, error) Disconnect(RPCClientConn) error // Register clients and create new ones given a service name RegisterClient(string, RPCNewClientFunc) error NewClient(string, RPCClientConn) RPCClient // Lookup service records by parameter - returns records // which match either name or addr up to max number of records // Can wait for new records and block until cancelled Lookup(ctx context.Context, name, addr string, max int) ([]RPCServiceRecord, error) }
RPCClientPool implements a pool of client connections for communicating with an RPC server and aides discovery new service records
type RPCEvent ¶
type RPCEvent interface { Event // Type of RPC Event Type() RPCEventType // Service Record ServiceRecord() RPCServiceRecord }
RPCEvent is an event which is emitted by either discovery or server.
type RPCEventType ¶
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_CLIENT_CONNECTED RPC_EVENT_CLIENT_DISCONNECTED )
func (RPCEventType) String ¶
func (t RPCEventType) String() string
type RPCNewClientFunc ¶
type RPCNewClientFunc func(RPCClientConn) RPCClient
RPCNewClientFunc creates a new client with a network connection returns nil otherwise
type RPCServer ¶
type RPCServer interface { Driver Publisher // Starts 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 // Return service record, or nil when the service record // cannot be generated. The first version uses the current // hostname as the name. You can also include text // records. Service(service string, text ...string) RPCServiceRecord ServiceWithName(service, name string, text ...string) RPCServiceRecord }
RPCServer is the server which serves RPCModule methods to a remote RPCClient
type RPCService ¶
type RPCService interface { Driver // CancelRequests is called by the server to gracefully end any // on-going streaming requests, but before the service is shutdown CancelRequests() error }
RPCService is a driver which implements all the necessary methods to handle remote calls
type RPCServiceDiscovery ¶
type RPCServiceDiscovery interface { Driver Publisher // Register a service record on the network, and cache it Register(RPCServiceRecord) error // Lookup service instances by name Lookup(ctx context.Context, service string) ([]RPCServiceRecord, error) // Return list of service names EnumerateServices(ctx context.Context) ([]string, error) // Return all cached service instances for a service name ServiceInstances(service string) []RPCServiceRecord }
RPCServiceDiscovery is the driver for discovering services on the network using mDNS or another mechanism
type RPCServiceRecord ¶
type RPCServiceRecord interface { Name() string Subtype() string Service() string Port() uint Text() []string Host() string IP4() []net.IP IP6() []net.IP TTL() time.Duration }
RPCServiceRecord defines a service which can be registered or discovered on the network
type SPI ¶
type SPI interface { Driver // 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 }
SPI implements the SPI interface for sensors, etc.
type SPIMode ¶
type SPIMode uint8
SPIMode
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 Sprite ¶ added in v1.0.43
Sprite implemnts a bitmap with a unique name and hotspot location (for cursors)
type SpriteManager ¶ added in v1.0.43
type SpriteManager interface { Driver // Open one or more sprites from a stream and return them OpenSprites(io.Reader) ([]Sprite, error) // Open sprites from path, checking to see if individual files should // be opened through a callback function OpenSpritesAtPath(path string, callback func(manager SpriteManager, path string, info os.FileInfo) bool) error // Return loaded sprites, or a specific sprite Sprites(name string) []Sprite }
SpriteManager loads sprites from io.Reader buffers
type Surface ¶
type Surface interface { Type() SurfaceFlags Size() Size Origin() Point Opacity() float32 Layer() uint16 }
Surface is manipulated by surface manager, and used by a GPU API (bitmap or vector drawing mostly)
type SurfaceFlags ¶
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 v1.0.47
func (f SurfaceFlags) Config() SurfaceFlags
Config() returns the configuration of the surface
func (SurfaceFlags) ConfigString ¶ added in v1.0.47
func (f SurfaceFlags) ConfigString() string
func (SurfaceFlags) Mod ¶ added in v1.0.47
func (f SurfaceFlags) Mod() SurfaceFlags
Mod() returns surface modifiers
func (SurfaceFlags) ModString ¶ added in v1.0.47
func (f SurfaceFlags) ModString() string
func (SurfaceFlags) String ¶
func (f SurfaceFlags) String() string
func (SurfaceFlags) Type ¶ added in v1.0.47
func (f SurfaceFlags) Type() SurfaceFlags
Type() returns the type of the surface
func (SurfaceFlags) TypeString ¶ added in v1.0.47
func (f SurfaceFlags) TypeString() string
type SurfaceManager ¶
type SurfaceManager interface { Driver SurfaceManagerSurfaceMethods SurfaceManagerBitmapMethods // Return the display associated with the surface manager Display() Display // Return the name of the surface manager. It's basically the // GPU driver Name() string // Return capabilities for the GPU Types() []SurfaceFlags }
SurfaceManager allows you to open, close and move surfaces around an open display
type SurfaceManagerBitmapMethods ¶
type SurfaceManagerBitmapMethods interface { // Create and destroy bitmaps CreateBitmap(SurfaceFlags, Size) (Bitmap, error) CreateSnapshot(SurfaceFlags) (Bitmap, error) DestroyBitmap(Bitmap) error }
type SurfaceManagerCallback ¶
type SurfaceManagerCallback func(graphics SurfaceManager, userInfo interface{}) error
SurfaceManagerCallback is a function callback for performing surface operations and is passed the surface manager and additional arguments
type SurfaceManagerSurfaceMethods ¶
type SurfaceManagerSurfaceMethods interface { // Perform all surface operations (create, destroy, move, set, paint) within the 'Do' method // to ensure atomic updates to the display. When Do returns, the display is updated and any error // from the callback is returned Do(SurfaceManagerCallback, interface{}) error // Create & destroy surfaces CreateSurface(flags SurfaceFlags, opacity float32, layer uint16, origin Point, size Size) (Surface, error) CreateSurfaceWithBitmap(bitmap Bitmap, flags SurfaceFlags, opacity float32, layer uint16, origin Point, size Size) (Surface, error) CreateBackground(flags SurfaceFlags, opacity float32) (Surface, error) CreateCursor(cursor Sprite, flags SurfaceFlags, origin Point) (Surface, error) DestroySurface(Surface) error // Change surface properties (size, position, etc) SetOrigin(Surface, Point) error MoveOriginBy(Surface, Point) error SetSize(Surface, Size) error SetLayer(Surface, uint16) error SetOpacity(Surface, float32) error SetBitmap(Bitmap) error }
type Timer ¶
type Timer interface { Driver Publisher // Schedule a timeout (one shot) NewTimeout(duration time.Duration, userInfo interface{}) error // Schedule an interval, which can fire immediately NewInterval(duration time.Duration, userInfo interface{}, immediately bool) error // Schedule a backoff timer with maximum backoff duration NewBackoff(duration time.Duration, max_duration time.Duration, userInfo interface{}) error }
Timer implements a time keeping driver
type TimerEvent ¶
type TimerEvent interface { Event // Provide the timestamp for the event Timestamp() time.Time // The user info for the event UserInfo() interface{} // The number of fires for the timer event Counter() uint // Cancel the timer which fired this event Cancel() }
TimerEvent is emitted by the timer driver on maturity
type VGFillRule ¶ added in v1.0.45
type VGFillRule uint16
const ( VG_STYLE_FILL_NONE VGFillRule = 0x0000 VG_STYLE_FILL_NONZERO VGFillRule = 0x1900 VG_STYLE_FILL_EVENODD VGFillRule = 0x1901 // Default )
type VGPaint ¶ added in v1.0.45
type VGPaint interface { // Set color SetColor(color Color) error // Set fill rule SetFillRule(style VGFillRule) error // Set stroke width SetStrokeWidth(width float32) error // Set miter limit SetMiterLimit(value float32) error // Set stroke path endpoint styles (for joins and cap). Use // NONE as a value for no change SetStrokeStyle(VGStrokeJoinStyle, VGStrokeCapStyle) error // Set stroke dash pattern, call with no arguments to reset SetStrokeDash(...float32) error }
Paintbrush for Fill and Stroke
type VGPath ¶ added in v1.0.45
type VGPath interface { // Draw the path with both stroke and fill Draw(stroke, fill VGPaint) error // Stroke the path Stroke(stroke VGPaint) error // Fill the path Fill(fill VGPaint) error // Reset to empty path Clear() error // Close Path Close() error // Move To MoveTo(Point) error // Line To LineTo(...Point) error // Quad To QuadTo(p1, p2 Point) error // Cubic To CubicTo(p1, p2, p3 Point) error // Append a line to the path Line(start, end Point) error // Append a rectangle to the path Rect(origin Point, size Size) error // Append an ellipse to the path Ellipse(origin Point, diameter Size) error // Append a circle to the path Circle(origin Point, diameter float32) error }
VGPath implements Drawing Path
type VGStrokeCapStyle ¶ added in v1.0.45
type VGStrokeCapStyle uint16
const ( VG_STYLE_CAP_NONE VGStrokeCapStyle = 0x0000 VG_STYLE_CAP_BUTT VGStrokeCapStyle = 0x1700 // Default VG_STYLE_CAP_ROUND VGStrokeCapStyle = 0x1701 VG_STYLE_CAP_SQUARE VGStrokeCapStyle = 0x1702 )
type VGStrokeJoinStyle ¶ added in v1.0.45
type VGStrokeJoinStyle uint16
const ( VG_STYLE_JOIN_NONE VGStrokeJoinStyle = 0x0000 VG_STYLE_JOIN_MITER VGStrokeJoinStyle = 0x1800 // Default VG_STYLE_JOIN_ROUND VGStrokeJoinStyle = 0x1801 VG_STYLE_JOIN_BEVEL VGStrokeJoinStyle = 0x1802 )
type View ¶
type View interface { // Require ability to marshall XML xml.Marshaler // Return tag for this view Tag() uint // Return class for this view Class() string // Return positioning Positioning() ViewPositioning // Get Style Attributes Display() ViewDisplay Overflow() ViewOverflow Direction() ViewDirection Wrap() ViewWrap JustifyContent() ViewJustify AlignItems() ViewAlign AlignContent() ViewAlign AlignSelf() ViewAlign Grow() float32 Shrink() float32 BasisString() string // Set Style Attributes SetDisplay(value ViewDisplay) SetOverflow(value ViewOverflow) SetDirection(value ViewDirection) SetWrap(value ViewWrap) SetJustifyContent(value ViewJustify) SetAlignItems(value ViewAlign) SetAlignContent(value ViewAlign) SetAlignSelf(value ViewAlign) SetGrow(value float32) SetShrink(value float32) SetBasisValue(value float32) SetBasisPercent(value float32) SetBasisAuto() // Set position SetPositionValue(value float32, edges ...ViewEdge) SetPositionPercent(percent float32, edges ...ViewEdge) // Set padding SetPaddingValue(value float32, edges ...ViewEdge) SetPaddingPercent(percent float32, edges ...ViewEdge) // Set margin SetMarginValue(value float32, edges ...ViewEdge) SetMarginPercent(percent float32, edges ...ViewEdge) SetMarginAuto(edges ...ViewEdge) // Set width and height SetDimensionValue(value float32, dimension ViewDimension) SetDimensionPercent(percent float32, dimension ViewDimension) SetDimensionAuto(dimension ViewDimension) // Minimum and maximum dimensions SetDimensionMinValue(value float32, dimension ViewDimension) SetDimensionMinPercent(percent float32, dimension ViewDimension) SetDimensionMinAuto(dimension ViewDimension) SetDimensionMaxValue(value float32, dimension ViewDimension) SetDimensionMaxPercent(percent float32, dimension ViewDimension) SetDimensionMaxAuto(dimension ViewDimension) // Get strings for position, margin and padding, each edge is separated by a space PositionString(edges ...ViewEdge) string MarginString(edges ...ViewEdge) string PaddingString(edges ...ViewEdge) string DimensionString(dimension ViewDimension) string DimensionMinString(dimension ViewDimension) string DimensionMaxString(dimension ViewDimension) string // Determine if view changes on this element require layout IsDirty() bool // Get layout values which are provided once 'CalculateLayout' // has been called in the Layout object LayoutValue(edge ViewEdge) float32 LayoutWidth() float32 LayoutHeight() float32 }
View defines a 2D rectangular drawable element
type ViewAlign ¶
type ViewAlign uint
ViewAlign determines alignment of children within the parent by default it's STRETCH
const ( VIEW_ALIGN_AUTO ViewAlign = iota VIEW_ALIGN_FLEX_START VIEW_ALIGN_CENTER VIEW_ALIGN_FLEX_END VIEW_ALIGN_STRETCH VIEW_ALIGN_BASELINE VIEW_ALIGN_SPACE_BETWEEN VIEW_ALIGN_SPACE_AROUND VIEW_ALIGN_CENTRE = VIEW_ALIGN_CENTER )
type ViewDimension ¶
type ViewDimension uint
ViewDimension defines width or height
const ( VIEW_DIMENSION_NONE ViewDimension = iota VIEW_DIMENSION_WIDTH VIEW_DIMENSION_HEIGHT VIEW_DIMENSION_ALL )
func (ViewDimension) String ¶
func (v ViewDimension) String() string
type ViewDirection ¶
type ViewDirection uint
ViewDirection is how the view children are laid out, column, columnereverse, row, rowreverse
const ( VIEW_DIRECTION_ROW ViewDirection = iota VIEW_DIRECTION_COLUMN VIEW_DIRECTION_ROW_REVERSE VIEW_DIRECTION_COLUMN_REVERSE )
func (ViewDirection) String ¶
func (d ViewDirection) String() string
type ViewDisplay ¶
type ViewDisplay uint
ViewDisplay is either flex (default) or none
const ( VIEW_DISPLAY_FLEX ViewDisplay = iota VIEW_DISPLAY_NONE )
func (ViewDisplay) String ¶
func (v ViewDisplay) String() string
type ViewJustify ¶
type ViewJustify uint
ViewJustify is how view children are aligned within a parent START is default
const ( VIEW_JUSTIFY_FLEX_START ViewJustify = iota VIEW_JUSTIFY_FLEX_END VIEW_JUSTIFY_CENTER VIEW_JUSTIFY_SPACE_BETWEEN VIEW_JUSTIFY_SPACE_AROUND VIEW_JUSTIFY_CENTRE = VIEW_JUSTIFY_CENTER )
func (ViewJustify) String ¶
func (v ViewJustify) String() string
type ViewOverflow ¶
type ViewOverflow uint
ViewOverflow is either visible, hidden or scroll
const ( VIEW_OVERFLOW_VISIBLE ViewOverflow = iota VIEW_OVERFLOW_HIDDEN VIEW_OVERFLOW_SCROLL )
func (ViewOverflow) String ¶
func (v ViewOverflow) String() string
type ViewPositioning ¶
type ViewPositioning uint
ViewPosition is by default relative. When absolute, uses only left, right, top, bottom, start and end in order to set position
const ( VIEW_POSITIONING_RELATIVE ViewPositioning = iota VIEW_POSITIONING_ABSOLUTE )
func (ViewPositioning) String ¶
func (v ViewPositioning) String() string
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
helloworld
The canonical hello world example demonstrates printing hello world and then exiting.
|
The canonical hello world example demonstrates printing hello world and then exiting. |
timer
Runs either a one-shot or interval timer
|
Runs either a one-shot or interval timer |
sys
|
|
Go Language Raspberry Pi Interface (c) Copyright David Thorpe 2016 All Rights Reserved For Licensing and Usage information, please see LICENSE.md
|
Go Language Raspberry Pi Interface (c) Copyright David Thorpe 2016 All Rights Reserved For Licensing and Usage information, please see LICENSE.md |