PyTmcStepper 0.21.1__tar.gz → 0.21.2__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 (86) hide show
  1. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/PKG-INFO +1 -1
  2. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/pyproject.toml +1 -1
  3. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/PKG-INFO +1 -1
  4. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/__init__.py +1 -2
  5. pytmcstepper-0.21.2/src/tmc_driver/_tmc_exceptions.py +20 -0
  6. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_math.py +9 -34
  7. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_stallguard.py +45 -29
  8. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_stepperdriver.py +13 -13
  9. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_validation.py +1 -2
  10. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_xxxx.py +44 -45
  11. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/__init__.py +2 -2
  12. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com.py +27 -43
  13. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi.py +10 -11
  14. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi_base.py +26 -21
  15. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi_circuitpython.py +4 -4
  16. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi_ftdi.py +10 -11
  17. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi_micropython.py +5 -5
  18. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_uart.py +18 -24
  19. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_uart_base.py +41 -33
  20. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_uart_circuitpython.py +9 -9
  21. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_uart_micropython.py +10 -10
  22. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/enable_control/__init__.py +2 -2
  23. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/enable_control/_tmc_ec.py +11 -13
  24. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/enable_control/_tmc_ec_pin.py +8 -9
  25. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/enable_control/_tmc_ec_toff.py +4 -6
  26. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/__init__.py +2 -2
  27. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc.py +47 -60
  28. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +19 -16
  29. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +32 -44
  30. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_pio.py +28 -44
  31. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_pio_base.py +14 -14
  32. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_pio_circuitpython.py +10 -11
  33. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_pio_micropython.py +13 -14
  34. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +8 -14
  35. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +5 -7
  36. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +22 -39
  37. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/platform_utils.py +9 -3
  38. pytmcstepper-0.21.2/src/tmc_driver/reg/__init__.py +1 -0
  39. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc2209_reg.py +5 -7
  40. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc220x_reg.py +17 -19
  41. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc224x_reg.py +28 -30
  42. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc5160_reg.py +37 -39
  43. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc_reg.py +20 -23
  44. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc_shared_regs.py +44 -45
  45. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_2208.py +2 -2
  46. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_2209.py +4 -4
  47. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_220x.py +45 -35
  48. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_2240.py +29 -26
  49. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_5160.py +27 -25
  50. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/__init__.py +9 -8
  51. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +19 -19
  52. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_circuitpython.py +12 -14
  53. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +15 -17
  54. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +27 -21
  55. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +16 -17
  56. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +25 -20
  57. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +26 -26
  58. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_logger/__init__.py +1 -3
  59. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_logger/_tmc_logger_base.py +15 -21
  60. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py +14 -21
  61. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py +3 -5
  62. pytmcstepper-0.21.1/src/tmc_driver/_tmc_exceptions.py +0 -21
  63. pytmcstepper-0.21.1/src/tmc_driver/reg/__init__.py +0 -0
  64. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/LICENSE +0 -0
  65. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/README.md +0 -0
  66. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/setup.cfg +0 -0
  67. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/SOURCES.txt +0 -0
  68. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
  69. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/requires.txt +0 -0
  70. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
  71. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_gpiozero.py +0 -0
  72. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc2209.py +0 -0
  73. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc2240.py +0 -0
  74. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_com_spi.py +0 -0
  75. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_com_uart.py +0 -0
  76. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_ec_pin.py +0 -0
  77. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_imports.py +0 -0
  78. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_math.py +0 -0
  79. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_modules.py +0 -0
  80. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_move_intramp.py +0 -0
  81. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_move_stepdir.py +0 -0
  82. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_move_steppwmdir.py +0 -0
  83. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_move_stepreg.py +0 -0
  84. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_move_vactual.py +0 -0
  85. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_set_current.py +0 -0
  86. {pytmcstepper-0.21.1 → pytmcstepper-0.21.2}/tests/test_tmc_stallguard.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyTmcStepper
3
- Version: 0.21.1
3
+ Version: 0.21.2
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.21.1"
7
+ version = "0.21.2"
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"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyTmcStepper
3
- Version: 0.21.1
3
+ Version: 0.21.2
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
@@ -1,5 +1,4 @@
1
- """
2
- PyTmcStepper - Python library for Trinamic TMC stepper motor drivers
1
+ """PyTmcStepper - Python library for Trinamic TMC stepper motor drivers.
3
2
 
4
3
  This package provides a high-level interface for controlling TMC stepper motor drivers
5
4
  via UART or SPI communication on various platforms including Raspberry Pi, Jetson, and MicroPython.
