4#ifndef PROTOCORE_RCWL0516_H
5#define PROTOCORE_RCWL0516_H
60#ifndef PROTOCORE_RCWL0516_HOLD_MS
61#define PROTOCORE_RCWL0516_HOLD_MS 2000
65#ifndef PROTOCORE_RCWL0516_DEBOUNCE_MS
66#define PROTOCORE_RCWL0516_DEBOUNCE_MS 50
90 embed_bool (*
begin)(uint8_t *, int);
91 embed_bool (*
poll)(uint8_t *);
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
embed_bool protocore_rcwl0516_present(uint8_t *work)
Latest debounced, hold-extended presence.
embed_bool protocore_rcwl0516_presence_take_event(const uint8_t *work, PresenceCore *c)
Consume the presence-changed event.
embed_bool protocore_rcwl0516_presence_update(const uint8_t *work, PresenceCore *c, embed_bool pin_high, uint32_t now)
Feed one sample of the presence pin. Call it as often as .
void protocore_rcwl0516_presence_init(const uint8_t *work, PresenceCore *c, uint32_t debounce_ms, uint32_t hold_ms, uint32_t now)
Initialize to absent at now, with the pin treated as idle (LOW). .
embed_bool protocore_rcwl0516_presence_get(const uint8_t *work, const PresenceCore *c)
Current presence, without sampling.
uint8_t * protocore_rcwl0516_span(void)
The PROTOCORE_RCWL0516_BORROW bytes this module's state lives in.
void protocore_rcwl0516_core_init(const uint8_t *work, PresenceCore *c, uint32_t now)
Initialize c with the RCWL-0516 defaults .
embed_bool protocore_rcwl0516_begin(uint8_t *work, int out_pin)
Configure out_pin as an input and start the core. true where the .
embed_bool protocore_rcwl0516_poll(uint8_t *work)
Sample the pin at the current time. true if presence changed on .
Debounced, hold-extended state of one active-high presence pin. Pure: it decides.
uint32_t hold_ms
presence persists this long past the last believed-HIGH sample.
uint8_t present
presence output (0/1) - stable, extended by hold_ms.
uint32_t raw_since_ms
when the raw pin level last changed.
uint8_t changed
set when present flipped; cleared by protocore_presence_take_event.
uint8_t raw
last raw pin level as sampled (0/1).
uint32_t debounce_ms
a level must hold this long before it is believed.
uint32_t last_high_ms
when the believed level was last HIGH.
uint8_t stable
believed level, after debouncing (0/1).
Dispatch table. Addressed by offset, so the layout is asserted below.
embed_bool(* presence_update)(const uint8_t *, PresenceCore *, embed_bool, uint32_t)
embed_bool(* presence_get)(const uint8_t *, const PresenceCore *)
void(* presence_init)(const uint8_t *, PresenceCore *, uint32_t, uint32_t, uint32_t)
embed_bool(* present)(uint8_t *)
embed_bool(* presence_take_event)(const uint8_t *, PresenceCore *)
embed_bool(* poll)(uint8_t *)
void(* core_init)(const uint8_t *, PresenceCore *, uint32_t)
embed_bool(* begin)(uint8_t *, int)