Skip to content

Commit

Permalink
add query_endstop() in hx71x_endstop.
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoGeTiertime committed Jan 19, 2024
1 parent 827209e commit 8e1562e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions klippy/extras/hx71x.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def trigger(self, eventime):
if not self.bTouched:
self.bTouched = True
self.trigger_time = eventime

def query_endstop(self, eventime):
return self._hx71x.is_endstop_on(eventime)


class HX71X:
Expand Down Expand Up @@ -322,10 +325,17 @@ def _handle_hx71x_state(self, params):

# timer interval is short when homing
if (self._endstop is not None) and self._endstop.bHoming:
# call endstop trigger function. add all sensor's weight endstop.
if self.total_weight > (self.endstop_base + self.endstop_threshold):
# call endstop trigger function.
if self.is_endstop_on():
self._endstop.trigger(last_read_time)

# compare the total weight with endstop_base+threshold, if total weight is bigger than it, return True.
def is_endstop_on(self, eventtime):
if self.total_weight > (self.endstop_base + self.endstop_threshold):
return True
else:
return False

# def read_hx71x(self, read_len):
# return self.read_hx71x_cmd.send([self.oid, read_len])

Expand Down

0 comments on commit 8e1562e

Please sign in to comment.