@@ -0,0 +1,20 @@
1
+ """Exceptions module."""
2
+
3
+ class TmcException(Exception):
4
+ """Base class for all TMC exceptions."""
5
+
6
+
7
+ class TmcDriverException(TmcException):
8
+ """Base class for all TMC driver exceptions."""
9
+
10
+
11
+ class TmcComException(TmcException):
12
+ """Base class for all TMC communication exceptions."""
13
+
14
+
15
+ class TmcMotionControlException(TmcException):
16
+ """Base class for all TMC motion control exceptions."""
17
+
18
+
19
+ class TmcEnableControlException(TmcException):
20
+ """Base class for all TMC enable control exceptions."""
@@ -1,10 +1,8 @@
1
- """
2
- TMC2209_Raspberry_Pi math library
3
- """
1
+ """TMC2209_Raspberry_Pi math library."""
4
2
 
5
3
 
6
4
  def rps_to_vactual(rps, steps_per_rev: int, fclk: int = 12000000) -> int:
7
- """converts rps -> vactual
5
+ """Converts rps -> vactual.
8
6
 
9
7
  Args:
10
8
  rps (float): revolutions per second
@@ -18,7 +16,7 @@ def rps_to_vactual(rps, steps_per_rev: int, fclk: int = 12000000) -> int:
18
16
 
19
17
 
20
18
  def vactual_to_rps(vactual: int, steps_per_rev: int, fclk: int = 12000000) -> float:
21
- """converts vactual -> rps
19
+ """Converts vactual -> rps.
22
20
 
23
21
  Args:
24
22
  vactual (int): value for VACTUAL
@@ -32,7 +30,7 @@ def vactual_to_rps(vactual: int, steps_per_rev: int, fclk: int = 12000000) -> fl
32
30
 
33
31
 
34
32
  def rps_to_steps(rps: float, steps_per_rev: int) -> int:
35
- """converts rps -> steps/second
33
+ """Converts rps -> steps/second.
36
34
 
37
35
  Args:
38
36
  rps (float): revolutions per second
@@ -45,20 +43,12 @@ def rps_to_steps(rps: float, steps_per_rev: int) -> int:
45
43
 
46
44
 
47
45
  def steps_to_rps(steps: int, steps_per_rev: int) -> float:
48
- """converts steps/second -> rps
49
-
50
- Args:
51
- steps (int): speed in steps per second
52
- steps_per_rev (int): steps per revolution
53
-
54
- Returns:
55
- rps (float): revolutions per second
56
- """
46
+ """Converts steps/second -> rps."""
57
47
  return steps / steps_per_rev
58
48
 
59
49
 
60
50
  def rps_to_tstep(rps: float, steps_per_rev: int, mres: int) -> int:
61
- """converts rps -> tstep
51
+ """Converts rps -> tstep.
62
52
 
63
53
  Args:
64
54
  rps (float): revolutions per second
@@ -72,22 +62,14 @@ def rps_to_tstep(rps: float, steps_per_rev: int, mres: int) -> int:
72
62
 
73
63
 
74
64
  def steps_to_tstep(steps: int, mres: int) -> int:
75
- """converts steps/second -> tstep
76
-
77
- Args:
78
- steps (int): speed in steps per second
79
- mres (int): µstep resolution
80
-
81
- Returns:
82
- tstep (int): time per step
83
- """
65
+ """Converts steps/second -> tstep."""
84
66
  if steps == 0:
85
67
  return 0
86
68
  return int(round(12000000 / (steps * 256 / mres)))
87
69
 
88
70
 
89
71
  def constrain(val: int, min_val: int, max_val: int) -> int:
90
- """constrains a value between a min and a max
72
+ """Constrains a value between a min and a max.
91
73
 
92
74
  Args:
93
75
  val (int): value that should be constrained
@@ -105,14 +87,7 @@ def constrain(val: int, min_val: int, max_val: int) -> int:
105
87
 
106
88
 
107
89
  def mean(data) -> int:
108
- """Return the arithmetic mean
109
-
110
- Args:
111
- data (list): data to calculate the mean from
112
-
113
- Returns:
114
- int: mean of the data
115
- """
90
+ """Calculates the mean of a list of numbers."""
116
91
  count = len(data)
117
92
  if count == 0:
118
93
  return 0
@@ -3,12 +3,11 @@
3
3
  # pylint: disable=too-many-branches
4
4
  # pylint: disable=too-many-instance-attributes
5
5
  # pylint: disable=too-many-positional-arguments
