mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-04 07:10:16 +00:00
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
#pragma once
|
|
#include "IR_DecoderRaw.h"
|
|
#include "PacketTypes.h"
|
|
|
|
class IR_Decoder : public IR_DecoderRaw {
|
|
public:
|
|
PacketTypes::Data gotData;
|
|
PacketTypes::DataBack gotBackData;
|
|
PacketTypes::Accept gotAccept;
|
|
PacketTypes::Request gotRequest;
|
|
|
|
IR_Decoder(const uint8_t isrPin, uint16_t addr, IR_Encoder* encPair = nullptr) : IR_DecoderRaw(isrPin, addr, encPair) {
|
|
}
|
|
|
|
void tick() {
|
|
IR_DecoderRaw::tick();
|
|
if (available()) {
|
|
#ifdef IRDEBUG_INFO
|
|
Serial.println("PARSING RAW DATA");
|
|
#endif
|
|
bool isNeenAccept = false;
|
|
switch (packInfo.buffer[0] >> 5 & IR_MASK_MSG_TYPE) {
|
|
case IR_MSG_DATA_ACCEPT:
|
|
isNeenAccept = true;
|
|
case IR_MSG_DATA_NOACCEPT:
|
|
gotData.set(&packInfo, id);
|
|
break;
|
|
case IR_MSG_BACK:
|
|
case IR_MSG_BACK_TO:
|
|
gotBackData.set(&packInfo, id);
|
|
break;
|
|
case IR_MSG_REQUEST:
|
|
gotRequest.set(&packInfo, id);
|
|
break;
|
|
case IR_MSG_ACCEPT:
|
|
gotAccept.set(&packInfo, id);
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
};
|