File syn_ir.h¶
Go to the source code of this file
Infrared (IR) Remote Control Protocol Engine (NEC, Sony, RC5, RC6, Samsung, Panasonic, Denon, Apple). More...
#include "../common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_IR_Decoder Non-blocking IR Decoder Handle. |
| struct | SYN_IR_Frame Decoded IR Remote Control Frame. |
| struct | SYN_IR_Pulse Single pulse duration timing pair for IR transmitter. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_IR_EncodingType IR signal encoding types. |
| enum | SYN_IR_FsmState |
| enum | SYN_IR_Protocol Supported IR remote control protocols. |
Public Functions¶
| Type | Name |
|---|---|
| bool | syn_ir_decode_pulse (SYN_IR_Decoder * decoder, uint16_t duration_us, bool is_mark, SYN_IR_Frame * frame_out) Process a single pulse duration (mark or space) in microseconds. |
| bool | syn_ir_decode_timeout (SYN_IR_Decoder * decoder, SYN_IR_Frame * frame_out) Signal a gap/timeout (>10ms silence) to finalize protocols. |
| SYN_Status | syn_ir_decoder_init (SYN_IR_Decoder * decoder) Initialize or reset an IR decoder instance. |
| SYN_Status | syn_ir_encode_frame (const SYN_IR_Frame * frame, SYN_IR_Pulse * pulse_buf, size_t buf_len, size_t * count_out) Encode a frame into a sequence of pulse timing pairs. |
| const char * | syn_ir_protocol_name (SYN_IR_Protocol proto) Get human-readable protocol string name. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_IR_FLAG_NONE 0x0000U |
| define | SYN_IR_FLAG_REPEAT (1U << 0) |
| define | SYN_IR_FLAG_TOGGLE (1U << 1) |
Detailed Description¶
Implements non-blocking, zero-malloc IR pulse decoding and encoding for common consumer remote control protocols using microsecond pulse timing inputs.
** **
- NEC (Standard & Extended 32-bit)
- Sony SIRCS (12-bit, 15-bit, 20-bit)
- Philips RC5 (14-bit Manchester)
- Philips RC6 Mode 0 (21-bit Manchester)
- Samsung (32-bit PDM)
- Kaseikyo / Panasonic (48-bit PDM)
- Denon / Sharp (15-bit PDM)
- Apple (32-bit NEC variant)
** **
static SYN_IR_Decoder decoder;
syn_ir_decoder_init(&decoder);
// In Timer Input Capture / EXTI ISR:
SYN_IR_Frame frame;
if (syn_ir_decode_pulse(&decoder, duration_us, is_mark, &frame)) {
// Process decoded frame: frame.protocol, frame.address, frame.command
}
Public Types Documentation¶
enum SYN_IR_EncodingType¶
IR signal encoding types.
enum SYN_IR_EncodingType {
SYN_IR_ENC_PDM = 0,
SYN_IR_ENC_PWM = 1,
SYN_IR_ENC_MANCHESTER = 2,
SYN_IR_ENC_PPM = 3
};
enum SYN_IR_FsmState¶
enum SYN_IR_FsmState {
SYN_IR_STATE_IDLE = 0,
SYN_IR_STATE_LEADER,
SYN_IR_STATE_DATA,
SYN_IR_STATE_TRAILER
};
enum SYN_IR_Protocol¶
Supported IR remote control protocols.
enum SYN_IR_Protocol {
SYN_IR_PROTO_UNKNOWN = 0,
SYN_IR_PROTO_NEC,
SYN_IR_PROTO_NEC_EXTENDED,
SYN_IR_PROTO_SONY_12,
SYN_IR_PROTO_SONY_15,
SYN_IR_PROTO_SONY_20,
SYN_IR_PROTO_RC5,
SYN_IR_PROTO_RC6,
SYN_IR_PROTO_SAMSUNG,
SYN_IR_PROTO_KASEIKYO,
SYN_IR_PROTO_DENON,
SYN_IR_PROTO_APPLE,
SYN_IR_PROTO_COUNT
};
Public Functions Documentation¶
function syn_ir_decode_pulse¶
Process a single pulse duration (mark or space) in microseconds.
bool syn_ir_decode_pulse (
SYN_IR_Decoder * decoder,
uint16_t duration_us,
bool is_mark,
SYN_IR_Frame * frame_out
)
Parameters:
decoderPointer to IR decoder handle.duration_usPulse duration in microseconds.is_marktrue if pulse is active IR carrier (mark), false if space.frame_out[out] Populated with decoded frame when function returns true.
Returns:
true if a complete, valid frame was decoded, false otherwise.
function syn_ir_decode_timeout¶
Signal a gap/timeout (>10ms silence) to finalize protocols.
Parameters:
decoderPointer to IR decoder handle.frame_out[out] Populated with decoded frame if timeout completed frame.
Returns:
true if a complete valid frame was finalized by timeout, false otherwise.
function syn_ir_decoder_init¶
Initialize or reset an IR decoder instance.
Parameters:
decoderPointer to IR decoder handle.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
function syn_ir_encode_frame¶
Encode a frame into a sequence of pulse timing pairs.
SYN_Status syn_ir_encode_frame (
const SYN_IR_Frame * frame,
SYN_IR_Pulse * pulse_buf,
size_t buf_len,
size_t * count_out
)
Parameters:
framePointer to frame to encode.pulse_bufOutput array for pulse timings.buf_lenCapacity of pulse_buf.count_out[out] Number of pulse timing pairs written.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on failure.
function syn_ir_protocol_name¶
Get human-readable protocol string name.
Parameters:
protoProtocol enum value.
Returns:
Pointer to const string.
Macro Definition Documentation¶
define SYN_IR_FLAG_NONE¶
define SYN_IR_FLAG_REPEAT¶
Set if this frame is a repeat code / held key
define SYN_IR_FLAG_TOGGLE¶
Toggle bit active (RC5 / RC6)
The documentation for this class was generated from the following file src/syntropic/proto/syn_ir.h