Serial Wombat Arduino Library
Loading...
Searching...
No Matches
SerialWombatIRTx Class Reference

A class for the Serial Wombat 8B or SW18AB chips which allows sending NEC IR Commands. More...

#include <SerialWombatIRTx.h>

Inheritance diagram for SerialWombatIRTx:
Collaboration diagram for SerialWombatIRTx:

Public Member Functions

 SerialWombatIRTx (SerialWombatChip &serialWombat)
 Constructor for the SerialWombatIRTx class.
 
int16_t begin (uint8_t pin, uint16_t address, uint8_t irMode=0)
 
int16_t enableSW8b38KHzWP6 ()
 Causes pin WP6 on the Serial Wombat 8B to generate a 38kHz carrier wave.
 
int sendMessage (uint8_t command, int32_t address=-1, uint8_t repeat=0)
 Write a byte to the SerialWombatIRTx for Transmit as a command using the prior specified address.
 
virtual int available ()
 This function exists to satisfy stream requirements, and always returns 0.
 
virtual int read ()
 This function exists to satisfy stream requirements, and always returns -1.
 
virtual void flush ()
 Discard all received bytes. Does nothing, exists to satisfy stream requirements.
 
virtual int peek ()
 This function exists to satisfy stream requirements, and always returns -1.
 
virtual size_t write (uint8_t data)
 Write a byte to the SerialWombatIRTx for Transmit as a command using the prior specified address.
 
virtual size_t write (const uint8_t *buffer, size_t size)
 Write bytes to the SerialWombatUART for Transmit.
 
virtual int availableForWrite ()
 Queries the SerialWombatUART for the amount of free TX queue space.
 
virtual size_t readBytes (char *buffer, size_t length)
 This function exists to satisfy stream requirements, and always returns 0.
 
virtual void setTimeout (long timeout_mS)
 This function exists to satisfy stream requirements.
 
- Public Member Functions inherited from SerialWombatPin
 SerialWombatPin (SerialWombatChip &serialWombatChip)
 Instantiates a Serial Wombat Pin.
 
 SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
 Instantiates a Serial Wombat Pin.
 
uint16_t readPublicData ()
 Read the 16 Bit public data associated with this pin.
 
void pinMode (uint8_t mode, bool pullDown=false, bool openDrain=false)
 Set pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings.
 
void digitalWrite (uint8_t val)
 Set output pin High or Low.
 
int digitalRead ()
 Reads the state of the Pin.
 
uint16_t writePublicData (uint16_t value)
 Write a 16 bit value to this pin.
 
uint8_t pin ()
 Returns the current SW pin number. Used primarily for virtual calls by derived classes.
 
uint8_t swPinModeNumber ()
 Returns the Mode number. Used primarily by derived classes to populate packet data.
 
int16_t initPacketNoResponse (uint8_t packetNumber, uint8_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55, uint8_t param4=0x55)
 
int16_t initPacketNoResponse (uint8_t packetNumber, uint16_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55)
 
int16_t initPacketNoResponse (uint8_t packetNumber, uint16_t param0, uint16_t param1, uint8_t param2=0x55)
 
int16_t disable ()
 Disables the pin mode (if applicable)
 
int16_t enablePullup (bool enabled)
 Enables the weak pull up on a pin. Implemented on SW18AB and SW8B only.
 
int16_t enablePulldown (bool enabled)
 Enables the weak pull down on a pin. Implemented on SW18AB and SW8B only.
 
int16_t enableOpenDrain (bool enabled)
 Enables open drain mode on a pin. Implemented on SW18AB and SW8B only.
 
int16_t forceDMA (bool enabled)
 Forces use of DMA instead of hardware timing resources on SW18AB.
 
void setPinNumberForTesting (uint8_t pin)
 A function designed for testing only. May have unpredictable results if used in real time. Not intended for general use.
 

Protected Attributes

uint16_t _address
 
- Protected Attributes inherited from SerialWombatPin
uint8_t _pin = 255
 
SerialWombatChip_sw
 
uint8_t _pinMode = 0
 

Detailed Description

A class for the Serial Wombat 8B or SW18AB chips which allows sending NEC IR Commands.

This class sends NEC IR commands with a 16 bit address, and optional repeats. It provides the high level protocol, but not the 38kHz carrier. The carrier needs to be combined with the high level protocol in order to transmit IR signals. This can be achieved with an AND logic chip, or by connecting an an IR LED and resistor to two pins where current flows from the protocol pin into the carrier pin.

The Serial Wombat 18AB chip can generate the carrier frequency on any enchanced digital capability pin using the SerialWombatFrequencyOutput pin mode. The Serial Wombat 8B chip can generate a 38kHz carrier on WP6 by using an internal peripheral.

