From ba1d22ac29cb2c6c48661b34f9cb49a246873771 Mon Sep 17 00:00:00 2001 From: DashyFox Date: Mon, 19 Feb 2024 10:07:21 +0300 Subject: [PATCH] clean --- IR_Decoder.h | 26 +++++------------ IR_config.h | 82 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/IR_Decoder.h b/IR_Decoder.h index 659515b..4a36fb1 100644 --- a/IR_Decoder.h +++ b/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: class InputData : protected IR_FOX { @@ -121,12 +109,12 @@ public: uint8_t dataRawSize() { return _dataRawSize; }; uint8_t* dataRaw() { return _data; }; bool isNeedAccept() { return ((_msgType >> 5) & IR_MASK_MSG_TYPE) == IR_MSG_DATA_ACCEPT; }; - String printRawData(uint8_t mode = 10) { - return printBytes(dataRaw(), dataRawSize(), mode); - } - String printData(uint8_t mode = 10) { - return printBytes(data(), dataSize(), mode); - } + // String printRawData(uint8_t mode = 10) { + // return printBytes(dataRaw(), dataRawSize(), mode); + // } + // String printData(uint8_t mode = 10) { + // return printBytes(data(), dataSize(), mode); + // } ~Data() {}; private: void ini() override { diff --git a/IR_config.h b/IR_config.h index ba61120..368a77f 100644 --- a/IR_config.h +++ b/IR_config.h @@ -138,9 +138,23 @@ typedef uint16_t crc_t; #define tolerance 300U class IR_FOX { -private: - bool isSending = false; +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; } + + }; + protected: + ErrorsStruct errors; uint8_t crc8(uint8_t* data, uint8_t start, uint8_t end, uint8_t poly) { //TODO: сделать возможность межбайтовой проверки uint8_t crc = 0xff; size_t i, j; @@ -155,41 +169,43 @@ protected: } return crc; } + + // public: - /// @brief Вывод массива байт в строковом формате - /// @param d Указатель на массив - /// @param s Размер массива - /// @param mode Формат вывода DEC, BIN - /// @return Готовая для вывода строка - String printBytes(uint8_t* d, uint8_t s, uint8_t mode = 10) { - String str = ""; - uint8_t control = bitPerByte; - uint8_t* _data = d; - switch (mode) { - case 2: - for (size_t i = 0; i < s * 8; i++) { - if (i == control) { - str += " "; - control += bitPerByte; - } + // /// @brief Вывод массива байт в строковом формате + // /// @param d Указатель на массив + // /// @param s Размер массива + // /// @param mode Формат вывода DEC, BIN + // /// @return Готовая для вывода строка + // String printBytes(uint8_t* d, uint8_t s, uint8_t mode = 10) { + // String str = ""; + // uint8_t control = bitPerByte; + // uint8_t* _data = d; + // switch (mode) { + // case 2: + // for (size_t i = 0; i < s * 8; i++) { + // if (i == control) { + // str += " "; + // control += bitPerByte; + // } - str += _data[(i / 8)] >> (7 - (i % 8)) & 1; - } - break; - case 10: - for (size_t i = 0; i < s; i++) { - str += _data[i]; - str += " "; - } + // str += _data[(i / 8)] >> (7 - (i % 8)) & 1; + // } + // break; + // case 10: + // for (size_t i = 0; i < s; i++) { + // str += _data[i]; + // str += " "; + // } - break; + // break; - default: - break; - } + // default: + // break; + // } - str += " "; - return str; - } + // str += " "; + // return str; + // } };