mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-06-28 05:09:40 +00:00
fix extra zero, docs and debag
This commit is contained in:
31
IR_Decoder.h
31
IR_Decoder.h
@ -21,7 +21,7 @@
|
||||
#define aroundRise(t) (riseTimeMin < t && t < riseTimeMax)
|
||||
#define IR_timeout ((riseTimeMax * 8) + syncBits +1) // us // таймаут в 8 data + 3 sync + 1
|
||||
|
||||
#define subBuffer 5 //Буфер для складирования фронтов, пока их не обработают
|
||||
#define subBufferSize 15 //Буфер для складирования фронтов, пока их не обработают
|
||||
|
||||
class IR_Encoder;
|
||||
class IR_Decoder : private IR_FOX {
|
||||
@ -200,13 +200,15 @@ private:
|
||||
const uint8_t bufferDataSize = dataByteSizeMax; // + crc
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void noFunc();
|
||||
volatile uint8_t currentFrontBufferWriteIndex;
|
||||
volatile uint8_t currentSubBufferIndex; // Счетчик текущей позиции во вспомогательном буфере фронтов/спадов
|
||||
// Структура для хранения времени и направления фронта/спада
|
||||
struct FrontStorage {
|
||||
volatile uint32_t time;
|
||||
volatile bool dir;
|
||||
volatile FrontStorage* next;
|
||||
volatile uint32_t time; // Время
|
||||
volatile bool dir; // Направление (true = ↑; false = ↓)
|
||||
volatile FrontStorage* next; // Указатель на следующий связанный фронт/спад, или nullptr если конец
|
||||
|
||||
FrontStorage& operator= (FrontStorage& val) {
|
||||
// Операторо присвоения
|
||||
FrontStorage& operator= (FrontStorage& val) {
|
||||
this->next = val.next;
|
||||
this->time = val.time;
|
||||
this->dir = val.dir;
|
||||
@ -214,9 +216,9 @@ private:
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
volatile FrontStorage* lastFront = nullptr;
|
||||
volatile FrontStorage* firstUnHandledFront = nullptr;
|
||||
volatile FrontStorage frontBuffer[subBuffer];
|
||||
volatile FrontStorage* lastFront = nullptr; // Указатель последнего фронта/спада
|
||||
volatile FrontStorage* firstUnHandledFront = nullptr; // Указатель первого необработанного фронта/спада
|
||||
volatile FrontStorage subBuffer[subBufferSize]; // вспомогательный буфер для хранения необработанных фронтов/спадов
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
uint8_t* rawBuffer = nullptr;
|
||||
uint8_t* dataBuffer = nullptr;
|
||||
@ -229,9 +231,14 @@ private:
|
||||
private:
|
||||
uint8_t* getDataBuffer(bool reset = false);
|
||||
bool crcCheck(uint8_t len);
|
||||
|
||||
inline void writeToBuffer(bool);
|
||||
inline void start_RX();
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
bool isData = true; // Флаг относится ли бит к данным, или битам синхронизации
|
||||
uint16_t i_dataBuffer; // Счётчик буфера данных
|
||||
uint8_t nextControlBit = bitPerByte; // Метка для смены флага isData
|
||||
uint8_t i_syncBit; // Счётчик битов синхронизации
|
||||
void writeToBuffer(bool);
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void start_RX();
|
||||
void resetAvaliable();
|
||||
|
||||
uint16_t ceil_div(uint16_t, uint16_t);
|
||||
|
Reference in New Issue
Block a user