Serial Wombat Arduino Library

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
SerialWombatIRRx Class Reference

A class for the Serial Wombat SW8B or SW18AB chips which received IR remote signals. Currently only NEC protocol is supported. More...

`#include <SerialWombatIRRx.h>`

Inheritance diagram for SerialWombatIRRx:
[legend]
Collaboration diagram for SerialWombatIRRx:
[legend]

## Public Types
enum | publicDataOutput { COMMAND = 0 , ADDRESS = 1 , DATACOUNT = 2 }

## Public Member Functions
| SerialWombatIRRx (SerialWombatChip &serialWombatChip)
| Constructor for the SerialWombatIRRx class.
int16_t | begin (uint8_t pin, uint8_t irMode=0, bool useRepeat=true, SerialWombatPinState_t activeState=SW_LOW, uint16_t publicDataTimeoutPeriod_mS=1000, uint16_t publicDataTimeoutValue=0xFFFF, bool useAddressFilter=false, uint16_t addressFilterValue=0x1234, SerialWombatIRRx::publicDataOutput dataOutput=SerialWombatIRRx::publicDataOutput::COMMAND)
| Initalize the SerialWombatIRRx.
int | available ()
| Returns the number of bytes available in the SerialWombatIRRx queue.
int | read ()
| Reads a byte from the SerialWombatIRRx queue.
void | flush ()
| Discard all bytes from the SerialWombatIRRx queue.
int | peek ()
| Query the SerialWombatIRRx queue for the next avaialble byte, but don't remove it from the queue.
size_t | write (uint8_t data)
| Write a byte to the SerialWombatIRRx queue (Does Nothing)
size_t | write (const uint8_t *buffer, size_t size)
| Write bytes to the SerialWombatIRRx queue (Does nothing)
int | availableForWrite ()
| Number of bytes avaialble to write to SerialWombatIRRx queue. Returns 0.
size_t | readBytes (char *buffer, size_t length)
| Reads a specified number of bytes from the SerialWombatIRRx queue queue.
void | setTimeout (long timeout_mS)
| implemented to fulfill Stream requirement.
SerialWombatIRRx & | operator= (SerialWombatIRRx &irrx)
| used to allow reference copy. Not for user use.
uint16_t | readAddress ()
| Returns the address of the last received IR command.
uint16_t | readDataCount ()
| Returns the total number of queued commands (rolls over at 65535)
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
uint32_t | timeout = 1
Protected Attributes inherited from SerialWombatPin
uint8_t | _pin = 255
SerialWombatChip & | _sw
uint8_t | _pinMode = 0

## Detailed Description

A class for the Serial Wombat SW8B or SW18AB chips which received IR remote signals. Currently only NEC protocol is supported.

A Tutorial video is avaialble:

COMING SOON

The class inherits from the Arduino Stream class, so queued button presses can be read like a Serial port.

Definition at line 47 of file SerialWombatIRRx.h.

## Member Enumeration Documentation

## ◆ publicDataOutput

enum SerialWombatIRRx::publicDataOutput

Enumerator
COMMAND | The last 8 bit command received (address filtered if enabled)
ADDRESS | the last 16 bit address received. Not Address filtered
DATACOUNT | The number of data that have been queued (Affected by address filtering and repeat settings)

Definition at line 51 of file SerialWombatIRRx.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatIRRx()

SerialWombatIRRx::SerialWombatIRRx | ( | SerialWombatChip & | serialWombatChip | ) |
| inline

Constructor for the SerialWombatIRRx class.

Parameters

  serialWombatChip | The Serial Wombat Chip on which the SerialWombatUART instance will run.

Definition at line 62 of file SerialWombatIRRx.h.

## Member Function Documentation

## ◆ available()

int SerialWombatIRRx::available | ( |  | ) |
| inline

Returns the number of bytes available in the SerialWombatIRRx queue.

Returns
  The number of bytes available

Definition at line 126 of file SerialWombatIRRx.h.

## ◆ availableForWrite()

int SerialWombatIRRx::availableForWrite | ( |  | ) |
| inline

Number of bytes avaialble to write to SerialWombatIRRx queue. Returns 0.

Returns
  Zero. Writes are not suppored.

Definition at line 212 of file SerialWombatIRRx.h.

## ◆ begin()

