mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-06-28 05:09:40 +00:00
MultiGen isr
This commit is contained in:
53
IR_Encoder.h
53
IR_Encoder.h
@ -6,22 +6,16 @@
|
||||
class IR_Decoder;
|
||||
class IR_Encoder : IR_FOX {
|
||||
friend IR_Decoder;
|
||||
friend void isr(IR_Encoder& e);
|
||||
public:
|
||||
/// @brief Вывод передатчика
|
||||
uint8_t ir_out;
|
||||
|
||||
/// @brief Адрес передатчика
|
||||
uint16_t addrSelf;
|
||||
uint8_t ir_out; /// @brief Вывод передатчика
|
||||
uint16_t addrSelf; /// @brief Адрес передатчика
|
||||
|
||||
private:
|
||||
/// @brief предыдущий бит преамбулы
|
||||
bool prevPreambBit = true;
|
||||
uint8_t carrierTune; /// @brief Подстройка несущей частоты
|
||||
uint8_t halfPeriod; /// @brief полупериод несущей частоты
|
||||
|
||||
/// @brief Подстройка несущей частоты
|
||||
uint8_t carrierTune;
|
||||
|
||||
/// @brief полупериод несущей частоты
|
||||
uint8_t halfPeriod;
|
||||
public:
|
||||
|
||||
/// @brief Класс передатчика
|
||||
@ -35,23 +29,50 @@ public:
|
||||
void sendData(uint16_t addrTo, T& data, bool needAccept = false);
|
||||
void sendACK(uint16_t addrTo, uint8_t addInfo = 0, bool forAll = false);
|
||||
void sendRequest(uint16_t addrTo, uint8_t addInfo = 0);
|
||||
|
||||
void rawSend(uint8_t* ptr, uint8_t len);
|
||||
void isr();
|
||||
|
||||
~IR_Encoder();
|
||||
volatile bool ir_out_virtual;
|
||||
private:
|
||||
IR_Decoder* decoder;
|
||||
void meanderBlock(uint16_t count, uint16_t _period, bool isNoPause = true);
|
||||
void _sendData(uint16_t addrTo, uint8_t* data, uint8_t len, uint8_t msgType);
|
||||
void sendByte(uint8_t byte, bool* prev, bool LOW_FIRST);
|
||||
void addSync(bool* prev, bool* next);
|
||||
void send_HIGH(bool = 1);
|
||||
void send_LOW();
|
||||
void send_EMPTY(uint8_t count);
|
||||
void rawSend(uint8_t* ptr, uint8_t len);
|
||||
void _sendData(uint16_t addrTo, uint8_t* data, uint8_t len, uint8_t msgType);
|
||||
|
||||
enum SignalPart : uint8_t {
|
||||
noSignal = 0,
|
||||
preamb = 1,
|
||||
data = 2, // 2 должен инвертироваться в sync
|
||||
sync = (uint8_t)~(uint8_t)2U // 253 должен инвертироваться в data
|
||||
};
|
||||
|
||||
|
||||
volatile bool isSending = false;
|
||||
// volatile bool genState = HIGH;
|
||||
|
||||
volatile bool state; /// @brief Текущий уровень генерации
|
||||
volatile uint8_t toggleCounter; /// @brief Счётчик переключений
|
||||
volatile uint8_t preambBitCounter;
|
||||
volatile uint8_t dataBitCounter;
|
||||
volatile uint8_t syncBitCounter;
|
||||
|
||||
volatile uint8_t preambFrontCounter;
|
||||
volatile uint8_t dataFrontCounter;
|
||||
volatile uint8_t syncFrontCounter;
|
||||
|
||||
// uint8_t bitSequence[2];
|
||||
// volatile uint32_t toggle_counter;
|
||||
|
||||
SignalPart signal;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T>
|
||||
|
Reference in New Issue
Block a user