diff --git a/src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp b/src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp index f1cf401f..51175949 100644 --- a/src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp +++ b/src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp @@ -1322,11 +1322,37 @@ const bool ManchesterpatternDecoder::doDecode() { int pulseCnt = 0; bool preamble = false; - if (i > 0) - ManchesterBits.addValue(pdec->pattern[pdec->message[i]] > 0 ? 1 : 0); + // if (i > 0) + // ManchesterBits.addValue(pdec->pattern[pdec->message[i]] > 0 ? 1 : 0); + + + bool pulseIsLong = isLong(pdec->message[i]); + if (pulseIsLong && i > 0) { + int pClock = abs(pdec->pattern[pdec->message[i - 1]]); + if (pClock < maxPulse && (pdec->pattern[pdec->message[i - 1]] ^ pdec->pattern[pdec->message[i]]) >> 15) + { + int pClocks = round(pClock / (float)clock); + if (pClocks > 1 && abs(1 - (pClock / (pClocks * (float)clock))) <= 0.07) { +#ifdef DEBUGDECODE + DBG_PRINT(F("preamble:")); DBG_PRINT(pClocks); DBG_PRINT(F("C;")); + if (pClock > 0) { DBG_PRINT("P"); } + else { DBG_PRINT("p"); } + DBG_PRINT(bit ^1); +#endif + ManchesterBits.addValue(bit^1); + //preamble = true; + + } + } + + } // Todo: Prüfen ob noch notwendig + /* for (uint8_t l=i; lmessageLen; l++) { + #ifdef DEBUGDECODE + DBG_PRINT(F("pc:")); DBG_PRINTLN(l); + #endif bool pulseIsLong = isLong(pdec->message[l]); // no manchester @@ -1365,7 +1391,9 @@ const bool ManchesterpatternDecoder::doDecode() { break; } } - + */ + + // interpret first long as short if preamble was found if (preamble) { ht = true; @@ -1725,7 +1753,7 @@ const bool ManchesterpatternDecoder::isManchester() equal_cnt = pdec->histo[shorthigh] + pdec->histo[longhigh] - pdec->histo[shortlow] - pdec->histo[longlow]; #if DEBUGDETECT >= 1 - DBG_PRINT("equalcnt: pos "); DBG_PRINT(pdec->mstart); DBG_PRINT(" to ") DBG_PRINT(pdec->mend); DBG_PRINT("count="); DBG_PRINT(equal_cnt); DBG_PRINT(" "); + DBG_PRINT("equalcnt: pos "); DBG_PRINT(pdec->mstart); DBG_PRINT(" to ") DBG_PRINT(pdec->mend); DBG_PRINT(" count="); DBG_PRINT(equal_cnt); DBG_PRINT(" "); #endif mc_start_found = false; if (abs(equal_cnt) > round(pdec->messageLen*0.04)) break; //Next loop @@ -1813,7 +1841,7 @@ const bool ManchesterpatternDecoder::isManchester() seq_found = a; } else if (seqptr[a] == -1) { - DBG_PRINT(" +seq[:"); DBG_PRINT(seq); DBG_PRINTLN("]"); + //DBG_PRINT(" +seq[:"); DBG_PRINT(seq); DBG_PRINTLN("]"); seqptr[a] = seq; seq_found = a;