6
- # pylint: disable=bare-except
7
6
  # pylint: disable=no-member
8
7
  # pylint: disable=unused-import
9
8
  # pylint: disable=wildcard-import
10
9
  # pylint: disable=unused-wildcard-import
11
- """StallGuard mixin"""
10
+ """StallGuard mixin."""
12
11
 
13
12
  import types
14
13
  from ._tmc_stepperdriver import *
@@ -28,10 +27,11 @@ _CB_SENTINEL = object()
28
27
 
29
28
 
30
29
  class StallGuard:
31
- """StallGuard
30
+ """StallGuard.
32
31
 
33
- This class is used to control the stallguard feature of the TMC stepper driver.
34
- The drivers class needs to inherit from this class to use the stallguard feature (mixin).
32
+ This class is used to control the stallguard feature of the TMC
33
+ stepper driver. The drivers class needs to inherit from this class
34
+ to use the stallguard feature (mixin).
35
35
  """
36
36
 
37
37
  tmc_logger: TmcLogger
@@ -46,18 +46,24 @@ class StallGuard:
46
46
 
47
47
  # Stub methods - implemented by the driver class (Tmc2209, Tmc2240, Tmc5160)
48
48
  def set_spreadcycle(self, en: bool) -> None:
49
- """Set spreadcycle mode. Implemented by driver class."""
49
+ """Set spreadcycle mode.
50
+
51
+ Implemented by driver class.
52
+ """
50
53
  raise NotImplementedError("set_spreadcycle must be implemented by driver class")
51
54
 
52
55
  def get_microstepping_resolution(self) -> int:
53
- """Get microstepping resolution. Implemented by driver class."""
56
+ """Get microstepping resolution.
57
+
58
+ Implemented by driver class.
59
+ """
54
60
  raise NotImplementedError(
55
61
  "get_microstepping_resolution must be implemented by driver class"
56
62
  )
57
63
 
58
64
  @property
59
65
  def sg_callback(self):
60
- """stallguard callback function"""
66
+ """Stallguard callback function."""
61
67
  return self._sg_callback
62
68
 
63
69
  @sg_callback.setter
@@ -72,15 +78,16 @@ class StallGuard:
72
78
  tmc_gpio.tmc_gpio.gpio_add_event_detect(self._pin_stallguard, callback)
73
79
 
74
80
  def __init__(self):
75
- """initialize StallGuard instance variables"""
81
+ """Initialize StallGuard instance variables."""
76
82
  self._pin_stallguard: int | None = None
77
83
  self._sg_threshold: int = 100 # threshold for stallguard
78
84
 
79
85
  def __del__(self):
86
+ """Destructor."""
80
87
  self.deinit()
81
88
 
82
89
  def deinit(self):
83
- """destructor"""
90
+ """Destructor."""
84
91
  if hasattr(self, "_pin_stallguard") and self._pin_stallguard is not None:
85
92
  tmc_gpio.tmc_gpio.gpio_remove_event_detect(self._pin_stallguard)
86
93
  tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_stallguard)
@@ -89,9 +96,10 @@ class StallGuard:
89
96
  def set_stallguard_callback(
90
97
  self, pin_stallguard, threshold, callback, min_speed=100
91
98
  ):
92
- """set a function to call back, when the driver detects a stall
93
- via stallguard
94
- high value on the diag pin can also mean a driver error
99
+ """Set a function to call back when the driver detects a stall.
100
+
101
+ Uses StallGuard. A high value on the DIAG pin can also mean a
102
+ driver error.
95
103
 
96
104
  Args:
97
105
  pin_stallguard (int): pin needs to be connected to DIAG
@@ -129,14 +137,17 @@ class StallGuard:
129
137
  sedn: int = 3,
130
138
  min_speed: int = 100,
131
139
  ):
132
- """enables coolstep and sets the parameters for coolstep
133
- The values for semin etc. can be tested with the test_stallguard_threshold function
140
+ """Enables CoolStep and sets the parameters.
141
+
142
+ The values for semin etc. can be tested with the
143
+ test_stallguard_threshold function.
134
144
 
135
145
  Args:
136
146
  semin_sg (int): lower threshold. Current will be increased if SG_Result goes below this
137
147
  semax_sg (int): upper threshold. Current will be decreased if SG_Result goes above this
138
148
  seup (int): current increment step
139
149
  sedn (int): number of SG_Result readings for each current decrement
150
+ min_speed (int): min speed [steps/s] for CoolStep
140
151
  """
