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