From 851c25ffe0f1378dc45cd52049822cfee622261b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Wed, 27 Jul 2022 10:41:36 +0200 Subject: [PATCH] app: add dials command --- application.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/application.c b/application.c index bd629e0..e89c1d8 100644 --- a/application.c +++ b/application.c @@ -621,6 +621,24 @@ static void command_strip_white(void* argument) printf("white channel set to %u%%\n", set); } +static void command_dials(void* argument) +{ + if (argument) { + const uint32_t seconds = *(uint32_t*)argument; // get provide value + if (seconds < 12 * 60 * 60) { + const uint32_t goal = DIAL_CYCLE_STEPS * seconds * 1.0 / (12 * 60 * 60); + if (goal != drv8825_goal) { + drv8825_goal = goal; // set new goal + uint32_t speed = 300; + command_speed(&speed); + } + } + } + + printf("dial position/goal: %u/%u\n", drv8825_steps, drv8825_goal); +} + + /** list of all supported commands */ static const struct menu_command_t menu_commands[] = { { @@ -735,6 +753,14 @@ static const struct menu_command_t menu_commands[] = { .argument_description = "%", .command_handler = &command_strip_white, }, + { + .shortcut = 'd', + .name = "dial", + .command_description = "set dial position", + .argument = MENU_ARGUMENT_UNSIGNED, + .argument_description = "[sec]", + .command_handler = &command_dials, + }, }; static void command_help(void* argument)