141
152
  semax_sg = semax_sg - semin_sg
142
153
 
@@ -153,9 +164,10 @@ class StallGuard:
153
164
  )
154
165
 
155
166
  def get_stallguard_result(self):
156
- """return the current stallguard result
157
- its will be calculated with every fullstep
158
- higher values means a lower motor load
167
+ """Return the current StallGuard result.
168
+
169
+ It is calculated with every fullstep.
170
+ Higher values means a lower motor load.
159
171
 
160
172
  Returns:
161
173
  sgresult (int): StallGuard Result
@@ -164,10 +176,11 @@ class StallGuard:
164
176
  return self.sgresult.sgresult
165
177
 
166
178
  def _set_stallguard_threshold(self, threshold):
167
- """sets the register bit "SGTHRS" to to a given value
168
- this is needed for the stallguard interrupt callback
179
+ """Sets the register bit 'SGTHRS' to a given value.
180
+
181
+ This is needed for the StallGuard interrupt callback.
169
182
  SGRESULT becomes compared to the double of this threshold.
170
- SGRESULT ≤ SGTHRS*2
183
+ SGRESULT ≤ SGTHRS*2.
171
184
 
172
185
  Args:
173
186
  threshold (int): value for SGTHRS
@@ -175,8 +188,9 @@ class StallGuard:
175
188
  self.sgthrs.modify("sgthrs", int(threshold))
176
189
 
177
190
  def _set_coolstep_threshold(self, threshold):
178
- """This is the lower threshold velocity for switching
179
- on smart energy CoolStep and StallGuard to DIAG output. (unsigned)
191
+ """Lower threshold velocity for switching on smart energy CoolStep.
192
+
193
+ Also enables StallGuard to DIAG output (unsigned).
180
194
 
181
195
  Args:
182
196
  threshold (int): threshold velocity for coolstep
@@ -184,7 +198,7 @@ class StallGuard:
184
198
  self.tcoolthrs.modify("tcoolthrs", int(threshold))
185
199
 
186
200
  def _reset_current_pos(self):
187
- """resets the current position of the motor to 0"""
201
+ """Resets the current position of the motor to 0."""
188
202
  if self.tmc_mc is None:
189
203
  raise TmcMotionControlException("tmc_mc is None; cannot reset current pos")
190
204
  self.tmc_mc.current_pos = 0
@@ -194,7 +208,8 @@ class StallGuard:
194
208
  threshold: int,
195
209
  min_speed: int,
196
210
  ):
197
- """internal setup for stallguard
211
+ """Internal setup for stallguard.
212
+
198
213
  Args:
199
214
  threshold (int): value for SGTHRS
200
215
  min_speed (int): min speed [steps/s] for StallGuard
@@ -216,7 +231,8 @@ class StallGuard:
216
231
  cb_success: types.FunctionType | object | None = _CB_SENTINEL,
217
232
  cb_failure: types.FunctionType | object | None = None,
218
233
  ) -> bool:
219
- """homes the motor in the given direction using stallguard.
234
+ """Homes the motor in the given direction using stallguard.
235
+
220
236
  this method is using vactual to move the motor and an interrupt on the DIAG pin
221
237
 
222
238
  Args:
@@ -268,14 +284,14 @@ class StallGuard:
268
284
 
269
285
  return homing_succeeded
270
286
 
271
- def test_stallguard_threshold(self, steps):
272
- """test method for tuning stallguard threshold
287
+ def test_stallguard_threshold(self, steps: int):
288
+ """Test method for tuning stallguard threshold.
273
289
 
274
290
  run this function with your motor settings and your motor load
275
291
  the function will determine the minimum stallguard results for each movement phase
276
292
 
277
293
  Args:
278
- steps (int):
294
+ steps (int): number of steps to move
279
295
  """
280
296
  if not isinstance(self.tmc_mc, TmcMotionControlStepDir):
281
297
  raise TmcMotionControlException(
@@ -3,11 +3,10 @@
3
3
  # pylint: disable=too-many-branches
4
4
  # pylint: disable=too-many-positional-arguments
5
5
  # pylint: disable=import-outside-toplevel
6
- # pylint: disable=bare-except
7
6
  # pylint: disable=unused-import
8
7
  # pylint: disable=wildcard-import
9
8
  # pylint: disable=unused-wildcard-import
10
- """TmcStepperDriver module
9
+ """TmcStepperDriver module.
11
10
 
12
11
  this module has the function to move the motor via STEP/DIR pins
13
12
  """
