Skip to content

Commit 8f7771f

Browse files
committed
hardware/button: program correction
1 parent c83064d commit 8f7771f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

m5stack/libs/hardware/button.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,47 @@ def __init__(self, pin_num, active_low=True, pullup_active=True) -> None:
2222
self.CB_TYPE = CB_TYPE()
2323

2424
def isHolding(self):
25-
return super().last_state == super().current_state and super().last_state == super().HOLD
25+
return self.last_state == self.current_state and self.last_state == self.HOLD
2626

2727
def isPressed(self):
2828
return (
29-
super().last_state == super().current_state and super().last_state == super().PRESSED
29+
self.last_state == self.current_state and self.last_state == self.PRESSED
3030
)
3131

3232
def isReleased(self):
3333
return (
34-
super().last_state == super().current_state and super().last_state == super().RELEASED
34+
self.last_state == self.current_state and self.last_state == self.RELEASED
3535
)
3636

37+
def isClicked(self):
38+
return self.last_state == self.current_state and self.last_state == self.CLICKED
39+
3740
def wasHold(self):
38-
return super().last_state == super().HOLD
41+
return self.last_state == self.HOLD
3942

4043
def wasPressed(self):
41-
return super().last_state == super().PRESSED
44+
return self.last_state == self.PRESSED
4245

4346
def wasReleased(self):
44-
return super().last_state == super().RELEASED
47+
return self.last_state == self.RELEASED
4548

4649
def wasClicked(self):
47-
return super().last_state == super().CLICKED
50+
return self.last_state == self.CLICKED
4851

4952
def wasSingleClicked(self):
50-
return super().last_state == super().CLICKED
53+
return self.last_state == self.CLICKED
5154

5255
def wasDoubleClicked(self):
53-
return super().last_state == super().DOUBLE_CLICKED
56+
return self.last_state == self.DOUBLE_CLICKED
5457

5558
def setCallback(self, type=None, cb=None):
5659
if type == 0:
57-
super().attach_click_event(cb, parameter=self.WAS_CLICKED)
60+
self.attach_click_event(cb, parameter=self.WAS_CLICKED)
5861
elif type == 1:
59-
super().attach_double_click(cb, parameter=self.WAS_DOUBLECLICKED)
62+
self.attach_double_click(cb, parameter=self.WAS_DOUBLECLICKED)
6063
elif type == 2:
61-
super().attach_during_long_press(cb, parameter=self.WAS_HOLD)
64+
self.attach_during_long_press(cb, parameter=self.WAS_HOLD)
6265
elif type == 3:
63-
super().attach_long_press_start(cb, parameter=self.WAS_PRESSED)
66+
self.attach_long_press_start(cb, parameter=self.WAS_PRESSED)
6467
elif type == 4:
65-
super().attach_long_press_stop(cb, parameter=self.WAS_RELEASED)
68+
self.attach_long_press_stop(cb, parameter=self.WAS_RELEASED)

0 commit comments

Comments
 (0)