ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
sen0192.h File Reference

DFRobot SEN0192 10.525 GHz microwave Doppler motion sensor (PROTOCORE_ENABLE_SEN0192). More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  Sen0192Motion
 Debounced motion-presence tracker over a single digital line. More...
 
struct  Sen0192Ns
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Functions

 PROTOCORE_NS_LAYOUT (Sen0192Ns, motion_init, motion_update, motion_tick, motion_present, motion_events, motion_active_age_ms, begin, poll, present, motion_count)
 
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.
 
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 .
 
proto_bool protocore_sen0192_motion_present (uint8_t *work, const Sen0192Motion *m)
 Current presence (respecting the hold window).
 
uint32_t protocore_sen0192_motion_events (uint8_t *work, const Sen0192Motion *m)
 Number of clear -> present transitions since init.
 
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).
 
proto_bool protocore_sen0192_begin (uint8_t *work)
 Configure PROTOCORE_SEN0192_PIN as an input and start tracking .
 
proto_bool protocore_sen0192_poll (uint8_t *work)
 Sample the pin now (via protocore_millis()). true iff a new .
 
void protocore_sen0192_present (uint8_t *work)
 Current presence.
 
void protocore_sen0192_motion_count (uint8_t *work)
 Count of motion events (clear -> present transitions) since .
 
uint8_t * protocore_sen0192_span (void)
 The PROTOCORE_SEN0192_BORROW bytes this module's state lives in.
 

Variables

PROTOCORE_NS Sen0192Ns Sen0192 PROTOCORE_UNUSED
 Module namespace.
 

Detailed Description

DFRobot SEN0192 10.525 GHz microwave Doppler motion sensor (PROTOCORE_ENABLE_SEN0192).

The SEN0192 is a 3-pin part (V / G / digital OUT) whose OUT line asserts while it senses motion (Doppler shift) within its adjustable range. Unlike the framed serial of an LD2410, it carries no protocol - it is a single digital line - so the "driver" is a debounced presence tracker over that line: assert presence on an active sample and hold it for a configurable window after the last active sample, so brief gaps between Doppler returns don't make presence flap.

The presence state machine (Sen0192Motion) is pure and host-tested - it takes a sampled line level and a timestamp and needs no clock or GPIO. The binding reads PROTOCORE_SEN0192_PIN each poll (via protocore_millis()) and feeds it in; only that read reaches the pin seam. The OUT polarity and hold window come from ServerConfig (PROTOCORE_SEN0192_ACTIVE_HIGH / PROTOCORE_SEN0192_HOLD_MS / PROTOCORE_SEN0192_PIN).

work is PROTOCORE_SEN0192_BORROW bytes the CALLER took, at an address it knows. It is not held past the call, so nothing here aliases it. How those bytes are carved is this module's and is never named here.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file sen0192.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( Sen0192Ns  ,
motion_init  ,
motion_update  ,
motion_tick  ,
motion_present  ,
motion_events  ,
motion_active_age_ms  ,
begin  ,
poll  ,
present  ,
motion_count   
)

◆ protocore_sen0192_motion_init()

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 .

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.
mM
hold_msHold ms
active_highActive high

◆ protocore_sen0192_motion_update()

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.

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.
mM
level_highLevel high
now_msNow ms
Returns
PROTO_TRUE on success.

◆ protocore_sen0192_motion_tick()

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 .

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.
mM
now_msNow ms
Returns
PROTO_TRUE on success.

◆ protocore_sen0192_motion_present()

proto_bool protocore_sen0192_motion_present ( uint8_t *  work,
const Sen0192Motion *  m 
)

Current presence (respecting the hold window).

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.
mM
Returns
PROTO_TRUE on success.

◆ protocore_sen0192_motion_events()

uint32_t protocore_sen0192_motion_events ( uint8_t *  work,
const Sen0192Motion *  m 
)

Number of clear -> present transitions since init.

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.
mM
Returns
The uint32_t.

◆ protocore_sen0192_motion_active_age_ms()

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).

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.
mM
now_msNow ms
Returns
The uint32_t.

◆ protocore_sen0192_begin()

proto_bool protocore_sen0192_begin ( uint8_t *  work)

Configure PROTOCORE_SEN0192_PIN as an input and start tracking .

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.
Returns
PROTO_TRUE on success.

◆ protocore_sen0192_poll()

proto_bool protocore_sen0192_poll ( uint8_t *  work)

Sample the pin now (via protocore_millis()). true iff a new .

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.
Returns
PROTO_TRUE on success.

◆ protocore_sen0192_present()

void protocore_sen0192_present ( uint8_t *  work)

Current presence.

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.

◆ protocore_sen0192_motion_count()

void protocore_sen0192_motion_count ( uint8_t *  work)

Count of motion events (clear -> present transitions) since .

Parameters
workPROTOCORE_SEN0192_BORROW bytes the caller took. Not held past the call.

◆ protocore_sen0192_span()

uint8_t * protocore_sen0192_span ( void  )

The PROTOCORE_SEN0192_BORROW bytes this module's state lives in.

Stated beside the namespace rather than on it: an entry takes a borrow, and this is where that borrow comes from. Taken once from the end of the pool, which no mark and no release walks, so the state lasts the life of the program.

Returns
the span.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS Sen0192Ns Sen0192 PROTOCORE_UNUSED
Initial value:
.motion_active_age_ms = protocore_sen0192_motion_active_age_ms,
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.
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).
proto_bool protocore_sen0192_poll(uint8_t *work)
Sample the pin now (via protocore_millis()). true iff a new .

Module namespace.

Definition at line 148 of file sen0192.h.