gopi

package module
v3.0.33 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: BSD-2-Clause Imports: 13 Imported by: 0

README

Read me first

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
  • Font loading and rendering in bitmap and vector forms
  • Infrared transmission and receiving, for example for remote controls
  • Network microservices, announcement and discovery using mDNS and gRPC

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

  • Image and video encoding/decoding, including utilizing hardware acceleration
  • GPU acceleration for 2D graphics
  • 3D graphics
  • Audio devices
  • Input devices like the mouse, keyboard and touchscreen
  • Display and display surfaces, bitmaps and vector graphics
  • Connected cameras
  • User interface widgets and layout
  • Building for Darwin (Macintosh) targets

Requirements

The tested requirements are currently:

  • Any Raspberry Pi (v2, v3, v4, Zero and Zero W have been tested)
  • Raspbian GNU/Linux 9 (other distributions may work, but not tested)
  • Go 1.13

In order to use the library, you'll need to have a working version of Go on your Raspberry Pi, which you can download. Then retrieve the library on your device, using:

go get github.com/djthorpe/gopi/v3

Some libraries will need to be installed for building, RPC and Media services. In order to satisfy these dependencies,

sudo apt install make protobuf-compiler libprotobuf-dev

Other dependencies will be satisfied when running the make command.

Getting Started

In order to get started, build some of the examples in the "cmd" folder. They can be built with the makefile.

  • make all will build the example commands into the build folder;
  • make test runs all tests for the pkg folder;
  • make debian will create .deb packages which can be distributed;
  • make clean removes build intermediate files.

Fuller documentation of the examples and developing your own code against this framework will be available in documentation.

License

Copyright 2016-2020 David Thorpe All Rights Reserved

Redistribution and use in source and binary forms, with or without modification, are permitted with some conditions.

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

Documentation

Index

Constants

View Source
const (
	CAST_APPID_DEFAULT      = "CC1AD845"
	CAST_APPID_MUTABLEMEDIA = "5C292C3E"
	CAST_APPID_BACKDROP     = "E8C28D3C"
)

Variables

View Source
var (
	ZeroPoint = Point{0, 0}
	ZeroSize  = Size{0, 0}
)

Functions

This section is empty.

Types

type ArgonOne

type ArgonOne interface {
	// Set fan duty cycle (0-100)
	SetFan(uint8) error

	// Set Power Mode
	SetPower(ArgonOnePowerMode) error
}

ArgonOne interfaces with the ArgonOne case for the Raspberry Pi

type ArgonOnePowerMode

type ArgonOnePowerMode uint

Ref: https://github.com/Argon40Tech/Argon-ONE-i2c-Codes

const (
	ARGONONE_POWER_DEFAULT ArgonOnePowerMode = iota
	ARGONONE_POWER_ALWAYSON
	ARGONONE_POWER_UART
)

CONSTANTS

func (ArgonOnePowerMode) String

func (v ArgonOnePowerMode) String() string

STRINGIFY

type AudioContext added in v3.0.3

type AudioContext interface {
	// Write data to audio output device
	Write(MediaFrame) error
}

type AudioManager added in v3.0.3

type AudioManager interface {
	// OpenDefaultSink opens default output device
	OpenDefaultSink() (AudioContext, error)

	// Close audio stream
	Close(AudioContext) error
}

type Bitmap added in v3.0.11

type Bitmap interface {
	image.Image

	Format() SurfaceFormat
	Size() Size
	ClearToColor(color.Color)
}

Bitmap represents pixel-based images

type Cast added in v3.0.11

type Cast interface {
	// Id returns the identifier for a chromecast
	Id() string

	// Name returns the readable name for a chromecast
	Name() string

	// Model returns the reported model information
	Model() string

	// Service returns the currently running service
	Service() string

	// State returns 0 if backdrop, else returns 1
	State() uint
}

Cast represents a Google Chromecast device

type CastApp added in v3.0.23

type CastApp interface {
	// Id returns the identifier for the application
	Id() string

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

	// Status is the current status of the application
	Status() string
}

CastApp represents an application running on the Chromecast

type CastEvent added in v3.0.11

type CastEvent interface {
	Event

	Flags() CastFlag
	Cast() Cast
	App() CastApp
	Volume() (float32, bool)
}

type CastFlag added in v3.0.11

type CastFlag uint

Flags define changes to a device

const (
	CAST_FLAG_CONNECT CastFlag = (1 << iota)
	CAST_FLAG_VOLUME
	CAST_FLAG_MUTE
	CAST_FLAG_MEDIA
	CAST_FLAG_APP
	CAST_FLAG_DISCONNECT
	CAST_FLAG_NONE CastFlag = 0
	CAST_FLAG_MIN           = CAST_FLAG_CONNECT
	CAST_FLAG_MAX           = CAST_FLAG_DISCONNECT
)

TYPES

func (CastFlag) FlagString added in v3.0.11

func (f CastFlag) FlagString() string

func (CastFlag) String added in v3.0.11

func (f CastFlag) String() string

STRINGIFY

type CastManager added in v3.0.11

type CastManager interface {
	// Return list of discovered Google Chromecast Devices
	Devices(context.Context) ([]Cast, error)

	// Connect to the control channel for a device
	Connect(Cast) error

	// Disconnect from the device
	Disconnect(Cast) error

	// LaunchAppWithId launches application with Id on a cast device.
	LaunchAppWithId(Cast, string) error

	// SetVolume sets the volume for a device, the value is between 0.0
	// and 1.0
	SetVolume(Cast, float32) error

	// SetMuted sets the volume as muted or unmuted. Does not affect the
	// volume level
	SetMuted(Cast, bool) error

	// SetPlay sets media playback state to either PLAY or STOP
	SetPlay(Cast, bool) error

	// SetPause sets media state to PLAY or PAUSE. Will not affect
	// state if currently STOP
	SetPause(Cast, bool) error

	// Seek within media stream relative to start of stream
	SeekAbs(Cast, time.Duration) error

	// Seek within media stream relative to current position
	SeekRel(Cast, time.Duration) error

	// Send stop signal, terminating any playing media
	Stop(Cast) error

	// Stream URL to Chromecast supports HTTP and HTTPS protocols,
	// and the stream can be automatically started if the third
	// argument is set to true. Requires application load before
	// calling, to set the transport, or else returns an OutOfOrder
	// error
	LoadURL(Cast, *url.URL, bool) error

	// Returns current volume state (level and muted)
	Volume(Cast) (float32, bool, error)

	// Returns app state
	App(Cast) (CastApp, error)
}

CastManager returns all discovered Chromecast devices, and allows you to connect and disconnect

type CastService added in v3.0.11

type CastService interface {
	Service
}

type CastStub added in v3.0.11

