From d1be60df24677c5e3fd4e7d363696cfbfb20d70d Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 29 Aug 2023 09:38:53 -0700 Subject: modules/pixbounce: filter same-tick movements This needs a bit more work, but at least filtering the same-tick renders avoids the many-movements-per-frame potential when used as something like a checkers::fill_module --- src/modules/pixbounce/pixbounce.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/modules') diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c index 7dfceaf..6fac758 100644 --- a/src/modules/pixbounce/pixbounce.c +++ b/src/modules/pixbounce/pixbounce.c @@ -303,16 +303,18 @@ static void pixbounce_render_fragment(til_module_context_t *context, til_stream_ } /* update pixmap location */ - if(ctxt->x+ctxt->x_dir < 0 || ctxt->x+ctxt->pix->width*ctxt->multiplier+ctxt->x_dir > width) { - ctxt->x_dir = ctxt->x_dir * -1; - ctxt->color = pick_color(&ctxt->til_module_context.seed); - } - if(ctxt->y+ctxt->y_dir < 0 || ctxt->y+ctxt->pix->height*ctxt->multiplier+ctxt->y_dir > height) { - ctxt->y_dir = ctxt->y_dir * -1; - ctxt->color = pick_color(&ctxt->til_module_context.seed); + if (ticks != context->last_ticks) { + if(ctxt->x+ctxt->x_dir < 0 || ctxt->x+ctxt->pix->width*ctxt->multiplier+ctxt->x_dir > width) { + ctxt->x_dir = ctxt->x_dir * -1; + ctxt->color = pick_color(&ctxt->til_module_context.seed); + } + if(ctxt->y+ctxt->y_dir < 0 || ctxt->y+ctxt->pix->height*ctxt->multiplier+ctxt->y_dir > height) { + ctxt->y_dir = ctxt->y_dir * -1; + ctxt->color = pick_color(&ctxt->til_module_context.seed); + } + ctxt->x = ctxt->x+ctxt->x_dir; + ctxt->y = ctxt->y+ctxt->y_dir; } - ctxt->x = ctxt->x+ctxt->x_dir; - ctxt->y = ctxt->y+ctxt->y_dir; } int pixbounce_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); -- cgit v1.2.3