mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-04 07:10:16 +00:00
fix multiBlind
This commit is contained in:
parent
bfa978394f
commit
1ee3386c31
@ -62,26 +62,15 @@ void IR_Decoder::tick() {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if (currentFront.time - prevRise > IR_timeout) { // первый
|
if (currentFront.time - prevRise > IR_timeout) { // первый
|
||||||
// if (!currentFront.dir) { // ↓
|
|
||||||
|
|
||||||
errorCounter = 0;
|
errorCounter = 0;
|
||||||
isRecive = true;
|
isRecive = true;
|
||||||
isPreamb = true;
|
isPreamb = true;
|
||||||
// preambFrontCounter = preambFronts - 1U;
|
|
||||||
// } else { // ↑
|
|
||||||
riseSyncTime = bitTime /* 1100 */;
|
riseSyncTime = bitTime /* 1100 */;
|
||||||
start_RX();
|
start_RX();
|
||||||
preambFrontCounter = preambFronts - 1U;
|
preambFrontCounter = preambFronts - 1U;
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Serial.println();
|
|
||||||
// Serial.print("currentFront.time: "); Serial.println(currentFront.time);
|
|
||||||
// Serial.print("currentFront.dir: "); Serial.println(currentFront.dir ? "UP" : "Down");
|
|
||||||
// Serial.print("prevRise: "); Serial.println(prevRise);
|
|
||||||
// Serial.print("preambFrontCounter: "); Serial.println(preambFrontCounter);
|
|
||||||
|
|
||||||
// prevRise = currentFront.time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preambFrontCounter > 0) { // в преамбуле
|
if (preambFrontCounter > 0) { // в преамбуле
|
||||||
|
@ -14,20 +14,24 @@ IR_Encoder::IR_Encoder(uint16_t addr, uint8_t pin, IR_Decoder* decPair = nullptr
|
|||||||
this->decPair = decPair;
|
this->decPair = decPair;
|
||||||
signal = noSignal;
|
signal = noSignal;
|
||||||
isSending = false;
|
isSending = false;
|
||||||
|
#if disablePairDec
|
||||||
if(decPair != nullptr){
|
if(decPair != nullptr){
|
||||||
// blindDecoders = &decPair;/////////////////////////////////////////////////////////TODO:
|
blindDecoders = new IR_Decoder*[1]{decPair};
|
||||||
// decodersCount = 1;
|
decodersCount = 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
void IR_Encoder::setBlindDecoders(IR_Decoder* decoders[], uint8_t count){
|
void IR_Encoder::setBlindDecoders(IR_Decoder* decoders[], uint8_t count){
|
||||||
|
#if disablePairDec
|
||||||
|
if(blindDecoders != nullptr) delete[] blindDecoders;
|
||||||
|
#endif
|
||||||
decodersCount = count;
|
decodersCount = count;
|
||||||
blindDecoders = decoders;
|
blindDecoders = decoders;
|
||||||
}
|
}
|
||||||
|
|
||||||
IR_Encoder::~IR_Encoder() {
|
IR_Encoder::~IR_Encoder() {
|
||||||
delete [] bitHigh;
|
|
||||||
delete [] bitLow;
|
delete [] bitLow;
|
||||||
// delete [] sendBuffer;
|
delete [] bitHigh;
|
||||||
};
|
};
|
||||||
|
|
||||||
void IR_Encoder::sendData(uint16_t addrTo, uint8_t* data, uint8_t len, bool needAccept = false) {
|
void IR_Encoder::sendData(uint16_t addrTo, uint8_t* data, uint8_t len, bool needAccept = false) {
|
||||||
@ -116,6 +120,7 @@ void IR_Encoder::setDecoder_isSending() {
|
|||||||
if (decodersCount) {
|
if (decodersCount) {
|
||||||
for (uint8_t i = 0; i < decodersCount; i++) {
|
for (uint8_t i = 0; i < decodersCount; i++) {
|
||||||
blindDecoders[i]->isPairSending ^= id;
|
blindDecoders[i]->isPairSending ^= id;
|
||||||
|
digitalToggle(9); digitalToggle(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -132,7 +137,7 @@ void IR_Encoder::rawSend(uint8_t* ptr, uint8_t len) {
|
|||||||
sendLen = len;
|
sendLen = len;
|
||||||
|
|
||||||
setDecoder_isSending();
|
setDecoder_isSending();
|
||||||
Serial.println("^");
|
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
toggleCounter = preambToggle; // Первая генерация для первого signal
|
toggleCounter = preambToggle; // Первая генерация для первого signal
|
||||||
@ -171,7 +176,6 @@ void IR_Encoder::isr() {
|
|||||||
// ...
|
// ...
|
||||||
isSending = false;
|
isSending = false;
|
||||||
setDecoder_isSending();
|
setDecoder_isSending();
|
||||||
Serial.println("^^^");
|
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -80,6 +80,8 @@ typedef uint16_t crc_t;
|
|||||||
|
|
||||||
#define preambPulse 3
|
#define preambPulse 3
|
||||||
|
|
||||||
|
#define disablePairDec false // Отключать парный приёмник, возможны баги, используйте setBlindDecoders()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define bitPerByte 8U // Колличество бит в байте
|
#define bitPerByte 8U // Колличество бит в байте
|
||||||
|
Loading…
x
Reference in New Issue
Block a user