From d5953892db5729fec6ffd5d8a42456c514782de4 Mon Sep 17 00:00:00 2001 From: Philip J Freeman Date: Wed, 9 Nov 2022 22:21:43 -0800 Subject: modules/strobe: force flash even at low FPS At low framerates, the strobe module timer can expire from frame to frame. This has the effect of appearing "always on." This condition was obscuring output in compose mode. #BirdwalkCommit #WinterStormWarning --- src/modules/strobe/strobe.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c index 4616df4..bff1e64 100644 --- a/src/modules/strobe/strobe.c +++ b/src/modules/strobe/strobe.c @@ -17,9 +17,6 @@ /* TODO: * - Make period setting more flexible - * - Currently if the frame rate can't keep up with the period, strobe will - * just stick on. There should probably be a force_flash={yes,no} setting - * to ensure a flash still occurs when the frame rate can't keep up. */ #define STROBE_DEFAULT_PERIOD .1 @@ -34,6 +31,7 @@ typedef struct strobe_context_t { strobe_setup_t setup; unsigned ticks; unsigned flash:1; + unsigned flash_ready:1; } strobe_context_t; @@ -66,8 +64,12 @@ static void strobe_prepare_frame(til_module_context_t *context, unsigned ticks, *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu }; - if (ticks - ctxt->ticks >= (unsigned)(ctxt->setup.period * 1000.f)) + if (ctxt->flash_ready && (ticks - ctxt->ticks >= (unsigned)(ctxt->setup.period * 1000.f))){ ctxt->flash = 1; + ctxt->flash_ready = 0; + } else { + ctxt->flash_ready = 1; + } } -- cgit v1.2.3