IRremote
ir_FAST.hpp
Go to the documentation of this file.
1 /*
2  * ir_FAST.hpp
3  *
4  * Contains functions for receiving and sending FAST IR protocol
5  * with no address and 16 bit data, interpreted as 8 bit command and 8 bit inverted command
6  *
7  * This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
8  *
9  ************************************************************************************
10  * MIT License
11  *
12  * Copyright (c) 2023 Armin Joachimsmeyer
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining a copy
15  * of this software and associated documentation files (the "Software"), to deal
16  * in the Software without restriction, including without limitation the rights
17  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18  * copies of the Software, and to permit persons to whom the Software is furnished
19  * to do so, subject to the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be included in all
22  * copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
25  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
26  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
28  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
29  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30  *
31  ************************************************************************************
32  */
33 #ifndef _IR_FAST_HPP
34 #define _IR_FAST_HPP
35 
36 #include "TinyIR.h"
37 
38 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
39 #define LOCAL_DEBUG
40 #else
41 //#define LOCAL_DEBUG // This enables debug output only for this file
42 #endif
43 
47 // generated with https://patorjk.com/software/taag/#p=display&f=Alphabet&t=FAST
48 //==============================================================================
49 // FFFF AA SSS TTTTTT
50 // F A A S TT
51 // FFF AAAA SSS TT
52 // F A A S TT
53 // F A A SSSS TT
54 //==============================================================================
55 #include "TinyIR.h"
56 /*
57 Protocol=FAST Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
58  +2100,-1050
59  + 550,- 500 + 550,-1550 + 550,-1550 + 550,- 500
60  + 550,-1550 + 550,-1550 + 550,-1550 + 550,- 500
61  + 550,-1550 + 550,- 500 + 550,- 500 + 550,-1550
62  + 550,- 500 + 550,- 500 + 550,- 500 + 550,-1550
63  + 550
64 Sum: 28900
65 */
68 NULL };
69 
70 /************************************
71  * Start of send and decode functions
72  ************************************/
73 
77 void IRsend::sendFAST(uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
78  // Set IR carrier frequency
79  enableIROut(FAST_KHZ); // 38 kHz
80 
81  uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
82  while (tNumberOfCommands > 0) {
83 
86 
88 
89  tNumberOfCommands--;
90  // skip last delay!
91  if (tNumberOfCommands > 0) {
92  // send repeated command in a fixed raster
94  }
95  }
96 }
97 
99 
100 // uint_fast8_t tRawlen = decodedIRData.rawlen; // Using a local variable does not improve code size
101 
102  // Check we have the right amount of data (36). The +4 is for initial gap, start bit mark and space + stop bit mark.
103  if (decodedIRData.rawlen != ((2 * FAST_BITS) + 4)) {
104  IR_DEBUG_PRINT(F("FAST: "));
105  IR_DEBUG_PRINT(F("Data length="));
107  IR_DEBUG_PRINTLN(F(" is not 36"));
108  return false;
109  }
110 
112  return false;
113  }
114 
116 #if defined(LOCAL_DEBUG)
117  Serial.print(F("FAST: "));
118  Serial.println(F("Decode failed"));
119 #endif
120  return false;
121  }
122 
123  WordUnion tValue;
125 
126  if (tValue.UByte.LowByte != (uint8_t)~(tValue.UByte.HighByte)) {
127 #if defined(LOCAL_DEBUG)
128  Serial.print(F("FAST: "));
129  Serial.print(F("8 bit parity is not correct. Expected=0x"));
130  Serial.print((uint8_t)~(tValue.UByte.LowByte), HEX);
131  Serial.print(F(" received=0x"));
132  Serial.print(tValue.UByte.HighByte, HEX);
133  Serial.print(F(" data=0x"));
134  Serial.println(tValue.UWord, HEX);
135 #endif
137  }
138 
140 
141  // Success
142 // decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
144  decodedIRData.address = 0; // No address for this protocol
147 
148  return true;
149 }
150 
152 #if defined(LOCAL_DEBUG)
153 #undef LOCAL_DEBUG
154 #endif
155 #endif // _IR_FAST_HPP
IRData::address
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
Definition: IRProtocol.h:110
FAST_BITS
#define FAST_BITS
Definition: TinyIR.h:92
MICROS_PER_TICK
#define MICROS_PER_TICK
microseconds per clock interrupt tick
Definition: IRremote.hpp:250
IRData::numberOfBits
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
Definition: IRProtocol.h:119
IRsend::aNumberOfRepeats
void int_fast8_t aNumberOfRepeats
Definition: IRremoteInt.h:547
WordUnion
Union to specify parts / manifestations of a 16 bit Word without casts and shifts.
Definition: LongUnion.h:36
FAST
@ FAST
Definition: IRProtocol.h:71
FAST_BIT_MARK
#define FAST_BIT_MARK
Definition: TinyIR.h:96
MICROS_IN_ONE_MILLI
#define MICROS_IN_ONE_MILLI
Definition: IRremote.hpp:255
FASTProtocolConstants
struct PulseDistanceWidthProtocolConstants FASTProtocolConstants
Definition: ir_FAST.hpp:66
WordUnion::UByte
struct WordUnion::@2 UByte
WordUnion::HighByte
uint8_t HighByte
Definition: LongUnion.h:39
IRsend::mark
void mark(uint16_t aMarkMicros)
Sends an IR mark for the specified number of microseconds.
Definition: IRSend.hpp:947
TinyIR.h
IRData::decodedRawData
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
Definition: IRProtocol.h:113
IRrecv::checkForRepeatSpaceTicksAndSetFlag
void checkForRepeatSpaceTicksAndSetFlag(uint16_t aMaximumRepeatSpaceTicks)
Definition: IRReceive.hpp:1150
IR_DEBUG_PRINT
#define IR_DEBUG_PRINT(...)
If DEBUG, print the arguments, otherwise do nothing.
Definition: IRremoteInt.h:161
IRDATA_FLAGS_PARITY_FAILED
#define IRDATA_FLAGS_PARITY_FAILED
The current (autorepeat) frame violated parity check.
Definition: IRProtocol.h:94
IRrecv::decodeFAST
bool decodeFAST()
Definition: ir_FAST.hpp:98
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:134
IRrecv::decodedIRData
IRData decodedIRData
Definition: IRremoteInt.h:358
IRData::flags
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
Definition: IRProtocol.h:120
PROTOCOL_IS_LSB_FIRST
#define PROTOCOL_IS_LSB_FIRST
Definition: IRProtocol.h:148
IRrecv::checkHeader
bool checkHeader(PulseDistanceWidthProtocolConstants *aProtocolConstants)
Definition: IRReceive.hpp:1126
IRrecv::decodePulseDistanceWidthData
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
Definition: IRReceive.hpp:954
IRData::command
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
Definition: IRProtocol.h:111
FAST_MAXIMUM_REPEAT_DISTANCE
#define FAST_MAXIMUM_REPEAT_DISTANCE
Definition: TinyIR.h:105
FAST_ZERO_SPACE
#define FAST_ZERO_SPACE
Definition: TinyIR.h:98
FAST_REPEAT_PERIOD
#define FAST_REPEAT_PERIOD
Definition: TinyIR.h:103
IRsend::space
static void space(uint16_t aSpaceMicros)
Sends an IR space for the specified number of microseconds.
Definition: IRSend.hpp:1148
FAST_KHZ
#define FAST_KHZ
The FAST protocol is a proprietary modified JVC protocol without address, with parity and with a shor...
Definition: TinyIR.h:89
IRData::rawlen
IRRawlenType rawlen
counter of entries in rawbuf of last received frame.
Definition: IRProtocol.h:128
FAST_HEADER_SPACE
#define FAST_HEADER_SPACE
Definition: TinyIR.h:101
FAST_REPEAT_DISTANCE
#define FAST_REPEAT_DISTANCE
Definition: TinyIR.h:104
sendFAST
void sendFAST(uint8_t aSendPin, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0)
Definition: TinyIRSender.hpp:294
IRsend::sendPulseDistanceWidthData
void sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits)
Sends PulseDistance from data contained in parameter using ProtocolConstants structure for timing etc...
Definition: IRSend.hpp:812
WordUnion::LowByte
uint8_t LowByte
Definition: LongUnion.h:38
FAST_HEADER_MARK
#define FAST_HEADER_MARK
Definition: TinyIR.h:100
WordUnion::UWord
uint16_t UWord
Definition: LongUnion.h:47
IR_DEBUG_PRINTLN
#define IR_DEBUG_PRINTLN(...)
If DEBUG, print the arguments as a line, otherwise do nothing.
Definition: IRremoteInt.h:165
IRData::protocol
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
Definition: IRProtocol.h:109
IRsend::aCommand
void aCommand
Definition: IRremoteInt.h:610
FAST_ONE_SPACE
#define FAST_ONE_SPACE
Definition: TinyIR.h:97
IRsend::enableIROut
void enableIROut(uint_fast8_t aFrequencyKHz)
Enables IR output.
Definition: IRSend.hpp:1188