10 changed files with 145 additions and 82 deletions
-
2components/cmdscheduler/cmd_scheduler.cpp
-
4components/cmdscheduler/cmd_scheduler.hpp
-
24components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.cpp
-
51components/step_motor_45/script_cmder_step_motor_45.cpp
-
5components/step_motor_45/script_cmder_step_motor_45.hpp
-
0components/step_motor_45/script_cmder_step_motor_45_scheduler.cpp
-
32components/step_motor_45/step_motor_45.cpp
-
35components/step_motor_45/step_motor_45.hpp
-
34components/xy_robot_ctrl_module/xy_robot_script_cmder_module.cpp
@ -0,0 +1,51 @@ |
|||
|
|||
#include "script_cmder_step_motor_45.hpp"
|
|||
|
|||
#include <string.h>
|
|||
|
|||
// #include "sdk\components\zprotocols\zcancmder\zcancmder_protocol.hpp"
|
|||
using namespace iflytop; |
|||
#define TAG "CMD"
|
|||
|
|||
void ScriptCmderStepMotor45::initialize(CmdScheduler* cmdScheduler) { |
|||
m_cmdScheduler = cmdScheduler; |
|||
ZASSERT(m_cmdScheduler != nullptr); |
|||
regcmd(); |
|||
} |
|||
|
|||
int32_t ScriptCmderStepMotor45::findmodule(int id, StepMotor45** module) { |
|||
auto it = moduler.find(id); |
|||
if (it == moduler.end()) { |
|||
return err::kce_no_such_module; |
|||
} |
|||
*module = it->second; |
|||
return 0; |
|||
} |
|||
|
|||
// static bool streq(const char* a, const char* b) { return strcmp(a, b) == 0; }
|
|||
|
|||
void ScriptCmderStepMotor45::regmodule(int id, StepMotor45* robot) { |
|||
ZASSERT(moduler.find(id) == moduler.end()); |
|||
ZASSERT(robot != nullptr); |
|||
moduler[id] = robot; |
|||
} |
|||
|
|||
static void cmd_dump_ack(int32_t& ack) { ZLOGI(TAG, "ack %d", ack); } |
|||
static void cmd_dump_ack(bool& ack) { ZLOGI(TAG, "ack %d", ack); } |
|||
|
|||
void ScriptCmderStepMotor45::regcmd() { |
|||
#define PREFIX "step_motor_45_"
|
|||
|
|||
REG_CMD___NO_ACK(PREFIX, rotate, "(id,direction)", 2, con->getInt(2)); |
|||
REG_CMD___NO_ACK(PREFIX, move_by, "(id,pos)", 2, con->getInt(2)); |
|||
REG_CMD___NO_ACK(PREFIX, move_to, "(id,pos)", 2, con->getInt(2)); |
|||
REG_CMD___NO_ACK(PREFIX, set_default_speed, "(id,speed)", 2, con->getInt(2)); |
|||
REG_CMD_WITH_ACK(PREFIX, get_default_speed, "(id)", 1, int32_t, ack); |
|||
REG_CMD_WITH_ACK(PREFIX, is_reach_target_pos, "(id)", 1, bool, ack); |
|||
REG_CMD___NO_ACK(PREFIX, stop, "(id)", 1); |
|||
REG_CMD___NO_ACK(PREFIX, zero_calibration, "(id)", 1); |
|||
REG_CMD_WITH_ACK(PREFIX, get_pos, "(id)", 1, int32_t, ack); |
|||
REG_CMD___NO_ACK(PREFIX, set_pos, "(id,pos)", 2, con->getInt(2)); |
|||
|
|||
// REG_CMD___NO_ACK(PREFIX, initialize, "(id,driverPin1,driverPin2,driverPin3,driverPin4,zeroPin)", 6, con->getInt(2), con->getInt(3), con->getInt(4), con->getInt(5), con->getInt(6), con->getInt(7));
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue