From 784365181e99fae134a8b665b7fc25b09552f703 Mon Sep 17 00:00:00 2001 From: DashyFox Date: Wed, 28 Aug 2024 18:00:18 +0300 Subject: [PATCH] default constructor and operator() for test --- IR_Decoder.cpp | 3 +++ IR_Decoder.h | 4 ++++ IR_DecoderRaw.cpp | 1 + IR_DecoderRaw.h | 1 + IR_Encoder.cpp | 8 ++++---- IR_Encoder.h | 6 +++--- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/IR_Decoder.cpp b/IR_Decoder.cpp index 4f23b1f..0bb2711 100644 --- a/IR_Decoder.cpp +++ b/IR_Decoder.cpp @@ -6,12 +6,15 @@ std::list& IR_Decoder::get_dec_list() // определение ф return dec_list; // возвращается ссылка на переменную } +IR_Decoder::IR_Decoder(){}; IR_Decoder::IR_Decoder(const uint8_t pin, uint16_t addr, IR_Encoder *encPair) : IR_DecoderRaw(pin, addr, encPair) { get_dec_list().push_back(this); }; +void IR_Decoder::operator()() { isr(); } + IR_Decoder::~IR_Decoder() { IR_Decoder::get_dec_list().remove(this); diff --git a/IR_Decoder.h b/IR_Decoder.h index ba6b696..60c40cc 100644 --- a/IR_Decoder.h +++ b/IR_Decoder.h @@ -24,7 +24,11 @@ public: PacketTypes::Request gotRequest; PacketTypes::BasePack gotRaw; + IR_Decoder(); IR_Decoder(const uint8_t pin, uint16_t addr, IR_Encoder *encPair = nullptr); + + void operator()() ; + ~IR_Decoder(); static void tick(); diff --git a/IR_DecoderRaw.cpp b/IR_DecoderRaw.cpp index 997b54a..c38f964 100644 --- a/IR_DecoderRaw.cpp +++ b/IR_DecoderRaw.cpp @@ -1,6 +1,7 @@ #include "IR_DecoderRaw.h" #include "IR_Encoder.h" +IR_DecoderRaw::IR_DecoderRaw(){}; IR_DecoderRaw::IR_DecoderRaw(const uint8_t pin, uint16_t addr, IR_Encoder *encPair) : encoder(encPair) { setPin(pin); diff --git a/IR_DecoderRaw.h b/IR_DecoderRaw.h index 7f3c696..832df7f 100644 --- a/IR_DecoderRaw.h +++ b/IR_DecoderRaw.h @@ -36,6 +36,7 @@ protected: public: ////////////////////////////////////////////////////////////////////////// + IR_DecoderRaw(); /// @brief Конструктор /// @param pin Номер вывода прерывания/данных от приёмника (2 или 3 для atmega 328p) /// @param addr Адрес приёмника diff --git a/IR_Encoder.cpp b/IR_Encoder.cpp index 14a1087..8464a46 100644 --- a/IR_Encoder.cpp +++ b/IR_Encoder.cpp @@ -11,6 +11,8 @@ std::list& IR_Encoder::get_enc_list() // определение ф return dec_list; // возвращается ссылка на переменную } +IR_Encoder::IR_Encoder(){}; + IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair) { setPin(pin); @@ -46,8 +48,6 @@ void IR_Encoder::setBlindDecoders(IR_DecoderRaw *decoders[], uint8_t count) IR_Encoder::~IR_Encoder() { - delete[] bitLow; - delete[] bitHigh; get_enc_list().remove(this); }; @@ -392,10 +392,10 @@ void IR_Encoder::addSync(bool *prev, bool *next) } } -uint8_t* IR_Encoder::bitHigh = new uint8_t[2]{ +uint8_t IR_Encoder::bitHigh[2] = { (bitPauseTakts) * 2 - 1, (bitActiveTakts) * 2 - 1}; -uint8_t* IR_Encoder::bitLow = new uint8_t[2]{ +uint8_t IR_Encoder::bitLow[2] = { (bitPauseTakts/2 + bitActiveTakts) * 2 - 1, (bitPauseTakts) - 1}; diff --git a/IR_Encoder.h b/IR_Encoder.h index 16c1904..f6a26c2 100644 --- a/IR_Encoder.h +++ b/IR_Encoder.h @@ -12,7 +12,7 @@ public: private: uint16_t id; /// @brief Адрес передатчика public: - + IR_Encoder(); /// @brief Класс передатчика /// @param addr Адрес передатчика /// @param pin Вывод передатчика @@ -82,8 +82,8 @@ private: uint8_t low; uint8_t high; }; - static uint8_t *bitHigh; - static uint8_t *bitLow; + static uint8_t bitHigh[2]; + static uint8_t bitLow[2]; uint8_t *currentBitSequence = bitLow; volatile SignalPart signal; };