Browse Source

fix some bug

master
zhaohe 2 years ago
parent
commit
f319c64868
  1. 10
      components/step_motor_45/step_motor_45.cpp
  2. 5
      components/step_motor_45/step_motor_45.hpp

10
components/step_motor_45/step_motor_45.cpp

@ -57,16 +57,20 @@ void StepMotor45::initialize(cfg_t cfg) {
return;
}
void StepMotor45::rotate(bool direction, int speed) {
void StepMotor45::rotate(int direction, int speed) {
CriticalContext cc;
if (direction) {
if (direction == 0) {
stop();
}
if (direction > 0) {
if (getzeropinstate()) {
m_calibration = true;
m_pos = 0;
}
}
posmode = false;
m_state = direction ? kforward_rotation : krollback;
m_state = direction > 0 ? kforward_rotation : krollback;
ZLOGI(TAG, "rotate %d", direction);
}
void StepMotor45::stop() {

5
components/step_motor_45/step_motor_45.hpp

@ -61,8 +61,8 @@ class StepMotor45 {
public:
void initialize(cfg_t cfg);
void rotate(bool direction) { rotate(direction, defaultspeed); }
void rotate(bool direction, int speed);
void rotate(int direction) { rotate(direction, defaultspeed); }
void rotate(int direction, int speed);
void moveBy(int pos, int speed);
void moveBy(int pos) { moveBy(pos, defaultspeed); }
@ -72,6 +72,7 @@ class StepMotor45 {
bool isReachTargetPos();
void stop();
void zeroCalibration();
void setPos(int pos) { m_pos = pos; }
int getPos() { return m_pos; }

Loading…
Cancel
Save