30 lines
651 B
Python

from TMC2130 import TMC2130_Rotate
from config import *
steps_mm = 0
def Motion_Init():
global steps_mm
steps_mm = (MOTOR_STEPS * MICROSTEPPING) / SCREW_PITCH
def Motion_Move(distance, speed): #distance in mm, speed in mm/min
global steps_mm
steps = steps_mm * abs(distance)
direction = 0
if distance < 0:
if AXIS_REVERSE == False:
direction = 0
else:
direction = 1
else:
if AXIS_REVERSE == False:
direction = 1
else:
direction = 0
rpm = speed / SCREW_PITCH
TMC2130_Rotate(direction, steps, rpm)