From 43ce7c0b9ad4f30277c10b086b86a0937dbfebbc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 16 Dec 2023 22:00:23 -0500 Subject: adxl345: No need to implement is_measuring() The APIDumpHelper class already ensures that the start/stop callbacks will only be called when needed. Signed-off-by: Kevin O'Connor --- klippy/extras/lis2dw.py | 9 --------- 1 file changed, 9 deletions(-) (limited to 'klippy/extras/lis2dw.py') diff --git a/klippy/extras/lis2dw.py b/klippy/extras/lis2dw.py index a1e89123..7eaf38d7 100644 --- a/klippy/extras/lis2dw.py +++ b/klippy/extras/lis2dw.py @@ -42,7 +42,6 @@ class LIS2DW: def __init__(self, config): self.printer = config.get_printer() adxl345.AccelCommandHelper(config, self) - self.query_rate = 0 am = {'x': (0, SCALE), 'y': (1, SCALE), 'z': (2, SCALE), '-x': (0, -SCALE), '-y': (1, -SCALE), '-z': (2, -SCALE)} axes_map = config.getlist('axes_map', ('x','y','z'), count=3) @@ -102,8 +101,6 @@ class LIS2DW: "(e.g. faulty wiring) or a faulty lis2dw chip." % ( reg, val, stored_val)) # Measurement collection - def is_measuring(self): - return self.query_rate > 0 def _extract_samples(self, raw_samples): # Load variables to optimize inner loop below (x_pos, x_scale), (y_pos, y_scale), (z_pos, z_scale) = self.axes_map @@ -145,8 +142,6 @@ class LIS2DW: minclock=minclock) self.clock_updater.update_clock(params) def _start_measurements(self): - if self.is_measuring(): - return # In case of miswiring, testing LIS2DW device ID prevents treating # noise or wrong signal as a correctly initialized device dev_id = self.read_reg(REG_LIS2DW_WHO_AM_I_ADDR) @@ -173,7 +168,6 @@ class LIS2DW: print_time = self.mcu.estimated_print_time(systime) + MIN_MSG_TIME reqclock = self.mcu.print_time_to_clock(print_time) rest_ticks = self.mcu.seconds_to_clock(4. / self.data_rate) - self.query_rate = self.data_rate self.query_lis2dw_cmd.send([self.oid, reqclock, rest_ticks], reqclock=reqclock) logging.info("LIS2DW starting '%s' measurements", self.name) @@ -183,11 +177,8 @@ class LIS2DW: self.clock_updater.clear_duration_filter() self.last_error_count = 0 def _finish_measurements(self): - if not self.is_measuring(): - return # Halt bulk reading params = self.query_lis2dw_end_cmd.send([self.oid, 0, 0]) - self.query_rate = 0 self.bulk_queue.clear_samples() logging.info("LIS2DW finished '%s' measurements", self.name) self.set_reg(REG_LIS2DW_FIFO_CTRL, 0x00) -- cgit v1.2.3-70-g09d2