From 1aa9ede09bb1dec856f4519a6c47b934662883b5 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 6 Sep 2023 03:37:55 +0800 Subject: [PATCH] update --- usrc/main.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/usrc/main.cpp b/usrc/main.cpp index fb9c9e3..51cc61d 100644 --- a/usrc/main.cpp +++ b/usrc/main.cpp @@ -173,7 +173,6 @@ void regfn() { }); cmdScheduler.registerCmd("stepmotor45_moveTo", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - // stepmotor45_rotate motorid pos CHECK_ARGC(2); int motorid = atoi(argv[1]); int pos = atoi(argv[2]); @@ -187,7 +186,6 @@ void regfn() { }); cmdScheduler.registerCmd("stepmotor45_moveBy", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - // stepmotor45_rotate motorid pos CHECK_ARGC(2); int motorid = atoi(argv[1]); int pos = atoi(argv[2]); @@ -201,7 +199,6 @@ void regfn() { }); cmdScheduler.registerCmd("stepmotor45_stop", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { - // stepmotor45_rotate motorid pos CHECK_ARGC(1); int motorid = atoi(argv[1]); @@ -213,6 +210,19 @@ void regfn() { g_step_motor45[motorid].stop(); }); + cmdScheduler.registerCmd("stepmotor45_setSpeed", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { + CHECK_ARGC(1); + int motorid = atoi(argv[1]); + int speed = atoi(argv[2]); + + if (motorid < 1 || motorid > 6) { + ZLOGE(TAG, "motorid out of range"); + return; + } + + g_step_motor45[motorid].setDefaultSpeed(speed); + }); + /******************************************************************************* * ²½½øµç»ú * *******************************************************************************/