This pin mode works very well witht the SerialWombat 8B REMCON PCB0041 which has the protocol pin on WP7 and the carrier pin on WP6, connected to an AND chip which feeds a transistor driven high power LED.

See the Examples in the examples area for usage.

A Tutorial video is avaialble:

https://youtu.be/TODO

The class inherits from the Arduino Sream class, so functions such as write can be used once the class is initialized.

Definition at line 62 of file SerialWombatIRTx.h.

Constructor & Destructor Documentation

◆ SerialWombatIRTx()

SerialWombatIRTx::SerialWombatIRTx ( SerialWombatChip & serialWombat)
inline

Constructor for the SerialWombatIRTx class.

Parameters
serialWombatThe Serial Wombat chip on which the SerialWombatIRTx instance will run.

Definition at line 70 of file SerialWombatIRTx.h.

Member Function Documentation

◆ available()

virtual int SerialWombatIRTx::available ( )
inlinevirtual

This function exists to satisfy stream requirements, and always returns 0.

Returns
-1

Definition at line 135 of file SerialWombatIRTx.h.

◆ availableForWrite()

virtual int SerialWombatIRTx::availableForWrite ( )
inlinevirtual

Queries the SerialWombatUART for the amount of free TX queue space.

Returns
A value between 0 and 64 for the SW4B

Definition at line 209 of file SerialWombatIRTx.h.

◆ begin()

int16_t SerialWombatIRTx::begin ( uint8_t pin,
uint16_t address,
uint8_t irMode = 0 )
inline
@brief Initalize the SerialWombatIRTx.  
Parameters
pinThe pin that will host the state machine. For the REMCON board thsi should be 7
irModeReserved for possible future support of non NEC protocols
Returns
negative error code or positive success

Definition at line 79 of file SerialWombatIRTx.h.

◆ enableSW8b38KHzWP6()

int16_t SerialWombatIRTx::enableSW8b38KHzWP6 ( )
inline

Causes pin WP6 on the Serial Wombat 8B to generate a 38kHz carrier wave.

This can only be turned off by resetting the chip. No effect on SW18AB. Use the frequency output function on that chip.

Definition at line 96 of file SerialWombatIRTx.h.

◆ flush()

virtual void SerialWombatIRTx::flush ( )
inlinevirtual

Discard all received bytes. Does nothing, exists to satisfy stream requirements.

Definition at line 150 of file SerialWombatIRTx.h.

◆ peek()

virtual int SerialWombatIRTx::peek ( )
inlinevirtual

This function exists to satisfy stream requirements, and always returns -1.

Returns
-1

Definition at line 157 of file SerialWombatIRTx.h.

◆ read()

virtual int SerialWombatIRTx::read ( )
inlinevirtual

This function exists to satisfy stream requirements, and always returns -1.

Returns
-1

Definition at line 143 of file SerialWombatIRTx.h.

◆ readBytes()

virtual size_t SerialWombatIRTx::readBytes ( char * buffer,
size_t length )
inlinevirtual

This function exists to satisfy stream requirements, and always returns 0.

Returns
0

Definition at line 220 of file SerialWombatIRTx.h.

◆ sendMessage()

int SerialWombatIRTx::sendMessage ( uint8_t command,
int32_t address = -1,
uint8_t repeat = 0 )
inline

Write a byte to the SerialWombatIRTx for Transmit as a command using the prior specified address.

Parameters
dataByte to write
Returns
Number of bytes written

Definition at line 108 of file SerialWombatIRTx.h.

◆ setTimeout()

virtual void SerialWombatIRTx::setTimeout ( long timeout_mS)
inlinevirtual

This function exists to satisfy stream requirements.

Definition at line 231 of file SerialWombatIRTx.h.

◆ write() [1/2]

virtual size_t SerialWombatIRTx::write ( const uint8_t * buffer,
size_t size )
inlinevirtual

Write bytes to the SerialWombatUART for Transmit.

Parameters
bufferAn array of uint8_t bytes to send
sizethe number of bytes to send
Returns
the number of bytes sent

This function queries the SerialWombatUART for avaialble TX buffer space, and sends bytes as buffer space is avaialble. If avaialable buffer space is not sufficient to send the entire array then the function will block and continue trying until the entire message has been sent to the SerialWombatUART transmit queue.

Definition at line 190 of file SerialWombatIRTx.h.

◆ write() [2/2]

virtual size_t SerialWombatIRTx::write ( uint8_t data)
inlinevirtual

Write a byte to the SerialWombatIRTx for Transmit as a command using the prior specified address.

Parameters
dataByte to write
Returns
Number of bytes written

Definition at line 166 of file SerialWombatIRTx.h.

Member Data Documentation

◆ _address

uint16_t SerialWombatIRTx::_address
protected

Definition at line 236 of file SerialWombatIRTx.h.