type CastStub interface {
	ServiceStub

	// ListCasts returns all discovered Chromecast devices
	ListCasts(ctx context.Context) ([]Cast, error)

	// Return Volume
	Volume(ctx context.Context, castId string) (float32, bool, error)

	// SetVolume sets the Chromecast sound volume
	SetVolume(ctx context.Context, castId string, value float32) error

	// SetMute mutes and unmutes the sound
	SetMute(ctx context.Context, castId string, value bool) error

	// Return App
	App(ctx context.Context, castId string) (CastApp, error)

	// SetApp loads an application into the Chromecast
	SetApp(ctx context.Context, castId, appId string) error

	// LoadURL loads a video, audio or image onto the Chromecast,
	// assuming an application has already been loaded
	LoadURL(ctx context.Context, castId string, url *url.URL) error

	// Stop stops currently playing media if a media session is ongoing
	// or else resets the Chromecast to the backdrop if no media session
	Stop(ctx context.Context, castId string) error

	// Play resumes playback after paused media
	Play(ctx context.Context, castId string) error

	// Pause the media session
	Pause(ctx context.Context, castId string) error

	// SeekAbs within playing audio or video relative to the start of the
	// playing media
	SeekAbs(ctx context.Context, castId string, value time.Duration) error

	// SeekRel within playing audio or video relative to the current position
	SeekRel(ctx context.Context, castId string, value time.Duration) error

	// Stream emits events from Chromecasts, filtered
	// by the id of the chromecast  until context is cancelled. Where
	// the id filter is empty, all connected chromecast events are emitted
	Stream(context.Context, string, chan<- CastEvent) error
}

type Command

type Command interface {
	Name() string              // Return command name
	Usage() (string, string)   // Return command syntax and description
	Args() []string            // Return command arguments
	Run(context.Context) error // Run the command
}

Command is determined from parsed arguments

type CommandFunc

type CommandFunc func(context.Context) error

CommandFunc is the function signature for running a command

type Config

type Config interface {
	Parse() error     // Parse command line arguments
	Args() []string   // Return arguments, not including flags
	Usage(string)     // Print out usage for all or specific command
	Version() Version // Return version information

	// Define flags
	FlagString(string, string, string, ...string) *string
	FlagBool(string, bool, string, ...string) *bool
	FlagUint(string, uint, string, ...string) *uint
	FlagInt(string, int, string, ...string) *int
	FlagDuration(string, time.Duration, string, ...string) *time.Duration
	FlagFloat(string, float64, string, ...string) *float64

	// Define a command with name, description, calling function
	Command(string, string, CommandFunc) error

	// Get command from provided arguments
	GetCommand([]string) (Command, error)

	// Get flag values
	GetString(string) string
	GetBool(string) bool
	GetUint(string) uint
	GetInt(string) int
	GetDuration(string) time.Duration
	GetFloat(string) float64
}

type Conn

type Conn interface {
	// Addr returns the bound server address, or empty string if connection is closed
	Addr() string

	// Mutex
	Lock()   // Lock during RPC call
	Unlock() // Unlock at end of RPC call

	// ListServices returns a list of all services supported by the
	// remote server
	ListServices(context.Context) ([]string, error)

	// NewStub returns the stub for a named service
	NewStub(string) ServiceStub

	// Err translates service error codes to gopi error types
	Err(error) error
}

Conn is a connection to a remote server

type ConnPool

type ConnPool interface {
	// Connect accepts a network (tcp, udp, unix) and either
	// an IP:port or a path name to a socket and returns a connection
	Connect(network, addr string) (Conn, error)

	// ConnectService accepts a network (tcp, udp, unix) and a service
	// name. If network is 'unix' or service is an IP:port or host:port
	// it will default to a normal Connect. The service name should be
	// alphanumeric and the flags will determine if a connection by hostname,
	// IP4 or IP6 connection is made. In addition, the service parameter can
	// be either <service>:<name> or <name> to connecto to the correct service
	// instance.
	ConnectService(ctx context.Context, network, service string, flags ServiceFlag) (Conn, error)
}

ConnPool is a factory of client connections

type DVBContext added in v3.0.32

type DVBContext interface {
}

DVBTuneContext represents information obtained during the tuning process

type DVBManager added in v3.0.32

type DVBManager interface {
	// Tuners returns all tuners
	Tuners() []DVBTuner

	// ParseTunerParams returns a list of tuner parameters
	ParseTunerParams(r io.Reader) ([]DVBTunerParams, error)

	// Tune to parameters with context, which can be used to cancel
	// or timeout the tuning process
	Tune(context.Context, DVBTuner, DVBTunerParams, DVBTuneCallack) error

	// Close tuner
	Close(DVBTuner) error
}

DVBManager encapsulates methods for DVB reception

type DVBService added in v3.0.32

type DVBService interface {
	Id() uint16
}

DVBService represents a service that can be received

type DVBTuneCallack added in v3.0.32

type DVBTuneCallack func(DVBContext)

DVBTunerCallack is called when tuning has completed, so that set-up can begin

type DVBTuner added in v3.0.32

type DVBTuner interface {
	// Return tuner identifier
	Id() uint

	// Return tuner name
	Name() string
}

DVBTuner represents a tuning device, some hardware comtains more than one tuner. Each is represented by a unique identifier

type DVBTunerParams added in v3.0.32

type DVBTunerParams interface {
	// Name returns name for tune parameters
	Name() string
}

DVBTunerParams represents tune parameters

type DecodeFrameIteratorFunc

type DecodeFrameIteratorFunc func(MediaFrame) error

type DecodeIteratorFunc

type DecodeIteratorFunc func(MediaDecodeContext, MediaPacket) error

type Display

type Display interface {
	Id() uint32             // Return display number
	Flags() DisplayFlag     // Return information about the display
	Name() string           // Return name of the display
	Size() (uint32, uint32) // Return display size for nominated display number, or (0,0) if display does not exist
	PixelsPerInch() uint32  // Return the PPI (pixels-per-inch) for the display, or return zero if unknown
}

Display implements a pixel-based display device

type DisplayFlag added in v3.0.4

type DisplayFlag uint32
const (
	DISPLAY_FLAG_HDMI DisplayFlag = (1 << iota)
	DISPLAY_FLAG_DVI
	DISPLAY_FLAG_LCD
	DISPLAY_FLAG_SDTV
	DISPLAY_FLAG_NTSC
	DISPLAY_FLAG_PAL
	DISPLAY_FLAG_UNPLUGGED
	DISPLAY_FLAG_ATTACHED

	DISPLAY_FLAG_NONE DisplayFlag = 0
	DISPLAY_FLAG_MIN              = DISPLAY_FLAG_HDMI
	DISPLAY_FLAG_MAX              = DISPLAY_FLAG_ATTACHED
)

func (DisplayFlag) FlagString added in v3.0.4

func (f DisplayFlag) FlagString() string

func (DisplayFlag) String added in v3.0.4

func (f DisplayFlag) String() string

type DisplayManager added in v3.0.4

