Documentation
¶
Overview ¶
The gpio package can be used to setup and access the raspberrie's gpio pins. If the configuration and access happens via file access an internal loop is implemented in the corresponding method that ensures the file access is repeated until a fixed bound of repeats is reached or the file access was successfully.
Index ¶
Constants ¶
const ( OUTPUT PinMode = 1 + iota INPUT GPIO2 GpioId = iota GPIO3 GPIO4 GPIO5 GPIO6 GPIO7 GPIO8 GPIO9 GPIO10 GPIO11 GPIO12 GPIO13 GPIO14 GPIO15 GPIO16 GPIO17 GPIO18 GPIO19 GPIO20 GPIO21 GPIO22 GPIO23 GPIO24 GPIO25 GPIO26 GPIO27 DIRECTION_FILE_NAME = "direction" IN = "in" OUT = "out" ACTIVE_LOW_FILE_NAME = "active_low" ALTRUE = "1" ALFALSE = "0" VALUE_FILE_NAME = "value" FILE_ACCESS_BOUND = 1000 )
Constants declatation
Variables ¶
var ( EXPORT_FILE = "/sys/class/gpio/export" UNEXPORT_FILE = "/sys/class/gpio/unexport" PATH_PREFIX = "/sys/class/gpio/gpio" )
Functions ¶
This section is empty.
Types ¶
type Pin ¶
type Pin struct {
// contains filtered or unexported fields
}
struct representing a gpio pin internally
func NewPin ¶
func NewPin() (p *Pin)
Constructor method for the Pin struct mode set to INPUT by default value set to FALSE by default @return pointer to Pin struct with
func (*Pin) GetValue ¶
Reads and returns the current value from any kind of pins. If the pin's direction is set to OUT the internal value is returned directly. For INPUT pins the actual value is read from the file each time the function is called. This function is active_low safe which means, if the returned value is TRUE the pin's physical signal is HIGH. @return true if signal at pin is HIGH, false if signal is LOW
func (*Pin) PinMode ¶
Configures the internal fields of a Pin struct and calls the export function, which introduces the pin to the os with the given configuration. @param: pin the Pin's id on the raspberry board @param: mode weather read or write access is required @param: activeLow (optional) true if the pin should be run in active_low mode (raspberry default is false)
func (*Pin) SetValue ¶
Sets the value for a gpio pin. This method is only applicable to OUT direction pins and as no effect if Pin.mode is INPUT. The method sets the associated gpio value at the raspberry via file access to the corresponding value file. The function is active_low safe. @param val if true the pin is set to mode HIGH else to mode LOW