21void pc_sen0192_motion_init(Sen0192Motion *m, uint32_t hold_ms,
bool active_high)
25 m->active_high = active_high;
27 m->last_active_ms = 0;
31bool pc_sen0192_motion_update(Sen0192Motion *m,
bool level_high, uint32_t now_ms)
33 bool active = (level_high == m->active_high);
36 m->last_active_ms = now_ms;
46 pc_sen0192_motion_tick(m, now_ms);
50bool pc_sen0192_motion_tick(Sen0192Motion *m, uint32_t now_ms)
52 if (m->present && m->seeded && (uint32_t)(now_ms - m->last_active_ms) > m->hold_ms)
59bool pc_sen0192_motion_present(
const Sen0192Motion *m)
64uint32_t pc_sen0192_motion_events(
const Sen0192Motion *m)
66 return m->motion_events;
69uint32_t pc_sen0192_motion_active_age_ms(
const Sen0192Motion *m, uint32_t now_ms)
71 return m->seeded ? (uint32_t)(now_ms - m->last_active_ms) : 0;
91bool pc_sen0192_begin(
void)
94 pinMode(s_sen.pin, INPUT);
99bool pc_sen0192_poll(
void)
105 bool level = digitalRead(s_sen.pin) != 0;
106 return pc_sen0192_motion_update(&s_sen.motion, level,
pc_millis());
109bool pc_sen0192_present(
void)
111 pc_sen0192_motion_tick(&s_sen.motion,
pc_millis());
112 return pc_sen0192_motion_present(&s_sen.motion);
115uint32_t pc_sen0192_motion_count(
void)
117 return pc_sen0192_motion_events(&s_sen.motion);
122bool pc_sen0192_begin(
void)
126bool pc_sen0192_poll(
void)
130bool pc_sen0192_present(
void)
134uint32_t pc_sen0192_motion_count(
void)
Pluggable monotonic clock for all library timing.
uint32_t pc_millis(void)
The library's monotonic time at 1000 Hz (milliseconds).
#define PC_SEN0192_PIN
GPIO the SEN0192 OUT line is wired to.
#define PC_SEN0192_HOLD_MS
Presence is held this many ms after the last active (motion) sample before it clears.
#define PC_SEN0192_ACTIVE_HIGH
SEN0192 OUT polarity: 1 = the OUT line reads HIGH on motion, 0 = active-LOW.
DFRobot SEN0192 10.525 GHz microwave Doppler motion sensor (PC_ENABLE_SEN0192).