/* IRLibSendBase.cpp * Part of IRLib Library for Arduino receiving, decoding, and sending * infrared signals. See COPYRIGHT.txt and LICENSE.txt for more information. */ /* * This module contains the base classes for sending. You will not create instances * of these classes, rather you will use them as base classes in creating derived * protocol specific decoders. Each protocol specific send class begins * by calling enableIROut(uint8_t kHz) to set the carrier frequency. * It then calls mark(int usec) and space(inc usec) to transmit marks and * spaces of varying length of microseconds in the manner which the protocol defines. */ #include "IRLibSendBase.h" #include "IRLibHardware.h" /* * Most of the protocols have a header consisting of a mark/space of a particular length followed by * a series of variable length mark/space signals. Depending on the protocol they very the lengths of the * mark or the space to indicate a data bit of "0" or "1". Most also end with a stop bit of "1". * The basic structure of the sending and decoding these protocols led to lots of redundant code. * Therefore I have implemented generic sending and decoding routines. You just need to pass a bunch of customized * parameters and it does the work. This reduces compiled code size with only minor speed degradation. * You may be able to implement new protocols by simply passing the proper values to these generic routines. * The decoding routines do not encode stop bits. So you have to tell this routine whether or not to send one. * Some protocols have a fixed amount of space between frames while others require that the entire frame * be a particularly length despite the fact that the data transmission time may be veritable. Pass this * frame length of time the parameter maxExtent. It's default value is zero. */ void IRsendBase::sendGeneric(uint32_t data, uint8_t numBits, uint16_t headMark, uint16_t headSpace, uint16_t markOne, uint16_t markZero, uint16_t spaceOne, uint16_t spaceZero, uint8_t kHz, bool useStop, uint32_t maxExtent) { extent=0; data = data << (32 - numBits); enableIROut(kHz); //Some protocols do not send a header when sending repeat codes. So we pass a zero value to indicate skipping this. if(headMark) mark(headMark); if(headSpace) space(headSpace); for (uint8_t i = 0; i