type DisplayManager interface {
	// Displays return all attached displays
	Displays() []Display

	// Displays returns specific display
	Display(uint32) (Display, error)

	// PowerOn a display, can return ErrNotImplemented if
	// a specific display does not support control
	PowerOn(Display) error

	// PowerOff a display, can return ErrNotImplemented if
	// a specific display does not support control
	PowerOff(Display) error
}

DisplayManager manages the connected displays and emits Display objects when their state changes

type EPD added in v3.0.3

type EPD interface {
	// Return screen size
	Size() Size

	// Clear display
	Clear(context.Context) error

	// Draw image on the display
	Draw(context.Context, image.Image) error

	// Size image and draw on the display. A size value of
	// 1.0 is equivalent to calling Draw
	DrawSized(context.Context, float64, image.Image) error

	// Sleep display
	Sleep() error
}

type Error

type Error uint
const (
	ErrNone Error = iota
	ErrBadParameter
	ErrNotImplemented
	ErrNotFound
	ErrUnexpectedResponse
	ErrHelp
	ErrInternalAppError
	ErrDuplicateEntry
	ErrOutOfOrder
	ErrChannelFull
)

func (Error) Error

func (e Error) Error() string

func (Error) WithPrefix

func (e Error) WithPrefix(p ...interface{}) error

type Event

type Event interface {
	Name() string // Return name of the event
}

Event is an emitted event

type Field

type Field interface {
	// Name returns field name
	Name() string

	// Kind returns kind of field or nil
	Kind() string

	// IsNil returns true if value is nil
	IsNil() bool

	// Value returns field value, or nil
	Value() interface{}

	// SetValue sets specific value and returns error if unsupported
	SetValue(interface{}) error

	// Copy returns a copy of the field
	Copy() Field
}

type FilePoll

type FilePoll interface {
	// Watch a file descriptor for changes
	Watch(uintptr, FilePollFlags, FilePollFunc) error

	// Unwatch a file descriptor
	Unwatch(uintptr) error
}

type FilePollFlags

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

func (f FilePollFlags) String() string

func (FilePollFlags) StringFlag

func (f FilePollFlags) StringFlag() string

type FilePollFunc

type FilePollFunc func(uintptr, FilePollFlags)

FilePollFunc is the handler for file polling

type FontFace

type FontFace interface {
	Name() string     // Get Face Name (from the filename)
	Index() uint      // Get Face Index
	NumFaces() uint   // Get Number of faces within the file
	NumGlyphs() uint  // Number of glyphs for the face
	Family() string   // Return name of font family
	Style() string    // Return style name of font face
	Flags() FontFlags // Return properties for face
}

FontFace represents a typeface

type FontFlags

type FontFlags uint16
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

func (f FontFlags) String() string

func (FontFlags) StringFlag

func (f FontFlags) StringFlag() string

type FontManager

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 faces in a family and/or with a particular set of attributes
	Faces(family string, flags FontFlags) []FontFace
}

FontManager for font management

type FontSize

type FontSize struct {
	Size float32
	Unit FontSizeUnit
}

type FontSizeUnit

type FontSizeUnit uint
const (
	FONT_SIZE_PIXELS FontSizeUnit = iota
	FONT_SIZE_POINTS
)

type GPIO

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
}

GPIO implements the GPIO interface for simple input and output

type GPIOEdge

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

func (e GPIOEdge) String() string

type GPIOEvent added in v3.0.3

type GPIOEvent interface {
	Event
	Pin() GPIOPin
	Edge() GPIOEdge
}

GPIOEvent happens when a pin is watched and edge is either rising or falling

type GPIOMode

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

func (m GPIOMode) String() string

type GPIOPin

type GPIOPin uint8 // GPIOPin is the logical GPIO pin
const (
	// Invalid pin constant
	GPIO_PIN_NONE GPIOPin = 0xFF
)

func (GPIOPin) String

func (p GPIOPin) String() string

type GPIOPull

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

func (p GPIOPull) String() string

type GPIOState

type GPIOState uint8 // GPIOState is the GPIO Pin state
const (
	GPIO_LOW GPIOState = iota
	GPIO_HIGH
)

func (GPIOState) String

func (s GPIOState) String() string

type GraphicsContext added in v3.0.32

type GraphicsContext interface{}

GraphicsContext is an opaque type

type HttpError added in v3.0.19

type HttpError interface {
	// Code returns the HTTP status code
	Code() int

	// Error returns the error message to be returned to the client
	Error() string

	// Path returns the redirect path for http.PermanentRedirect status
	Path() string
}

HttpError provides the correct error code to the client which can be returned by the ServeContent method in order to more correctly respond to the client

type HttpLogger added in v3.0.14

type HttpLogger interface {
	// Log all requests as named measurement
	Log(string) error
}

HttpLogger logs request and response metrics

type HttpRenderContext added in v3.0.24

type HttpRenderContext struct {
	Template string
	Type     string
	Content  interface{}
	Modified time.Time
}

HttpRenderContext represents information used to render a response through a template. If no template is returned then the content is served without a template. The type is returned on the Content-Type field of the response. The response is cached if the Modified field is not zero.

type HttpRenderer added in v3.0.19

type HttpRenderer interface {
	// IsModifiedSince should return true if content that
	// would be served for this request by the renderer and has
	// been modified since a certain time and rendering should
	// occur for that path. It should return false if this
	// renderer should not serve the request
	IsModifiedSince(docroot string, req *http.Request, t time.Time) bool

	// ServeContent returns the serving contexttemplate name, content object
	// last modified time for caching or zero-time if no
	// caching should occur, and an error. If the error is a
	// HttpError then the error return to the client is sent
	// correctly or else client gets InternalServerError
	// on error
	ServeContent(docroot string, req *http.Request) (HttpRenderContext, error)
}

HttpRenderer returns content to process with template for a request

type HttpStatic added in v3.0.4

type HttpStatic interface {
	// Serve static files in child folders with root URL as "path"
	Serve(string) error
}

HttpStatic serves files and folders from the filesystem

type HttpTemplate added in v3.0.17

type HttpTemplate interface {
	// Serve templates with root URL as "path" with files
	// in folder "docroot"
	Serve(path, docroot string) error

	// Register a document renderer
	RegisterRenderer(HttpRenderer) error

	// Return environment for request for FastCGI
	// or return nil otherwise
	Env(req *http.Request) map[string]string

	// Return content for request, which had passed through
	// a renderer
	Render(req *http.Request) (HttpRenderContext, error)
}

HttpTemplate loads and serves templates

type I2C

type I2C interface {
	// Return all valid devices
	Devices() []I2CBus

	// Set current slave address
	SetSlave(I2CBus, uint8) error

	// Get current slave address
	GetSlave(I2CBus) uint8

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

	// Read and Write data directly
	Read(I2CBus) ([]byte, error)
	Write(I2CBus, []byte) (int, error)

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

	// Write Byte (8-bits) and Word (16-bits)
	WriteUint8(bus I2CBus, reg, value uint8) error
	WriteInt8(bus I2CBus, reg uint8, value int8) error
	WriteUint16(bus I2CBus, reg uint8, value uint16) error
	WriteInt16(bus I2CBus, reg uint8, value int16) error
}

