2021-07-16 16:43:54 +00:00
|
|
|
#pragma once
|
|
|
|
#include <irda_worker.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
#include <irda.h>
|
|
|
|
|
|
|
|
class IrdaAppSignal {
|
|
|
|
public:
|
|
|
|
typedef struct {
|
|
|
|
size_t timings_cnt;
|
|
|
|
uint32_t* timings;
|
2022-01-10 17:13:41 +00:00
|
|
|
uint32_t frequency;
|
|
|
|
float duty_cycle;
|
2021-07-16 16:43:54 +00:00
|
|
|
} RawSignal;
|
|
|
|
|
|
|
|
private:
|
2022-01-10 17:13:41 +00:00
|
|
|
bool raw_signal;
|
2021-07-16 16:43:54 +00:00
|
|
|
union {
|
|
|
|
IrdaMessage message;
|
|
|
|
RawSignal raw;
|
|
|
|
} payload;
|
|
|
|
|
2022-01-10 17:13:41 +00:00
|
|
|
void
|
|
|
|
copy_raw_signal(const uint32_t* timings, size_t size, uint32_t frequency, float duty_cycle);
|
2021-07-16 16:43:54 +00:00
|
|
|
void clear_timings();
|
|
|
|
|
|
|
|
public:
|
|
|
|
IrdaAppSignal() {
|
2022-01-10 17:13:41 +00:00
|
|
|
raw_signal = false;
|
2021-07-16 16:43:54 +00:00
|
|
|
payload.message.protocol = IrdaProtocolUnknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
~IrdaAppSignal() {
|
|
|
|
clear_timings();
|
|
|
|
}
|
|
|
|
|
2022-01-10 17:13:41 +00:00
|
|
|
IrdaAppSignal(
|
|
|
|
const uint32_t* timings,
|
|
|
|
size_t timings_cnt,
|
|
|
|
uint32_t frequency,
|
|
|
|
float duty_cycle);
|
2021-07-16 16:43:54 +00:00
|
|
|
IrdaAppSignal(const IrdaMessage* irda_message);
|
|
|
|
|
|
|
|
IrdaAppSignal(const IrdaAppSignal& other);
|
|
|
|
IrdaAppSignal(IrdaAppSignal&& other);
|
|
|
|
|
|
|
|
IrdaAppSignal& operator=(const IrdaAppSignal& signal);
|
|
|
|
|
|
|
|
void set_message(const IrdaMessage* irda_message);
|
2022-01-10 17:13:41 +00:00
|
|
|
void
|
|
|
|
set_raw_signal(uint32_t* timings, size_t timings_cnt, uint32_t frequency, float duty_cycle);
|
2021-07-16 16:43:54 +00:00
|
|
|
|
|
|
|
void transmit() const;
|
|
|
|
|
|
|
|
bool is_raw(void) const {
|
2022-01-10 17:13:41 +00:00
|
|
|
return raw_signal;
|
2021-07-16 16:43:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const IrdaMessage& get_message(void) const {
|
2022-01-10 17:13:41 +00:00
|
|
|
furi_assert(!raw_signal);
|
2021-07-16 16:43:54 +00:00
|
|
|
return payload.message;
|
|
|
|
}
|
|
|
|
|
|
|
|
const RawSignal& get_raw_signal(void) const {
|
2022-01-10 17:13:41 +00:00
|
|
|
furi_assert(raw_signal);
|
2021-07-16 16:43:54 +00:00
|
|
|
return payload.raw;
|
|
|
|
}
|
|
|
|
};
|