default constructor and operator() for test

This commit is contained in:
DashyFox 2024-08-28 18:00:18 +03:00
parent c66d47e464
commit 784365181e
6 changed files with 16 additions and 7 deletions

View File

@ -6,12 +6,15 @@ std::list<IR_Decoder*>& 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);

View File

@ -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();

View File

@ -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);

View File

@ -36,6 +36,7 @@ protected:
public:
//////////////////////////////////////////////////////////////////////////
IR_DecoderRaw();
/// @brief Конструктор
/// @param pin Номер вывода прерывания/данных от приёмника (2 или 3 для atmega 328p)
/// @param addr Адрес приёмника

View File

@ -11,6 +11,8 @@ std::list<IR_Encoder*>& 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};

View File

@ -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;
};