PyTmcStepper 0.15.0__tar.gz → 0.18.1__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.
Files changed (77) hide show
  1. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/PKG-INFO +23 -2
  2. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/README.md +20 -1
  3. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/pyproject.toml +59 -45
  4. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/PyTmcStepper.egg-info/PKG-INFO +23 -2
  5. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/PyTmcStepper.egg-info/SOURCES.txt +3 -0
  6. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/__init__.py +15 -0
  7. pytmcstepper-0.18.1/src/tmc_driver/com/_tmc_com_spi_circuitpython.py +113 -0
  8. pytmcstepper-0.18.1/src/tmc_driver/com/_tmc_com_uart_circuitpython.py +127 -0
  9. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/enable_control/_tmc_ec.py +4 -1
  10. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/platform_utils.py +4 -1
  11. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/reg/_tmc220x_reg.py +8 -5
  12. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/reg/_tmc224x_reg.py +6 -3
  13. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/reg/_tmc5160_reg.py +6 -3
  14. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_gpio/__init__.py +27 -12
  15. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +1 -0
  16. pytmcstepper-0.18.1/src/tmc_driver/tmc_gpio/_tmc_gpio_board_circuitpython.py +124 -0
  17. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_logger/__init__.py +2 -1
  18. pytmcstepper-0.18.1/tests/test_tmc2209.py +107 -0
  19. pytmcstepper-0.18.1/tests/test_tmc2240.py +148 -0
  20. pytmcstepper-0.18.1/tests/test_tmc_com_spi.py +32 -0
  21. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/tests/test_tmc_math.py +4 -0
  22. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/tests/test_tmc_modules.py +7 -1
  23. pytmcstepper-0.15.0/tests/test_tmc2209.py +0 -44
  24. pytmcstepper-0.15.0/tests/test_tmc2240.py +0 -44
  25. pytmcstepper-0.15.0/tests/test_tmc_com_spi.py +0 -27
  26. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/LICENSE +0 -0
  27. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/setup.cfg +0 -0
  28. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
  29. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/PyTmcStepper.egg-info/requires.txt +0 -0
  30. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
  31. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/__init__.py +0 -0
  32. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/_tmc_exceptions.py +0 -0
  33. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/_tmc_math.py +0 -0
  34. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/_tmc_stallguard.py +0 -0
  35. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/_tmc_stepperdriver.py +0 -0
  36. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/_tmc_validation.py +0 -0
  37. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/_tmc_xxxx.py +0 -0
  38. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/_tmc_com.py +0 -0
  39. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/_tmc_com_spi.py +0 -0
  40. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/_tmc_com_spi_base.py +0 -0
  41. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/_tmc_com_spi_ftdi.py +0 -0
  42. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/_tmc_com_spi_micropython.py +0 -0
  43. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/_tmc_com_uart.py +0 -0
  44. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/_tmc_com_uart_base.py +0 -0
  45. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/com/_tmc_com_uart_micropython.py +0 -0
  46. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/enable_control/__init__.py +0 -0
  47. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/enable_control/_tmc_ec_pin.py +0 -0
  48. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/enable_control/_tmc_ec_toff.py +0 -0
  49. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/motion_control/__init__.py +0 -0
  50. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/motion_control/_tmc_mc.py +0 -0
  51. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +0 -0
  52. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +0 -0
  53. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +0 -0
  54. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +0 -0
  55. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +0 -0
  56. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/reg/__init__.py +0 -0
  57. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/reg/_tmc2209_reg.py +0 -0
  58. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/reg/_tmc_reg.py +0 -0
  59. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/reg/_tmc_shared_regs.py +0 -0
  60. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_2208.py +0 -0
  61. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_2209.py +0 -0
  62. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_220x.py +0 -0
  63. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_2240.py +0 -0
  64. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_5160.py +0 -0
  65. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +0 -0
  66. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +0 -0
  67. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +0 -0
  68. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +0 -0
  69. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +0 -0
  70. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_logger/_tmc_logger_base.py +0 -0
  71. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py +0 -0
  72. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py +0 -0
  73. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/tests/test_tmc_com_uart.py +0 -0
  74. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/tests/test_tmc_ec_pin.py +0 -0
  75. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/tests/test_tmc_move.py +0 -0
  76. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/tests/test_tmc_set_current.py +0 -0
  77. {pytmcstepper-0.15.0 → pytmcstepper-0.18.1}/tests/test_tmc_stallguard.py +0 -0
