Documentation
¶
Overview ¶
Package gpio provides receiver and transmitter functionality for reading remote control codes and sending them out to control remote controlled outlets.
Most of the receiver and transmitter code as well as the protocols were ported from the rc-switch c++ implementation to go. Check out the rc-switch repository at https://github.com/sui77/rc-switch for the awesome work.
Index ¶
Constants ¶
const ( // DefaultTransmitPin defines the default gpio pin for transmitting rf codes DefaultTransmitPin uint = 17 // DefaultReceivePin defines the default gpio pin for receiving rf codes DefaultReceivePin uint = 27 // DefaultProtocol defines the default rf protocol DefaultProtocol int = 1 // DefaultPulseLength defines the default pulse length DefaultPulseLength uint = 189 )
Variables ¶
var Protocols = []Protocol{ {350, HighLow{1, 31}, HighLow{1, 3}, HighLow{3, 1}}, {650, HighLow{1, 10}, HighLow{1, 2}, HighLow{2, 1}}, {100, HighLow{30, 71}, HighLow{4, 11}, HighLow{9, 6}}, {380, HighLow{1, 6}, HighLow{1, 3}, HighLow{3, 1}}, {500, HighLow{6, 14}, HighLow{1, 2}, HighLow{2, 1}}, }
Protocols defines known remote control protocols. These are exported to give users the ability to add more protocols if needed.
var TransmitRetries int = 10
TransmitRetries defines how many times a code should be transmitted in a row. The higher the value, the more likely it is that an outlet actually received the code.
Functions ¶
This section is empty.
Types ¶
type CodeReceiver ¶
type CodeReceiver interface { Receive() <-chan ReceiveResult Close() error }
CodeReceiver defines the interface for a rf code receiver.
func NewReceiver ¶
func NewReceiver(gpioPin uint) CodeReceiver
NewReceiver create a new receiver on the gpio pin
type CodeTransmitter ¶
CodeTransmitter defines the interface for a rf code transmitter.
func NewTransmitter ¶
func NewTransmitter(gpioPin uint) (CodeTransmitter, error)
NewTransmitter creates a NativeTransmitter when /dev/gpiomem is available, NullTransmitter otherwise.
type NativeReceiver ¶
type NativeReceiver struct {
// contains filtered or unexported fields
}
NativeReceiver type definition
func NewNativeReceiver ¶
func NewNativeReceiver(gpioPin uint, watcher Watcher) *NativeReceiver
NewNativeReceiver create a new receiver on the gpio pin using watcher
func (*NativeReceiver) Close ¶
func (r *NativeReceiver) Close() error
Close stops the watcher and receiver goroutines and perform cleanup
func (*NativeReceiver) Receive ¶
func (r *NativeReceiver) Receive() <-chan ReceiveResult
Receive blocks until there is a result on the receive channel
type NativeTransmitter ¶
type NativeTransmitter struct {
// contains filtered or unexported fields
}
NativeTransmitter type definition.
func NewNativeTransmitter ¶
func NewNativeTransmitter(gpioPin Pin) (*NativeTransmitter, error)
NewNativeTransmitter create a native transmitter on the gpio pin.
func (*NativeTransmitter) Close ¶
func (t *NativeTransmitter) Close() error
Close stops started goroutines and closes the gpio pin
func (*NativeTransmitter) Transmit ¶
func (t *NativeTransmitter) Transmit(code uint64, protocol int, pulseLength uint) error
Transmit transmits a code using given protocol and pulse length. It will return an error if the provided protocol is does not exist.
This method returns immediately. The code is transmitted in the background. If you need to ensure that a code has been fully transmitted, call Wait() after calling Transmit().
func (*NativeTransmitter) Wait ¶
func (t *NativeTransmitter) Wait()
Wait blocks until a code is fully transmitted.
type NullTransmitter ¶
type NullTransmitter struct{}
NullTransmitter type definition.
func NewNullTransmitter ¶
func NewNullTransmitter() (*NullTransmitter, error)
NewNullTransmitter create a transmitter that does nothing except logging the transmissions. This is mainly useful for development on systems where /dev/gpiomem is not available.
type ReceiveResult ¶
ReceiveResult type definition