PyTmcStepper 0.18.3__tar.gz → 0.19.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/PKG-INFO +1 -1
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/pyproject.toml +23 -1
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/PyTmcStepper.egg-info/PKG-INFO +1 -1
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/PyTmcStepper.egg-info/SOURCES.txt +1 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/__init__.py +0 -2
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/_tmc_validation.py +4 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/_tmc_xxxx.py +15 -13
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc.py +20 -2
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +0 -28
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_220x.py +18 -14
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_2240.py +18 -14
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_5160.py +22 -16
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +2 -2
- pytmcstepper-0.19.0/tests/test_gpiozero.py +118 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/LICENSE +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/README.md +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/setup.cfg +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/PyTmcStepper.egg-info/requires.txt +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/_tmc_exceptions.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/_tmc_math.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/_tmc_stallguard.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/_tmc_stepperdriver.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/__init__.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_spi.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_spi_base.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_spi_circuitpython.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_spi_ftdi.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_spi_micropython.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_uart.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_uart_base.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_uart_circuitpython.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_uart_micropython.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/enable_control/__init__.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/enable_control/_tmc_ec.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/enable_control/_tmc_ec_pin.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/enable_control/_tmc_ec_toff.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/__init__.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/platform_utils.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/reg/__init__.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/reg/_tmc2209_reg.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/reg/_tmc220x_reg.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/reg/_tmc224x_reg.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/reg/_tmc5160_reg.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/reg/_tmc_reg.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/reg/_tmc_shared_regs.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_2208.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_2209.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/__init__.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_circuitpython.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_logger/__init__.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_logger/_tmc_logger_base.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc2209.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc2240.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_com_spi.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_com_uart.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_ec_pin.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_imports.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_math.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_modules.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_move_intramp.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_move_stepdir.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_move_steppwmdir.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_move_stepreg.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_move_vactual.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_set_current.py +0 -0
- {pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/tests/test_tmc_stallguard.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.0
|
|
4
4
|
Summary: This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi
|
|
5
5
|
Author-email: Christian Köhlke <christian@koehlke.de>
|
|
6
6
|
License-Expression: GPL-3.0
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "PyTmcStepper"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.19.0"
|
|
8
8
|
authors = [{ name = "Christian Köhlke", email = "christian@koehlke.de" }]
|
|
9
9
|
description = "This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi"
|
|
10
10
|
readme = "README.md"
|
|
@@ -50,6 +50,28 @@ max-line-length = 160
|
|
|
50
50
|
relative_files = true
|
|
51
51
|
source = ["src"]
|
|
52
52
|
|
|
53
|
+
[tool.coverage.report]
|
|
54
|
+
omit = [
|
|
55
|
+
"tests/*",
|
|
56
|
+
"*_micropython.py",
|
|
57
|
+
"*_circuitpython.py",
|
|
58
|
+
"*_ftdi.py",
|
|
59
|
+
"*_periphery.py",
|
|
60
|
+
]
|
|
61
|
+
exclude_lines = [
|
|
62
|
+
"pragma: no cover",
|
|
63
|
+
"def __repr__",
|
|
64
|
+
"if self.debug:",
|
|
65
|
+
"if settings.DEBUG:",
|
|
66
|
+
"if TYPE_CHECKING:",
|
|
67
|
+
"raise AssertionError",
|
|
68
|
+
"raise NotImplementedError",
|
|
69
|
+
"if 0:",
|
|
70
|
+
"if __name__ == .__main__.:",
|
|
71
|
+
"class .*\\bProtocol\\):",
|
|
72
|
+
"@(abc\\.)?abstractmethod",
|
|
73
|
+
]
|
|
74
|
+
|
|
53
75
|
[tool.semantic_release]
|
|
54
76
|
branch = "main"
|
|
55
77
|
version_toml = ["pyproject.toml:project.version"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.0
|
|
4
4
|
Summary: This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi
|
|
5
5
|
Author-email: Christian Köhlke <christian@koehlke.de>
|
|
6
6
|
License-Expression: GPL-3.0
|
|
@@ -60,6 +60,7 @@ src/tmc_driver/tmc_logger/__init__.py
|
|
|
60
60
|
src/tmc_driver/tmc_logger/_tmc_logger_base.py
|
|
61
61
|
src/tmc_driver/tmc_logger/_tmc_logger_cpython.py
|
|
62
62
|
src/tmc_driver/tmc_logger/_tmc_logger_micropython.py
|
|
63
|
+
tests/test_gpiozero.py
|
|
63
64
|
tests/test_tmc2209.py
|
|
64
65
|
tests/test_tmc2240.py
|
|
65
66
|
tests/test_tmc_com_spi.py
|
|
@@ -4,9 +4,13 @@ TMC validation module
|
|
|
4
4
|
This module provides validation functions for TMC driver components.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
import sys
|
|
7
8
|
from ._tmc_exceptions import TmcDriverException
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
SUBMODULE_VALIDATION = sys.implementation.name not in ("micropython", "circuitpython")
|
|
12
|
+
|
|
13
|
+
|
|
10
14
|
def validate_submodule(
|
|
11
15
|
module, supported_types: tuple, driver_name: str, module_name: str = "module"
|
|
12
16
|
):
|
|
@@ -22,7 +22,7 @@ from .motion_control._tmc_mc import TmcMotionControl
|
|
|
22
22
|
from .com._tmc_com import TmcCom
|
|
23
23
|
from .reg._tmc_reg import TmcReg
|
|
24
24
|
from .reg import _tmc_shared_regs as tmc_shared_regs
|
|
25
|
-
from ._tmc_validation import validate_submodule
|
|
25
|
+
from ._tmc_validation import validate_submodule, SUBMODULE_VALIDATION
|
|
26
26
|
from ._tmc_exceptions import (
|
|
27
27
|
TmcException,
|
|
28
28
|
TmcComException,
|
|
@@ -35,9 +35,10 @@ from ._tmc_exceptions import (
|
|
|
35
35
|
class TmcXXXX(TmcStepperDriver):
|
|
36
36
|
"""TmcXXXX"""
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if SUBMODULE_VALIDATION:
|
|
39
|
+
SUPPORTED_COM_TYPES = ()
|
|
40
|
+
SUPPORTED_EC_TYPES = ()
|
|
41
|
+
SUPPORTED_MC_TYPES = ()
|
|
41
42
|
DRIVER_FAMILY = "TMCXXXX"
|
|
42
43
|
|
|
43
44
|
gstat: tmc_shared_regs.GStat
|
|
@@ -87,15 +88,16 @@ class TmcXXXX(TmcStepperDriver):
|
|
|
87
88
|
tmc_ec, tmc_mc, gpio_mode, loglevel, logprefix, log_handlers, log_formatter
|
|
88
89
|
)
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
if SUBMODULE_VALIDATION:
|
|
92
|
+
validate_submodule(
|
|
93
|
+
tmc_com, self.SUPPORTED_COM_TYPES, self.__class__.__name__, "tmc_com"
|
|
94
|
+
)
|
|
95
|
+
validate_submodule(
|
|
96
|
+
tmc_ec, self.SUPPORTED_EC_TYPES, self.__class__.__name__, "tmc_ec"
|
|
97
|
+
)
|
|
98
|
+
validate_submodule(
|
|
99
|
+
tmc_mc, self.SUPPORTED_MC_TYPES, self.__class__.__name__, "tmc_mc"
|
|
100
|
+
)
|
|
99
101
|
|
|
100
102
|
if self.tmc_com is not None:
|
|
101
103
|
self.tmc_com.tmc_logger = self.tmc_logger
|
|
@@ -120,12 +120,12 @@ class TmcMotionControl:
|
|
|
120
120
|
@property
|
|
121
121
|
def speed_fullstep(self):
|
|
122
122
|
"""_speed property"""
|
|
123
|
-
return self._speed
|
|
123
|
+
return int(self._speed // self.mres)
|
|
124
124
|
|
|
125
125
|
@speed_fullstep.setter
|
|
126
126
|
def speed_fullstep(self, speed_fullstep: int):
|
|
127
127
|
"""_speed_fullstep setter"""
|
|
128
|
-
self._speed = speed_fullstep
|
|
128
|
+
self._speed = speed_fullstep * self.mres
|
|
129
129
|
|
|
130
130
|
@property
|
|
131
131
|
def max_speed(self):
|
|
@@ -278,3 +278,21 @@ class TmcMotionControl:
|
|
|
278
278
|
Returns:
|
|
279
279
|
stop (enum): how the movement was finished
|
|
280
280
|
"""
|
|
281
|
+
|
|
282
|
+
def run_to_position_revolutions(
|
|
283
|
+
self, revolutions, movement_abs_rel: MovementAbsRel | None = None
|
|
284
|
+
) -> StopMode:
|
|
285
|
+
"""runs the motor to the given position.
|
|
286
|
+
with acceleration and deceleration
|
|
287
|
+
blocks the code until finished!
|
|
288
|
+
|
|
289
|
+
Args:
|
|
290
|
+
revolutions (int): amount of revs; can be negative
|
|
291
|
+
movement_abs_rel (enum): whether the movement should be absolute or relative
|
|
292
|
+
|
|
293
|
+
Returns:
|
|
294
|
+
stop (enum): how the movement was finished
|
|
295
|
+
"""
|
|
296
|
+
return self.run_to_position_steps(
|
|
297
|
+
round(revolutions * self._steps_per_rev), movement_abs_rel
|
|
298
|
+
)
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py
RENAMED
|
@@ -89,16 +89,6 @@ class TmcMotionControlStepDir(TmcMotionControl):
|
|
|
89
89
|
|
|
90
90
|
self._speed = speed
|
|
91
91
|
|
|
92
|
-
@property
|
|
93
|
-
def speed_fullstep(self):
|
|
94
|
-
"""_speed property"""
|
|
95
|
-
return self._speed * self.mres
|
|
96
|
-
|
|
97
|
-
@speed_fullstep.setter
|
|
98
|
-
def speed_fullstep(self, speed: int):
|
|
99
|
-
"""_speed setter"""
|
|
100
|
-
self.speed = speed * self.mres
|
|
101
|
-
|
|
102
92
|
@property
|
|
103
93
|
def pin_step(self):
|
|
104
94
|
"""_pin_step property"""
|
|
@@ -216,24 +206,6 @@ class TmcMotionControlStepDir(TmcMotionControl):
|
|
|
216
206
|
self._movement_phase = MovementPhase.STANDSTILL
|
|
217
207
|
return self._stop
|
|
218
208
|
|
|
219
|
-
def run_to_position_revolutions(
|
|
220
|
-
self, revolutions, movement_abs_rel: MovementAbsRel | None = None
|
|
221
|
-
) -> StopMode:
|
|
222
|
-
"""runs the motor to the given position.
|
|
223
|
-
with acceleration and deceleration
|
|
224
|
-
blocks the code until finished!
|
|
225
|
-
|
|
226
|
-
Args:
|
|
227
|
-
revolutions (int): amount of revs; can be negative
|
|
228
|
-
movement_abs_rel (enum): whether the movement should be absolut or relative
|
|
229
|
-
|
|
230
|
-
Returns:
|
|
231
|
-
stop (enum): how the movement was finished
|
|
232
|
-
"""
|
|
233
|
-
return self.run_to_position_steps(
|
|
234
|
-
round(revolutions * self._steps_per_rev), movement_abs_rel
|
|
235
|
-
)
|
|
236
|
-
|
|
237
209
|
def run_to_position_steps_threaded(
|
|
238
210
|
self, steps, movement_abs_rel: MovementAbsRel | None = None
|
|
239
211
|
):
|
|
@@ -14,27 +14,31 @@ this module has two different functions:
|
|
|
14
14
|
|
|
15
15
|
from ._tmc_xxxx import *
|
|
16
16
|
from .com._tmc_com import TmcCom
|
|
17
|
-
from .com._tmc_com_uart_base import TmcComUartBase
|
|
18
|
-
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepReg
|
|
19
|
-
from .motion_control._tmc_mc_step_pwm_dir import TmcMotionControlStepPwmDir
|
|
20
|
-
from .motion_control._tmc_mc_vactual import TmcMotionControlVActual
|
|
21
|
-
from .enable_control._tmc_ec_toff import TmcEnableControlToff
|
|
22
|
-
from .enable_control._tmc_ec_pin import TmcEnableControlPin
|
|
23
17
|
from .tmc_logger import Loglevel
|
|
24
18
|
from .reg._tmc220x_reg import *
|
|
19
|
+
from ._tmc_validation import SUBMODULE_VALIDATION
|
|
20
|
+
|
|
21
|
+
if SUBMODULE_VALIDATION:
|
|
22
|
+
from .com._tmc_com_uart_base import TmcComUartBase
|
|
23
|
+
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepReg
|
|
24
|
+
from .motion_control._tmc_mc_step_pwm_dir import TmcMotionControlStepPwmDir
|
|
25
|
+
from .motion_control._tmc_mc_vactual import TmcMotionControlVActual
|
|
26
|
+
from .enable_control._tmc_ec_toff import TmcEnableControlToff
|
|
27
|
+
from .enable_control._tmc_ec_pin import TmcEnableControlPin
|
|
25
28
|
|
|
26
29
|
|
|
27
30
|
class Tmc220x(TmcXXXX):
|
|
28
31
|
"""Tmc220X"""
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
if SUBMODULE_VALIDATION:
|
|
34
|
+
SUPPORTED_COM_TYPES = (TmcComUartBase,)
|
|
35
|
+
SUPPORTED_EC_TYPES = (TmcEnableControlToff, TmcEnableControlPin)
|
|
36
|
+
SUPPORTED_MC_TYPES = (
|
|
37
|
+
TmcMotionControlStepDir,
|
|
38
|
+
TmcMotionControlStepReg,
|
|
39
|
+
TmcMotionControlStepPwmDir,
|
|
40
|
+
TmcMotionControlVActual,
|
|
41
|
+
)
|
|
38
42
|
DRIVER_FAMILY = "TMC220X"
|
|
39
43
|
|
|
40
44
|
# Constructor/Destructor
|
|
@@ -14,28 +14,32 @@ this module has two different functions:
|
|
|
14
14
|
|
|
15
15
|
from ._tmc_xxxx import *
|
|
16
16
|
from .com._tmc_com import TmcCom
|
|
17
|
-
from .com._tmc_com_spi_base import TmcComSpiBase
|
|
18
|
-
from .com._tmc_com_uart_base import TmcComUartBase
|
|
19
|
-
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepDir
|
|
20
|
-
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepReg
|
|
21
|
-
from .motion_control._tmc_mc_step_pwm_dir import TmcMotionControlStepPwmDir
|
|
22
|
-
from .enable_control._tmc_ec_toff import TmcEnableControlToff
|
|
23
|
-
from .enable_control._tmc_ec_pin import TmcEnableControlPin
|
|
24
17
|
from ._tmc_stallguard import StallGuard
|
|
25
18
|
from .tmc_logger import *
|
|
26
19
|
from .reg._tmc224x_reg import *
|
|
20
|
+
from ._tmc_validation import SUBMODULE_VALIDATION
|
|
21
|
+
|
|
22
|
+
if SUBMODULE_VALIDATION:
|
|
23
|
+
from .com._tmc_com_spi_base import TmcComSpiBase
|
|
24
|
+
from .com._tmc_com_uart_base import TmcComUartBase
|
|
25
|
+
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepDir
|
|
26
|
+
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepReg
|
|
27
|
+
from .motion_control._tmc_mc_step_pwm_dir import TmcMotionControlStepPwmDir
|
|
28
|
+
from .enable_control._tmc_ec_toff import TmcEnableControlToff
|
|
29
|
+
from .enable_control._tmc_ec_pin import TmcEnableControlPin
|
|
27
30
|
|
|
28
31
|
|
|
29
32
|
class Tmc2240(TmcXXXX, StallGuard):
|
|
30
33
|
"""Tmc2240"""
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
if SUBMODULE_VALIDATION:
|
|
36
|
+
SUPPORTED_COM_TYPES = (TmcComSpiBase, TmcComUartBase)
|
|
37
|
+
SUPPORTED_EC_TYPES = (TmcEnableControlToff, TmcEnableControlPin)
|
|
38
|
+
SUPPORTED_MC_TYPES = (
|
|
39
|
+
TmcMotionControlStepDir,
|
|
40
|
+
TmcMotionControlStepReg,
|
|
41
|
+
TmcMotionControlStepPwmDir,
|
|
42
|
+
)
|
|
39
43
|
DRIVER_FAMILY = "TMC2240"
|
|
40
44
|
|
|
41
45
|
# Constructor/Destructor
|
|
@@ -14,30 +14,36 @@ this module has two different functions:
|
|
|
14
14
|
|
|
15
15
|
from ._tmc_xxxx import *
|
|
16
16
|
from .com._tmc_com import TmcCom
|
|
17
|
-
from .com._tmc_com_spi_base import TmcComSpiBase
|
|
18
|
-
from .com._tmc_com_uart_base import TmcComUartBase
|
|
19
|
-
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepDir
|
|
20
|
-
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepReg
|
|
21
|
-
from .motion_control._tmc_mc_step_pwm_dir import TmcMotionControlStepPwmDir
|
|
22
|
-
from .motion_control._tmc_mc_int_ramp_generator import TmcMotionControlIntRampGenerator
|
|
23
|
-
from .enable_control._tmc_ec_toff import TmcEnableControlToff
|
|
24
|
-
from .enable_control._tmc_ec_pin import TmcEnableControlPin
|
|
25
17
|
from ._tmc_stallguard import StallGuard
|
|
26
18
|
from .tmc_logger import *
|
|
27
19
|
from .reg._tmc5160_reg import *
|
|
20
|
+
from ._tmc_validation import SUBMODULE_VALIDATION
|
|
21
|
+
|
|
22
|
+
if SUBMODULE_VALIDATION:
|
|
23
|
+
from .com._tmc_com_spi_base import TmcComSpiBase
|
|
24
|
+
from .com._tmc_com_uart_base import TmcComUartBase
|
|
25
|
+
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepDir
|
|
26
|
+
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepReg
|
|
27
|
+
from .motion_control._tmc_mc_step_pwm_dir import TmcMotionControlStepPwmDir
|
|
28
|
+
from .motion_control._tmc_mc_int_ramp_generator import (
|
|
29
|
+
TmcMotionControlIntRampGenerator,
|
|
30
|
+
)
|
|
31
|
+
from .enable_control._tmc_ec_toff import TmcEnableControlToff
|
|
32
|
+
from .enable_control._tmc_ec_pin import TmcEnableControlPin
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
class Tmc5160(TmcXXXX, StallGuard):
|
|
31
36
|
"""Tmc5160"""
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if SUBMODULE_VALIDATION:
|
|
39
|
+
SUPPORTED_COM_TYPES = (TmcComSpiBase, TmcComUartBase)
|
|
40
|
+
SUPPORTED_EC_TYPES = (TmcEnableControlToff, TmcEnableControlPin)
|
|
41
|
+
SUPPORTED_MC_TYPES = (
|
|
42
|
+
TmcMotionControlStepDir,
|
|
43
|
+
TmcMotionControlStepReg,
|
|
44
|
+
TmcMotionControlStepPwmDir,
|
|
45
|
+
TmcMotionControlIntRampGenerator,
|
|
46
|
+
)
|
|
41
47
|
DRIVER_FAMILY = "TMC5160"
|
|
42
48
|
|
|
43
49
|
# Constructor/Destructor
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py
RENAMED
|
@@ -122,14 +122,14 @@ class GpiozeroWrapper(BaseGPIOWrapper):
|
|
|
122
122
|
|
|
123
123
|
def gpio_add_event_detect(self, pin: int, callback: types.FunctionType):
|
|
124
124
|
"""add event detect"""
|
|
125
|
-
gpio = self.
|
|
125
|
+
gpio = self._gpios[pin]
|
|
126
126
|
if not isinstance(gpio, DigitalInputDevice):
|
|
127
127
|
raise RuntimeError(f"GPIO pin {pin} not configured as input")
|
|
128
128
|
gpio.when_activated = callback
|
|
129
129
|
|
|
130
130
|
def gpio_remove_event_detect(self, pin: int):
|
|
131
131
|
"""remove event detect"""
|
|
132
|
-
gpio = self.
|
|
132
|
+
gpio = self._gpios[pin]
|
|
133
133
|
if not isinstance(gpio, DigitalInputDevice):
|
|
134
134
|
raise RuntimeError(f"GPIO pin {pin} not configured as input")
|
|
135
135
|
gpio.when_activated = None
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""
|
|
2
|
+
test for Tmc2209 with gpiozero
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import time
|
|
6
|
+
import unittest
|
|
7
|
+
from gpiozero.pins.mock import MockFactory, MockPWMPin
|
|
8
|
+
from gpiozero import Device
|
|
9
|
+
|
|
10
|
+
# Konfiguriere MockFactory mit PWM-Unterstützung
|
|
11
|
+
Device.pin_factory = MockFactory(pin_class=MockPWMPin)
|
|
12
|
+
|
|
13
|
+
import src.tmc_driver.tmc_gpio as tmc_driver_gpio
|
|
14
|
+
from src.tmc_driver.tmc_gpio._tmc_gpio_board_gpiozero import GpiozeroWrapper
|
|
15
|
+
|
|
16
|
+
from src.tmc_driver import (
|
|
17
|
+
Tmc2209,
|
|
18
|
+
TmcEnableControlPin,
|
|
19
|
+
TmcMotionControlStepPwmDir,
|
|
20
|
+
MovementAbsRel,
|
|
21
|
+
)
|
|
22
|
+
from src.tmc_driver import tmc_2209
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class _FakeTmcCom:
|
|
26
|
+
"""_FakeTmcCom class for testing purposes"""
|
|
27
|
+
|
|
28
|
+
def read_int(self, addr: int, tries: int = 3): # pylint: disable=unused-argument
|
|
29
|
+
"""fake read_int method for testing purposes"""
|
|
30
|
+
value = 0
|
|
31
|
+
return value, None
|
|
32
|
+
|
|
33
|
+
def write_reg(self, addr: int, data: int):
|
|
34
|
+
"""fake write_reg method for testing purposes"""
|
|
35
|
+
# if addr == tmc_5160.XActual.ADDR:
|
|
36
|
+
# current_pos = data
|
|
37
|
+
# if addr == tmc_5160.XTarget.ADDR:
|
|
38
|
+
# current_pos = data
|
|
39
|
+
|
|
40
|
+
def write_reg_check(self, addr: int, data: int):
|
|
41
|
+
"""fake write_reg_check method for testing purposes"""
|
|
42
|
+
self.write_reg(addr, data)
|
|
43
|
+
return True
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
fake_com = _FakeTmcCom()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class TestTMCMove(unittest.TestCase):
|
|
50
|
+
"""TestTMCMove with gpiozero"""
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def setUpClass(cls):
|
|
54
|
+
"""setUpClass"""
|
|
55
|
+
|
|
56
|
+
cls.original_tmc_gpio = tmc_driver_gpio.tmc_gpio
|
|
57
|
+
tmc_driver_gpio.tmc_gpio = GpiozeroWrapper()
|
|
58
|
+
|
|
59
|
+
@classmethod
|
|
60
|
+
def tearDownClass(cls):
|
|
61
|
+
"""tearDownClass"""
|
|
62
|
+
# Setze tmc_gpio auf die ursprüngliche Implementierung zurück
|
|
63
|
+
if cls.original_tmc_gpio is not None:
|
|
64
|
+
tmc_driver_gpio.tmc_gpio = cls.original_tmc_gpio
|
|
65
|
+
|
|
66
|
+
def setUp(self):
|
|
67
|
+
"""setUp"""
|
|
68
|
+
|
|
69
|
+
self.MovementAbsRel = MovementAbsRel
|
|
70
|
+
self.tmc = Tmc2209(TmcEnableControlPin(1), TmcMotionControlStepPwmDir(2, 3))
|
|
71
|
+
self.tmc.gconf = tmc_2209.GConf(fake_com)
|
|
72
|
+
self.tmc.sgthrs = tmc_2209.SgThrs(fake_com)
|
|
73
|
+
self.tmc.tcoolthrs = tmc_2209.TCoolThrs(fake_com)
|
|
74
|
+
|
|
75
|
+
# these values are normally set by reading the driver
|
|
76
|
+
self.tmc.mres = 2
|
|
77
|
+
|
|
78
|
+
self.tmc.acceleration_fullstep = 100000
|
|
79
|
+
self.tmc.max_speed_fullstep = 10000
|
|
80
|
+
self.tmc.movement_abs_rel = MovementAbsRel.ABSOLUTE
|
|
81
|
+
|
|
82
|
+
def tearDown(self):
|
|
83
|
+
"""tearDown"""
|
|
84
|
+
del self.tmc
|
|
85
|
+
|
|
86
|
+
def test_run_to_position_steps(self):
|
|
87
|
+
"""test_run_to_position_steps"""
|
|
88
|
+
|
|
89
|
+
self.tmc.run_to_position_steps(400, self.MovementAbsRel.RELATIVE)
|
|
90
|
+
pos = self.tmc.tmc_mc.current_pos
|
|
91
|
+
self.assertEqual(pos, 400, f"actual position: {pos}, expected position: 400")
|
|
92
|
+
|
|
93
|
+
self.tmc.run_to_position_steps(-200, self.MovementAbsRel.RELATIVE)
|
|
94
|
+
pos = self.tmc.tmc_mc.current_pos
|
|
95
|
+
self.assertEqual(pos, 200, f"actual position: {pos}, expected position: 200")
|
|
96
|
+
|
|
97
|
+
self.tmc.run_to_position_steps(400)
|
|
98
|
+
pos = self.tmc.tmc_mc.current_pos
|
|
99
|
+
self.assertEqual(pos, 400, f"actual position: {pos}, expected position: 400")
|
|
100
|
+
|
|
101
|
+
def test_stallguard_interrupt(self):
|
|
102
|
+
"""test_stallguard_interrupt"""
|
|
103
|
+
self.tmc.set_stallguard_callback(4, 100, lambda: print("Stallguard interrupt"))
|
|
104
|
+
|
|
105
|
+
def test_run_pwm(self):
|
|
106
|
+
"""test_run_to_position_steps_threaded"""
|
|
107
|
+
# continous movement using pwm
|
|
108
|
+
self.tmc.tmc_mc.run_speed_pwm_fullstep(250)
|
|
109
|
+
time.sleep(0.1)
|
|
110
|
+
self.tmc.tmc_mc.run_speed_pwm_fullstep(0)
|
|
111
|
+
time.sleep(0.1)
|
|
112
|
+
self.tmc.tmc_mc.run_speed_pwm_fullstep(-250)
|
|
113
|
+
time.sleep(0.1)
|
|
114
|
+
self.tmc.tmc_mc.run_speed_pwm_fullstep(0)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_spi_circuitpython.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/com/_tmc_com_uart_circuitpython.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py
RENAMED
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py
RENAMED
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/motion_control/_tmc_mc_vactual.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_circuitpython.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py
RENAMED
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py
RENAMED
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py
RENAMED
|
File without changes
|
{pytmcstepper-0.18.3 → pytmcstepper-0.19.0}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|