I2C implements the I2C interface for sensors, etc.

type I2CBus

type I2CBus uint

type InputDevice added in v3.0.3

type InputDevice interface {
	Name() string
	Type() InputDeviceType
}

InputDevice provides information about an input device

type InputDeviceType added in v3.0.3

type InputDeviceType uint16
const (
	INPUT_DEVICE_NONE        InputDeviceType = 0x0000
	INPUT_DEVICE_KEYBOARD    InputDeviceType = 0x0001
	INPUT_DEVICE_MOUSE       InputDeviceType = 0x0002
	INPUT_DEVICE_TOUCHSCREEN InputDeviceType = 0x0004
	INPUT_DEVICE_JOYSTICK    InputDeviceType = 0x0008
	INPUT_DEVICE_REMOTE      InputDeviceType = 0x0010 // IR Remote
	INPUT_DEVICE_SONY_12     InputDeviceType = 0x0020 // 12-bit Sony IR codes
	INPUT_DEVICE_SONY_15     InputDeviceType = 0x0040 // 15-bit Sony IR codes
	INPUT_DEVICE_SONY_20     InputDeviceType = 0x0080 // 20-bit Sony IR codes
	INPUT_DEVICE_RC5_14      InputDeviceType = 0x0100 // 14-bit RC5 IR codes
	INPUT_DEVICE_NEC_32      InputDeviceType = 0x0200 // 32-bit NEC IR codes
	INPUT_DEVICE_APPLETV_32  InputDeviceType = 0x0400 // 32-bit Apple TV IR codes
	INPUT_DEVICE_ANY         InputDeviceType = 0xFFFF
	INPUT_DEVICE_MIN                         = INPUT_DEVICE_KEYBOARD
	INPUT_DEVICE_MAX                         = INPUT_DEVICE_APPLETV_32
)

func (InputDeviceType) FlagString added in v3.0.3

func (d InputDeviceType) FlagString() string

func (InputDeviceType) String added in v3.0.3

func (d InputDeviceType) String() string

type InputEvent added in v3.0.3

type InputEvent interface {
	Event
	Key() KeyCode                      // Translated keycode
	Type() InputType                   // Event type (key press, repeat, etc)
	Device() (InputDeviceType, uint32) // Device information
}

InputEvent is a key press, mouse move, etc.

type InputManager added in v3.0.3

type InputManager interface {
	Devices() []InputDevice

	RegisterDevice(InputDevice) error
}

InputManager provides information on registered devices

type InputService added in v3.0.3

type InputService interface {
	Service
}

type InputStub added in v3.0.3

type InputStub interface {
	ServiceStub

	Stream(ctx context.Context, ch chan<- InputEvent) error
}

type InputType added in v3.0.3

type InputType uint
const (
	INPUT_EVENT_NONE InputType = 0x0000

	// Mouse and/or keyboard key/button press events
	INPUT_EVENT_KEYPRESS   InputType = 0x0001
	INPUT_EVENT_KEYRELEASE InputType = 0x0002
	INPUT_EVENT_KEYREPEAT  InputType = 0x0003

	// Mouse and/or touchscreen move events
	INPUT_EVENT_ABSPOSITION InputType = 0x0004
	INPUT_EVENT_RELPOSITION InputType = 0x0005

	// Multi-touch events
	INPUT_EVENT_TOUCHPRESS    InputType = 0x0006
	INPUT_EVENT_TOUCHRELEASE  InputType = 0x0007
	INPUT_EVENT_TOUCHPOSITION InputType = 0x0008
)

func (InputType) String added in v3.0.3

func (e InputType) String() string

type KeyCode added in v3.0.3

type KeyCode uint16
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
)
const (
	KEYCODE_EJECT KeyCode = iota + 0x0200
	KEYCODE_POWER_OFF
	KEYCODE_POWER_ON
	KEYCODE_INPUT_SELECT
	KEYCODE_INPUT_PC
	KEYCODE_INPUT_VIDEO1
	KEYCODE_INPUT_VIDEO2
	KEYCODE_INPUT_VIDEO3
	KEYCODE_INPUT_VIDEO4
	KEYCODE_INPUT_VIDEO5
	KEYCODE_INPUT_HDMI1
	KEYCODE_INPUT_HDMI2
	KEYCODE_INPUT_HDMI3
	KEYCODE_INPUT_HDMI4
	KEYCODE_INPUT_HDMI5
	KEYCODE_INPUT_AUX1
	KEYCODE_INPUT_AUX2
	KEYCODE_INPUT_AUX3
	KEYCODE_INPUT_AUX4
	KEYCODE_INPUT_AUX5
	KEYCODE_INPUT_CD
	KEYCODE_INPUT_DVD
	KEYCODE_INPUT_PHONO
	KEYCODE_INPUT_TAPE1
	KEYCODE_INPUT_TAPE2
	KEYCODE_INPUT_TUNER
	KEYCODE_INPUT_ANALOG
	KEYCODE_INPUT_DIGITAL
	KEYCODE_INPUT_INTERNET
	KEYCODE_INPUT_TEXT
	KEYCODE_INPUT_NEXT
	KEYCODE_INPUT_PREV
	KEYCODE_VIDEO_ASPECT
	KEYCODE_VIDEO_PIP
	KEYCODE_AUDIO_MONITOR
	KEYCODE_CLEAR
	KEYCODE_TIMER
	KEYCODE_CHANNEL_PREV
	KEYCODE_CHANNEL_GUIDE
	KEYCODE_RECORD
	KEYCODE_RECORD_SPEED
	KEYCODE_PLAY_SPEED
	KEYCODE_PLAY_MODE
	KEYCODE_REPLAY
	KEYCODE_DISPLAY
	KEYCODE_MENU
	KEYCODE_INFO
	//KEYCODE_HOME
	KEYCODE_THUMBS_UP
	KEYCODE_THUMBS_DOWN
	KEYCODE_FAVOURITE
	KEYCODE_BUTTON_RED
	KEYCODE_BUTTON_GREEN
	KEYCODE_BUTTON_YELLOW
	KEYCODE_BUTTON_BLUE
	KEYCODE_SEARCH_LEFT
	KEYCODE_SEARCH_RIGHT
	KEYCODE_CHAPTER_NEXT
	KEYCODE_CHAPTER_PREV
	KEYCODE_NAV_SELECT
	KEYCODE_SUBTITLE_TOGGLE
	KEYCODE_SUBTITLE_ON
	KEYCODE_SUBTITLE_OFF
	KEYCODE_STOP
	KEYCODE_PAUSE
	//KEYCODE_SLEEP
	KEYCODE_BROWSE
	KEYCODE_SHUFFLE
	KEYCODE_REPEAT
	KEYCODE_KEYPAD_10PLUS
)

