gopi

package module
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: BSD-2-Clause Imports: 7 Imported by: 0

README

GOPI Go Language Application Framework

CircleCI

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

  • The GPIO, I2C and SPI interfaces
  • 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

Getting Started

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

  • make rpi will run the tests and install the examples

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 for a copy of this license and for a list of the conditions for redistribution and use.

Documentation

Index

Constants

This section is empty.

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
}

type ArgonOnePowerMode

type ArgonOnePowerMode uint
const (
	ARGONONE_POWER_DEFAULT ArgonOnePowerMode = iota
	ARGONONE_POWER_ALWAYSON
	ARGONONE_POWER_UART
)

func (ArgonOnePowerMode) String

func (v ArgonOnePowerMode) String() string

type Command

type Command interface {
	Name() string              // Return command name
	Usage() string             // Return usage information
	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
	FlagBool(string, bool, string) *bool
	FlagUint(string, uint, string) *uint
	FlagDuration(string, time.Duration, string) *time.Duration

	// Define commands
	Command(string, string, CommandFunc) error // Append a command with name and usage arguments

	// Get values
	GetString(string) string
	GetBool(string) bool
	GetUint(string) uint
	GetDuration(string) time.Duration
	GetCommand([]string) Command // Get command from provided arguments
}

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

	// Methods
	ListServices(context.Context) ([]string, error) // Return a list of services supported
	NewStub(string) ServiceStub                     // Return the stub for a named service
}

Conn is a connection to a remote server

type ConnPool

type ConnPool interface {
	Connect(network, addr string) (Conn, error)
}

ConnPool is a factory of client connections

type DecodeFrameIteratorFunc

type DecodeFrameIteratorFunc func(MediaDecodeContext, MediaFrame) error

type DecodeIteratorFunc

type DecodeIteratorFunc func(MediaDecodeContext, MediaPacket) error

type Display

type Display interface {
	Id() uint16             // Return display number
	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 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 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 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 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 value from LIRC

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
}

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 dimenstions/tags for the data point
	Metrics() []Field // Return the metrics for the data point
}

Measurement is a single data point

type Media

type Media interface {
	// Properties
	URL() *url.URL                  // Return URL for the media location
	Metadata() MediaMetadata        // Return metadata
	Flags() MediaFlag               // Return flags
	Streams() []MediaStream         // Return streams
	StreamsForFlag(MediaFlag) []int // Return stream index for flag(s)

	// DecodeIterator loops over selected streams from media object
	DecodeIterator([]int, DecodeIteratorFunc) error

	// DecodeFrameIterator loops over decoded frames from media stream
	DecodeFrameIterator(MediaDecodeContext, MediaPacket, DecodeFrameIteratorFunc) error
}

Media is an input or output

type MediaCodec

type MediaCodec interface {
	Flags() MediaFlag // Flags for the codec (Audio, Video, etc)
}

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 uint
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_DATA                                      // Contains data stream
	MEDIA_FLAG_ATTACHMENT                                // Contains attachment
	MEDIA_FLAG_ARTWORK                                   // Contains artwork
	MEDIA_FLAG_CAPTIONS                                  // Contains captions
	MEDIA_FLAG_NONE              MediaFlag = 0
	MEDIA_FLAG_MIN                         = MEDIA_FLAG_ALBUM
	MEDIA_FLAG_MAX                         = MEDIA_FLAG_CAPTIONS
)

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 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(path string) (Media, error)   // Open a media file
	CreateFile(path string) (Media, error) // Create an output file
	Close(Media) error                     // Close a media object
}

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 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 Metrics

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

	// NewFields returns array of fields
	NewFields(...string) []Field

	// Emit metrics for a named measurement, omitting timestamp
	Emit(string, ...interface{}) error

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

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

Metrics provides a mechanism for defining measurements and emitting data, which may be time-series based and include tags/dimensions (which are indexed) and metrics (which are not)

type PingService

type PingService interface {
	Service
}

type PingStub

type PingStub interface {
	ServiceStub

	Ping(ctx context.Context) error
	Version(ctx context.Context) (Version, error)
}

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
	NumberOfDisplays() uint                    // NumberOfDisplays returns the number of possible displays for this host
	AttachedDisplays() []uint                  // AttachedDisplays returns array of displays which are connected
}

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 SPI

type SPI interface {
	Mode() SPIMode                        // Get SPI mode
	MaxSpeedHz() uint32                   // Get SPI speed
	BitsPerWord() uint8                   // Get Bits Per Word
	SetMode(SPIMode) error                // Set SPI mode
	SetMaxSpeedHz(uint32) error           // Set SPI speed
	SetBitsPerWord(uint8) error           // Set Bits Per Word
	Transfer(send []byte) ([]byte, error) // Read/Write
	Read(len uint32) ([]byte, error)      // Read
	Write(send []byte) error              // Write
}

SPI implements the SPI interface for sensors, etc.

type SPIDevice

type SPIDevice struct {
	Bus, Slave uint
}

type SPIMode

type SPIMode uint8 // SPIMode is the SPI Mode
const (
	SPI_MODE_CPHA SPIMode = 0x01
	SPI_MODE_CPOL SPIMode = 0x02
	SPI_MODE_0    SPIMode = 0x00
	SPI_MODE_1    SPIMode = (0x00 | SPI_MODE_CPHA)
	SPI_MODE_2    SPIMode = (SPI_MODE_CPOL | 0x00)
	SPI_MODE_3    SPIMode = (SPI_MODE_CPOL | SPI_MODE_CPHA)
	SPI_MODE_NONE SPIMode = 0xFF
)

func (SPIMode) String

func (m SPIMode) String() string

type Server

type Server interface {
	RegisterService(interface{}, Service) error   // Register an RPC service
	StartInBackground(network, addr string) error // Start server in background and return
	Stop(bool) error                              // Stop server, when argument is true forcefully disconnects any clients
	Addr() string                                 // Addr returns the address of the server, or empty if not connected
}

Server is a generic gRPC server, which can serve registered services

type Service

type Service interface {
	CancelStreams()
}

Service defines an RPC service, which can cancel any on-going streams when server stops

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 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) 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
}

Jump to

Keyboard shortcuts

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