mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-04 07:10:16 +00:00
no default construct
This commit is contained in:
parent
784365181e
commit
2f4ac3ddf8
@ -1,19 +1,22 @@
|
|||||||
#include "IR_Decoder.h"
|
#include "IR_Decoder.h"
|
||||||
|
|
||||||
std::list<IR_Decoder*>& IR_Decoder::get_dec_list() // определение функции
|
std::list<IR_Decoder *> &IR_Decoder::get_dec_list() // определение функции
|
||||||
{
|
{
|
||||||
static std::list<IR_Decoder*> dec_list; // статическая локальная переменная
|
static std::list<IR_Decoder *> dec_list; // статическая локальная переменная
|
||||||
return dec_list; // возвращается ссылка на переменную
|
return dec_list; // возвращается ссылка на переменную
|
||||||
}
|
}
|
||||||
|
|
||||||
IR_Decoder::IR_Decoder(){};
|
// IR_Decoder::IR_Decoder() {};
|
||||||
IR_Decoder::IR_Decoder(const uint8_t pin, uint16_t addr, IR_Encoder *encPair)
|
IR_Decoder::IR_Decoder(const uint8_t pin, uint16_t addr, IR_Encoder *encPair)
|
||||||
: IR_DecoderRaw(pin, addr, encPair)
|
: IR_DecoderRaw(pin, addr, encPair)
|
||||||
{
|
{
|
||||||
get_dec_list().push_back(this);
|
get_dec_list().push_back(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
void IR_Decoder::operator()() { isr(); }
|
std::function<void()> IR_Decoder::operator()()
|
||||||
|
{
|
||||||
|
return std::bind(&IR_Decoder::isr, this);
|
||||||
|
}
|
||||||
|
|
||||||
IR_Decoder::~IR_Decoder()
|
IR_Decoder::~IR_Decoder()
|
||||||
{
|
{
|
||||||
|
@ -24,10 +24,10 @@ public:
|
|||||||
PacketTypes::Request gotRequest;
|
PacketTypes::Request gotRequest;
|
||||||
PacketTypes::BasePack gotRaw;
|
PacketTypes::BasePack gotRaw;
|
||||||
|
|
||||||
IR_Decoder();
|
// IR_Decoder();
|
||||||
IR_Decoder(const uint8_t pin, uint16_t addr, IR_Encoder *encPair = nullptr);
|
IR_Decoder(const uint8_t pin, uint16_t addr, IR_Encoder *encPair = nullptr);
|
||||||
|
|
||||||
void operator()() ;
|
std::function<void()> operator()();
|
||||||
|
|
||||||
~IR_Decoder();
|
~IR_Decoder();
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "IR_DecoderRaw.h"
|
#include "IR_DecoderRaw.h"
|
||||||
#include "IR_Encoder.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)
|
IR_DecoderRaw::IR_DecoderRaw(const uint8_t pin, uint16_t addr, IR_Encoder *encPair) : encoder(encPair)
|
||||||
{
|
{
|
||||||
setPin(pin);
|
setPin(pin);
|
||||||
@ -651,3 +650,179 @@ inline void IR_DecoderRaw::infoPulse(uint8_t pin, uint8_t count)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Конструктор копирования
|
||||||
|
IR_DecoderRaw::IR_DecoderRaw(const IR_DecoderRaw& other)
|
||||||
|
: packInfo(other.packInfo),
|
||||||
|
encoder(other.encoder), // Если IR_Encoder имеет безопасный копируемый указатель
|
||||||
|
isAvailable(other.isAvailable),
|
||||||
|
packSize(other.packSize),
|
||||||
|
crcValue(other.crcValue),
|
||||||
|
isPairSending(other.isPairSending),
|
||||||
|
isRecive(other.isRecive),
|
||||||
|
isPreamb(other.isPreamb),
|
||||||
|
isSubBufferOverflow(other.isSubBufferOverflow),
|
||||||
|
isBufferOverflow(other.isBufferOverflow),
|
||||||
|
isWrongPack(other.isWrongPack),
|
||||||
|
riseSyncTime(other.riseSyncTime),
|
||||||
|
currentSubBufferIndex(other.currentSubBufferIndex),
|
||||||
|
subBuffer(other.subBuffer), // Копирование буфера
|
||||||
|
lastFront(other.lastFront),
|
||||||
|
firstUnHandledFront(other.firstUnHandledFront),
|
||||||
|
prevRise(other.prevRise),
|
||||||
|
prevPrevRise(other.prevPrevRise),
|
||||||
|
prevFall(other.prevFall),
|
||||||
|
prevPrevFall(other.prevPrevFall),
|
||||||
|
risePeriod(other.risePeriod),
|
||||||
|
highTime(other.highTime),
|
||||||
|
lowTime(other.lowTime),
|
||||||
|
oldTime(other.oldTime),
|
||||||
|
wrongCounter(other.wrongCounter),
|
||||||
|
highCount(other.highCount),
|
||||||
|
lowCount(other.lowCount),
|
||||||
|
allCount(other.allCount),
|
||||||
|
errorCounter(other.errorCounter),
|
||||||
|
preambFrontCounter(other.preambFrontCounter),
|
||||||
|
bufBitPos(other.bufBitPos),
|
||||||
|
isData(other.isData),
|
||||||
|
i_dataBuffer(other.i_dataBuffer),
|
||||||
|
nextControlBit(other.nextControlBit),
|
||||||
|
i_syncBit(other.i_syncBit),
|
||||||
|
err_syncBit(other.err_syncBit)
|
||||||
|
{
|
||||||
|
// Специфическое копирование, если нужно
|
||||||
|
}
|
||||||
|
|
||||||
|
// Оператор копирующего присваивания
|
||||||
|
IR_DecoderRaw& IR_DecoderRaw::operator=(const IR_DecoderRaw& other) {
|
||||||
|
if (this != &other) { // Проверка на самоприсваивание
|
||||||
|
packInfo = other.packInfo;
|
||||||
|
encoder = other.encoder;
|
||||||
|
isAvailable = other.isAvailable;
|
||||||
|
packSize = other.packSize;
|
||||||
|
crcValue = other.crcValue;
|
||||||
|
isPairSending = other.isPairSending;
|
||||||
|
isRecive = other.isRecive;
|
||||||
|
isPreamb = other.isPreamb;
|
||||||
|
isSubBufferOverflow = other.isSubBufferOverflow;
|
||||||
|
isBufferOverflow = other.isBufferOverflow;
|
||||||
|
isWrongPack = other.isWrongPack;
|
||||||
|
riseSyncTime = other.riseSyncTime;
|
||||||
|
currentSubBufferIndex = other.currentSubBufferIndex;
|
||||||
|
subBuffer = other.subBuffer;
|
||||||
|
lastFront = other.lastFront;
|
||||||
|
firstUnHandledFront = other.firstUnHandledFront;
|
||||||
|
prevRise = other.prevRise;
|
||||||
|
prevPrevRise = other.prevPrevRise;
|
||||||
|
prevFall = other.prevFall;
|
||||||
|
prevPrevFall = other.prevPrevFall;
|
||||||
|
risePeriod = other.risePeriod;
|
||||||
|
highTime = other.highTime;
|
||||||
|
lowTime = other.lowTime;
|
||||||
|
oldTime = other.oldTime;
|
||||||
|
wrongCounter = other.wrongCounter;
|
||||||
|
highCount = other.highCount;
|
||||||
|
lowCount = other.lowCount;
|
||||||
|
allCount = other.allCount;
|
||||||
|
errorCounter = other.errorCounter;
|
||||||
|
preambFrontCounter = other.preambFrontCounter;
|
||||||
|
bufBitPos = other.bufBitPos;
|
||||||
|
isData = other.isData;
|
||||||
|
i_dataBuffer = other.i_dataBuffer;
|
||||||
|
nextControlBit = other.nextControlBit;
|
||||||
|
i_syncBit = other.i_syncBit;
|
||||||
|
err_syncBit = other.err_syncBit;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Конструктор перемещения
|
||||||
|
IR_DecoderRaw::IR_DecoderRaw(IR_DecoderRaw&& other)
|
||||||
|
: packInfo(std::move(other.packInfo)),
|
||||||
|
encoder(other.encoder),
|
||||||
|
isAvailable(other.isAvailable),
|
||||||
|
packSize(other.packSize),
|
||||||
|
crcValue(other.crcValue),
|
||||||
|
isPairSending(other.isPairSending),
|
||||||
|
isRecive(other.isRecive),
|
||||||
|
isPreamb(other.isPreamb),
|
||||||
|
isSubBufferOverflow(other.isSubBufferOverflow),
|
||||||
|
isBufferOverflow(other.isBufferOverflow),
|
||||||
|
isWrongPack(other.isWrongPack),
|
||||||
|
riseSyncTime(other.riseSyncTime),
|
||||||
|
currentSubBufferIndex(other.currentSubBufferIndex),
|
||||||
|
subBuffer(std::move(other.subBuffer)),
|
||||||
|
lastFront(other.lastFront),
|
||||||
|
firstUnHandledFront(other.firstUnHandledFront),
|
||||||
|
prevRise(other.prevRise),
|
||||||
|
prevPrevRise(other.prevPrevRise),
|
||||||
|
prevFall(other.prevFall),
|
||||||
|
prevPrevFall(other.prevPrevFall),
|
||||||
|
risePeriod(other.risePeriod),
|
||||||
|
highTime(other.highTime),
|
||||||
|
lowTime(other.lowTime),
|
||||||
|
oldTime(other.oldTime),
|
||||||
|
wrongCounter(other.wrongCounter),
|
||||||
|
highCount(other.highCount),
|
||||||
|
lowCount(other.lowCount),
|
||||||
|
allCount(other.allCount),
|
||||||
|
errorCounter(other.errorCounter),
|
||||||
|
preambFrontCounter(other.preambFrontCounter),
|
||||||
|
bufBitPos(other.bufBitPos),
|
||||||
|
isData(other.isData),
|
||||||
|
i_dataBuffer(other.i_dataBuffer),
|
||||||
|
nextControlBit(other.nextControlBit),
|
||||||
|
i_syncBit(other.i_syncBit),
|
||||||
|
err_syncBit(other.err_syncBit)
|
||||||
|
{
|
||||||
|
other.encoder = nullptr;
|
||||||
|
other.lastFront = nullptr;
|
||||||
|
other.firstUnHandledFront = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Оператор перемещающего присваивания
|
||||||
|
IR_DecoderRaw& IR_DecoderRaw::operator=(IR_DecoderRaw&& other) {
|
||||||
|
if (this != &other) { // Проверка на самоприсваивание
|
||||||
|
packInfo = std::move(other.packInfo);
|
||||||
|
encoder = other.encoder;
|
||||||
|
isAvailable = other.isAvailable;
|
||||||
|
packSize = other.packSize;
|
||||||
|
crcValue = other.crcValue;
|
||||||
|
isPairSending = other.isPairSending;
|
||||||
|
isRecive = other.isRecive;
|
||||||
|
isPreamb = other.isPreamb;
|
||||||
|
isSubBufferOverflow = other.isSubBufferOverflow;
|
||||||
|
isBufferOverflow = other.isBufferOverflow;
|
||||||
|
isWrongPack = other.isWrongPack;
|
||||||
|
riseSyncTime = other.riseSyncTime;
|
||||||
|
currentSubBufferIndex = other.currentSubBufferIndex;
|
||||||
|
subBuffer = std::move(other.subBuffer);
|
||||||
|
lastFront = other.lastFront;
|
||||||
|
firstUnHandledFront = other.firstUnHandledFront;
|
||||||
|
prevRise = other.prevRise;
|
||||||
|
prevPrevRise = other.prevPrevRise;
|
||||||
|
prevFall = other.prevFall;
|
||||||
|
prevPrevFall = other.prevPrevFall;
|
||||||
|
risePeriod = other.risePeriod;
|
||||||
|
highTime = other.highTime;
|
||||||
|
lowTime = other.lowTime;
|
||||||
|
oldTime = other.oldTime;
|
||||||
|
wrongCounter = other.wrongCounter;
|
||||||
|
highCount = other.highCount;
|
||||||
|
lowCount = other.lowCount;
|
||||||
|
allCount = other.allCount;
|
||||||
|
errorCounter = other.errorCounter;
|
||||||
|
preambFrontCounter = other.preambFrontCounter;
|
||||||
|
bufBitPos = other.bufBitPos;
|
||||||
|
isData = other.isData;
|
||||||
|
i_dataBuffer = other.i_dataBuffer;
|
||||||
|
nextControlBit = other.nextControlBit;
|
||||||
|
i_syncBit = other.i_syncBit;
|
||||||
|
err_syncBit = other.err_syncBit;
|
||||||
|
|
||||||
|
other.encoder = nullptr;
|
||||||
|
other.lastFront = nullptr;
|
||||||
|
other.firstUnHandledFront = nullptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
@ -36,7 +36,6 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
IR_DecoderRaw();
|
|
||||||
/// @brief Конструктор
|
/// @brief Конструктор
|
||||||
/// @param pin Номер вывода прерывания/данных от приёмника (2 или 3 для atmega 328p)
|
/// @param pin Номер вывода прерывания/данных от приёмника (2 или 3 для atmega 328p)
|
||||||
/// @param addr Адрес приёмника
|
/// @param addr Адрес приёмника
|
||||||
@ -133,4 +132,4 @@ private:
|
|||||||
inline void errPulse(uint8_t pin, uint8_t count);
|
inline void errPulse(uint8_t pin, uint8_t count);
|
||||||
inline void infoPulse(uint8_t pin, uint8_t count);
|
inline void infoPulse(uint8_t pin, uint8_t count);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,6 @@ std::list<IR_Encoder*>& IR_Encoder::get_enc_list() // определение ф
|
|||||||
return dec_list; // возвращается ссылка на переменную
|
return dec_list; // возвращается ссылка на переменную
|
||||||
}
|
}
|
||||||
|
|
||||||
IR_Encoder::IR_Encoder(){};
|
|
||||||
|
|
||||||
IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair)
|
IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair)
|
||||||
{
|
{
|
||||||
@ -404,4 +403,4 @@ uint8_t IR_Encoder::bitLow[2] = {
|
|||||||
// (bitActiveTakts) * 2 - 0};
|
// (bitActiveTakts) * 2 - 0};
|
||||||
// uint8_t* IR_Encoder::bitLow = new uint8_t[2]{
|
// uint8_t* IR_Encoder::bitLow = new uint8_t[2]{
|
||||||
// (bitPauseTakts/2 + bitActiveTakts) * 2 - 0,
|
// (bitPauseTakts/2 + bitActiveTakts) * 2 - 0,
|
||||||
// (bitPauseTakts) - 0};
|
// (bitPauseTakts) - 0};
|
||||||
|
@ -12,7 +12,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
uint16_t id; /// @brief Адрес передатчика
|
uint16_t id; /// @brief Адрес передатчика
|
||||||
public:
|
public:
|
||||||
IR_Encoder();
|
|
||||||
/// @brief Класс передатчика
|
/// @brief Класс передатчика
|
||||||
/// @param addr Адрес передатчика
|
/// @param addr Адрес передатчика
|
||||||
/// @param pin Вывод передатчика
|
/// @param pin Вывод передатчика
|
||||||
|
Loading…
x
Reference in New Issue
Block a user