コード例 #1
0
 def sync(self):
     """Read any events from the Trellis hardware and call associated
        callbacks
        """
     available = self.count
     if available > 0:
         available = available + 2
         buf = self.read_keypad(available)
         for raw in buf:
             evt = KeyEvent(_seesaw_key((raw >> 2) & 0x3F), raw & 0x3)
             if evt.number < _NEO_TRELLIS_NUM_KEYS and self.callbacks[evt.number] is not None:
                 self.callbacks[evt.number](evt)
コード例 #2
0
    def sync(self):
        """Read all trellis boards in the matrix and call any callbacks"""
        for _n in range(self._rows):
            for _m in range(self._cols):

                _t = self._trelli[_n][_m]
                available = _t.count
                sleep(0.0005)
                if available > 0:
                    available = available + 2
                    buf = _t.read_keypad(available)
                    for raw in buf:
                        evt = KeyEvent(_seesaw_key((raw >> 2) & 0x3F),
                                       raw & 0x3)
                        if (evt.number < _NEO_TRELLIS_NUM_KEYS
                                and _t.callbacks[evt.number] is not None):
                            y = int(evt.number / 4) + _n * 4
                            x = int(evt.number % 4) + _m * 4
                            _t.callbacks[evt.number](x, y, evt.edge)