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
85 void (*presence_init)(uint8_t *,
PresenceCore *, uint32_t, uint32_t, uint32_t);
92 void (*present)(uint8_t *);
#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.
void protocore_rcwl0516_presence_init(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). .
proto_bool protocore_rcwl0516_presence_get(uint8_t *work, const PresenceCore *c)
Current presence, without sampling.
proto_bool protocore_rcwl0516_presence_take_event(uint8_t *work, PresenceCore *c)
Consume the presence-changed event.
uint8_t * protocore_rcwl0516_span(void)
The PROTOCORE_RCWL0516_BORROW bytes this module's state lives in.
proto_bool protocore_rcwl0516_poll(uint8_t *work)
Sample the pin at the current time. true if presence changed on .
void protocore_rcwl0516_core_init(uint8_t *work, PresenceCore *c, uint32_t now)
Initialize c with the RCWL-0516 defaults .
PROTOCORE_NS Rcwl0516Ns Rcwl0516 PROTOCORE_UNUSED
Module namespace.
proto_bool protocore_rcwl0516_begin(uint8_t *work, int out_pin)
Configure out_pin as an input and start the core. true where the .
void protocore_rcwl0516_present(uint8_t *work)
Latest debounced, hold-extended presence.
proto_bool protocore_rcwl0516_presence_update(uint8_t *work, PresenceCore *c, proto_bool pin_high, uint32_t now)
Feed one sample of the presence pin. Call it as often as .
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.
void(* presence_init)(uint8_t *, PresenceCore *, uint32_t, uint32_t, uint32_t)
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS