mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-04 15:20:16 +00:00
clean
This commit is contained in:
parent
8525f8330c
commit
ba1d22ac29
24
IR_Decoder.h
24
IR_Decoder.h
@ -51,19 +51,7 @@ public:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct ErrorsStruct {
|
|
||||||
uint8_t lowSignal;
|
|
||||||
uint8_t highSignal;
|
|
||||||
uint8_t other;
|
|
||||||
|
|
||||||
void reset() {
|
|
||||||
lowSignal = 0;
|
|
||||||
highSignal = 0;
|
|
||||||
other = 0;
|
|
||||||
}
|
|
||||||
uint16_t all() { return lowSignal + highSignal + other; }
|
|
||||||
|
|
||||||
} errors;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class InputData : protected IR_FOX {
|
class InputData : protected IR_FOX {
|
||||||
@ -121,12 +109,12 @@ public:
|
|||||||
uint8_t dataRawSize() { return _dataRawSize; };
|
uint8_t dataRawSize() { return _dataRawSize; };
|
||||||
uint8_t* dataRaw() { return _data; };
|
uint8_t* dataRaw() { return _data; };
|
||||||
bool isNeedAccept() { return ((_msgType >> 5) & IR_MASK_MSG_TYPE) == IR_MSG_DATA_ACCEPT; };
|
bool isNeedAccept() { return ((_msgType >> 5) & IR_MASK_MSG_TYPE) == IR_MSG_DATA_ACCEPT; };
|
||||||
String printRawData(uint8_t mode = 10) {
|
// String printRawData(uint8_t mode = 10) {
|
||||||
return printBytes(dataRaw(), dataRawSize(), mode);
|
// return printBytes(dataRaw(), dataRawSize(), mode);
|
||||||
}
|
// }
|
||||||
String printData(uint8_t mode = 10) {
|
// String printData(uint8_t mode = 10) {
|
||||||
return printBytes(data(), dataSize(), mode);
|
// return printBytes(data(), dataSize(), mode);
|
||||||
}
|
// }
|
||||||
~Data() {};
|
~Data() {};
|
||||||
private:
|
private:
|
||||||
void ini() override {
|
void ini() override {
|
||||||
|
82
IR_config.h
82
IR_config.h
@ -138,9 +138,23 @@ typedef uint16_t crc_t;
|
|||||||
#define tolerance 300U
|
#define tolerance 300U
|
||||||
|
|
||||||
class IR_FOX {
|
class IR_FOX {
|
||||||
private:
|
public:
|
||||||
bool isSending = false;
|
struct ErrorsStruct {
|
||||||
|
uint8_t lowSignal;
|
||||||
|
uint8_t highSignal;
|
||||||
|
uint8_t other;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
lowSignal = 0;
|
||||||
|
highSignal = 0;
|
||||||
|
other = 0;
|
||||||
|
}
|
||||||
|
uint16_t all() { return lowSignal + highSignal + other; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
ErrorsStruct errors;
|
||||||
uint8_t crc8(uint8_t* data, uint8_t start, uint8_t end, uint8_t poly) { //TODO: сделать возможность межбайтовой проверки
|
uint8_t crc8(uint8_t* data, uint8_t start, uint8_t end, uint8_t poly) { //TODO: сделать возможность межбайтовой проверки
|
||||||
uint8_t crc = 0xff;
|
uint8_t crc = 0xff;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
@ -155,41 +169,43 @@ protected:
|
|||||||
}
|
}
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public:
|
// public:
|
||||||
/// @brief Вывод массива байт в строковом формате
|
// /// @brief Вывод массива байт в строковом формате
|
||||||
/// @param d Указатель на массив
|
// /// @param d Указатель на массив
|
||||||
/// @param s Размер массива
|
// /// @param s Размер массива
|
||||||
/// @param mode Формат вывода DEC, BIN
|
// /// @param mode Формат вывода DEC, BIN
|
||||||
/// @return Готовая для вывода строка
|
// /// @return Готовая для вывода строка
|
||||||
String printBytes(uint8_t* d, uint8_t s, uint8_t mode = 10) {
|
// String printBytes(uint8_t* d, uint8_t s, uint8_t mode = 10) {
|
||||||
String str = "";
|
// String str = "";
|
||||||
uint8_t control = bitPerByte;
|
// uint8_t control = bitPerByte;
|
||||||
uint8_t* _data = d;
|
// uint8_t* _data = d;
|
||||||
switch (mode) {
|
// switch (mode) {
|
||||||
case 2:
|
// case 2:
|
||||||
for (size_t i = 0; i < s * 8; i++) {
|
// for (size_t i = 0; i < s * 8; i++) {
|
||||||
if (i == control) {
|
// if (i == control) {
|
||||||
str += " ";
|
// str += " ";
|
||||||
control += bitPerByte;
|
// control += bitPerByte;
|
||||||
}
|
// }
|
||||||
|
|
||||||
str += _data[(i / 8)] >> (7 - (i % 8)) & 1;
|
// str += _data[(i / 8)] >> (7 - (i % 8)) & 1;
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case 10:
|
// case 10:
|
||||||
for (size_t i = 0; i < s; i++) {
|
// for (size_t i = 0; i < s; i++) {
|
||||||
str += _data[i];
|
// str += _data[i];
|
||||||
str += " ";
|
// str += " ";
|
||||||
}
|
// }
|
||||||
|
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
str += " ";
|
// str += " ";
|
||||||
return str;
|
// return str;
|
||||||
}
|
// }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user