func (KeyCode) String added in v3.0.3

func (k KeyCode) String() string

type LIRC

type LIRC interface {
	// Get receive and send modes
	RecvMode() LIRCMode
	SendMode() LIRCMode
	SetRecvMode(LIRCMode) error
	SetSendMode(LIRCMode) error

	// Receive parameters
	RecvDutyCycle() uint32
	RecvResolutionMicros() uint32

	// Receive parameters
	SetRecvTimeoutMs(uint32) error
	SetRecvTimeoutReports(bool) error
	SetRecvCarrierHz(uint32) error
	SetRecvCarrierRangeHz(min, max uint32) error

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

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

LIRC implements the IR send & receive interface

type LIRCEvent

type LIRCEvent interface {
	Event
	Type() LIRCType
	Mode() LIRCMode
	Value() interface{} // value is uint32 in ms when mode is LIRC_MODE_MODE2
}

LIRCEvent is a pulse, space or timeout from an IR sensor

type LIRCKeycodeManager added in v3.0.3

type LIRCKeycodeManager interface {
	// Keycode returns keycodes which match a search phrase
	Keycode(string) []KeyCode

	// Lookup returns Keycodes in priority order for scancode
	Lookup(InputDevice, uint32) []KeyCode

	// Set Keycode for scancode, InputDevice and device name
	Set(InputDevice, uint32, KeyCode, string) error
}

LIRCKeycodeManager manages the database of keycodes and IR codes

type LIRCMode

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
)

func (LIRCMode) String

func (m LIRCMode) String() string

type LIRCType

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
)

func (LIRCType) String

func (t LIRCType) String() string

type Logger

type Logger interface {
	Print(args ...interface{})              // Output logging
	Debug(args ...interface{})              // Output debugging information
	Printf(fmt string, args ...interface{}) // Output logging with format
	Debugf(fmt string, args ...interface{}) // Output debugging with format
	IsDebug() bool                          // IsDebug returns true if debug flag is set
	T() *testing.T                          // When testing, provides testing context
}

Logger outputs information and debug messages

type Measurement

type Measurement interface {
	Event

	Time() time.Time  // Time returns the timestamp for the data point or time.Time{}
	Tags() []Field    // Return the dimensions/tags for the data point
	Metrics() []Field // Return the metrics for the data point

	Get(string) interface{}        // Return a field value
	Set(string, interface{}) error // Set a field value
}

Measurement is a single data point

type Media

type Media interface {
	URL() *url.URL           // Return URL for the media location
	Metadata() MediaMetadata // Return metadata
	Flags() MediaFlag        // Return flags
	Streams() []MediaStream  // Return streams
}

Media is an input or output

type MediaCodec

type MediaCodec interface {
	// Name returns the unique name for the codec
	Name() string

	// Description returns the long description for the codec
	Description() string

	// Flags for the codec (Audio, Video, Encoder, Decoder)
	Flags() MediaFlag
}

MediaCodec is the codec and parameters

type MediaDecodeContext

type MediaDecodeContext interface {
	Stream() MediaStream // Origin of the packet
	Frame() int          // Frame counter
}

MediaDecodeContext provides packet data and streams for decoding frames of data

type MediaFlag

type MediaFlag uint64
const (
	MEDIA_FLAG_ALBUM             MediaFlag = (1 << iota) // Is part of an album
	MEDIA_FLAG_ALBUM_TRACK                               // Is an album track
	MEDIA_FLAG_ALBUM_COMPILATION                         // Album is a compliation
	MEDIA_FLAG_TVSHOW                                    // Is part of a TV Show
	MEDIA_FLAG_TVSHOW_EPISODE                            // Is a TV Show episode
	MEDIA_FLAG_FILE                                      // Is a file
	MEDIA_FLAG_VIDEO                                     // Contains video
	MEDIA_FLAG_AUDIO                                     // Contains audio
	MEDIA_FLAG_SUBTITLE                                  // Contains subtitles
	MEDIA_FLAG_DATA                                      // Contains data stream
	MEDIA_FLAG_ATTACHMENT                                // Contains attachment
	MEDIA_FLAG_ARTWORK                                   // Contains artwork
	MEDIA_FLAG_CAPTIONS                                  // Contains captions
	MEDIA_FLAG_ENCODER                                   // Is an encoder
	MEDIA_FLAG_DECODER                                   // Is an decoder
	MEDIA_FLAG_NONE              MediaFlag = 0
	MEDIA_FLAG_MIN                         = MEDIA_FLAG_ALBUM
	MEDIA_FLAG_MAX                         = MEDIA_FLAG_DECODER
)

func (MediaFlag) FlagString

func (f MediaFlag) FlagString() string

func (MediaFlag) String

func (f MediaFlag) String() string

type MediaFrame

type MediaFrame interface {
	image.Image
}

MediaFrame is a decoded audio or video frame

type MediaInput added in v3.0.3

type MediaInput interface {
	Media

	// StreamsForFlag returns array of stream indexes for
	// the best streams to use according to the flags
	StreamsForFlag(MediaFlag) []int

	// Read loops over selected streams from media object, and
	// packets are provided to a Decode function
	Read(context.Context, []int, DecodeIteratorFunc) error

	// DecodeFrameIterator loops over data packets from media stream
	DecodeFrameIterator(MediaDecodeContext, MediaPacket, DecodeFrameIteratorFunc) error
}

type MediaKey

