4#ifndef PROTOCORE_SEN0192_H
5#define PROTOCORE_SEN0192_H
59 embed_bool (*
poll)(uint8_t *);
64 motion_active_age_ms, begin, poll, present, motion_count);
#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_sen0192_motion_update(const uint8_t *work, Sen0192Motion *m, embed_bool level_high, uint32_t now_ms)
Feed one sampled line level at now_ms.
uint32_t protocore_sen0192_motion_active_age_ms(const uint8_t *work, const Sen0192Motion *m, uint32_t now_ms)
Milliseconds since the last active-level sample (0 if none yet).
uint8_t * protocore_sen0192_span(void)
The PROTOCORE_SEN0192_BORROW bytes this module's state lives in.
void protocore_sen0192_motion_init(const uint8_t *work, Sen0192Motion *m, uint32_t hold_ms, embed_bool active_high)
Initialize a tracker: active_high sets the motion polarity, hold_ms .
embed_bool protocore_sen0192_motion_tick(const uint8_t *work, Sen0192Motion *m, uint32_t now_ms)
Re-evaluate presence against the hold window at now_ms without a .
embed_bool protocore_sen0192_poll(uint8_t *work)
Sample the pin now (via protocore_millis()). true iff a new .
embed_bool protocore_sen0192_motion_present(const uint8_t *work, const Sen0192Motion *m)
Current presence (respecting the hold window).
embed_bool protocore_sen0192_present(uint8_t *work)
Current presence.
uint32_t protocore_sen0192_motion_events(const uint8_t *work, const Sen0192Motion *m)
Number of clear -> present transitions since init.
uint32_t protocore_sen0192_motion_count(uint8_t *work)
Count of motion events (clear -> present transitions) since .
embed_bool protocore_sen0192_begin(uint8_t *work)
Configure PROTOCORE_SEN0192_PIN as an input and start tracking .
Debounced motion-presence tracker over a single digital line.
uint32_t last_active_ms
timestamp of the last active-level sample
uint32_t motion_events
count of clear -> present transitions (rising edges of presence)
embed_bool present
presence currently asserted (respecting the hold window)
embed_bool active_high
the active (motion) state is a logic HIGH
uint32_t hold_ms
presence is held this long after the last active sample
embed_bool seeded
a first sample has been fed (so the hold timing is meaningful)
Dispatch table. Addressed by offset, so the layout is asserted below.
embed_bool(* poll)(uint8_t *)
embed_bool(* present)(uint8_t *)
uint32_t(* motion_active_age_ms)(const uint8_t *, const Sen0192Motion *, uint32_t)
uint32_t(* motion_events)(const uint8_t *, const Sen0192Motion *)
uint32_t(* motion_count)(uint8_t *)
embed_bool(* motion_update)(const uint8_t *, Sen0192Motion *, embed_bool, uint32_t)
embed_bool(* begin)(uint8_t *)
void(* motion_init)(const uint8_t *, Sen0192Motion *, uint32_t, embed_bool)
embed_bool(* motion_tick)(const uint8_t *, Sen0192Motion *, uint32_t)
embed_bool(* motion_present)(const uint8_t *, const Sen0192Motion *)