ir

package
v0.511.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package ir decodes raw infrared remote-control timing captures into the protocol + address/command — the IR analogue of the Sub-GHz protocol decoders, and the complement to the file-level ir_decode_file (which only reads a .ir file's already-parsed entries).

Wrap-vs-native judgement

Native. Consumer-IR protocols are public, fully-deterministic pulse-distance encodings documented for decades (NEC by NEC/Renesas, reproduced in LIRC, the Flipper IR stack, and Arduino-IRremote). Decoding is a leader-match plus a per-bit mark/space classifier over the captured microsecond timings the operator already has (ir_receive raw, a Flipper RAW .ir entry, or a logic-analyser capture) — no IR hardware at decode time.

Verifiable / no confidently-wrong output

NEC carries a built-in checksum: the 8-bit address is followed by its bitwise inverse and the 8-bit command by its inverse. A standard NEC frame is reported only when BOTH inversions hold; when only the command inversion holds it is reported as NEC-extended (16-bit address, no address inversion); when neither holds the raw 4 bytes are surfaced with a note rather than a guessed address/command. The leader and every bit are tolerance-matched, so a non-NEC pulse train is rejected, not mis-decoded.

Covered / deferred

The NEC family (standard, extended, and the repeat code) and Sony SIRC (12 / 15 / 20-bit) are covered — the two most common consumer-IR pulse-distance protocols. NEC is gated by its address/command inverse-byte checksum; SIRC carries no checksum, so it is gated structurally instead — the distinctive 2400µs leader, an exact 12/15/20-bit count, and a clean per-bit mark classification reject any non-SIRC pulse train. RC5/RC6 (Manchester), Samsung, and the Pronto/`ir_build` parsed formats are deliberately not decoded here yet — they need a different (bi-phase) decoder or carry no comparable structural gate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Protocol      string   `json:"protocol"`
	Address       int      `json:"address"`
	AddressHex    string   `json:"address_hex"`
	Command       int      `json:"command"`
	CommandHex    string   `json:"command_hex"`
	Bits          int      `json:"bits"`
	ChecksumValid bool     `json:"checksum_valid"`
	RawBytesHex   string   `json:"raw_bytes_hex,omitempty"`
	Notes         []string `json:"notes,omitempty"`
}

Result is the decoded view of a raw IR capture.

func DecodeRaw

func DecodeRaw(timings string) (*Result, error)

DecodeRaw parses a space-separated list of microsecond timings (the alternating mark/space durations from a raw IR capture) and decodes the NEC-family frame it carries.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL