Loading...
Searching...
No Matches
infrared_common_i.h
1#pragma once
2
3#include <stdint.h>
4#include "infrared.h"
5#include "infrared_i.h"
6
7#define MATCH_TIMING(x, v, delta) (((x) < ((v) + (delta))) && ((x) > ((v) - (delta))))
8
11
12typedef InfraredStatus (*InfraredCommonDecode)(InfraredCommonDecoder*, bool, uint32_t);
13typedef InfraredStatus (*InfraredCommonDecodeRepeat)(InfraredCommonDecoder*);
14typedef bool (*InfraredCommonInterpret)(InfraredCommonDecoder*);
15typedef InfraredStatus (
16 *InfraredCommonEncode)(InfraredCommonEncoder* encoder, uint32_t* out, bool* polarity);
17
18typedef struct {
19 InfraredTimings timings;
20 bool manchester_start_from_space;
21 uint8_t databit_len[4];
22 InfraredCommonDecode decode;
23 InfraredCommonDecodeRepeat decode_repeat;
24 InfraredCommonInterpret interpret;
25 InfraredCommonEncode encode;
26 InfraredCommonEncode encode_repeat;
28
29typedef enum {
30 InfraredCommonDecoderStateWaitPreamble,
31 InfraredCommonDecoderStateDecode,
32 InfraredCommonDecoderStateProcessRepeat,
33} InfraredCommonStateDecoder;
34
35typedef enum {
36 InfraredCommonEncoderStateSilence,
37 InfraredCommonEncoderStatePreamble,
38 InfraredCommonEncoderStateEncode,
39 InfraredCommonEncoderStateEncodeRepeat,
40} InfraredCommonStateEncoder;
41
43 const InfraredCommonProtocolSpec* protocol;
44 void* context;
45 uint32_t timings[6];
46 InfraredMessage message;
47 InfraredCommonStateDecoder state;
48 uint8_t timings_cnt;
49 bool switch_detect;
50 bool level;
51 uint16_t databit_cnt;
52 uint8_t data[];
53};
54
56 const InfraredCommonProtocolSpec* protocol;
57 InfraredCommonStateEncoder state;
58 bool switch_detect;
59 uint8_t bits_to_encode;
60 uint8_t bits_encoded;
61 uint32_t timings_sum;
62 uint32_t timings_encoded;
63 void* context;
64 uint8_t data[];
65};
66
68 infrared_common_decode(InfraredCommonDecoder* decoder, bool level, uint32_t duration);
69InfraredStatus
70 infrared_common_decode_pdwm(InfraredCommonDecoder* decoder, bool level, uint32_t timing);
71InfraredStatus
72 infrared_common_decode_manchester(InfraredCommonDecoder* decoder, bool level, uint32_t timing);
73void* infrared_common_decoder_alloc(const InfraredCommonProtocolSpec* protocol);
74void infrared_common_decoder_free(InfraredCommonDecoder* decoder);
75void infrared_common_decoder_reset(InfraredCommonDecoder* decoder);
76InfraredMessage* infrared_common_decoder_check_ready(InfraredCommonDecoder* decoder);
77
78InfraredStatus
79 infrared_common_encode(InfraredCommonEncoder* encoder, uint32_t* duration, bool* polarity);
80InfraredStatus
81 infrared_common_encode_pdwm(InfraredCommonEncoder* encoder, uint32_t* duration, bool* polarity);
82InfraredStatus infrared_common_encode_manchester(
83 InfraredCommonEncoder* encoder,
84 uint32_t* duration,
85 bool* polarity);
86void* infrared_common_encoder_alloc(const InfraredCommonProtocolSpec* protocol);
87void infrared_common_encoder_free(InfraredCommonEncoder* encoder);
88void infrared_common_encoder_reset(InfraredCommonEncoder* encoder);
Definition infrared_common_i.h:42
Definition infrared_common_i.h:55
Definition infrared_common_i.h:18
Definition infrared.h:42
Definition infrared_i.h:6