moved id to parrent class

This commit is contained in:
DashyFox 2024-02-28 10:03:31 +03:00
parent b7d0179092
commit f6bbd96a4c
4 changed files with 8 additions and 5 deletions

View File

@ -2,7 +2,8 @@
#include "IR_Encoder.h"
IR_DecoderRaw::IR_DecoderRaw(const uint8_t isrPin, uint16_t addr, IR_Encoder* encPair = nullptr) : isrPin(isrPin), id(addr), encoder(encPair) {
IR_DecoderRaw::IR_DecoderRaw(const uint8_t isrPin, uint16_t addr, IR_Encoder* encPair = nullptr) : isrPin(isrPin), encoder(encPair) {
id = addr;
prevRise = prevFall = prevPrevFall = prevPrevRise = 0;
if (encPair != nullptr) {
encPair->decPair = this;

View File

@ -27,7 +27,6 @@ class IR_DecoderRaw : virtual public IR_FOX {
friend IR_Encoder;
protected:
PackInfo packInfo;
uint16_t id;
IR_Encoder* encoder; // Указатель на парный передатчик
public:
const uint8_t isrPin; // Пин прерывания
@ -44,8 +43,6 @@ public:
bool available() { if (isAvailable) { isAvailable = false; return true; } else { return false; } };
bool isOverflow() { return isBufferOverflow; }; // Буффер переполнился
bool isReciving() { return isBufferOverflow; }; // Возвращает true, если происходит приём пакета
uint16_t getId() {return id;}
void setId(uint16_t id) {this->id = id;}
//////////////////////////////////////////////////////////////////////////
private:

View File

@ -7,9 +7,9 @@ class IR_DecoderRaw;
class IR_Encoder : IR_FOX {
friend IR_DecoderRaw;
public:
uint16_t id; /// @brief Адрес передатчика
private:
uint16_t id; /// @brief Адрес передатчика
public:
@ -51,6 +51,7 @@ public:
void sendBackTo(uint16_t addrTo, uint8_t* data = nullptr, uint8_t len = 0);
void isr();
~IR_Encoder();
volatile bool ir_out_virtual;
private:

View File

@ -176,8 +176,12 @@ public:
flag |= address >= IR_Broadcast;
}
uint16_t getId() { return id; }
void setId(uint16_t id) { this->id = id; }
protected:
ErrorsStruct errors;
uint16_t id;
uint8_t crc8(uint8_t* data, uint8_t start, uint8_t end, uint8_t poly) { //TODO: сделать возможность межбайтовой проверки
uint8_t crc = 0xff;
size_t i, j;