11#if DETWS_ENABLE_SEN0192
17void sen0192_motion_init(Sen0192Motion *m, uint32_t hold_ms,
bool active_high)
21 m->active_high = active_high;
23 m->last_active_ms = 0;
27bool sen0192_motion_update(Sen0192Motion *m,
bool level_high, uint32_t now_ms)
29 bool active = (level_high == m->active_high);
32 m->last_active_ms = now_ms;
42 sen0192_motion_tick(m, now_ms);
46bool sen0192_motion_tick(Sen0192Motion *m, uint32_t now_ms)
48 if (m->present && m->seeded && (uint32_t)(now_ms - m->last_active_ms) > m->hold_ms)
53bool sen0192_motion_present(
const Sen0192Motion *m)
58uint32_t sen0192_motion_events(
const Sen0192Motion *m)
60 return m->motion_events;
63uint32_t sen0192_motion_active_age_ms(
const Sen0192Motion *m, uint32_t now_ms)
65 return m->seeded ? (uint32_t)(now_ms - m->last_active_ms) : 0;
88bool sen0192_begin(
void)
91 pinMode(s_sen.pin, INPUT);
96bool sen0192_poll(
void)
100 bool level = digitalRead(s_sen.pin) != 0;
101 return sen0192_motion_update(&s_sen.motion, level,
detws_millis());
104bool sen0192_present(
void)
107 return sen0192_motion_present(&s_sen.motion);
110uint32_t sen0192_motion_count(
void)
112 return sen0192_motion_events(&s_sen.motion);
117bool sen0192_begin(
void)
121bool sen0192_poll(
void)
125bool sen0192_present(
void)
129uint32_t sen0192_motion_count(
void)
#define DETWS_SEN0192_PIN
GPIO the SEN0192 OUT line is wired to.
#define DETWS_SEN0192_ACTIVE_HIGH
SEN0192 OUT polarity: 1 = the OUT line reads HIGH on motion, 0 = active-LOW.
#define DETWS_SEN0192_HOLD_MS
Presence is held this many ms after the last active (motion) sample before it clears.
Pluggable monotonic clock for all library timing.
uint32_t detws_millis(void)
The library's monotonic time at 1000 Hz (milliseconds).
DFRobot SEN0192 10.525 GHz microwave Doppler motion sensor (DETWS_ENABLE_SEN0192).