Skip to content

Commit

Permalink
ManchesterpatternDecoder
Browse files Browse the repository at this point in the history
Fehler im MC Decoder entfernt und preamble detection wieder funktionsfähig gemacht
#68
  • Loading branch information
sidey79 committed Nov 7, 2017
1 parent e613d7c commit 40e637c
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; l<pdec->messageLen; l++) {
#ifdef DEBUGDECODE
DBG_PRINT(F("pc:")); DBG_PRINTLN(l);
#endif
bool pulseIsLong = isLong(pdec->message[l]);
// no manchester
Expand Down Expand Up @@ -1365,7 +1391,9 @@ const bool ManchesterpatternDecoder::doDecode() {
break;
}
}

*/


// interpret first long as short if preamble was found
if (preamble) {
ht = true;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 40e637c

Please sign in to comment.