Browse Source

update

master
zhaohe 2 years ago
parent
commit
a796f5c582
  1. 1
      components/step_motor_45/script_cmder_step_motor_45.cpp
  2. 8
      components/step_motor_45/step_motor_45.cpp
  3. 7
      components/step_motor_45/step_motor_45.hpp

1
components/step_motor_45/script_cmder_step_motor_45.cpp

@ -46,6 +46,7 @@ void ScriptCmderStepMotor45::regcmd() {
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_WITH_ACK(PREFIX, get_zero_pin_state, "(id,pos)", 1, int32_t, ack);
// 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));
}

8
components/step_motor_45/step_motor_45.cpp

@ -51,7 +51,7 @@ void StepMotor45::initialize(StepMotor45Scheduler* scheduler, cfg_t cfg) {
if (cfg.zeroPin != PinNull) {
m_zeroPinZGPIO = new ZGPIO();
ZASSERT(m_zeroPinZGPIO != NULL);
m_zeroPinZGPIO->initAsInput(cfg.zeroPin, ZGPIO::kMode_pullup, ZGPIO::kIRQ_noIrq, cfg.zeroPinMirror);
m_zeroPinZGPIO->initAsInput(cfg.zeroPin, cfg.ioPollType, ZGPIO::kIRQ_noIrq, cfg.zeroPinMirror);
}
setdriverpinstate(1, 1, 1, 1);
scheduler->addMotor(this);
@ -101,6 +101,12 @@ void StepMotor45::onTimIRQ1ms() {
schedule();
}
int32_t StepMotor45::get_zero_pin_state(int32_t& state) {
CriticalContext cc;
state = getzeropinstate();
return (int32_t)0;
}
void StepMotor45::schedule() {
/**
* @brief Ö´ÐÐÁãµãУ׼Âß¼­

7
components/step_motor_45/step_motor_45.hpp

@ -25,8 +25,9 @@ class StepMotor45 {
bool enable_max_pos_limit = false; // 是否启用最大位置限位
bool mirror = false; // 是否镜像
Pin_t zeroPin = PinNull;
bool zeroPinMirror = false;
Pin_t zeroPin = PinNull;
ZGPIO::GPIOMode_t ioPollType = ZGPIO::kMode_nopull;
bool zeroPinMirror = false;
Pin_t driverPin[4] = {PinNull, PinNull, PinNull, PinNull};
bool driverPinMirror = false;
@ -79,6 +80,8 @@ class StepMotor45 {
int32_t zero_calibration();
int32_t set_pos(int32_t pos) { m_pos = pos; }
int32_t get_zero_pin_state(int32_t &state);
int32_t get_pos(int32_t &pos) {
pos = m_pos;
return (int32_t)0;

Loading…
Cancel
Save