add acceptDelay change

This commit is contained in:
DashyFox 2024-02-27 12:45:52 +03:00
parent 523bb0712c
commit 909fac5d1a
2 changed files with 174 additions and 95 deletions

View File

@ -60,7 +60,7 @@ uint32_t loopTimer;
uint8_t sig = 255;
uint16_t targetAddr = IR_Broadcast;
Timer t1(730, millis, []() {
Timer t1(500, millis, []() {
// Serial.println(sig);
@ -227,106 +227,178 @@ void loop() {
//test
void status(IR_Decoder& dec) {
if (dec.gotData.available()) {
String str;
if (/* dec.gotData.getDataPrt()[1] */1) {
str += ("Data on pin "); str += (dec.isrPin); str += "\n";
if (dec.gotData.available()) {
String str;
if (/* dec.gotData.getDataPrt()[1] */1) {
str += ("Data on pin "); str += (dec.isrPin); str += "\n";
uint8_t msg = dec.gotData.getMsgRAW();
str += (" MSG: ");
for (size_t i = 0; i < 8; i++) {
if (i == 3) str += " ";
str += (msg >> (7 - i)) & 1U;
}
str += "\n";
str += (" DATA SIZE: "); str += (dec.gotData.getDataSize()); str += "\n";
str += (" ADDRESS FROM: "); str += (dec.gotData.getAddrFrom()); str += "\n";
str += (" ADDRESS TO: "); str += (dec.gotData.getAddrTo()); str += "\n";
// str += (" CRC PACK: "); str += (dec.gotData.getCrcIN()); str += "\n";
// str += (" CRC CALC: "); str += (dec.gotData.getCrcCALC()); str += "\n";
str += "\n";
for (size_t i = 0; i < min(10, dec.gotData.getDataSize()); i++) {
switch (i) {
// case 0:
// str += (" ADDR: ");
// break;
// case 1:
// str += (" CMD: ");
// break;
default:
str += (" Data["); str += (i); str += ("]: ");
break;
}
str += (dec.gotData.getDataPrt()[i]); str += "\n";
}
str += ("\n*******ErrAll: "); str += (dec.gotData.getErrorCount()); str += "\n";
str += ("**ErrDistance: "); str += ((int)(dec.gotData.getErrorHighSignal() - dec.gotData.getErrorLowSignal())); str += "\n";
str += "\n";
} else {
str += ("SELF"); str += "\n";
str += "\n";
uint8_t msg = dec.gotData.getMsgRAW();
str += (" MSG: ");
for (size_t i = 0; i < 8; i++) {
if (i == 3) str += " ";
str += (msg >> (7 - i)) & 1U;
}
// obj->resetAvailable();
Serial.write(str.c_str());
}
if (dec.gotBackData.available()) {
String str;
if (/* dec.gotData.getDataPrt()[1] */1) {
str += ("BackData on pin "); str += (dec.isrPin); str += "\n";
str += "\n";
uint8_t msg = dec.gotBackData.getMsgRAW();
str += (" MSG: ");
for (size_t i = 0; i < 8; i++) {
if (i == 3) str += " ";
str += (msg >> (7 - i)) & 1U;
str += (" DATA SIZE: "); str += (dec.gotData.getDataSize()); str += "\n";
str += (" ADDRESS FROM: "); str += (dec.gotData.getAddrFrom()); str += "\n";
str += (" ADDRESS TO: "); str += (dec.gotData.getAddrTo()); str += "\n";
// str += (" CRC PACK: "); str += (dec.gotData.getCrcIN()); str += "\n";
// str += (" CRC CALC: "); str += (dec.gotData.getCrcCALC()); str += "\n";
str += "\n";
for (size_t i = 0; i < min(10, dec.gotData.getDataSize()); i++) {
switch (i) {
// case 0:
// str += (" ADDR: ");
// break;
// case 1:
// str += (" CMD: ");
// break;
default:
str += (" Data["); str += (i); str += ("]: ");
break;
}
str += "\n";
str += (" DATA SIZE: "); str += (dec.gotBackData.getDataSize()); str += "\n";
str += (" ADDRESS FROM: "); str += (dec.gotBackData.getAddrFrom()); str += "\n";
// str += (" ADDRESS TO: "); str += (dec.gotBackData.getAddrTo()); str += "\n";
// str += (" CRC PACK: "); str += (dec.gotBackData.getCrcIN()); str += "\n";
// str += (" CRC CALC: "); str += (dec.gotBackData.getCrcCALC()); str += "\n";
str += "\n";
for (size_t i = 0; i < min(10, dec.gotBackData.getDataSize()); i++) {
switch (i) {
// case 0:
// str += (" ADDR: ");
// break;
// case 1:
// str += (" CMD: ");
// break;
default:
str += (" Data["); str += (i); str += ("]: ");
break;
}
str += (dec.gotBackData.getDataPrt()[i]); str += "\n";
}
str += ("\n*******ErrAll: "); str += (dec.gotBackData.getErrorCount()); str += "\n";
str += ("**ErrDistance: "); str += ((int)(dec.gotBackData.getErrorHighSignal() - dec.gotBackData.getErrorLowSignal())); str += "\n";
str += "\n";
} else {
str += ("SELF"); str += "\n";
str += "\n";
str += (dec.gotData.getDataPrt()[i]); str += "\n";
}
// obj->resetAvailable();
Serial.write(str.c_str());
str += ("\n*******ErrAll: "); str += (dec.gotData.getErrorCount()); str += "\n";
str += ("**ErrDistance: "); str += ((int)(dec.gotData.getErrorHighSignal() - dec.gotData.getErrorLowSignal())); str += "\n";
str += "\n";
} else {
str += ("SELF"); str += "\n";
str += "\n";
}
// obj->resetAvailable();
Serial.write(str.c_str());
}
if (dec.gotBackData.available()) {
String str;
if (/* dec.gotData.getDataPrt()[1] */1) {
str += ("BackData on pin "); str += (dec.isrPin); str += "\n";
uint8_t msg = dec.gotBackData.getMsgRAW();
str += (" MSG: ");
for (size_t i = 0; i < 8; i++) {
if (i == 3) str += " ";
str += (msg >> (7 - i)) & 1U;
}
str += "\n";
str += (" DATA SIZE: "); str += (dec.gotBackData.getDataSize()); str += "\n";
str += (" ADDRESS FROM: "); str += (dec.gotBackData.getAddrFrom()); str += "\n";
// str += (" ADDRESS TO: "); str += (dec.gotBackData.getAddrTo()); str += "\n";
// str += (" CRC PACK: "); str += (dec.gotBackData.getCrcIN()); str += "\n";
// str += (" CRC CALC: "); str += (dec.gotBackData.getCrcCALC()); str += "\n";
str += "\n";
for (size_t i = 0; i < min(10, dec.gotBackData.getDataSize()); i++) {
switch (i) {
// case 0:
// str += (" ADDR: ");
// break;
// case 1:
// str += (" CMD: ");
// break;
default:
str += (" Data["); str += (i); str += ("]: ");
break;
}
str += (dec.gotBackData.getDataPrt()[i]); str += "\n";
}
str += ("\n*******ErrAll: "); str += (dec.gotBackData.getErrorCount()); str += "\n";
str += ("**ErrDistance: "); str += ((int)(dec.gotBackData.getErrorHighSignal() - dec.gotBackData.getErrorLowSignal())); str += "\n";
str += "\n";
} else {
str += ("SELF"); str += "\n";
str += "\n";
}
// obj->resetAvailable();
Serial.write(str.c_str());
}
if (dec.gotAccept.available()) {
String str;
if (/* dec.gotData.getDataPrt()[1] */1) {
str += ("Accept on pin "); str += (dec.isrPin); str += "\n";
uint8_t msg = dec.gotAccept.getMsgRAW();
str += (" MSG: ");
for (size_t i = 0; i < 8; i++) {
if (i == 3) str += " ";
str += (msg >> (7 - i)) & 1U;
}
str += "\n";
// str += (" DATA SIZE: "); str += (dec.gotAccept.getDataSize()); str += "\n";
str += (" ADDRESS FROM: "); str += (dec.gotAccept.getAddrFrom()); str += "\n";
// str += (" ADDRESS TO: "); str += (dec.gotAccept.getAddrTo()); str += "\n";
// str += (" CRC PACK: "); str += (dec.gotAccept.getCrcIN()); str += "\n";
// str += (" CRC CALC: "); str += (dec.gotAccept.getCrcCALC()); str += "\n";
str += "\n";
str += (" Data["); str += (dec.gotAccept.getCustomByte()); str += ("]: \n");
str += ("\n*******ErrAll: "); str += (dec.gotAccept.getErrorCount()); str += "\n";
str += ("**ErrDistance: "); str += ((int)(dec.gotAccept.getErrorHighSignal() - dec.gotAccept.getErrorLowSignal())); str += "\n";
str += "\n";
} else {
str += ("SELF"); str += "\n";
str += "\n";
}
// obj->resetAvailable();
Serial.write(str.c_str());
}
if (dec.gotRequest.available()) {
String str;
if (/* dec.gotData.getDataPrt()[1] */1) {
str += ("Request on pin "); str += (dec.isrPin); str += "\n";
uint8_t msg = dec.gotRequest.getMsgRAW();
str += (" MSG: ");
for (size_t i = 0; i < 8; i++) {
if (i == 3) str += " ";
str += (msg >> (7 - i)) & 1U;
}
str += "\n";
// str += (" DATA SIZE: "); str += (dec.gotRequest.getDataSize()); str += "\n";
str += (" ADDRESS FROM: "); str += (dec.gotRequest.getAddrFrom()); str += "\n";
str += (" ADDRESS TO: "); str += (dec.gotRequest.getAddrTo()); str += "\n";
// str += (" CRC PACK: "); str += (dec.gotRequest.getCrcIN()); str += "\n";
// str += (" CRC CALC: "); str += (dec.gotRequest.getCrcCALC()); str += "\n";
str += "\n";
str += ("\n*******ErrAll: "); str += (dec.gotRequest.getErrorCount()); str += "\n";
str += ("**ErrDistance: "); str += ((int)(dec.gotRequest.getErrorHighSignal() - dec.gotRequest.getErrorLowSignal())); str += "\n";
str += "\n";
} else {
str += ("SELF"); str += "\n";
str += "\n";
}
// obj->resetAvailable();
Serial.write(str.c_str());
}
}

View File

@ -8,7 +8,7 @@ class IR_Decoder : public IR_DecoderRaw {
bool isWaitingAcceptSend;
uint16_t addrAcceptSendTo;
uint16_t acceptDelay = 75;
public:
@ -56,4 +56,11 @@ public:
isWaitingAcceptSend = false;
}
}
void setAcceptDelay(uint16_t acceptDelay){
this->acceptDelay = acceptDelay;
}
uint16_t getAcceptDelay(){
return this->acceptDelay;
}
};