int16_t SerialWombatIRRx::begin | ( | uint8_t | pin,
|  | uint8_t | irMode = 0,
|  | bool | useRepeat = true,
|  | SerialWombatPinState_t | activeState = SW_LOW,
|  | uint16_t | publicDataTimeoutPeriod_mS = 1000,
|  | uint16_t | publicDataTimeoutValue = 0xFFFF,
|  | bool | useAddressFilter = false,
|  | uint16_t | addressFilterValue = 0x1234,
|  | SerialWombatIRRx::publicDataOutput | dataOutput = SerialWombatIRRx::publicDataOutput::COMMAND )
| inline

Initalize the SerialWombatIRRx.

Parameters

  pin | The Serial Wombat pin number to use for the IR receiver
  irMode | 0 for NEC protocol, other values reserved for future protocols
  useRepeat | If true, queue value on repeat commands
  activeState | The state of the pin which indicates an active IR signal (SW_LOW or SW_HIGH)
  publicDataTimeoutPeriod_mS | The number of milliseconds to wait for the next byte to be received before timing out
  publicDataTimeoutValue | The value to return when a timeout occurs
  useAddressFilter | If true, only queue commands from the specified address
  addressFilterValue | The address to filter on if useAddressFilter is true
  dataOutput | The type of data to output (COMMAND, ADDRESS, or DATACOUNT)

Returns
  0 on success, negative value on error

Definition at line 78 of file SerialWombatIRRx.h.

## ◆ flush()

void SerialWombatIRRx::flush | ( |  | ) |
| inline

Discard all bytes from the SerialWombatIRRx queue.

Definition at line 157 of file SerialWombatIRRx.h.

## ◆ operator=()

SerialWombatIRRx & SerialWombatIRRx::operator= | ( | SerialWombatIRRx & | irrx | ) |
| inline

used to allow reference copy. Not for user use.

Definition at line 292 of file SerialWombatIRRx.h.

## ◆ peek()

int SerialWombatIRRx::peek | ( |  | ) |
| inline

Query the SerialWombatIRRx queue for the next avaialble byte, but don't remove it from the queue.

Returns
  A byte from 0-255, or -1 if no bytes were avaialble

Definition at line 165 of file SerialWombatIRRx.h.

## ◆ read()

int SerialWombatIRRx::read | ( |  | ) |
| inline

Reads a byte from the SerialWombatIRRx queue.

Returns
  A byte from 0-255, or -1 if no bytes were avaialble

Definition at line 138 of file SerialWombatIRRx.h.

## ◆ readAddress()

uint16_t SerialWombatIRRx::readAddress | ( |  | ) |
| inline

Returns the address of the last received IR command.

Returns
  The address as a uint16_t

Definition at line 301 of file SerialWombatIRRx.h.

## ◆ readBytes()

size_t SerialWombatIRRx::readBytes | ( | char * | buffer,
|  | size_t | length )
| inline

Reads a specified number of bytes from the SerialWombatIRRx queue queue.

Parameters

  buffer | An array into which to put received bytes
  length | The maximum number of bytes to be received

Returns
  the number of bytes written to buffer

This function will read bytes from the SerialWombatIRRx queue into buffer. If 'length' characters are not available to read then the value returned will be less than length.

Definition at line 227 of file SerialWombatIRRx.h.

## ◆ readDataCount()

uint16_t SerialWombatIRRx::readDataCount | ( |  | ) |
| inline

Returns the total number of queued commands (rolls over at 65535)

Definition at line 315 of file SerialWombatIRRx.h.

## ◆ setTimeout()

void SerialWombatIRRx::setTimeout | ( | long | timeout_mS | ) |
| inline

implemented to fulfill Stream requirement.

Definition at line 276 of file SerialWombatIRRx.h.

## ◆ write() [1/2]

size_t SerialWombatIRRx::write | ( | const uint8_t * | buffer,
|  | size_t | size )
| inline

Write bytes to the SerialWombatIRRx queue (Does nothing)

Parameters

  buffer | An array of uint8_t bytes to send
  size | the number of bytes to send

Returns
  the number of bytes sent

This function exists to fully implement the Stream class. It throws away the bytes.

Definition at line 202 of file SerialWombatIRRx.h.

## ◆ write() [2/2]

size_t SerialWombatIRRx::write | ( | uint8_t | data | ) |
| inline

Write a byte to the SerialWombatIRRx queue (Does Nothing)

Parameters

  data | Byte to write

Returns
  Number of bytes written

This function exists to fully implement the Stream class. It throws away the byte.

Definition at line 187 of file SerialWombatIRRx.h.

## Member Data Documentation

## ◆ timeout

uint32_t SerialWombatIRRx::timeout = 1
| protected

Definition at line 326 of file SerialWombatIRRx.h.