diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-08-29 15:49:27 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-08-29 15:49:27 -0700 |
commit | ee65637a655254cf1fbb5bf3404b14f179f2a2e7 (patch) | |
tree | a9bf6be878880cec30078b8cc9c0be0b817dfd26 /src/modules/strobe | |
parent | 23a2d320ddb70f07de18860672d61a38445728e3 (diff) |
modules/strobe: s/period/hz/
Preparatory commit for exposing strobe::hz as a tap, it seems
awkward to work in periods especially in the track data.
Though I do like the 0-1 range of period, though that doesn't
even hold for slower than 1HZ frequencies so... it's kind of a
lie anyways.
At least if the track is called "hz" anyone will know what the
values mean and easily reason about them. So I'm making the
setting consistent with the soon to be added "hz" tap.
Diffstat (limited to 'src/modules/strobe')
-rw-r--r-- | src/modules/strobe/strobe.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c index 3b90c2d..8b3658e 100644 --- a/src/modules/strobe/strobe.c +++ b/src/modules/strobe/strobe.c @@ -16,14 +16,14 @@ /* Copyright (C) 2022 Vito Caputo <vcaputo@pengaru.com> */ /* TODO: - * - Make period setting more flexible + * - Make hz setting more flexible */ -#define STROBE_DEFAULT_PERIOD .1 +#define STROBE_DEFAULT_HZ 10 typedef struct strobe_setup_t { til_setup_t til_setup; - float period; + float hz; } strobe_setup_t; typedef struct strobe_context_t { @@ -56,7 +56,7 @@ static void strobe_prepare_frame(til_module_context_t *context, til_stream_t *st *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu_x16 }; - if (ctxt->flash_ready && (ticks - ctxt->ticks >= (unsigned)(ctxt->setup->period * 1000.f))){ + if (ctxt->flash_ready && (ticks - ctxt->ticks >= (unsigned)((1.f / ctxt->setup->hz) * 1000.f))){ ctxt->flash = 1; ctxt->flash_ready = 0; } else { @@ -107,15 +107,15 @@ til_module_t strobe_module = { static int strobe_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) { - const char *period; - const char *period_values[] = { - ".0166", - ".02", - ".025", - ".05", - ".1", - ".25", - ".5", + const char *hz; + const char *hz_values[] = { + "60", + "50", + "40", + "20", + "10", + "4", + "2", "1", NULL }; @@ -123,14 +123,14 @@ static int strobe_setup(const til_settings_t *settings, til_setting_t **res_sett r = til_settings_get_and_describe_value(settings, &(til_setting_spec_t){ - .name = "Strobe period", - .key = "period", + .name = "Strobe frequency in hz", + .key = "hz", .regex = "\\.[0-9]+", - .preferred = TIL_SETTINGS_STR(STROBE_DEFAULT_PERIOD), - .values = period_values, + .preferred = TIL_SETTINGS_STR(STROBE_DEFAULT_HZ), + .values = hz_values, .annotations = NULL }, - &period, + &hz, res_setting, res_desc); if (r) @@ -143,7 +143,7 @@ static int strobe_setup(const til_settings_t *settings, til_setting_t **res_sett if (!setup) return -ENOMEM; - sscanf(period, "%f", &setup->period); + sscanf(hz, "%f", &setup->hz); *res_setup = &setup->til_setup; } |