@@ -1,12 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyTmcStepper
3
- Version: 0.15.0
3
+ Version: 0.18.1
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
7
7
  Project-URL: Homepage, https://github.com/Chr157i4n/PyTmcStepper
8
8
  Project-URL: Bug Tracker, https://github.com/Chr157i4n/PyTmcStepper/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: Implementation :: CPython
11
+ Classifier: Programming Language :: Python :: Implementation :: MicroPython
10
12
  Classifier: Operating System :: POSIX :: Linux
11
13
  Classifier: Development Status :: 4 - Beta
12
14
  Classifier: Intended Audience :: Developers
@@ -35,6 +37,9 @@ Dynamic: license-file
35
37
  [![PyPI downloads PyTmcStepper](https://img.shields.io/pypi/dm/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
36
38
  [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/PyTmcStepper.svg)](https://GitHub.com/Chr157i4n/PyTmcStepper/issues/)
37
39
 
40
+ [![Test](https://github.com/Chr157i4n/PyTmcStepper/actions/workflows/test.yml/badge.svg)](https://github.com/Chr157i4n/PyTmcStepper/actions/workflows/test.yml)
41
+ ![Code Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Chr157i4n/PyTmcStepper/python-coverage-comment-action-data/endpoint.json)
42
+
38
43
  \
39
44
  \
40
45
  This is a Python library to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
@@ -279,7 +284,9 @@ You can also use MicroPico to run the demo script by opening one and then pressi
279
284
  The library currently uses functions to access the TMC registers, but Python properties for internal getters/setters.
280
285
 
281
286
  ```python
282
- from tmc_driver.tmc_2209 import *
287
+ from tmc_driver import Tmc2209, TmcEnableControlPin, TmcMotionControlStepDir
288
+ from tmc_driver.com import TmcComUart
289
+
283
290
  tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
284
291
 
285
292
  tmc.set_direction_reg(False)
@@ -300,6 +307,20 @@ tmc.run_to_position_steps(0)
300
307
  tmc.set_motor_enabled(False)
301
308
  ```
302
309
 
310
+ special register access:
311
+
312
+ ```python
313
+ from tmc_driver import Tmc2209, TmcEnableControlPin, TmcMotionControlStepDir
314
+ from tmc_driver.com import TmcComUart
315
+
316
+ tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
317
+
318
+ tmc.chopconf.read() # read register from the driver
319
+ print(tmc.chopconf.intpol) # print current interpolation setting
320
+ tmc.chopconf.intpol = True # enable interpolation
321
+ tmc.chopconf.write() # write register to the driver
322
+ ```
323
+
303
324
  ## Troubleshoot
304
325
 
305
326
  If you have questions please check out the [Wiki](https://github.com/Chr157i4n/PyTmcStepper/wiki) and the other issues.
@@ -5,6 +5,9 @@
5
5
  [![PyPI downloads PyTmcStepper](https://img.shields.io/pypi/dm/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
6
6
  [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/PyTmcStepper.svg)](https://GitHub.com/Chr157i4n/PyTmcStepper/issues/)
7
7
 
8
+ [![Test](https://github.com/Chr157i4n/PyTmcStepper/actions/workflows/test.yml/badge.svg)](https://github.com/Chr157i4n/PyTmcStepper/actions/workflows/test.yml)
9
+ ![Code Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Chr157i4n/PyTmcStepper/python-coverage-comment-action-data/endpoint.json)
10
+
8
11
  \
9
12
  \
10
13
  This is a Python library to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
@@ -249,7 +252,9 @@ You can also use MicroPico to run the demo script by opening one and then pressi
249
252
  The library currently uses functions to access the TMC registers, but Python properties for internal getters/setters.
250
253
 
251
254
  ```python
252
- from tmc_driver.tmc_2209 import *
255
+ from tmc_driver import Tmc2209, TmcEnableControlPin, TmcMotionControlStepDir
256
+ from tmc_driver.com import TmcComUart
257
+
253
258
  tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
254
259
 
255
260
  tmc.set_direction_reg(False)
@@ -270,6 +275,20 @@ tmc.run_to_position_steps(0)
270
275
  tmc.set_motor_enabled(False)
271
276
  ```
272
277
 
278
+ special register access:
279
+
280
+ ```python
281
+ from tmc_driver import Tmc2209, TmcEnableControlPin, TmcMotionControlStepDir
282
+ from tmc_driver.com import TmcComUart
283
+
284
+ tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
285
+
286
+ tmc.chopconf.read() # read register from the driver
287
+ print(tmc.chopconf.intpol) # print current interpolation setting
288
+ tmc.chopconf.intpol = True # enable interpolation
289
+ tmc.chopconf.write() # write register to the driver
290
+ ```
291
+
273
292
  ## Troubleshoot
274
293
 
275
294
  If you have questions please check out the [Wiki](https://github.com/Chr157i4n/PyTmcStepper/wiki) and the other issues.
@@ -1,45 +1,59 @@
1
- [build-system]
2
- requires = ["setuptools>=42", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "PyTmcStepper"
7
- version = "0.15.0"
8
- authors = [{ name = "Christian Köhlke", email = "christian@koehlke.de" }]
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
- readme = "README.md"
11
- license = "GPL-3.0"
12
- requires-python = ">=3.10"
13
- classifiers = [
14
- "Programming Language :: Python :: 3",
15
- "Operating System :: POSIX :: Linux",
16
- "Development Status :: 4 - Beta",
17
- "Intended Audience :: Developers",
18
- "Natural Language :: English",
19
- "Topic :: System :: Hardware :: Hardware Drivers",
20
- ]
21
- dependencies = ["pyserial"]
22
-
23
- [project.urls]
24
- Homepage = "https://github.com/Chr157i4n/PyTmcStepper"
25
- "Bug Tracker" = "https://github.com/Chr157i4n/PyTmcStepper/issues"
26
-
27
- [project.optional-dependencies]
28
- RASPBERRY_PI = ["RPi.GPIO"]
29
- RASPBERRY_PI5 = ["gpiozero"]
30
- NVIDIA_JETSON = ["Jetson.GPIO"]
31
- LUCKFOX_PICO = ["python-periphery"]
32
- ORANGE_PI = ["OPi.GPIO"]
33
-
34
- [tool.setuptools.packages.find]
35
- where = ["src"]
36
-
37
- [tool.pylint."messages control"]
38
- disable = "C0103,W0511,W0012,R0801"
39
-
40
- [tool.pylint.main]
41
- ignored-modules = "machine"
42
- unsafe-load-any-extension = true
43
-
44
- [tool.pylint.format]
45
- max-line-length = 160
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "PyTmcStepper"
7
+ version = "0.18.1"
8
+ authors = [{ name = "Christian Köhlke", email = "christian@koehlke.de" }]
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
+ readme = "README.md"
11
+ license = "GPL-3.0"
12
+ requires-python = ">=3.10"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: Implementation :: CPython",
16
+ "Programming Language :: Python :: Implementation :: MicroPython",
17
+ "Operating System :: POSIX :: Linux",
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Natural Language :: English",
21
+ "Topic :: System :: Hardware :: Hardware Drivers",
22
+ ]
23
+ dependencies = ["pyserial"]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/Chr157i4n/PyTmcStepper"
27
+ "Bug Tracker" = "https://github.com/Chr157i4n/PyTmcStepper/issues"
28
+
29
+ [project.optional-dependencies]
30
+ RASPBERRY_PI = ["RPi.GPIO"]
31
+ RASPBERRY_PI5 = ["gpiozero"]
32
+ NVIDIA_JETSON = ["Jetson.GPIO"]
33
+ LUCKFOX_PICO = ["python-periphery"]
34
+ ORANGE_PI = ["OPi.GPIO"]
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+
39
+ [tool.pylint."messages control"]
40
+ disable = "C0103,W0511,W0012,R0801"
41
+
42
+ [tool.pylint.main]
43
+ ignored-modules = "machine"
44
+ unsafe-load-any-extension = true
45
+
46
+ [tool.pylint.format]
47
+ max-line-length = 160
48
+
49
+ [tool.coverage.run]
50
+ relative_files = true
51
+ source = ["src"]
52
+
53
+ [tool.semantic_release]
54
+ branch = "main"
55
+ version_toml = ["pyproject.toml:project.version"]
56
+ build_command = "pip install build && python -m build"
57
+ changelog_file = 'CHANGELOG.md'
58
+ commit = true
59
+ allow_zero_version = true
@@ -1,12 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyTmcStepper
3
- Version: 0.15.0
3
+ Version: 0.18.1
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
7
7
  Project-URL: Homepage, https://github.com/Chr157i4n/PyTmcStepper
8
8
  Project-URL: Bug Tracker, https://github.com/Chr157i4n/PyTmcStepper/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: Implementation :: CPython
11
+ Classifier: Programming Language :: Python :: Implementation :: MicroPython
10
12
  Classifier: Operating System :: POSIX :: Linux
11
13
  Classifier: Development Status :: 4 - Beta
12
14
  Classifier: Intended Audience :: Developers
@@ -35,6 +37,9 @@ Dynamic: license-file
35
37
  [![PyPI downloads PyTmcStepper](https://img.shields.io/pypi/dm/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
36
38
  [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/PyTmcStepper.svg)](https://GitHub.com/Chr157i4n/PyTmcStepper/issues/)
37
39
 
40
+ [![Test](https://github.com/Chr157i4n/PyTmcStepper/actions/workflows/test.yml/badge.svg)](https://github.com/Chr157i4n/PyTmcStepper/actions/workflows/test.yml)
41
+ ![Code Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Chr157i4n/PyTmcStepper/python-coverage-comment-action-data/endpoint.json)
42
+
38
43
  \
39
44
  \
40
45
  This is a Python library to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
@@ -279,7 +284,9 @@ You can also use MicroPico to run the demo script by opening one and then pressi
279
284
  The library currently uses functions to access the TMC registers, but Python properties for internal getters/setters.
280
285
 
281
286
  ```python
282
- from tmc_driver.tmc_2209 import *
287
+ from tmc_driver import Tmc2209, TmcEnableControlPin, TmcMotionControlStepDir
288
+ from tmc_driver.com import TmcComUart
289
+
283
290
  tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
284
291
 
285
292
  tmc.set_direction_reg(False)
@@ -300,6 +307,20 @@ tmc.run_to_position_steps(0)
300
307
  tmc.set_motor_enabled(False)
301
308
  ```
302
309
 
310
+ special register access:
311
+
312
+ ```python
313
+ from tmc_driver import Tmc2209, TmcEnableControlPin, TmcMotionControlStepDir
314
+ from tmc_driver.com import TmcComUart
315
+
316
+ tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
317
+
318
+ tmc.chopconf.read() # read register from the driver
319
+ print(tmc.chopconf.intpol) # print current interpolation setting
320
+ tmc.chopconf.intpol = True # enable interpolation
321
+ tmc.chopconf.write() # write register to the driver
322
+ ```
323
+
303
324
  ## Troubleshoot
304
325
 
305
326
  If you have questions please check out the [Wiki](https://github.com/Chr157i4n/PyTmcStepper/wiki) and the other issues.
@@ -23,10 +23,12 @@ src/tmc_driver/com/__init__.py
23
23
  src/tmc_driver/com/_tmc_com.py
24
24
  src/tmc_driver/com/_tmc_com_spi.py
25
25
  src/tmc_driver/com/_tmc_com_spi_base.py
26
+ src/tmc_driver/com/_tmc_com_spi_circuitpython.py
26
27
  src/tmc_driver/com/_tmc_com_spi_ftdi.py
27
28
  src/tmc_driver/com/_tmc_com_spi_micropython.py
28
29
  src/tmc_driver/com/_tmc_com_uart.py
29
30
  src/tmc_driver/com/_tmc_com_uart_base.py
31
+ src/tmc_driver/com/_tmc_com_uart_circuitpython.py
30
32
  src/tmc_driver/com/_tmc_com_uart_micropython.py
31
33
  src/tmc_driver/enable_control/__init__.py
32
34
  src/tmc_driver/enable_control/_tmc_ec.py
@@ -48,6 +50,7 @@ src/tmc_driver/reg/_tmc_reg.py
48
50
  src/tmc_driver/reg/_tmc_shared_regs.py
49
51
  src/tmc_driver/tmc_gpio/__init__.py
50
52
  src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py
53
+ src/tmc_driver/tmc_gpio/_tmc_gpio_board_circuitpython.py
51
54
  src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py
52
55
  src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py
53
56
  src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py
@@ -6,6 +6,8 @@ Provides UART and SPI communication implementations for different platforms:
6
6
  - TmcComSpi: Standard SPI communication (CPython with spidev)
7
7
  - TmcComUartMicroPython: UART for MicroPython
8
8
  - TmcComSpiMicroPython: SPI for MicroPython
9
+ - TmcComUartCircuitPython: UART for CircuitPython
10
+ - TmcComSpiCircuitPython: SPI for CircuitPython
9
11
  - TmcComSpiFtdi: SPI via FTDI USB devices
10
12
 
11
13
  Example:
@@ -25,12 +27,15 @@ try:
25
27
  from ._tmc_com_spi import TmcComSpi
26
28
  from ._tmc_com_uart_micropython import TmcComUartMicroPython
27
29
  from ._tmc_com_spi_micropython import TmcComSpiMicroPython
30
+ from ._tmc_com_uart_circuitpython import TmcComUartCircuitPython
31
+ from ._tmc_com_spi_circuitpython import TmcComSpiCircuitPython
28
32
  from ._tmc_com_spi_ftdi import TmcComSpiFtdi
29
33
  except ImportError:
30
34
  pass
31
35
 
32
36
 
33
37
  def __getattr__(name):
38
+ # pylint: disable=too-many-return-statements
34
39
  """Lazy import of communication classes to avoid circular imports"""
35
40
  if name == "TmcComUart":
36
41
  from ._tmc_com_uart import TmcComUart
@@ -48,6 +53,14 @@ def __getattr__(name):
48
53
  from ._tmc_com_spi_micropython import TmcComSpiMicroPython
49
54
 
50
55
  return TmcComSpiMicroPython
56
+ if name == "TmcComUartCircuitPython":
57
+ from ._tmc_com_uart_circuitpython import TmcComUartCircuitPython
58
+
59
+ return TmcComUartCircuitPython
60
+ if name == "TmcComSpiCircuitPython":
61
+ from ._tmc_com_spi_circuitpython import TmcComSpiCircuitPython
62
+
63
+ return TmcComSpiCircuitPython
51
64
  if name == "TmcComSpiFtdi":
52
65
  from ._tmc_com_spi_ftdi import TmcComSpiFtdi
53
66
 
@@ -60,5 +73,7 @@ __all__ = [
60
73
  "TmcComSpi",
61
74
  "TmcComUartMicroPython",
62
75
  "TmcComSpiMicroPython",
76
+ "TmcComUartCircuitPython",
77
+ "TmcComSpiCircuitPython",
63
78
  "TmcComSpiFtdi",
64
79
  ]
@@ -0,0 +1,113 @@
1
+ # pylint: disable=too-many-instance-attributes
2
+ # pylint: disable=too-many-arguments
3
+ # pylint: disable=too-many-positional-arguments
4
+ """
5
+ TmcComSpiCircuitPython - SPI communication for CircuitPython
6
+
7
+ Uses the busio.SPI interface available on CircuitPython boards.
8
+ """
9
+
10
+ import busio # pylint: disable=import-error
11
+ import digitalio # pylint: disable=import-error
12
+ from ._tmc_com_spi_base import TmcComSpiBase
13
+ from .._tmc_exceptions import TmcComException
14
+
15
+
16
+ class TmcComSpiCircuitPython(TmcComSpiBase):
17
+ """SPI Communication class for CircuitPython
18
+
19
+ Example usage:
20
+ import board
21
+ from tmc_driver.com import TmcComSpiCircuitPython
22
+
23
+ spi_com = TmcComSpiCircuitPython(
24
+ cs=board.D17,
25
+ clock=board.SCK,
26
+ mosi=board.MOSI,
27
+ miso=board.MISO,
28
+ baudrate=1000000
29
+ )
30
+
31
+ TMC2240/TMC5160 uses SPI Mode 3: CPOL=1, CPHA=1
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ cs,
37
+ clock,
38
+ mosi,
39
+ miso,
40
+ baudrate=1000000,
41
+ ):
42
+ """Initialize SPI communication
43
+
44
+ Args:
45
+ cs: Chip select board pin (e.g., board.D17)
46
+ clock: SPI clock board pin (e.g., board.SCK)
47
+ mosi: MOSI board pin (e.g., board.MOSI)
48
+ miso: MISO board pin (e.g., board.MISO)
49
+ baudrate: SPI clock frequency in Hz (default 1MHz)
50
+ """
51
+ super().__init__()
52
+
53
+ self._cs_pin = cs
54
+ self._clock_pin = clock
55
+ self._mosi_pin = mosi
56
+ self._miso_pin = miso
57
+ self._baudrate = baudrate
58
+
59
+ self._spi = None
60
+ self._cs = None
61
+
62
+ def init(self):
63
+ """Initialize SPI hardware"""
64
+ # Create SPI bus
65
+ self._spi = busio.SPI(
66
+ clock=self._clock_pin, MOSI=self._mosi_pin, MISO=self._miso_pin
67
+ )
68
+
69
+ # Setup CS pin (active low)
70
+ self._cs = digitalio.DigitalInOut(self._cs_pin)
71
+ self._cs.direction = digitalio.Direction.OUTPUT
72
+ self._cs.value = True # CS high (inactive)
73
+
74
+ def deinit(self):
75
+ """Deinitialize SPI hardware"""
76
+ if self._spi is not None:
77
+ self._spi.deinit()
78
+ self._spi = None
79
+ if self._cs is not None:
80
+ self._cs.deinit()
81
+ self._cs = None
82
+
83
+ def _spi_transfer(self, data):
84
+ """Perform SPI transfer
85
+
86
+ Args:
87
+ data: List of bytes to send
88
+
89
+ Returns:
90
+ List of received bytes
91
+ """
92
+ if self._spi is None or self._cs is None:
93
+ raise TmcComException("SPI not initialized")
94
+
95
+ tx_data = bytes(data)
96
+ rx_data = bytearray(len(data))
97
+
98
+ # Lock the SPI bus and perform transfer
99
+ while not self._spi.try_lock():
100
+ pass
101
+
102
+ try:
103
+ # Configure SPI for TMC (Mode 3: CPOL=1, CPHA=1)
104
+ self._spi.configure(baudrate=self._baudrate, polarity=1, phase=1, bits=8)
105
+
106
+ # Perform transfer with CS control
107
+ self._cs.value = False # CS low (active)
108
+ self._spi.write_readinto(tx_data, rx_data)
109
+ self._cs.value = True # CS high (inactive)
110
+ finally:
111
+ self._spi.unlock()
112
+
113
+ return list(rx_data)
@@ -0,0 +1,127 @@
1
+ # pylint: disable=too-many-instance-attributes
2
+ # pylint: disable=too-many-arguments
3
+ # pylint: disable=too-many-positional-arguments
4
+ # pylint: disable=too-few-public-methods
5
+ """
6
+ TmcComUartCircuitPython - UART communication for CircuitPython
7
+
8
+ Uses the busio.UART interface for single-wire UART communication.
9
+ """
10
+
11
+ import time
12
+ import busio # pylint: disable=import-error
13
+ from ._tmc_com_uart_base import TmcComUartBase
14
+ from .._tmc_exceptions import TmcComException
15
+
16
+
17
+ class TmcComUartCircuitPython(TmcComUartBase):
18
+ """UART Communication class for CircuitPython
19
+
20
+ Example usage:
21
+ import board
22
+ from tmc_driver.com import TmcComUartCircuitPython
23
+
24
+ uart_com = TmcComUartCircuitPython(
25
+ tx=board.TX,
26
+ rx=board.RX,
27
+ baudrate=115200
28
+ )
29
+
30
+ For single-wire UART, connect TX to the TMC UART pin through a 1k resistor.
31
+ """
32
+
33
+ def __init__(self, tx, rx, baudrate=115200, timeout=1.0):
34
+ """Initialize UART communication
35
+
36
+ Args:
37
+ tx: TX board pin (e.g., board.TX or board.GP0)
38
+ rx: RX board pin (e.g., board.RX or board.GP1)
39
+ baudrate: UART baudrate (default 115200)
40
+ timeout: Read timeout in seconds (default 1.0)
41
+ """
42
+ super().__init__()
43
+
44
+ self._tx_pin = tx
45
+ self._rx_pin = rx
46
+ self._baudrate = baudrate
47
+ self._timeout = timeout
48
+
49
+ self._uart = None
50
+
51
+ def init(self):
52
+ """Initialize UART hardware"""
53
+ self._uart = busio.UART(
54
+ tx=self._tx_pin,
55
+ rx=self._rx_pin,
56
+ baudrate=self._baudrate,
57
+ timeout=self._timeout,
58
+ )
59
+ # Create a fake serial object for compatibility with base class
60
+ self.ser = _FakeSerial(self._uart)
61
+
62
+ def deinit(self):
63
+ """Deinitialize UART hardware"""
64
+ if self._uart is not None:
65
+ self._uart.deinit()
66
+ self._uart = None
67
+ self.ser = None
68
+
69
+ def _uart_write(self, data):
70
+ """Write data to UART
71
+
72
+ Args:
73
+ data: Bytes to write
74
+
75
+ Returns:
76
+ Number of bytes written
77
+ """
78
+ if self._uart is None:
79
+ raise TmcComException("UART not initialized")
80
+
81
+ data_bytes = bytes(data)
82
+ self._uart.write(data_bytes)
83
+
84
+ time.sleep(0.01) # Small delay to ensure data is sent
85
+
86
+ return len(data_bytes)
87
+
88
+ def _uart_read(self, length):
89
+ """Read data from UART
90
+
91
+ Args:
92
+ length: Number of bytes to read
93
+
94
+ Returns:
95
+ Bytes read or empty bytes if timeout
96
+ """
97
+ if self._uart is None:
98
+ raise TmcComException("UART not initialized")
99
+
100
+ # Wait a bit for data to arrive
101
+ time.sleep(0.01) # 10ms in seconds (CircuitPython uses seconds)
102
+
103
+ result = self._uart.read(length)
104
+ if result is None:
105
+ return bytes()
106
+ return bytes(result)
107
+
108
+ def _uart_flush(self):
109
+ """Flush UART receive buffer"""
110
+ if self._uart is None:
111
+ raise TmcComException("UART not initialized")
112
+
113
+ # Reset input buffer
114
+ self._uart.reset_input_buffer()
115
+
116
+
117
+ class _FakeSerial:
118
+ """Fake serial object for compatibility with base class"""
119
+
120
+ def __init__(self, uart):
121
+ """Constructor for fake serial object"""
122
+ self._uart = uart
123
+ self.is_open = True
124
+
125
+ def close(self):
126
+ """Close the fake serial port"""
127
+ self.is_open = False
@@ -48,7 +48,10 @@ class TmcEnableControl:
48
48
 
49
49
  def deinit(self):
50
50
  """destructor"""
51
- self.set_motor_enabled(False)
51
+ # Only disable motor if callback is still available
52
+ # During garbage collection, parent object may already be destroyed
53
+ if self._get_register_callback is not None:
54
+ self.set_motor_enabled(False)
52
55
 
53
56
  @abstractmethod
54
57
  def set_motor_enabled(self, en):
@@ -4,10 +4,13 @@ import sys
4
4
  import time
5
5
 
6
6
  MICROPYTHON = sys.implementation.name == "micropython"
7
+ CIRCUITPYTHON = sys.implementation.name == "circuitpython"
7
8
 
8
9
 
9
10
  def get_time_us():
10
- """Get current time in microseconds, compatible with both CPython and MicroPython"""
11
+ """Get current time in microseconds, compatible with CPython, MicroPython and CircuitPython"""
11
12
  if MICROPYTHON:
12
13
  return time.ticks_us() # pylint: disable=no-member
14
+ if CIRCUITPYTHON:
15
+ return time.monotonic_ns() // 1000 # pylint: disable=no-member
13
16
  return time.time_ns() // 1000
@@ -55,12 +55,12 @@ class GStat(shared.GStat):
55
55
  def check(self):
56
56
  """check if the driver is ok"""
57
57
  self.read()
58
- if self.reset:
59
- raise TmcDriverException("TMC220X: reset detected")
60
58
  if self.uv_cp:
61
59
  raise TmcDriverException("TMC220X: undervoltage detected")
62
60
  if self.drv_err:
63
61
  raise TmcDriverException("TMC220X: driver error detected")
62
+ if self.reset:
63
+ raise TmcDriverException("TMC220X: reset detected")
64
64
 
65
65
 
66
66
  class IfCnt(shared.IfCnt):
@@ -192,9 +192,12 @@ class ChopConf(shared.ChopConf):
192
192
  @mres_ms.setter
193
193
  def mres_ms(self, mres: int):
194
194
  """set µstep resolution"""
195
- mres_bit = int(math.log2(mres))
196
- mres_bit = 8 - mres_bit
197
- self.mres = mres_bit
195
+ mres_to_bit = {1: 8, 2: 7, 4: 6, 8: 5, 16: 4, 32: 3, 64: 2, 128: 1, 256: 0}
196
+ if mres not in mres_to_bit:
197
+ raise ValueError(
198
+ f"Invalid mres value: {mres}. Must be power of 2 from 1 to 256"
199
+ )
200
+ self.mres = mres_to_bit[mres]
198
201
 
199
202
 
200
203
  class PwmConf(shared.PwmConf):
@@ -310,9 +310,12 @@ class ChopConf(shared.ChopConf):
310
310
  @mres_ms.setter
311
311
  def mres_ms(self, mres: int):
312
312
  """set µstep resolution"""
313
- mres_bit = int(math.log2(mres))
314
- mres_bit = 8 - mres_bit
315
- self.mres = mres_bit
313
+ mres_to_bit = {1: 8, 2: 7, 4: 6, 8: 5, 16: 4, 32: 3, 64: 2, 128: 1, 256: 0}
314
+ if mres not in mres_to_bit:
315
+ raise ValueError(
316
+ f"Invalid mres value: {mres}. Must be power of 2 from 1 to 256"
317
+ )
318
+ self.mres = mres_to_bit[mres]
316
319
 
317
320
 
318
321
  class CoolConf(shared.CoolConf):
@@ -452,9 +452,12 @@ class ChopConf(shared.ChopConf):
452
452
  @mres_ms.setter
453
453
  def mres_ms(self, mres: int):
454
454
  """set µstep resolution"""
455
- mres_bit = int(math.log2(mres))
456
- mres_bit = 8 - mres_bit
457
- self.mres = mres_bit
455
+ mres_to_bit = {1: 8, 2: 7, 4: 6, 8: 5, 16: 4, 32: 3, 64: 2, 128: 1, 256: 0}
456
+ if mres not in mres_to_bit:
457
+ raise ValueError(
458
+ f"Invalid mres value: {mres}. Must be power of 2 from 1 to 256"
459
+ )
460
+ self.mres = mres_to_bit[mres]
458
461
 
459
462
 
460
463
  class CoolConf(shared.CoolConf):