2021-05-18 10:51:00 +00:00
|
|
|
#pragma once
|
2022-02-25 15:22:58 +00:00
|
|
|
#include "infrared.h"
|
2021-05-18 10:51:00 +00:00
|
|
|
#include <stddef.h>
|
2021-09-09 21:37:32 +00:00
|
|
|
#include <stdint.h>
|
2021-07-08 18:20:13 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2021-09-15 17:22:58 +00:00
|
|
|
uint32_t min_split_time;
|
2021-07-08 18:20:13 +00:00
|
|
|
uint32_t silence_time;
|
|
|
|
uint16_t preamble_mark;
|
|
|
|
uint16_t preamble_space;
|
|
|
|
uint16_t bit1_mark;
|
|
|
|
uint16_t bit1_space;
|
|
|
|
uint16_t bit0_mark;
|
|
|
|
uint16_t bit0_space;
|
2021-09-09 21:37:32 +00:00
|
|
|
uint32_t preamble_tolerance;
|
2021-07-08 18:20:13 +00:00
|
|
|
uint32_t bit_tolerance;
|
2022-02-25 15:22:58 +00:00
|
|
|
} InfraredTimings;
|
2021-05-18 10:51:00 +00:00
|
|
|
|
2021-08-20 20:51:15 +00:00
|
|
|
typedef struct {
|
|
|
|
const char* name;
|
|
|
|
uint8_t address_length;
|
|
|
|
uint8_t command_length;
|
|
|
|
uint32_t frequency;
|
|
|
|
float duty_cycle;
|
2023-01-13 13:50:19 +00:00
|
|
|
size_t repeat_count;
|
|
|
|
} InfraredProtocolVariant;
|
2021-08-20 20:51:15 +00:00
|
|
|
|
2023-01-13 13:50:19 +00:00
|
|
|
typedef const InfraredProtocolVariant* (*InfraredGetProtocolVariant)(InfraredProtocol protocol);
|
2021-08-20 20:51:15 +00:00
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
typedef void* (*InfraredAlloc)(void);
|
|
|
|
typedef void (*InfraredFree)(void*);
|
2021-05-18 10:51:00 +00:00
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
typedef void (*InfraredDecoderReset)(void*);
|
|
|
|
typedef InfraredMessage* (*InfraredDecode)(void* ctx, bool level, uint32_t duration);
|
|
|
|
typedef InfraredMessage* (*InfraredDecoderCheckReady)(void*);
|
2021-09-09 21:37:32 +00:00
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
typedef void (*InfraredEncoderReset)(void* encoder, const InfraredMessage* message);
|
|
|
|
typedef InfraredStatus (*InfraredEncode)(void* encoder, uint32_t* out, bool* polarity);
|
2021-07-08 18:20:13 +00:00
|
|
|
|
|
|
|
static inline uint8_t reverse(uint8_t value) {
|
|
|
|
uint8_t reverse_value = 0;
|
2022-01-05 16:10:18 +00:00
|
|
|
for(int i = 0; i < 8; ++i) {
|
2021-07-08 18:20:13 +00:00
|
|
|
reverse_value |= (value & (0x01 << i)) ? 1 << (7 - i) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return reverse_value;
|
|
|
|
}
|