Documentation ¶
Overview ¶
Package pi contains functionality to use the various I/O hardware of a Raspberry Pi, such as GPIO, I2C and the camera module.
Index ¶
Constants ¶
const ( // I2CRetries specifies the number of times a device should be polled when not acknowledging. I2CRetries uint32 = 0x00000701 + iota // I2CTimeout specifies the timeout in units of 10 ms. I2CTimeout // I2CSlave specifies the use this slave address. I2CSlave // I2CTenBit sets the use of ten-bit addresses (0 == 7 bits; not 0 == 10 bits). I2CTenBit // I2CFuncs gets the adapter functionality mask. I2CFuncs // I2CSlaveForce specifies the use of this slave address even if it's already in use by a driver. I2CSlaveForce // I2CRdWr specifieds the use of a combined read/write )on stop only). I2CRdWr // I2CPEC enables packet error checking. I2CPEC )
const Bcm2708Base int64 = 0x2000000
Bcm2708Base is the BCM 2708 base address.
const GpClr0 int = 10
GpClr0 is the register number for GPCLR0.
const GpLev0 int = 13
GpLev0 is the register number for GPLEV0.
const GpSet0 int = 7
GpSet0 is the register number for GPSET0.
const GpioOffset int64 = 0x20000
GpioOffset is the GPIO offset into the BCM2708 register space.
const PageSize int = 1 << 12
PageSize (4K) is page size for the BCM 2708 GPIO register space.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶ added in v0.2.0
type Camera interface { io.Closer // Driver returns the camera driver name. Driver() (string, error) // Card rturns the camera card name. Card() (string, error) // BusInfo returns the camera bus info. BusInfo() (string, error) // Formats returns the supported formats. Formats() ([]string, error) // FrameSizes returns the supported frame sizes for a given format. FrameSizes(desc string) ([]*FrameSize, error) // SetFormat sets the format and frame size. SetFormat(desc string, width uint32, height uint32) (uint32, uint32, error) // GrabFrame grabs a single frame. GrabFrame() ([]byte, error) // GrabImage grabs a single frame and returns it as an image. GrabImage() (image.Image, string, error) }
Camera defines the behavior of a Camera.
func OpenCamera ¶ added in v0.2.0
OpenCamera opens the camera device at the specified path.
type FrameSize ¶ added in v0.2.0
type FrameSize struct { // IsDiscreet indicates whether or not this frame size is discreet. IsDiscreet bool // IsStepwise indicates whether or not this frame size is stepwise. IsStepwise bool // IsContinuous indicates whether or not this frame size is continuous. IsContinuous bool // Width is the discreet width. Width uint32 // Height is the discreet height. Height uint32 // MinWidth is the minimum width. MinWidth uint32 // MaxWidth is the maximum width. MaxWidth uint32 // StepWidth is the step width. StepWidth uint32 // MinHeight is the minimum height. MinHeight uint32 // MaxHeight is the maximum height. MaxHeight uint32 // StepHeight is the step height. StepHeight uint32 }
FrameSize is an encapsulation of a support frame size or steps.
type GPIO ¶
type GPIO interface { io.Closer Direction() Direction Pin() Pin Value() (Value, error) SetValue(value Value) error }
GPIO represents a single GPIO pin.
type I2CBus ¶ added in v0.5.0
type I2CBus interface { io.Reader io.Writer io.Closer // SetSlave addresses a specific slave. SetSlave(address uint8) error }
I2CBus defines the behavior of an I2C bus).
func OpenI2CBus ¶ added in v0.5.0
OpenI2CBus opens the I2C bus at the specified path.
type Pin ¶
type Pin uint8
Pin is the GPIO pin type.
const ( // GPIO2 is GPIO pin 2. GPIO2 Pin = iota + 2 // GPIO3 is GPIO pin 3. GPIO3 // GPIO4 is GPIO pin 4. GPIO4 // GPIO5 is GPIO pin 5. GPIO5 // GPIO6 is GPIO pin 6. GPIO6 // GPIO7 is GPIO pin 7. GPIO7 // GPIO8 is GPIO pin 8. GPIO8 // GPIO9 is GPIO pin 9. GPIO9 // GPIO10 is GPIO pin 10. GPIO10 // GPIO11 is GPIO pin 11. GPIO11 // GPIO12 is GPIO pin 12. GPIO12 // GPIO13 is GPIO pin 13. GPIO13 // GPIO14 is GPIO pin 14. GPIO14 // GPIO15 is GPIO pin 15. GPIO15 // GPIO16 is GPIO pin 16. GPIO16 // GPIO17 is GPIO pin 17. GPIO17 // GPIO18 is GPIO pin 18. GPIO18 // GPIO19 is GPIO pin 19. GPIO19 // GPIO20 is GPIO pin 20. GPIO20 // GPIO21 is GPIO pin 21. GPIO21 // GPIO22 is GPIO pin 22. GPIO22 // GPIO23 is GPIO pin 23. GPIO23 // GPIO24 is GPIO pin 24. GPIO24 // GPIO25 is GPIO pin 25. GPIO25 // GPIO26 is GPIO pin 26. GPIO26 // GPIO27 is GPIO pin 27. GPIO27 )