mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2026-03-13 04:44:44 +00:00
upd
This commit is contained in:
24
IR_Encoder.h
24
IR_Encoder.h
@ -21,6 +21,14 @@ class IR_Encoder : public IR_FOX
|
||||
IR_Encoder *next;
|
||||
public:
|
||||
static HardwareTimer* IR_Timer;
|
||||
|
||||
struct IR_TxGateRun {
|
||||
uint16_t lenTicks; // number of timer ticks at carrierFrec*2
|
||||
bool gate; // true: carrier enabled (output toggles), false: silent (output forced low)
|
||||
};
|
||||
|
||||
using ExternalTxBusyFn = bool (*)(void *ctx);
|
||||
using ExternalTxStartFn = bool (*)(void *ctx, IR_Encoder *enc, const uint8_t *packet, uint8_t len);
|
||||
private:
|
||||
// uint16_t id; /// @brief Адрес передатчика
|
||||
public:
|
||||
@ -31,10 +39,21 @@ public:
|
||||
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);
|
||||
/** Configure timer frequency for TX clock (carrierFrec*2) without attaching ISR. */
|
||||
static void beginClockOnly(HardwareTimer *timer);
|
||||
static HardwareTimer* get_IR_Timer();
|
||||
/** Call from main loop/tick: if ISR requested carrier stop, pause timer here (not in ISR). */
|
||||
static void tick();
|
||||
|
||||
/** Optional: register external TX backend (e.g. DMA driver). */
|
||||
static void setExternalTxBackend(ExternalTxStartFn startFn, ExternalTxBusyFn busyFn, void *ctx);
|
||||
|
||||
/** Called by external TX backend on actual end of transmission. */
|
||||
void externalFinishSend();
|
||||
|
||||
/** Build RLE runs of carrier gate for a packet (no HW access). */
|
||||
static size_t buildGateRuns(const uint8_t *packet, uint8_t len, IR_TxGateRun *outRuns, size_t maxRuns);
|
||||
|
||||
void enable();
|
||||
void disable();
|
||||
|
||||
@ -74,6 +93,10 @@ private:
|
||||
static volatile bool carrierStopPending;
|
||||
static void carrierResume();
|
||||
static void carrierPauseIfIdle();
|
||||
|
||||
static ExternalTxStartFn externalTxStartFn;
|
||||
static ExternalTxBusyFn externalTxBusyFn;
|
||||
static void *externalTxCtx;
|
||||
IR_SendResult _sendBack(bool isAdressed, uint16_t addrTo, uint8_t *data, uint8_t len);
|
||||
|
||||
void setDecoder_isSending();
|
||||
@ -123,4 +146,3 @@ private:
|
||||
uint8_t *currentBitSequence = bitLow;
|
||||
volatile SignalPart signal;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user