mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-06-28 05:09:40 +00:00
formatting
This commit is contained in:
66
IR_Decoder.h
66
IR_Decoder.h
@ -3,7 +3,8 @@
|
||||
#include "PacketTypes.h"
|
||||
#include "IR_Encoder.h"
|
||||
|
||||
class IR_Decoder : public IR_DecoderRaw {
|
||||
class IR_Decoder : public IR_DecoderRaw
|
||||
{
|
||||
uint32_t acceptSendTimer;
|
||||
bool isWaitingAcceptSend;
|
||||
uint16_t addrAcceptSendTo;
|
||||
@ -12,59 +13,66 @@ class IR_Decoder : public IR_DecoderRaw {
|
||||
uint8_t acceptCustomByte;
|
||||
|
||||
public:
|
||||
|
||||
PacketTypes::Data gotData;
|
||||
PacketTypes::DataBack gotBackData;
|
||||
PacketTypes::Accept gotAccept;
|
||||
PacketTypes::Request gotRequest;
|
||||
PacketTypes::BasePack gotRaw;
|
||||
|
||||
IR_Decoder(const uint8_t isrPin, uint16_t addr, IR_Encoder* encPair = nullptr) : IR_DecoderRaw(isrPin, addr, encPair) {}
|
||||
IR_Decoder(const uint8_t isrPin, uint16_t addr, IR_Encoder *encPair = nullptr) : IR_DecoderRaw(isrPin, addr, encPair) {}
|
||||
|
||||
void tick() {
|
||||
void tick()
|
||||
{
|
||||
IR_DecoderRaw::tick();
|
||||
if (availableRaw()) {
|
||||
#ifdef IRDEBUG_INFO
|
||||
if (availableRaw())
|
||||
{
|
||||
#ifdef IRDEBUG_INFO
|
||||
Serial.println("PARSING RAW DATA");
|
||||
#endif
|
||||
#endif
|
||||
isWaitingAcceptSend = false;
|
||||
switch (packInfo.buffer[0] >> 5 & IR_MASK_MSG_TYPE) {
|
||||
case IR_MSG_DATA_ACCEPT:
|
||||
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;
|
||||
switch (packInfo.buffer[0] >> 5 & IR_MASK_MSG_TYPE)
|
||||
{
|
||||
case IR_MSG_DATA_ACCEPT:
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (gotData.isAvailable && (gotData.getMsgType() == IR_MSG_DATA_ACCEPT)) {
|
||||
if (gotData.isAvailable && (gotData.getMsgType() == IR_MSG_DATA_ACCEPT))
|
||||
{
|
||||
acceptSendTimer = millis();
|
||||
addrAcceptSendTo = gotData.getAddrFrom();
|
||||
acceptCustomByte = crc8(gotData.getDataPrt(), 0, gotData.getDataSize(), poly1);
|
||||
if (addrAcceptSendTo && addrAcceptSendTo < IR_Broadcast) isWaitingAcceptSend = true;
|
||||
if (addrAcceptSendTo && addrAcceptSendTo < IR_Broadcast)
|
||||
isWaitingAcceptSend = true;
|
||||
}
|
||||
gotRaw.set(&packInfo, id);
|
||||
}
|
||||
if (isWaitingAcceptSend && millis() - acceptSendTimer > 75) {
|
||||
if (isWaitingAcceptSend && millis() - acceptSendTimer > 75)
|
||||
{
|
||||
encoder->sendAccept(addrAcceptSendTo, acceptCustomByte);
|
||||
isWaitingAcceptSend = false;
|
||||
}
|
||||
}
|
||||
|
||||
void setAcceptDelay(uint16_t acceptDelay) {
|
||||
void setAcceptDelay(uint16_t acceptDelay)
|
||||
{
|
||||
this->acceptDelay = acceptDelay;
|
||||
}
|
||||
uint16_t getAcceptDelay() {
|
||||
uint16_t getAcceptDelay()
|
||||
{
|
||||
return this->acceptDelay;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user