@@ -34,7 +33,7 @@ from . import _tmc_math as tmc_math
34
33
 
35
34
 
36
35
  class TmcStepperDriver:
37
- """TmcStepperDriver
36
+ """TmcStepperDriver.
38
37
 
39
38
  this class has two different functions:
40
39
  1. change setting in the TMC-driver via UART
@@ -89,7 +88,7 @@ class TmcStepperDriver:
89
88
  log_handlers: list | None = None,
90
89
  log_formatter: logging.Formatter | None = None,
91
90
  ):
92
- """constructor
91
+ """constructor.
93
92
 
94
93
  Args:
95
94
  tmc_ec (TmcEnableControl): TMC Enable Control object
@@ -124,10 +123,11 @@ class TmcStepperDriver:
124
123
  self.tmc_ec.init(self.tmc_logger)
125
124
 
126
125
  def __del__(self):
126
+ """Destructor."""
127
127
  self.deinit()
128
128
 
129
129
  def deinit(self):
130
- """destructor"""
130
+ """Destructor."""
131
131
  if hasattr(self, "tmc_ec") and self.tmc_ec is not None:
132
132
  self.tmc_ec.deinit()
133
133
  self.tmc_ec = None
@@ -141,7 +141,7 @@ class TmcStepperDriver:
141
141
  # Attribute Forwarding
142
142
  # ----------------------------
143
143
  def __getattr__(self, name):
144
- """Forward attribute access to tmc_mc submodule dynamically"""
144
+ """Forward attribute access to tmc_mc submodule dynamically."""
145
145
  if name in self._MC_FORWARDED_ATTRS:
146
146
  if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
147
147
  raise AttributeError(
@@ -154,7 +154,7 @@ class TmcStepperDriver:
154
154
  )
155
155
 
156
156
  def __setattr__(self, name, value):
157
- """Forward attribute setting to tmc_mc submodule dynamically"""
157
+ """Forward attribute setting to tmc_mc submodule dynamically."""
158
158
  # Forward to tmc_mc if it's a forwarded attribute and tmc_mc exists
159
159
  if name in self._MC_FORWARDED_ATTRS:
160
160
  # Only forward if tmc_mc is already initialized (not during __init__)
@@ -169,7 +169,7 @@ class TmcStepperDriver:
169
169
  # TmcEnableControl Wrapper
170
170
  # ----------------------------
171
171
  def set_motor_enabled(self, en: bool):
172
- """enable control wrapper"""
172
+ """Enable control wrapper."""
173
173
  if self.tmc_ec is not None:
174
174
  self.tmc_ec.set_motor_enabled(en)
175
175
 
@@ -178,7 +178,7 @@ class TmcStepperDriver:
178
178
  def run_to_position_steps(
179
179
  self, steps, movement_abs_rel: MovementAbsRel | None = None
180
180
  ) -> StopMode:
181
- """motioncontrol wrapper"""
181
+ """Motioncontrol wrapper."""
182
182
  if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
183
183
  raise AttributeError("TmcMotionControl is not set")
184
184
  return self.tmc_mc.run_to_position_steps(steps, movement_abs_rel)
@@ -186,23 +186,23 @@ class TmcStepperDriver:
186
186
  def run_to_position_fullsteps(
187
187
  self, steps, movement_abs_rel: MovementAbsRel | None = None
188
188
  ) -> StopMode:
189
- """motioncontrol wrapper"""
189
+ """Motioncontrol wrapper."""
190
190
  return self.run_to_position_steps(steps * self.mres, movement_abs_rel)
191
191
 
192
192
  def run_to_position_revolutions(
193
193
  self, revs, movement_abs_rel: MovementAbsRel | None = None
194
194
  ) -> StopMode:
195
- """motioncontrol wrapper"""
195
+ """Motioncontrol wrapper."""
196
196
  return self.run_to_position_steps(revs * self.steps_per_rev, movement_abs_rel)
197
197
 
198
198
  def reset_position(self):
199
- """resets the current position to 0"""
199
+ """Resets the current position to 0."""
200
200
  self.current_pos_fullstep = 0
201
201
 
202
202
  # Test Methods
203
203
  # ----------------------------
204
204
  def test_step(self):
205
- """test method"""
205
+ """Test method."""
206
206
  if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
207
207
  raise AttributeError("TmcMotionControl is not set")
208
208
  for _ in range(100):
@@ -1,5 +1,4 @@
1
- """
2
- TMC validation module
1
+ """TMC validation module.
3
2
 
4
3
  This module provides validation functions for TMC driver components.
5
4
  """