diff --git a/IR_Decoder.cpp b/IR_Decoder.cpp index b8381f5..211dfda 100644 --- a/IR_Decoder.cpp +++ b/IR_Decoder.cpp @@ -61,6 +61,7 @@ void IR_Decoder::tick() void IR_Decoder::_tick() { IR_DecoderRaw::tick(); + if (availableRaw()) { #ifdef IRDEBUG_INFO @@ -102,4 +103,8 @@ void IR_Decoder::_tick() encoder->sendAccept(addrAcceptSendTo, acceptCustomByte); isWaitingAcceptSend = false; } -} \ No newline at end of file +} + +bool IR_Decoder::isReceive(uint8_t type) { + return (msgTypeReceive & 0b11111000) && ((msgTypeReceive & IR_MASK_MSG_TYPE) == type); +} diff --git a/IR_Decoder.h b/IR_Decoder.h index 9f616f5..3344562 100644 --- a/IR_Decoder.h +++ b/IR_Decoder.h @@ -31,6 +31,8 @@ public: void enable(); void disable(); + + bool isReceive(uint8_t type); ~IR_Decoder(); diff --git a/IR_DecoderRaw.cpp b/IR_DecoderRaw.cpp index d748143..5cfd3ce 100644 --- a/IR_DecoderRaw.cpp +++ b/IR_DecoderRaw.cpp @@ -129,6 +129,7 @@ inline void IR_DecoderRaw::checkTimeout() if (micros() - lastEdgeTime > IR_timeout * 2U) { isRecive = false; // приём завершён + msgTypeReceive = 0; // firstRX(); // подготовка к новому пакету lastEdgeTime = micros(); // защита от повторного срабатывания } @@ -475,6 +476,7 @@ void IR_DecoderRaw::writeToBuffer(bool bit) { isRecive = false; isReciveRaw = false; + msgTypeReceive = 0; return; } @@ -599,6 +601,7 @@ void IR_DecoderRaw::writeToBuffer(bool bit) isRecive = false; isReciveRaw = false; + msgTypeReceive = 0; isAvailable = crcCheck(packSize - crcBytes, crcValue); #ifdef BRUTEFORCE_CHECK @@ -629,6 +632,12 @@ void IR_DecoderRaw::writeToBuffer(bool bit) OUT_BRUTEFORCE:; #endif } + + if (packSize && (i_dataBuffer == 8)) { + msgTypeReceive = (dataBuffer[0]>>5) | 0b11111000; + // SerialUSB.println(msgTypeReceive & IR_MASK_MSG_TYPE); + + } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/IR_DecoderRaw.h b/IR_DecoderRaw.h index 5e9d2b0..7361982 100644 --- a/IR_DecoderRaw.h +++ b/IR_DecoderRaw.h @@ -31,9 +31,10 @@ class IR_DecoderRaw : virtual public IR_FOX friend IR_Encoder; protected: - PackInfo packInfo; - IR_Encoder *encoder; // Указатель на парный передатчик - bool availableRaw(); +PackInfo packInfo; +uint8_t msgTypeReceive = 0; +IR_Encoder *encoder; // Указатель на парный передатчик +bool availableRaw(); public: //////////////////////////////////////////////////////////////////////////