33 #ifndef _IR_PROTOCOL_HPP
34 #define _IR_PROTOCOL_HPP
36 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
46 const char string_Unknown[]
PROGMEM =
"UNKNOWN";
47 const char string_PulseWidth[]
PROGMEM =
"PulseWidth";
48 const char string_PulseDistance[]
PROGMEM =
"PulseDistance";
49 const char string_Apple[]
PROGMEM =
"Apple";
50 const char string_Denon[]
PROGMEM =
"Denon";
51 const char string_JVC[]
PROGMEM =
"JVC";
52 const char string_LG[]
PROGMEM =
"LG";
53 const char string_LG2[]
PROGMEM =
"LG2";
54 const char string_NEC[]
PROGMEM =
"NEC";
55 const char string_NEC2[]
PROGMEM =
"NEC2";
56 const char string_Onkyo[]
PROGMEM =
"Onkyo";
57 const char string_Panasonic[]
PROGMEM =
"Panasonic";
58 const char string_Kaseikyo[]
PROGMEM =
"Kaseikyo";
59 const char string_Kaseikyo_Denon[]
PROGMEM =
"Kaseikyo_Denon";
60 const char string_Kaseikyo_Sharp[]
PROGMEM =
"Kaseikyo_Sharp";
61 const char string_Kaseikyo_JVC[]
PROGMEM =
"Kaseikyo_JVC";
62 const char string_Kaseikyo_Mitsubishi[]
PROGMEM =
"Kaseikyo_Mitsubishi";
63 const char string_RC5[]
PROGMEM =
"RC5";
64 const char string_RC6[]
PROGMEM =
"RC6";
65 const char string_Samsung[]
PROGMEM =
"Samsung";
66 const char string_SamsungLG[]
PROGMEM =
"SamsungLG";
67 const char string_Samsung48[]
PROGMEM =
"Samsung48";
68 const char string_Sharp[]
PROGMEM =
"Sharp";
69 const char string_Sony[]
PROGMEM =
"Sony";
70 const char string_BangOlufsen[]
PROGMEM =
"Bang&Olufsen";
71 const char string_BoseWave[]
PROGMEM =
"BoseWave";
72 const char string_Lego[]
PROGMEM =
"Lego";
73 const char string_MagiQuest[]
PROGMEM =
"MagiQuest";
74 const char string_Whynter[]
PROGMEM =
"Whynter";
75 const char string_FAST[]
PROGMEM =
"FAST";
81 PROGMEM = { string_Unknown, string_PulseWidth, string_PulseDistance, string_Apple, string_Denon, string_JVC, string_LG, string_LG2,
82 string_NEC, string_NEC2, string_Onkyo, string_Panasonic, string_Kaseikyo, string_Kaseikyo_Denon, string_Kaseikyo_Sharp,
83 string_Kaseikyo_JVC, string_Kaseikyo_Mitsubishi, string_RC5, string_RC6, string_Samsung, string_SamsungLG, string_Samsung48,
84 string_Sharp, string_Sony
85 #if !defined(EXCLUDE_EXOTIC_PROTOCOLS)
86 , string_BangOlufsen, string_BoseWave, string_Lego, string_MagiQuest, string_Whynter, string_FAST
92 const char *tProtocolStringPtr = (
char*) pgm_read_word(&
ProtocolNames[aProtocol]);
93 return ((__FlashStringHelper*) (tProtocolStringPtr));
101 #if (__INT_WIDTH__ >= 32)
102 # if __has_include(<type_traits>)
107 #include <type_traits>
110 #if __cpp_lib_void_t >= 201411L
112 using void_t = std::void_t<T>;
114 template<
typename ... Ts>
struct make_void {
117 template<
typename ... Ts>
using void_t =
typename make_void<Ts...>::type;
121 template<
typename T,
typename =
void>
122 struct has_ull_print: std::false_type {
125 struct has_ull_print<T, void_t<decltype(std::declval<T>().print(0ull, 0))>> : std::true_type {
130 template<typename PrintImplType, typename std::enable_if<!has_ull_print<PrintImplType>::value,
bool>::type =
true>
131 size_t print(PrintImplType *p,
unsigned long long value,
int base) {
132 size_t tLength = p->print(
static_cast<uint32_t
>(value >> 32), base);
133 tLength += p->print(
static_cast<uint32_t
>(value), base);
137 template<typename PrintImplType, typename std::enable_if<has_ull_print<PrintImplType>::value,
bool>::type =
true>
138 size_t print(PrintImplType *p,
unsigned long long value,
int base) {
139 return p->print(value, base);
145 size_t print(Print *aSerial,
unsigned long long n,
int base) {
146 return aSerial->print(n, base);
164 aSerial->println(F(
"Overflow"));
167 aSerial->print(F(
"Protocol="));
170 #if defined(DECODE_HASH)
171 aSerial->print(F(
" Hash=0x"));
172 #if (__INT_WIDTH__ < 32)
179 #if !defined(DISABLE_CODE_FOR_RECEIVER)
181 aSerial->print((aIRDataPtr->
rawlen + 1) / 2, DEC);
182 aSerial->println(F(
" bits (incl. gap and start) received"));
185 #if defined(DECODE_DISTANCE_WIDTH)
191 aSerial->print(F(
" Address=0x"));
192 aSerial->print(aIRDataPtr->
address, HEX);
194 aSerial->print(F(
" Command=0x"));
195 aSerial->print(aIRDataPtr->
command, HEX);
198 aSerial->print(F(
" Extra=0x"));
199 aSerial->print(aIRDataPtr->
extra, HEX);
203 aSerial->print(F(
" Parity fail"));
207 aSerial->print(F(
" Toggle=1"));
209 #if defined(DECODE_DISTANCE_WIDTH)
215 aSerial->print(F(
"Auto-"));
217 aSerial->print(F(
"Repeat"));
218 #if !defined(DISABLE_CODE_FOR_RECEIVER)
219 if (aPrintRepeatGap) {
220 aSerial->print(F(
" gap="));
222 aSerial->print(F(
"us"));
225 (void)aPrintRepeatGap;
233 aSerial->print(F(
" Raw-Data=0x"));
234 #if (__INT_WIDTH__ < 32)
244 aSerial->print(F(
" bits"));
247 aSerial->println(F(
" MSB first"));
249 aSerial->println(F(
" LSB first"));
265 aValue = (aValue >> 4) | (aValue << 4);
267 aValue = ((aValue & 0xcc) >> 2) | ((aValue & 0x33) << 2);
269 aValue = ((aValue & 0xaa) >> 1) | ((aValue & 0x55) << 1);
286 #if defined(LOCAL_DEBUG)
289 #endif // _IR_PROTOCOL_HPP