feat: stepper logic

This commit is contained in:
xGlc
2026-04-14 21:31:59 +02:00
parent 07d93402b3
commit f94073e1ea
3 changed files with 73 additions and 2 deletions

40
drv8825.py Normal file
View File

@@ -0,0 +1,40 @@
from time import sleep_us
from machine import Pin
class DRV8825:
LEFT = 0
RIGHT = 1
def __init__(
self,
dir_pin: Pin,
step_pin: Pin,
sleep_pin: Pin,
rst_pin: Pin,
# microstep_pins: tuple[Pin, Pin, Pin],
) -> None:
self.sleep_pin = sleep_pin
self.step_pin = step_pin
self.dir_pin = dir_pin
self.rst_pin = rst_pin
# self.microstep_pins = microstep_pins
pass
def init(self):
self.sleep_pin.on()
self.rst_pin.on()
def set_direction(self, direction: int) -> None:
if direction == self.LEFT:
self.dir_pin.off()
else:
self.dir_pin.on()
def make_step(self, delay: int = 1000) -> None:
self.step_pin.on()
sleep_us(delay)
self.step_pin.off()
sleep_us(delay)
pass