type MediaKey string
const (
	MEDIA_KEY_BRAND_MAJOR      MediaKey = "major_brand"       // string
	MEDIA_KEY_BRAND_COMPATIBLE MediaKey = "compatible_brands" // string
	MEDIA_KEY_CREATED          MediaKey = "creation_time"     // time.Time
	MEDIA_KEY_ENCODER          MediaKey = "encoder"           // string
	MEDIA_KEY_ALBUM            MediaKey = "album"             // string
	MEDIA_KEY_ALBUM_ARTIST     MediaKey = "artist"            // string
	MEDIA_KEY_COMMENT          MediaKey = "comment"           // string
	MEDIA_KEY_COMPOSER         MediaKey = "composer"          // string
	MEDIA_KEY_COPYRIGHT        MediaKey = "copyright"         // string
	MEDIA_KEY_YEAR             MediaKey = "date"              // uint
	MEDIA_KEY_DISC             MediaKey = "disc"              // uint
	MEDIA_KEY_ENCODED_BY       MediaKey = "encoded_by"        // string
	MEDIA_KEY_FILENAME         MediaKey = "filename"          // string
	MEDIA_KEY_GENRE            MediaKey = "genre"             // string
	MEDIA_KEY_LANGUAGE         MediaKey = "language"          // string
	MEDIA_KEY_PERFORMER        MediaKey = "performer"         // string
	MEDIA_KEY_PUBLISHER        MediaKey = "publisher"         // string
	MEDIA_KEY_SERVICE_NAME     MediaKey = "service_name"      // string
	MEDIA_KEY_SERVICE_PROVIDER MediaKey = "service_provider"  // string
	MEDIA_KEY_TITLE            MediaKey = "title"             // string
	MEDIA_KEY_TRACK            MediaKey = "track"             // uint
	MEDIA_KEY_VERSION_MAJOR    MediaKey = "major_version"     // string
	MEDIA_KEY_VERSION_MINOR    MediaKey = "minor_version"     // string
	MEDIA_KEY_SHOW             MediaKey = "show"              // string
	MEDIA_KEY_SEASON           MediaKey = "season_number"     // uint
	MEDIA_KEY_EPISODE_SORT     MediaKey = "episode_sort"      // string
	MEDIA_KEY_EPISODE_ID       MediaKey = "episode_id"        // uint
	MEDIA_KEY_COMPILATION      MediaKey = "compilation"       // bool
	MEDIA_KEY_GAPLESS_PLAYBACK MediaKey = "gapless_playback"  // bool
	MEDIA_KEY_ACCOUNT_ID       MediaKey = "account_id"        // string
	MEDIA_KEY_DESCRIPTION      MediaKey = "description"       // string
	MEDIA_KEY_MEDIA_TYPE       MediaKey = "media_type"        // string
	MEDIA_KEY_PURCHASED        MediaKey = "purchase_date"     // time.Time
	MEDIA_KEY_ALBUM_SORT       MediaKey = "sort_album"        // string
	MEDIA_KEY_ARTIST_SORT      MediaKey = "sort_artist"       // string
	MEDIA_KEY_TITLE_SORT       MediaKey = "sort_name"         // string
	MEDIA_KEY_SYNOPSIS         MediaKey = "synopsis"          // string
	MEDIA_KEY_GROUPING         MediaKey = "grouping"          // string
)

type MediaManager

type MediaManager interface {
	// OpenFile opens a local media file
	OpenFile(path string) (MediaInput, error)

	// OpenURL opens a network-based stream
	OpenURL(url *url.URL) (MediaInput, error)

	// CreateFile creates a local media file for output
	CreateFile(path string) (MediaOutput, error)

	// Close will release resources and close a media object
	Close(Media) error

	// ListCodecs enumerates codecs for a specific name and/or
	// audio, video, encode and decode. By default (empty name and
	// MediaFlag) lists all codecs
	ListCodecs(string, MediaFlag) []MediaCodec
}

MediaManager for media file management

type MediaMetadata

type MediaMetadata interface {
	Keys() []MediaKey           // Return all existing keys
	Value(MediaKey) interface{} // Return value for key, or nil
}

MediaMetadata are key value pairs for a media object

type MediaOutput added in v3.0.3

type MediaOutput interface {
	Media

	// Write packets to output
	Write(MediaDecodeContext, MediaPacket) error
}

type MediaPacket

type MediaPacket interface {
	Size() int
	Bytes() []byte
	Stream() int
}

MediaPacket is a packet of data from a stream

type MediaStream

type MediaStream interface {
	Index() int        // Stream index
	Flags() MediaFlag  // Flags for the stream (Audio, Video, etc)
	Codec() MediaCodec // Return codec and parameters
}

MediaStream is a stream of packets from a media object

type MetricQuery added in v3.0.23

type MetricQuery interface{}

MetricQuery constructs queries which can be executed by the MetricReader, TODO methods which modify the basic query

type MetricReader added in v3.0.23

type MetricReader interface {
	Ping() (time.Duration, error) // Ping the database and return latency

	// NewQuery constructs a query with measurement name and the
	// names of tags which are grouped. By default, all metrics are returned
	NewQuery(string, ...string) MetricQuery
}

MetricReader implements a database query

type MetricWriter added in v3.0.3

type MetricWriter interface {
	Ping() (time.Duration, error) // Ping the database and return latency
	Write(...Measurement) error   // Write one or more measurements to the database
}

MetricWriter implements a database writing object

type Metrics

type Metrics interface {
	// Define a measurement with metric definitions and optional tag fields
	NewMeasurement(string, string, ...Field) (Measurement, error)

	// Emit tags and metrics for a named measurement, omitting timestamp
	Emit(string, []Field, ...interface{}) error

	// EmitTS emits tags and metrics for a named measurement, with defined timestamp
	EmitTS(string, time.Time, []Field, ...interface{}) error

	// Measurements returns array of all defined measurements
	Measurements() []Measurement

	// Field creates a field or nil if invalid
	Field(string, ...interface{}) Field

	// HostTag returns a field with the current hostname
	HostTag() Field

	// UserTag returns a field with the current username
	UserTag() Field

	// EnvTag returns a field with the value of an environment variable
	EnvTag(string) Field
}

Metrics provides a mechanism for defining measurements and emitting data, which may be time-series based and include tags (which are indexed and can be used for grouping) and metrics (which are not, and can be aggregated).

type MetricsService added in v3.0.10

type MetricsService interface {
	Service
}

type MetricsStub added in v3.0.10

type MetricsStub interface {
	ServiceStub

	// List returns the array of defined measurements
	List(context.Context) ([]Measurement, error)

	// Stream emits measurements defined by name filter on
	// the provided channel until context is cancelled. Where
	// the name filter is empty, all measurements are emitted
	Stream(context.Context, string, chan<- Measurement) error
}

type PingService

type PingService interface {
	Service
}

type PingStub

type PingStub interface {
	ServiceStub

	Ping(ctx context.Context) error
	Version(ctx context.Context) (Version, error)
	ListServices(context.Context) ([]string, error) // Return a list of services supported
}

type Platform

type Platform interface {
	Product() string                           // Product returns product name
	Type() PlatformType                        // Type returns flags identifying platform type
	SerialNumber() string                      // SerialNumber returns unique serial number for host
	Uptime() time.Duration                     // Uptime returns uptime for host
	LoadAverages() (float64, float64, float64) // LoadAverages returns 1, 5 and 15 minute load averages
	TemperatureZones() map[string]float32      // Return celcius values for zones
}

type PlatformType

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

func (p PlatformType) FlagString() string

func (PlatformType) String

func (p PlatformType) String() string

type Point

type Point struct {
	X, Y float32
}

func (Point) Equals

func (p1 Point) Equals(p2 Point) bool

func (Point) String

func (p Point) String() string

type Publisher

type Publisher interface {
	// Emit an event, which can block if second argument is true
	Emit(Event, bool) error

	// Subscribe to events
	Subscribe() <-chan Event

	// Unsubscribe from events
	Unsubscribe(<-chan Event)
}

Publisher emits events and allows for subscribing to emitted events

type RotelEvent added in v3.0.32

type RotelEvent interface {
	Event

	Flags() RotelFlag // Flags returns the state that has changed
}

RotelEvent is emitted on change of amplifier state

type RotelFlag added in v3.0.33

type RotelFlag uint16

RotelFlag provides flags on state changes

