Add basic motion API

pull/20/head
D.R.racer 2021-05-28 09:50:09 +02:00 committed by DRracer
parent 8e994c3b17
commit 3ef113cf6c
3 changed files with 61 additions and 0 deletions

View File

@ -192,6 +192,7 @@ target_sources(
src/modules/protocol.cpp
src/modules/buttons.cpp
src/modules/leds.cpp
src/modules/motion.cpp
)
set_property(

19
src/modules/motion.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "motion.h"
namespace modules {
namespace motion {
Motion motion;
void Motion::PlanMove(Axis axis, float targetPosition, uint16_t feedrate) {}
void Motion::Home(Axis axis) {}
void Motion::SetMode(Mode mode) {}
void Motion::Step() {}
void ISR() {}
} // namespace motion
} // namespace modules

View File

@ -1,4 +1,5 @@
#pragma once
#include <stdint.h>
/// @@TODO
/// Logic of motor handling
@ -19,3 +20,43 @@
/// rotate(speed)
/// rotate(speed, angle/steps)
/// home?
namespace modules {
namespace motion {
enum Axis {
Idler,
Selector,
Pulley
};
enum Mode {
Stealth,
Normal
};
class Motion {
public:
/// Enqueue move of a specific motor/axis into planner buffer
void PlanMove(Axis axis, float targetPosition, uint16_t feedrate);
/// Enqueue performing of homing of an axis
void Home(Axis axis);
/// Set mode of TMC/motors operation
/// Common for all axes/motors
void SetMode(Mode mode);
/// State machine doing all the planning and stepping preparation based on received commands
void Step();
private:
};
/// ISR stepping routine
extern void ISR();
extern Motion motion;
} // namespace motion
} // namespace modules