mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-04 15:20:16 +00:00
fix extra zero
This commit is contained in:
parent
d629b24864
commit
fdcb22b1a1
@ -24,31 +24,38 @@ void IR_Decoder::writeToBuffer(bool bit) {
|
|||||||
if (bufBitPos == nextControlBit) {
|
if (bufBitPos == nextControlBit) {
|
||||||
nextControlBit += (isData ? syncBits : bitPerByte);
|
nextControlBit += (isData ? syncBits : bitPerByte);
|
||||||
isData = !isData;
|
isData = !isData;
|
||||||
|
i_syncBit = 0;
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
}
|
}
|
||||||
Serial.print(bit);
|
|
||||||
|
|
||||||
if (isData) { // Запись битов в dataBuffer
|
if (isData) { // Запись битов в dataBuffer
|
||||||
dataBuffer[(i_dataBuffer / 8)] |= bit << (7 - i_dataBuffer%8);
|
if (i_dataBuffer % 8 == 7) {
|
||||||
|
Serial.print("+");
|
||||||
|
}
|
||||||
|
dataBuffer[(i_dataBuffer / 8)] |= bit << (7 - i_dataBuffer % 8);
|
||||||
i_dataBuffer++;
|
i_dataBuffer++;
|
||||||
bufBitPos++;
|
bufBitPos++;
|
||||||
i_syncBit = 0;
|
|
||||||
} else { // Проверка контрольных sync битов
|
} else { // Проверка контрольных sync битов
|
||||||
if (i_syncBit == 0) { // Первый бит синхронизации
|
if (i_syncBit == 0) { // Первый бит синхронизации
|
||||||
if (bit != dataBuffer[((i_dataBuffer - 1) / 8)] & 1 << (7 - ((i_dataBuffer - 1) & ~(~0 << 3)))) {
|
Serial.print("~");
|
||||||
|
if (bit != (dataBuffer[((i_dataBuffer - 1) / 8)] & 1 << (7 - (i_dataBuffer - 1) % 8) & 1)) {
|
||||||
bufBitPos++;
|
bufBitPos++;
|
||||||
|
i_syncBit++;
|
||||||
} else {
|
} else {
|
||||||
|
i_syncBit = 0;
|
||||||
errorCounter++;
|
errorCounter++;
|
||||||
Serial.print("E");
|
Serial.print("E");
|
||||||
// Serial.print("bit: ");Serial.println(bit);
|
// Serial.print("bit: "); Serial.println(bit);
|
||||||
// Serial.print("dataBuffer: ");Serial.println(dataBuffer[((i_dataBuffer - 1) / 8)] & 1 << (7 - ((i_dataBuffer - 1) & ~(~0 << 3))));
|
// Serial.print("dataBuffer: "); Serial.println(dataBuffer[((i_dataBuffer - 1) / 8)] & 1 << (7 - ((i_dataBuffer - 1) & ~(~0 << 3))));
|
||||||
}
|
}
|
||||||
} else { // Последующие биты синхронизации
|
} else { // Последующие биты синхронизации
|
||||||
|
Serial.print("`");
|
||||||
bufBitPos++;
|
bufBitPos++;
|
||||||
}
|
|
||||||
|
|
||||||
i_syncBit++;
|
i_syncBit++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Serial.print(bit);
|
||||||
|
|
||||||
// if (bufBitPos >= bufferRawSize * 8 - 1) { isBufferOverflow = true; }
|
// if (bufBitPos >= bufferRawSize * 8 - 1) { isBufferOverflow = true; }
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define aroundRise(t) (riseTimeMin < t && t < riseTimeMax)
|
#define aroundRise(t) (riseTimeMin < t && t < riseTimeMax)
|
||||||
#define IR_timeout ((riseTimeMax * 8) + syncBits +1) // us // таймаут в 8 data + 3 sync + 1
|
#define IR_timeout ((riseTimeMax * 8) + syncBits +1) // us // таймаут в 8 data + 3 sync + 1
|
||||||
|
|
||||||
#define subBufferSize 15 //Буфер для складирования фронтов, пока их не обработают
|
#define subBufferSize 5 //Буфер для складирования фронтов, пока их не обработают
|
||||||
|
|
||||||
class IR_Encoder;
|
class IR_Encoder;
|
||||||
class IR_Decoder : private IR_FOX {
|
class IR_Decoder : private IR_FOX {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user