mohan-bee/compact-pir
Compact 3.3 V ESP8684 wireless motion/GPIO breakout board with LiPo regulation, 40 MHz crystal, U.FL antenna matching, digital PIR sensor, switched LED, decoupling, and dual 10-pin headers.
- Version
- 1.0.2
- License
- unset
- Stars
- 0
firmware/tests/motion_logic_test.c
#include <assert.h>
#include <stdio.h>
#include "../main/motion_logic.h"
int main(void)
{
motion_state_t state = {.boot_ms = 100};
assert(!motion_update(&state, 100, true, 60000, 10000));
assert(!motion_update(&state, 60099, true, 60000, 10000));
assert(!motion_update(&state, 60100, false, 60000, 10000));
assert(motion_update(&state, 61000, true, 60000, 10000));
assert(motion_update(&state, 70999, false, 60000, 10000));
assert(motion_update(&state, 71000, true, 60000, 10000));
assert(motion_update(&state, 80999, false, 60000, 10000));
assert(!motion_update(&state, 81000, false, 60000, 10000));
assert(motion_update(&state, 90000, true, 60000, 10000));
assert(motion_update(&state, 120000, true, 60000, 10000));
assert(!motion_update(&state, 130000, false, 60000, 10000));
state = (motion_state_t){.boot_ms = UINT64_MAX - 100};
assert(!motion_update(&state, UINT64_MAX, true, 200, 10000));
assert(motion_update(&state, 99, true, 200, 10000));
assert(motion_update(&state, 10098, false, 200, 10000));
assert(!motion_update(&state, 10099, false, 200, 10000));
state = (motion_state_t){.boot_ms = 0};
assert(motion_update(&state, UINT64_MAX - 100, true, 0, 10000));
assert(motion_update(&state, 9898, false, 0, 10000));
assert(!motion_update(&state, 9899, false, 0, 10000));
assert(!motion_update(&state, UINT64_MAX - 100, false, 0, 10000));
puts("motion logic: startup, hold, retrigger, continuous HIGH and wrap checks passed");
}