Browse Source

update

master
zhaohe 1 year ago
parent
commit
563e4ca7f4
  1. 14
      components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  2. 12
      components/step_motor_ctrl_module/step_motor_ctrl_module.hpp
  3. 5
      components/zcancmder/zcan_protocol_parser.cpp
  4. 1
      components/zcancmder/zcan_protocol_parser.hpp

14
components/step_motor_ctrl_module/step_motor_ctrl_module.cpp

@ -401,9 +401,15 @@ int32_t StepMotorCtrlModule::step_motor_easy_move_to_io(int32_t ioindex, int32_t
return do_step_motor_easy_move_to_io(ioindex, direction);
}
//
//
//
int32_t StepMotorCtrlModule::step_motor_easy_move_to_end_point() {
ZLOGI(TAG, "m%d step_motor_easy_move_to_end_point", m_id);
int32_t ecode = check_befor_run();
if (ecode != 0) return ecode;
if (m_nio <= 1) {
return err::kstep_motor_ioindex_out_of_range;
}
return do_step_motor_easy_move_to_end_point();
}
int32_t StepMotorCtrlModule::do_step_motor_easy_rotate(int32_t direction) {
m_thread.stop();
@ -492,3 +498,5 @@ int32_t StepMotorCtrlModule::do_step_motor_easy_move_to_io(int32_t ioindex, int3
return 0;
}
int32_t StepMotorCtrlModule::do_step_motor_easy_move_to_end_point() { return do_step_motor_easy_move_to_io(1, 1); }

12
components/step_motor_ctrl_module/step_motor_ctrl_module.hpp

@ -2,8 +2,8 @@
//
#include "sdk/os/zos.hpp"
#include "sdk\components\tmc\basic\tmc_ic_interface.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp"
#include "sdk\components\tmc\ic\ztmc5130.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp"
namespace iflytop {
class StepMotorCtrlModule : public ZIModule, public ZIStepMotor {
ENABLE_MODULE(StepMotorCtrlModule, ktmc_step_motor, PC_VERSION);
@ -31,10 +31,10 @@ class StepMotorCtrlModule : public ZIModule, public ZIStepMotor {
} config_t;
typedef struct {
int32_t dpos;
int32_t after_move_pos;
int32_t before_move_pos;
int32_t enable;
int32_t dpos;
int32_t after_move_pos;
int32_t before_move_pos;
int32_t enable;
} state_t;
private:
@ -77,6 +77,7 @@ class StepMotorCtrlModule : public ZIModule, public ZIStepMotor {
virtual int32_t step_motor_easy_move_to(int32_t position) override;
virtual int32_t step_motor_easy_move_to_zero() override;
virtual int32_t step_motor_easy_move_to_io(int32_t ioindex, int32_t direction) override;
virtual int32_t step_motor_easy_move_to_end_point() override;
virtual int32_t step_motor_easy_set_current_pos(int32_t pos) override;
virtual int32_t step_motor_active_cfg() override;
@ -96,6 +97,7 @@ class StepMotorCtrlModule : public ZIModule, public ZIStepMotor {
int32_t do_step_motor_easy_move_to(int32_t position);
int32_t do_step_motor_easy_move_to_zero();
int32_t do_step_motor_easy_move_to_io(int32_t ioindex, int32_t direction);
int32_t do_step_motor_easy_move_to_end_point();
private:
void inter_inverse_kinematics(int32_t motor_pos, int32_t& x);

5
components/zcancmder/zcan_protocol_parser.cpp

@ -34,6 +34,7 @@ void ZCanProtocolParser::initialize(IZCanReceiver* cancmder) {
REGFN(step_motor_stop);
REGFN(step_motor_read_io_state);
REGFN(step_motor_read_tmc5130_status);
REGFN(step_motor_easy_move_to_end_point);
REGFN(mini_servo_enable);
REGFN(mini_servo_read_pos);
@ -253,6 +254,10 @@ int32_t ZCanProtocolParser::step_motor_read_tmc5130_status(cmdcontxt_t* cxt) {
cxt->acklen = 4;
return module->step_motor_read_tmc5130_status(&ack[0]);
}
int32_t ZCanProtocolParser::step_motor_easy_move_to_end_point(cmdcontxt_t* cxt) {
CHECK_AND_GET_MODULE(0);
return module->step_motor_easy_move_to_end_point();
}
#undef MODULE_CLASS
#define MODULE_CLASS ZIMiniServo

1
components/zcancmder/zcan_protocol_parser.hpp

@ -69,6 +69,7 @@ class ZCanProtocolParser : public IZCanReceiverListener {
static int32_t step_motor_active_cfg(cmdcontxt_t* cxt);
static int32_t step_motor_read_io_state(cmdcontxt_t* cxt);
static int32_t step_motor_read_tmc5130_status(cmdcontxt_t* cxt);
static int32_t step_motor_easy_move_to_end_point(cmdcontxt_t* cxt);
static int32_t mini_servo_enable(cmdcontxt_t* cxt);

Loading…
Cancel
Save