Documentation ¶
Index ¶
- Constants
- type VirtualWire
- func (vw *VirtualWire) ActiveTx() bool
- func (vw *VirtualWire) GetMessage() ([]byte, error)
- func (vw *VirtualWire) GetRxBad() byte
- func (vw *VirtualWire) GetRxGood() byte
- func (vw *VirtualWire) HaveMessage() bool
- func (vw *VirtualWire) Send(buf []byte) error
- func (vw *VirtualWire) SetPttInverted(inverted bool)
- func (vw *VirtualWire) SetRxInverted(inverted bool)
- func (vw *VirtualWire) SetSpeed(speed uint16)
- func (vw *VirtualWire) StartRx()
- func (vw *VirtualWire) StartTx()
- func (vw *VirtualWire) StopRx()
- func (vw *VirtualWire) StopTx()
- func (vw *VirtualWire) WaitRx()
- func (vw *VirtualWire) WaitRxMax(milliseconds int64) bool
- func (vw *VirtualWire) WaitTx()
Constants ¶
const ( /// Maximum number of bytes in a message, counting the byte count and FCS VW_MAX_MESSAGE_LEN = 80 /// Number of samples per bit VW_RX_SAMPLES_PER_BIT = 8 /// The maximum payload length VW_MAX_PAYLOAD = VW_MAX_MESSAGE_LEN - 3 /// The size of the receiver ramp. Ramp wraps modulo this number VW_RX_RAMP_LEN = 160 // Ramp adjustment parameters // Standard is if a transition occurs before VW_RAMP_TRANSITION (80) in the ramp, // the ramp is retarded by adding VW_RAMP_INC_RETARD (11) // else by adding VW_RAMP_INC_ADVANCE (29) // If there is no transition it is adjusted by VW_RAMP_INC (20) /// Internal ramp adjustment parameter VW_RAMP_INC = (VW_RX_RAMP_LEN / VW_RX_SAMPLES_PER_BIT) /// Internal ramp adjustment parameter VW_RAMP_TRANSITION = VW_RX_RAMP_LEN / 2 /// Internal ramp adjustment parameter VW_RAMP_ADJUST = 9 /// Internal ramp adjustment parameter VW_RAMP_INC_RETARD = (VW_RAMP_INC - VW_RAMP_ADJUST) /// Internal ramp adjustment parameter VW_RAMP_INC_ADVANCE = (VW_RAMP_INC + VW_RAMP_ADJUST) /// Outgoing message bits grouped as 6-bit words /// 36 alternating 1/0 bits, followed by 12 bits of start symbol /// Followed immediately by the 4-6 bit encoded byte count, /// message buffer and 2 byte FCS /// Each byte from the byte count on is translated into 2x6-bit words /// Caution, each symbol is transmitted LSBit first, /// but each byte is transmitted high nybble first VW_HEADER_LEN = 8 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type VirtualWire ¶
type VirtualWire struct {
// contains filtered or unexported fields
}
func NewVirtualWire ¶
func NewVirtualWire(pins ...byte) *VirtualWire
func (*VirtualWire) ActiveTx ¶
func (vw *VirtualWire) ActiveTx() bool
/ Returns the state of the / transmitter / \return true if the transmitter is active else false
func (*VirtualWire) GetMessage ¶
func (vw *VirtualWire) GetMessage() ([]byte, error)
/ If a message is available (good checksum or not), copies / up to *len octets to buf.
func (*VirtualWire) GetRxBad ¶
func (vw *VirtualWire) GetRxBad() byte
/ Returns the count of bad messages received, ie / messages with bogus lengths, indicating corruption / or lost octets. / Caution,: this is an 8 bit count and can easily overflow / \return Count of bad messages received
func (*VirtualWire) GetRxGood ¶
func (vw *VirtualWire) GetRxGood() byte
/ Returns the count of good messages received / Caution,: this is an 8 bit count and can easily overflow / \return Count of good messages received
func (*VirtualWire) HaveMessage ¶
func (vw *VirtualWire) HaveMessage() bool
/ Returns true if an unread message is available / \return true if a message is available to read
func (*VirtualWire) Send ¶
func (vw *VirtualWire) Send(buf []byte) error
/ Send a message with the given length. Returns almost immediately, / and message will be sent at the right timing by interrupts / \param[in] buf slice of the data to transmit / \return true if the message was accepted for transmission, false if the message is too long (>VW_MAX_MESSAGE_LEN - 3)
func (*VirtualWire) SetPttInverted ¶
func (vw *VirtualWire) SetPttInverted(inverted bool)
/ By default the PTT pin goes high when the transmitter is enabled. / This flag forces it low when the transmitter is enabled. / \param[in] inverted True to invert PTT
func (*VirtualWire) SetRxInverted ¶
func (vw *VirtualWire) SetRxInverted(inverted bool)
/ By default the RX pin is expected to be low when idle, and to pulse high / for each data pulse. / This flag forces it to be inverted. This may be necessary if your transport medium / inverts the logic of your signal, such as happens with some types of A/V tramsmitter. / \param[in] inverted True to invert sense of receiver input
func (*VirtualWire) SetSpeed ¶
func (vw *VirtualWire) SetSpeed(speed uint16)
/ Set vw to operate at speed bits per second / Must call StartRx() before you will get any messages / \param[in] speed Desired speed in bits per second
func (*VirtualWire) StartRx ¶
func (vw *VirtualWire) StartRx()
/ Start the Phase Locked Loop listening to the receiver / Must do this before you can receive any messages / When a message is available (good checksum or not), HaveMessage() / will return true.
func (*VirtualWire) StartTx ¶
func (vw *VirtualWire) StartTx()
func (*VirtualWire) StopRx ¶
func (vw *VirtualWire) StopRx()
/ Stop the Phase Locked Loop listening to the receiver / No messages will be received until StartRx() is called again / Saves interrupt processing cycles
func (*VirtualWire) StopTx ¶
func (vw *VirtualWire) StopTx()
func (*VirtualWire) WaitRx ¶
func (vw *VirtualWire) WaitRx()
/ Block until a message is available / then returns
func (*VirtualWire) WaitRxMax ¶
func (vw *VirtualWire) WaitRxMax(milliseconds int64) bool
/ Block until a message is available or for a max time / \param[in] milliseconds Maximum time to wait in milliseconds. / \return true if a message is available, false if the wait timed out.
func (*VirtualWire) WaitTx ¶
func (vw *VirtualWire) WaitTx()
/ Block until the transmitter is idle / then returns