aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-08-29 17:20:26 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-08-29 17:59:27 -0400
commit68d6788413ea8408d3c0290f4e6aa9974733a324 (patch)
tree02111f4a58166a6175b71e453b5dbfacf52c9661 /klippy/mcu.py
parentc7c551369f38eb3de73516ec9239a1014377a397 (diff)
downloadkutter-68d6788413ea8408d3c0290f4e6aa9974733a324.tar.gz
kutter-68d6788413ea8408d3c0290f4e6aa9974733a324.tar.xz
kutter-68d6788413ea8408d3c0290f4e6aa9974733a324.zip
mcu: Add get_mcu() call to the mcu oid objects
Allow external code to obtain the mcu object that controls a pin setup with setup_pin(). Also, don't bother defining print_to_mcu_time() and system_to_mcu_time() on each pin object as they can be obtained via the new get_mcu() method. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r--klippy/mcu.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 6628b462..506a5b5d 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -26,7 +26,8 @@ class MCU_stepper:
self._reset_cmd = self._get_position_cmd = None
self._ffi_lib = self._stepqueue = None
self.print_to_mcu_time = mcu.print_to_mcu_time
- self.system_to_mcu_time = mcu.system_to_mcu_time
+ def get_mcu(self):
+ return self._mcu
def setup_dir_pin(self, pin_params):
if pin_params['chip'] is not self._mcu:
raise pins.error("Stepper dir pin must be on same mcu as step pin")
@@ -153,8 +154,8 @@ class MCU_endstop:
self._next_query_clock = self._home_timeout_clock = 0
self._retry_query_ticks = 0
self._last_state = {}
- self.print_to_mcu_time = mcu.print_to_mcu_time
- self.system_to_mcu_time = mcu.system_to_mcu_time
+ def get_mcu(self):
+ return self._mcu
def add_stepper(self, stepper):
self._steppers.append(stepper)
def build_config(self):
@@ -246,8 +247,8 @@ class MCU_digital_out:
self._mcu_freq = 0.
self._cmd_queue = mcu.alloc_command_queue()
self._set_cmd = None
- self.print_to_mcu_time = mcu.print_to_mcu_time
- self.system_to_mcu_time = mcu.system_to_mcu_time
+ def get_mcu(self):
+ return self._mcu
def setup_max_duration(self, max_duration):
self._max_duration = max_duration
def setup_static(self):
@@ -296,8 +297,8 @@ class MCU_pwm:
self._pwm_max = 0.
self._cmd_queue = mcu.alloc_command_queue()
self._set_cmd = None
- self.print_to_mcu_time = mcu.print_to_mcu_time
- self.system_to_mcu_time = mcu.system_to_mcu_time
+ def get_mcu(self):
+ return self._mcu
def setup_max_duration(self, max_duration):
self._max_duration = max_duration
def setup_cycle_time(self, cycle_time):
@@ -371,6 +372,8 @@ class MCU_adc:
self._inv_max_adc = 0.
self._mcu_freq = 0.
self._cmd_queue = mcu.alloc_command_queue()
+ def get_mcu(self):
+ return self._mcu
def setup_minmax(self, sample_time, sample_count, minval=0., maxval=1.):
self._sample_time = sample_time
self._sample_count = sample_count