rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
frame_watch.c File Reference

The render loop's watchdog. More...

#include "frame_watch.h"
#include <stddef.h>

Functions

void frame_watch_init (frame_watch_t *w, uint32_t count, uint32_t now_ms)
 Start watching from count at now_ms.
bool frame_watch_step (frame_watch_t *w, uint32_t count, bool armed, bool supply_on, uint32_t now_ms)
 One look at the counter: whether the bench is to be stopped now.
uint32_t frame_watch_still_ms (const frame_watch_t *w, uint32_t now_ms)
 How long the counter has stood still, at now_ms.

Detailed Description

The render loop's watchdog.

See frame_watch.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ frame_watch_init()

void frame_watch_init ( frame_watch_t * w,
uint32_t count,
uint32_t now_ms )

Start watching from count at now_ms.

Parameters
wWatch state.
countThe render loop's counter now.
now_msCurrent time, in milliseconds.

◆ frame_watch_step()

bool frame_watch_step ( frame_watch_t * w,
uint32_t count,
bool armed,
bool supply_on,
uint32_t now_ms )

One look at the counter: whether the bench is to be stopped now.

A counter that differs from the last look has moved, whatever the difference, so a counter that wraps through 0 moves. The time is taken modulo 2^32ms. True once per stall, on the first look at or past FRAME_WATCH_MS from the last move with armed or supply_on; the next stall begins at the next move.

Parameters
wWatch state.
countThe render loop's counter now.
armedThe bench is ARMED.
supply_onThe supply's output is on.
now_msCurrent time, in milliseconds.
Returns
true to stop the bench.

◆ frame_watch_still_ms()

uint32_t frame_watch_still_ms ( const frame_watch_t * w,
uint32_t now_ms )

How long the counter has stood still, at now_ms.

Parameters
wWatch state.
now_msCurrent time, in milliseconds.
Returns
Milliseconds since the counter last moved, modulo 2^32.