InfraredService
Source:
InfraredService.h
Row¶
src/core/services/InfraredService.h:199One binding: a remote code and what it drives, the arm flag never persisted.
Public Attributes¶
uint32_t id = 0
uint32_t code = 0
: the learned frame, 0 = unbound
bool learn = false
InputAction action {}
InfraredService¶
src/core/services/InfraredService.h:41Inherits:
MoonModule,ListSource
An infrared receiver that decodes a remote and drives other modules' controls.
The same shape as the button service, which drives the same controls from a switch. A row is the binding, so twenty keys are twenty rows, each pointing where you want.

Public Methods¶
virtual inline ModuleRole role() const override
: A service, so the container accepts it as a child.
virtual inline void defineControls() override
: Declare the receiver pin and the list of learned rows.
virtual inline void onControlChanged(const char * controlName) override
: Re-report the receive state when the pin changes.
virtual inline void prepare() override
: Report whether the receiver opened, not merely that a pin is set.
virtual inline void tick() override
: Read one decoded frame, if the receiver has one.
inline uint32_t latestCode() const
: The last decoded code (0 = none yet).
inline void injectCodeForTest(uint32_t code)
: Feed a decoded code as if from the receiver, since a desktop has none.
virtual inline bool isEditableList() const override
: Editable, since the rows are the whole point of this module.
virtual inline uint8_t listRowCount() const override
: How many rows are configured.
virtual inline void writeListRow(JsonSink & sink, uint8_t row) const override
: Append one row's summary, its code as hex, the way a frame is read everywhere else.
virtual inline void writeListRowDetail(JsonSink & sink, uint8_t row) const override
: The row's editable fields, arming being a button since it is an action rather than a setting.
virtual inline void writeListOptionSets(JsonSink & sink) const override
: The target options, shared across every row rather than repeated in each.
virtual inline bool addListRow(uint32_t & outId) override
: Append an unbound row, ready to learn.
virtual inline bool deleteListRow(uint32_t id) override
: Remove one row by id.
virtual inline bool setListRowField(uint32_t id, const char * field, const char * valueJson) override
: Set one field of one row: the shared action fields, the arm button, or a typed code.
virtual inline bool restoreList(const char * json, const char * key) override
: Rebuild the rows from the persisted list.
More info¶
Learned, not shipped¶
No firmware can carry a code table for every remote in the world. So a binding is taught: arm a row, and the next decoded code binds to it. The first version carried five compiled actions, which made our opinion the user's ceiling.
A fresh service starts empty, so the first use is to add a row and learn a key. Shipping defaults would need the catalog to express a row, which no operation does yet.
How a press acts¶
Through the one control-set primitive every transport uses. So a remote press and a message are indistinguishable to whatever they drive. Pointing a row at the control surface puts the remote where every transport reaches it.
Prior art: consumer remotes use the NEC protocol, which the chip's own peripheral decodes. That decode lives behind the platform seam.