From b05b9dc9d5dde7202ebea8d72ea71a11ea5f6079 Mon Sep 17 00:00:00 2001 From: DashyFox Date: Thu, 25 Jan 2024 09:28:43 +0300 Subject: [PATCH] debug --- IR_Decoder.cpp | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/IR_Decoder.cpp b/IR_Decoder.cpp index 21a3b28..02f45d6 100644 --- a/IR_Decoder.cpp +++ b/IR_Decoder.cpp @@ -304,8 +304,14 @@ void IR_Decoder::tick() { if (aroundRise(risePeriod)) { // тактирование есть, сигнал хороший - без ошибок(?) if (highTime > riseTimeMin >> 1) { // 1 + #ifdef IRDEBUG + digitalWrite(wrHigh, 1); + #endif writeToBuffer(HIGH); } else { // 0 + #ifdef IRDEBUG + digitalWrite(wrLow, 1); + #endif writeToBuffer(LOW); } @@ -317,27 +323,49 @@ void IR_Decoder::tick() { if (highCount == 0 && highTime > riseTime / 3) { // fix короткой единицы (?)после пропуска нулей(?) highCount++; errorCounter++; + #ifdef IRDEBUG + errPulse(errOut, 2); + #endif } if (lowCount + highCount > allCount) { // fix ошибочных сдвигов if (lowCount > highCount) { // Лишние нули lowCount = allCount - highCount; + #ifdef IRDEBUG + errPulse(errOut, 3); + #endif } else if (lowCount < highCount) { // Лишние единицы highCount = allCount - lowCount; + #ifdef IRDEBUG + errPulse(errOut, 4); + #endif } else if (lowCount == highCount) {} // неизвестный случай errorCounter += allCount; } errorCounter += allCount; + #ifdef IRDEBUG + errPulse(errOut, 1); + #endif for (int8_t i = 0; i < lowCount && 8 - i; i++) { // отправка LOW битов, если есть writeToBuffer(LOW); + #ifdef IRDEBUG + digitalWrite(wrLow, 1); + #endif } for (int8_t i = 0; i < highCount && 8 - i; i++) { // отправка HIGH битов, если есть writeToBuffer(HIGH); + #ifdef IRDEBUG + digitalWrite(wrHigh, 1); + #endif } } + #ifdef IRDEBUG + digitalWrite(wrHigh, 0); + digitalWrite(wrLow, 0); + #endif } if (risePeriod > riseTimeMax / 2 || highCount || lowCount) { // комплексный фикс рваной единицы @@ -345,7 +373,9 @@ void IR_Decoder::tick() { prevRise = currentFront.time; } else { errorCounter++; - + #ifdef IRDEBUG + errPulse(errOut, 5); + #endif } } else { // Если ```\__ ↓ @@ -354,7 +384,9 @@ void IR_Decoder::tick() { prevPrevFall = prevFall; prevFall = currentFront.time; } else { - + #ifdef IRDEBUG + //errPulse(errOut, 5); + #endif } } @@ -362,9 +394,11 @@ void IR_Decoder::tick() { prevRise = currentFront.time + riseTime; } - +#ifdef IRDEBUG + digitalWrite(writeOp, isPreamb); +#endif //////////////////////////////////////////////////////////////////////////////////////////////////////////// - firstUnHandledFront = firstUnHandledFront->next; //переместить флаг на следующий элемент (next or nullptr) + firstUnHandledFront = firstUnHandledFront->next; //переместить флаг на следующий элемент для обработки (next or nullptr) } void IR_Decoder::isr() { // в прерывании вызываем isr()