Go to the documentation of this file.
9 #define __STDC_LIMIT_MACROS
21 uint64_t
reverseBits(uint64_t input, uint16_t nbits);
24 const bool isRepeat =
false);
33 uint8_t
sumBytes(
const uint8_t *
const start,
const uint16_t length,
34 const uint8_t init = 0);
35 uint8_t
xorBytes(
const uint8_t *
const start,
const uint16_t length,
36 const uint8_t init = 0);
37 uint16_t
countBits(
const uint8_t *
const start,
const uint16_t length,
38 const bool ones =
true,
const uint16_t init = 0);
39 uint16_t
countBits(
const uint64_t data,
const uint8_t length,
40 const bool ones =
true,
const uint16_t init = 0);
41 uint64_t
invertBits(
const uint64_t data,
const uint16_t nbits);
49 const bool precomma =
true);
51 const bool precomma =
true);
54 const bool precomma =
true);
56 const bool precomma =
true);
58 const bool precomma =
true);
60 const uint8_t cool,
const uint8_t heat,
61 const uint8_t dry,
const uint8_t fan);
63 const uint8_t low,
const uint8_t automatic,
64 const uint8_t quiet,
const uint8_t medium);
66 const bool precomma =
true);
70 uint8_t
sumNibbles(
const uint8_t *
const start,
const uint16_t length,
71 const uint8_t init = 0);
72 uint8_t
sumNibbles(
const uint64_t data,
const uint8_t count = 16,
73 const uint8_t init = 0,
const bool nibbleonly =
true);
76 bool getBit(
const uint64_t data,
const uint8_t position,
77 const uint8_t size = 64);
78 bool getBit(
const uint8_t data,
const uint8_t position);
79 #define GETBIT8(a, b) (a & ((uint8_t)1 << b))
80 #define GETBIT16(a, b) (a & ((uint16_t)1 << b))
81 #define GETBIT32(a, b) (a & ((uint32_t)1 << b))
82 #define GETBIT64(a, b) (a & ((uint64_t)1 << b))
83 #define GETBITS8(data, offset, size) \
84 (((data) & (((uint8_t)UINT8_MAX >> (8 - (size))) << (offset))) >> (offset))
85 #define GETBITS16(data, offset, size) \
86 (((data) & (((uint16_t)UINT16_MAX >> (16 - (size))) << (offset))) >> \
88 #define GETBITS32(data, offset, size) \
89 (((data) & (((uint32_t)UINT32_MAX >> (32 - (size))) << (offset))) >> \
91 #define GETBITS64(data, offset, size) \
92 (((data) & (((uint64_t)UINT64_MAX >> (64 - (size))) << (offset))) >> \
94 uint64_t
setBit(
const uint64_t data,
const uint8_t position,
95 const bool on =
true,
const uint8_t size = 64);
96 uint8_t
setBit(
const uint8_t data,
const uint8_t position,
97 const bool on =
true);
98 void setBit(uint8_t *
const data,
const uint8_t position,
99 const bool on =
true);
100 void setBit(uint32_t *
const data,
const uint8_t position,
101 const bool on =
true);
102 void setBit(uint64_t *
const data,
const uint8_t position,
103 const bool on =
true);
104 void setBits(uint8_t *
const dst,
const uint8_t offset,
const uint8_t nbits,
106 void setBits(uint32_t *
const dst,
const uint8_t offset,
const uint8_t nbits,
107 const uint32_t data);
108 void setBits(uint64_t *
const dst,
const uint8_t offset,
const uint8_t nbits,
109 const uint64_t data);
String addTempToString(const uint16_t degrees, const bool celsius, const bool precomma)
Create a String of human output for a given temperature. e.g. "Temp: 25C".
Definition: IRutils.cpp:577
decode_type_t
Enumerator for defining and numbering of supported IR protocol.
Definition: IRremoteESP8266.h:714
String addDayToString(const uint8_t day_of_week, const int8_t offset, const bool precomma)
Create a String of the 3-letter day of the week from a numerical day of the week. e....
Definition: IRutils.cpp:616
uint16_t * resultToRawArray(const decode_results *const decode)
Convert a decode_results into an array suitable for sendRaw().
Definition: IRutils.cpp:351
void setBits(uint8_t *const dst, const uint8_t offset, const uint8_t nbits, const uint8_t data)
Alter an uint8_t value by overwriting an arbitary given number of bits.
Definition: IRutils.cpp:873
String resultToSourceCode(const decode_results *const results)
Return a String containing the key values of a decode_results structure in a C/C++ code style format.
Definition: IRutils.cpp:193
Results returned from the decoder.
Definition: IRrecv.h:92
uint16_t getCorrectedRawLength(const decode_results *const results)
Return the corrected length of a 'raw' format array structure after over-large values are converted i...
Definition: IRutils.cpp:179
String addModelToString(const decode_type_t protocol, const int16_t model, const bool precomma)
Create a String of human output for a given protocol model number. e.g. "Model: JKE".
Definition: IRutils.cpp:562
uint16_t countBits(const uint8_t *const start, const uint16_t length, const bool ones=true, const uint16_t init=0)
Count the number of bits of a certain type in an array.
Definition: IRutils.cpp:402
String msToString(uint32_t const msecs)
Convert a nr. of milliSeconds into a Human-readable string. e.g. "1 Day 6 Hours 34 Minutes 17 Seconds...
Definition: IRutils.cpp:692
String addModeToString(const uint8_t mode, const uint8_t automatic, const uint8_t cool, const uint8_t heat, const uint8_t dry, const uint8_t fan)
Create a String of human output for the given operating mode. e.g. "Mode: 1 (Cool)".
Definition: IRutils.cpp:593
String resultToHumanReadableBasic(const decode_results *const results)
Dump out the decode_results structure into a human readable format.
Definition: IRutils.cpp:324
String resultToTimingInfo(const decode_results *const results)
Dump out the decode_results structure.
Definition: IRutils.cpp:274
std::string String
Definition: IRremoteESP8266.h:1093
const uint8_t kNibbleSize
Definition: IRutils.h:17
String modelToStr(const decode_type_t protocol, const int16_t model)
Generate the model string for a given Protocol/Model pair.
Definition: IRutils.cpp:498
const uint8_t kLowNibble
Definition: IRutils.h:18
uint8_t uint8ToBcd(const uint8_t integer)
Convert an Integer into a byte of Binary Coded Decimal(BCD).
Definition: IRutils.cpp:778
decode_type_t strToDecodeType(const char *str)
Convert a C-style string to a decode_type_t.
Definition: IRutils.cpp:83
const uint8_t kHighNibble
Definition: IRutils.h:19
uint8_t sumNibbles(const uint8_t *const start, const uint16_t length, const uint8_t init)
Sum all the nibbles together in a series of bytes.
Definition: IRutils.cpp:743
String uint64ToString(uint64_t input, uint8_t base=10)
Convert a uint64_t (unsigned long long) to a string. Arduino String/toInt/Serial.print() can't handle...
Definition: IRutils.cpp:44
float celsiusToFahrenheit(const float deg)
Convert degrees Celsius to degrees Fahrenheit.
Definition: IRutils.cpp:450
String addIntToString(const uint16_t value, const String label, const bool precomma)
Create a String with a colon separated labeled Integer suitable for Humans. e.g. "Foo: 23".
Definition: IRutils.cpp:489
uint8_t xorBytes(const uint8_t *const start, const uint16_t length, const uint8_t init=0)
Calculate a rolling XOR of all the bytes of an array.
Definition: IRutils.cpp:388
const uint8_t kModeBitsSize
Definition: IRutils.h:20
bool getBit(const uint64_t data, const uint8_t position, const uint8_t size)
Return the value of positionth bit of an Integer.
Definition: IRutils.cpp:788
float fahrenheitToCelsius(const float deg)
Convert degrees Fahrenheit to degrees Celsius.
Definition: IRutils.cpp:453
uint8_t sumBytes(const uint8_t *const start, const uint16_t length, const uint8_t init=0)
Sum all the bytes of an array and return the least significant 8-bits of the result.
Definition: IRutils.cpp:375
String typeToString(const decode_type_t protocol, const bool isRepeat=false)
Convert a protocol type (enum etc) to a human readable string.
Definition: IRutils.cpp:105
String addFanToString(const uint8_t speed, const uint8_t high, const uint8_t low, const uint8_t automatic, const uint8_t quiet, const uint8_t medium)
Create a String of human output for the given fan speed. e.g. "Fan: 0 (Auto)".
Definition: IRutils.cpp:642
String resultToHexidecimal(const decode_results *const result)
Convert the decode_results structure's value/state to simple hexadecimal.
Definition: IRutils.cpp:304
String addBoolToString(const bool value, const String label, const bool precomma)
Create a String with a colon separated flag suitable for Humans. e.g. "Power: On".
Definition: IRutils.cpp:477
String minsToString(const uint16_t mins)
Convert a nr. of minutes into a 24h clock format Human-readable string. e.g. "23:59".
Definition: IRutils.cpp:728
uint8_t bcdToUint8(const uint8_t bcd)
Convert a byte of Binary Coded Decimal(BCD) into an Integer.
Definition: IRutils.cpp:770
Namespace for covering common functions & procedures for advancd protocol handlers.
Definition: IRutils.cpp:455
uint64_t reverseBits(uint64_t input, uint16_t nbits)
Reverse the order of the requested least significant nr. of bits.
Definition: IRutils.cpp:24
String htmlEscape(const String unescaped)
Escape any special HTML (unsafe) characters in a string. e.g. anti-XSS.
Definition: IRutils.cpp:660
bool hasACState(const decode_type_t protocol)
Does the given protocol use a complex state as part of the decode?
Definition: IRutils.cpp:130
uint64_t setBit(const uint64_t data, const uint8_t position, const bool on, const uint8_t size)
Return the value of an Integer with the positionth bit changed.
Definition: IRutils.cpp:808
void serialPrintUint64(uint64_t input, uint8_t base=10)
Print a uint64_t/unsigned long long to the Serial port Serial.print() can't handle printing long long...
Definition: IRutils.cpp:75
String addLabeledString(const String value, const String label, const bool precomma)
Create a String with a colon separated "label: value" pair suitable for Humans.
Definition: IRutils.cpp:462
uint64_t invertBits(const uint64_t data, const uint16_t nbits)
Invert/Flip the bits in an Integer.
Definition: IRutils.cpp:439