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