const (
	ROTEL_FLAG_POWER RotelFlag = (1 << iota)
	ROTEL_FLAG_VOLUME
	ROTEL_FLAG_MUTE
	ROTEL_FLAG_BASS
	ROTEL_FLAG_TREBLE
	ROTEL_FLAG_BALANCE
	ROTEL_FLAG_SOURCE
	ROTEL_FLAG_FREQ
	ROTEL_FLAG_BYPASS
	ROTEL_FLAG_SPEAKER
	ROTEL_FLAG_DIMMER
	ROTEL_FLAG_NONE RotelFlag = 0
	ROTEL_FLAG_MIN            = ROTEL_FLAG_POWER
	ROTEL_FLAG_MAX            = ROTEL_FLAG_DIMMER
)

func (RotelFlag) FlagString added in v3.0.33

func (f RotelFlag) FlagString() string

func (RotelFlag) String added in v3.0.33

func (f RotelFlag) String() string

type RotelManager added in v3.0.32

type RotelManager interface {
	Publisher

	// Get model number
	Model() string

	// Get properties
	Power() bool
	Source() string
	Volume() uint
	Freq() string
	Bass() int
	Treble() int
	Muted() bool
	Bypass() bool
	Balance() (string, uint)
	Speakers() []string
	Dimmer() uint

	// Set properties
	SetPower(bool) error     // SetPower sets amplifier to standby or on
	SetSource(string) error  // SetSource sets input source
	SetVolume(uint) error    // SetVolume sets the volume between 1 and 96 inclusive
	SetMute(bool) error      // SetMute mutes and unmutes
	SetBypass(bool) error    // SetBypass sets preamp bypass
	SetTreble(int) error     // SetTreble sets treble -10 <> +10
	SetBass(int) error       // SetBass sets bass -10 <> +10
	SetBalance(string) error // SetBalance L,R or 0
	SetDimmer(uint) error    // SetDimmer display between 0 and 6 (0 is brightest)

	// Actions
	Play() error
	Stop() error
	Pause() error
	NextTrack() error
	PrevTrack() error
}

RotelManager controls a connected Rotel Amplifier

type RotelService added in v3.0.32

type RotelService interface {
	Service
}

RotelService defines an RPC service connected to the Rotel Amplifer

type RotelStub added in v3.0.32

type RotelStub interface {
	ServiceStub

	// Set Properties
	SetPower(context.Context, bool) error // SetPower to on or standby
	SetSource(context.Context, string) error
	SetVolume(context.Context, uint) error
	SetMute(context.Context, bool) error
	SetBypass(context.Context, bool) error
	SetTreble(context.Context, int) error
	SetBass(context.Context, int) error
	SetBalance(context.Context, string) error // L, R or 0
	SetDimmer(context.Context, uint) error

	// Actions
	Play(context.Context) error
	Stop(context.Context) error
	Pause(context.Context) error
	NextTrack(context.Context) error
	PrevTrack(context.Context) error

	// Stream change events
	Stream(context.Context, chan<- RotelEvent) error
}

RotelStub is an RPC client which connects to the RPC service

type SPI

type SPI interface {
	// Return all valid devices
	Devices() []SPIBus

	// Mode returns the current SPI mode
	Mode(SPIBus) SPIMode

	// SetMode sets the current SPI mode
	SetMode(SPIBus, SPIMode) error

	// MaxSpeedHz returns the current data transfer speed
	MaxSpeedHz(SPIBus) uint32

	// SetMaxSpeedHz sets the current data transfer speed
	SetMaxSpeedHz(SPIBus, uint32) error

	// BitsPerWord returns current configuration
	BitsPerWord(SPIBus) uint8

	// SetBitsPerWord updates the current configuration
	SetBitsPerWord(SPIBus, uint8) error

	// Transfer reads and writes on the SPI bus
	Transfer(SPIBus, []byte) ([]byte, error)

	// Read bytes into a buffer
	Read(SPIBus, []byte) error

	// Write bytes from the buffer
	Write(SPIBus, []byte) error
}

SPI implements the SPI interface for sensors, etc.

type SPIBus added in v3.0.3

type SPIBus struct {
	Bus, Slave uint
}

type SPIMode

type SPIMode uint32 // 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
	SPI_MODE_MASK SPIMode = 0x03
)

func (SPIMode) String

func (m SPIMode) String() string

type Server

type Server interface {
	// Register an RPC or HTTP service with the server
	RegisterService(interface{}, Service) error

	// Start server in background and return
	StartInBackground(network, addr string) error

	// Stop server, when argument is true forcefully disconnects any clients
	Stop(bool) error

	// Addr returns the address of the server, the path for the file socket
	// or empty if not connected
	Addr() string

	// Returns information about the server
	Flags() ServiceFlag

	// Service returns _http._tcp or _grpc._tcp or empty if networking
	// is file socket based
	Service() string

	// NewStreamContext returns a streaming context which should be used
	// to cancel streaming to clients when the server is shutdown
	NewStreamContext() context.Context
}

Server is a generic RPC or HTTP server, which can serve responses for registered services to clients

type Service

type Service interface{}

Service defines an RPC or HTTP service. At the moment HTTP services must adhere to the http.Handler interface.

type ServiceDiscovery added in v3.0.3

type ServiceDiscovery interface {
	// NewServiceRecord returns a record from service, name, port, txt and
	// flags for IP4, IP6 or both
	NewServiceRecord(string, string, uint16, []string, ServiceFlag) (ServiceRecord, error)

	// EnumerateServices queries for available service names
	EnumerateServices(context.Context) ([]string, error)

	// Lookup queries for records for a service name
	Lookup(context.Context, string) ([]ServiceRecord, error)

	// Serve will respond to service discovery queries and
	// de-register those services when ending
	Serve(context.Context, []ServiceRecord) error
}

type ServiceFlag added in v3.0.3

type ServiceFlag uint
const (
	SERVICE_FLAG_NONE   ServiceFlag = 0
	SERVICE_FLAG_IP4    ServiceFlag = (1 << iota) // IP4 Addressing
	SERVICE_FLAG_IP6                              // IP6 Addressing
	SERVICE_FLAG_SOCKET                           // Unix File Socket transport
	SERVICE_FLAG_TLS                              // TLS (SSL) Communication
	SERVICE_FLAG_FCGI                             // FastCGI Communiction
	SERVICE_FLAG_HTTP                             // HTTP Protocol
	SERVICE_FLAG_GRPC                             // gRPC Protocol
	SERVICE_FLAG_MIN    = SERVICE_FLAG_IP4
	SERVICE_FLAG_MAX    = SERVICE_FLAG_GRPC
)

func (ServiceFlag) FlagString added in v3.0.24

func (f ServiceFlag) FlagString() string

func (ServiceFlag) String added in v3.0.24

func (f ServiceFlag) String() string

type ServiceRecord added in v3.0.3

type ServiceRecord interface {
	Instance() string
	Service() string
	Name() string
	Zone() string
	Host() string
	Port() uint16
	Addrs() []net.IP
	Txt() []string
}

