Browse Source

update

master
zhaohe 2 years ago
parent
commit
fab2a5bfd4
  1. 5
      components/step_motor_45/step_motor_45.cpp
  2. 3
      components/step_motor_45/step_motor_45.hpp
  3. 1
      components/step_motor_45/step_motor_45_scheduler.cpp
  4. 4
      components/step_motor_45/step_motor_45_scheduler.hpp

5
components/step_motor_45/step_motor_45.cpp

@ -33,7 +33,7 @@ stepmotor_control_matrix_t onestepsq2[] = {
#define MAX_STEP_TABLE_OFF (ZARRAY_SIZE(onestepsq1) - 1)
void StepMotor45::initialize(cfg_t cfg) {
void StepMotor45::initialize(StepMotor45Scheduler* scheduler, cfg_t cfg) {
m_cfg = cfg;
// ³õʼ»¯GPIO
@ -54,6 +54,7 @@ void StepMotor45::initialize(cfg_t cfg) {
m_zeroPinZGPIO->initAsInput(cfg.zeroPin, ZGPIO::kMode_pullup, ZGPIO::kIRQ_noIrq, cfg.zeroPinMirror);
}
setdriverpinstate(1, 1, 1, 1);
scheduler->addMotor(this);
return;
}
@ -221,7 +222,7 @@ int32_t StepMotor45::move_to(int to, int speed) {
CriticalContext cc;
if (to == m_pos) {
return (int32_t)0;
return (int32_t)0;
}
if (to <= m_pos) {

3
components/step_motor_45/step_motor_45.hpp

@ -1,6 +1,7 @@
#pragma once
#include "sdk/os/zos.hpp"
#include "sdk\components\step_motor_45\step_motor_45_scheduler.hpp"
namespace iflytop {
using namespace std;
@ -59,7 +60,7 @@ class StepMotor45 {
int defaultspeed = 1000;
public:
void initialize(cfg_t cfg);
void initialize(StepMotor45Scheduler *scheduler, cfg_t cfg);
int32_t rotate(int direction) { rotate(direction, defaultspeed); }
int32_t rotate(int direction, int speed);

1
components/step_motor_45/step_motor_45_scheduler.cpp

@ -1,5 +1,6 @@
#include "step_motor_45_scheduler.hpp"
#include "step_motor_45.hpp"
using namespace iflytop;
void StepMotor45Scheduler::initialize(zchip_tim_t* tim, int freq) {

4
components/step_motor_45/step_motor_45_scheduler.hpp

@ -1,10 +1,10 @@
#pragma once
#include "sdk/os/zos.hpp"
#include "step_motor_45.hpp"
// #include "step_motor_45.hpp"
namespace iflytop {
using namespace std;
class StepMotor45;
class StepMotor45Scheduler {
public:
zchip_tim_t* m_htim;

Loading…
Cancel
Save