Read trackball only if state changed
This commit is contained in:
parent
c575fa396a
commit
0cc308c055
@ -193,14 +193,15 @@ class Trackball(Module):
|
|||||||
if not self._timer.tick():
|
if not self._timer.tick():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not (self._i2c_rdwr([_REG_INT], 1)[0] & _MSK_INT_TRIGGERED):
|
||||||
|
return
|
||||||
|
|
||||||
up, down, left, right, switch, state = self._read_raw_state()
|
up, down, left, right, switch, state = self._read_raw_state()
|
||||||
|
|
||||||
x, y = self._calculate_movement(right - left, down - up)
|
x, y = self._calculate_movement(right - left, down - up)
|
||||||
|
|
||||||
self.current_handler.handle(keyboard, self, x, y, switch, state)
|
self.current_handler.handle(keyboard, self, x, y, switch, state)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def after_matrix_scan(self, keyboard):
|
def after_matrix_scan(self, keyboard):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -254,7 +255,7 @@ class Trackball(Module):
|
|||||||
|
|
||||||
def _read_raw_state(self):
|
def _read_raw_state(self):
|
||||||
'''Read up, down, left, right and switch data from trackball.'''
|
'''Read up, down, left, right and switch data from trackball.'''
|
||||||
left, right, up, down, switch = self._i2c_rdwr([REG_LEFT], 5)
|
left, right, up, down, switch = self._i2c_rdwr([_REG_LEFT], 5)
|
||||||
switch_changed, switch_state = (
|
switch_changed, switch_state = (
|
||||||
switch & ~_MSK_SWITCH_STATE,
|
switch & ~_MSK_SWITCH_STATE,
|
||||||
(switch & _MSK_SWITCH_STATE) > 0,
|
(switch & _MSK_SWITCH_STATE) > 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user