type ServiceStub

type ServiceStub interface {
	New(Conn)
}

ServiceStub is a client-side stub used to invoke remote service methods

type Size

type Size struct {
	W, H float32
}

func (Size) String

func (s Size) String() string

type Surface added in v3.0.4

type Surface interface {
	Origin() Point
	Size() Size
	Bitmap() Bitmap
}

Surface is an on-screen surface, which embeds a drawable canvas

type SurfaceFlags added in v3.0.4

type SurfaceFlags uint16

SurfaceFlags are flags associated with renderable surface

const (
	SURFACE_FLAG_BITMAP SurfaceFlags = (1 << iota)
	SURFACE_FLAG_OPENGL
	SURFACE_FLAG_OPENGL_ES
	SURFACE_FLAG_OPENGL_ES2
	SURFACE_FLAG_OPENGL_ES3
	SURFACE_FLAG_OPENVG
	SURFACE_FLAG_NONE SurfaceFlags = 0
	SURFACE_FLAG_MASK              = (SURFACE_FLAG_OPENVG << 1) - 1
	SURFACE_FLAG_MIN               = SURFACE_FLAG_BITMAP
	SURFACE_FLAG_MAX               = SURFACE_FLAG_OPENVG
)

func (SurfaceFlags) String added in v3.0.4

func (f SurfaceFlags) String() string

func (SurfaceFlags) StringFlag added in v3.0.4

func (f SurfaceFlags) StringFlag() string

type SurfaceFormat added in v3.0.4

type SurfaceFormat uint

SurfaceFormat defines the pixel format for a surface

const (
	SURFACE_FMT_NONE   SurfaceFormat = iota
	SURFACE_FMT_RGBA32               // 4 bytes per pixel with transparency
	SURFACE_FMT_XRGB32               // 4 bytes per pixel without transparency
	SURFACE_FMT_RGB888               // 3 bytes per pixel
	SURFACE_FMT_RGB565               // 2 bytes per pixel
	SURFACE_FMT_1BPP                 // 1 bit per pixel (Mono)
	SURFACE_FMT_MAX    = SURFACE_FMT_1BPP
)

func (SurfaceFormat) String added in v3.0.4

func (f SurfaceFormat) String() string

type SurfaceManager added in v3.0.4

type SurfaceManager interface {
	//CreateBackground(GraphicsContext, SurfaceFlags) (Surface, error)
	CreateSurface(GraphicsContext, SurfaceFlags, float32, uint16, Point, Size) (Surface, error)
	//CreateSurfaceWithBitmap(GraphicsContext, SurfaceFlags, Bitmap, float32, uint16, Point, Size) (Surface, error)
	DisposeSurface(GraphicsContext, Surface) error

	// CreateBitmap returns a new bitmap with a specific pixel format
	// and size. The size cannot be zero
	CreateBitmap(SurfaceFormat, Size) (Bitmap, error)

	// DisposeBitmap frees resources for a bitmap
	DisposeBitmap(Bitmap) error

	// Do method is used to make graphics updates
	Do(SurfaceManagerCallback) error
}

SurfaceManager to manage graphics surfaces

type SurfaceManagerCallback added in v3.0.32

type SurfaceManagerCallback func(GraphicsContext) error

type TradfriDevice added in v3.0.33

type TradfriDevice interface {
	Name() string
	Id() uint
	Type() uint
	Created() time.Time
	Updated() time.Time
	Active() bool
	Vendor() string
	Product() string
	Version() string
}

TradfriDevice is a device connected to the gateway

type TradfriManager added in v3.0.33

type TradfriManager interface {
	// Connect to a gateway with gateway id, hostname and port
	Connect(string, string, uint16) error

	// Disconnect from a gateway
	Disconnect() error

	// Return all devices
	Devices(context.Context) ([]TradfriDevice, error)

	// Observe for device changes
	ObserveDevice(context.Context, TradfriDevice) error

	// Properties
	Addr() net.Addr  // Return IP Address for Gateway
	Id() string      // Return ID for authentication to gateway
	Version() string // Return version of gateway
}

TradfriManager communicates with an Ikea Tradfri gateway

type Unit

type Unit struct{}

Unit marks an singleton object

func (*Unit) Define

func (this *Unit) Define(Config) error

func (*Unit) Dispose

func (this *Unit) Dispose() error

func (*Unit) New

func (this *Unit) New(Config) error

func (*Unit) Require added in v3.0.24

func (this *Unit) Require(units ...interface{})

Call Require with a set of values and if any of them are nil then panic

func (*Unit) Run

func (this *Unit) Run(context.Context) error

type Version

type Version interface {
	Name() string                      // Return process name
	Version() (string, string, string) // Return tag, branch and hash
	BuildTime() time.Time              // Return time of process compilation
	GoVersion() string                 // Return go compiler version
}

Directories

Path Synopsis
cmd
dx
gx
hw
rpc
pkg
graphics/surface/eglgbm
Graphics Surface Management with EGL, DRM and GBM
Graphics Surface Management with EGL, DRM and GBM
http/fcgi
Package fcgi implements the FastCGI protocol.
Package fcgi implements the FastCGI protocol.
hw/display
Display package enumerates displays and emits events when displays are added and removed
Display package enumerates displays and emits events when displays are added and removed
hw/platform
Platform provides information about the hardware (Product, Serial Number, etc)
Platform provides information about the hardware (Product, Serial Number, etc)
log
sys/drm
DRM (Direct Rendering Manager) bindings for Go On Debian, use: bash# apt install libdrm-dev Then when you depend on this code, use -tags drm when running go build test and install
DRM (Direct Rendering Manager) bindings for Go On Debian, use: bash# apt install libdrm-dev Then when you depend on this code, use -tags drm when running go build test and install
sys/dvb
DVB (Digital Video Broadcasting) bindings for Go When you depend on this code, use -tags dvb when running go build test and install.
DVB (Digital Video Broadcasting) bindings for Go When you depend on this code, use -tags dvb when running go build test and install.
sys/egl
Khronos EGL bindings For debian, you need to install the headers and libraries first: sudo apt install libegl1-mesa-dev
Khronos EGL bindings For debian, you need to install the headers and libraries first: sudo apt install libegl1-mesa-dev
sys/ffmpeg
This package provides ffmpeg bindings, targetting new versions of the ffmpeg API.
This package provides ffmpeg bindings, targetting new versions of the ffmpeg API.
sys/gbm
GBM (Generic Buffer Manager) bindings for Go On Debian, use: bash# apt install libgbm-dev Then when you depend on this code, use -tags grm when running go build test and install
GBM (Generic Buffer Manager) bindings for Go On Debian, use: bash# apt install libgbm-dev Then when you depend on this code, use -tags grm when running go build test and install
sys/mmal
MMAL Multimedia Abstraction Layer Bindings
MMAL Multimedia Abstraction Layer Bindings

Jump to

Keyboard shortcuts

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