mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2026-04-28 03:08:08 +00:00
fix overflow and mute
This commit is contained in:
42
IR_Encoder.h
42
IR_Encoder.h
@ -35,7 +35,8 @@ public:
|
||||
/// @brief Класс передатчика
|
||||
/// @param addr Адрес передатчика
|
||||
/// @param pin Вывод передатчика
|
||||
/// @param decPair Приёмник, для которого отключается приём в момент передачи передатчиком
|
||||
/// @param decPair Если задан, конструктор регистрирует этот один приёмник как blind-decoder
|
||||
/// (аналог setBlindDecoders() для одного RX).
|
||||
IR_Encoder(uint8_t pin, uint16_t addr = 0, IR_DecoderRaw *decPair = nullptr, bool autoHandle = true);
|
||||
static void isr();
|
||||
static void begin(HardwareTimer* timer, uint8_t channel, IRQn_Type IRQn, uint8_t priority, void(*isrCallback)() = nullptr);
|
||||
@ -58,6 +59,13 @@ public:
|
||||
void disable();
|
||||
|
||||
void setBlindDecoders(IR_DecoderRaw *decoders[], uint8_t count);
|
||||
template <size_t N>
|
||||
void setBlindDecoders(IR_DecoderRaw *(&decoders)[N])
|
||||
{
|
||||
static_assert(N <= IR_PAIR_MUTE_MAX_ENCODERS,
|
||||
"IR_Encoder::setBlindDecoders: array size exceeds IR_PAIR_MUTE_MAX_ENCODERS");
|
||||
setBlindDecoders(decoders, static_cast<uint8_t>(N));
|
||||
}
|
||||
void rawSend(uint8_t *ptr, uint8_t len);
|
||||
|
||||
IR_SendResult sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept = false);
|
||||
@ -99,7 +107,8 @@ private:
|
||||
static void *externalTxCtx;
|
||||
IR_SendResult _sendBack(bool isAdressed, uint16_t addrTo, uint8_t *data, uint8_t len);
|
||||
|
||||
void setDecoder_isSending();
|
||||
void refreshBlindDecoderMuteState();
|
||||
void registerWithBlindDecoders();
|
||||
void sendByte(uint8_t byte, bool *prev, bool LOW_FIRST);
|
||||
void addSync(bool *prev, bool *next);
|
||||
uint32_t calculateSendTime(uint8_t packSize) const;
|
||||
@ -137,25 +146,26 @@ private:
|
||||
void loadTxFsmFromMembers(TxFsmState &st) const;
|
||||
void storeTxFsmToMembers(const TxFsmState &st);
|
||||
|
||||
IR_DecoderRaw *decPair;
|
||||
IR_DecoderRaw **blindDecoders;
|
||||
uint8_t decodersCount;
|
||||
IR_DecoderRaw *decPair = nullptr;
|
||||
IR_DecoderRaw *singleBlindDecoder = nullptr;
|
||||
IR_DecoderRaw **blindDecoders = nullptr;
|
||||
uint8_t decodersCount = 0;
|
||||
|
||||
uint8_t sendLen;
|
||||
uint8_t sendLen = 0;
|
||||
uint8_t sendBuffer[dataByteSizeMax]{0}; /// @brief Буффер данных для отправки
|
||||
|
||||
volatile bool isSending;
|
||||
volatile bool state; /// @brief Текущий уровень генерации
|
||||
volatile bool isSending = false;
|
||||
volatile bool state = LOW; /// @brief Текущий уровень генерации
|
||||
|
||||
volatile uint8_t dataByteCounter;
|
||||
volatile uint8_t dataByteCounter = 0;
|
||||
|
||||
volatile uint8_t toggleCounter; /// @brief Счётчик переключений
|
||||
volatile uint8_t dataBitCounter;
|
||||
volatile uint8_t toggleCounter = 0; /// @brief Счётчик переключений
|
||||
volatile uint8_t dataBitCounter = 0;
|
||||
|
||||
volatile uint8_t preambFrontCounter;
|
||||
volatile uint8_t dataSequenceCounter;
|
||||
volatile uint8_t syncSequenceCounter;
|
||||
volatile bool syncLastBit;
|
||||
volatile uint8_t preambFrontCounter = 0;
|
||||
volatile uint8_t dataSequenceCounter = 0;
|
||||
volatile uint8_t syncSequenceCounter = 0;
|
||||
volatile bool syncLastBit = false;
|
||||
|
||||
struct BitSequence
|
||||
{
|
||||
@ -165,5 +175,5 @@ private:
|
||||
static uint8_t bitHigh[2];
|
||||
static uint8_t bitLow[2];
|
||||
uint8_t *currentBitSequence = bitLow;
|
||||
volatile SignalPart signal;
|
||||
volatile SignalPart signal = noSignal;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user