def enter_calibration_mode(self):
        resp = self._sysex(SysExCommands.HELLO, response=True)
        self.version = bytearray(resp[3:-1]).decode("ascii")
        log.info(f"Gemini version: {self.version}")

        resp = self._sysex(SysExCommands.GET_SERIAL_NUMBER, response=True)
        self.serial_number = teeth.teeth_decode(resp[3:-1]).hex()
        log.info(f"Serial number: {self.serial_number}")
 def monitor(self):
     try:
         result = _wait_for_message(self.port_in)
         decoded = teeth.teeth_decode(result[3:-1])
         unpacked = gem_monitor_update.GemMonitorUpdate.unpack(decoded)
         return unpacked
     except Exception as e:
         self.disable_monitor()
         raise e
    def read_settings(self):
        settings_encoded = bytearray(self.SETTINGS_ENCODED_LEN)

        for n in range(self.SETTINGS_CHUNKS):
            data = self._sysex(SysExCommands.READ_SETTINGS, data=[n], response=True)
            assert len(data) == self.CHUNK_SIZE + 4
            settings_encoded[
                self.CHUNK_SIZE * n : self.CHUNK_SIZE * n + self.CHUNK_SIZE
            ] = data[3:-1]

        settings_buf = teeth.teeth_decode(settings_encoded)
        settings = gem_settings.GemSettings.unpack(settings_buf)
        return settings
    def _sysex(self, command, data=None, response=False, encode=False, decode=False):
        if data is None:
            data = []

        if encode:
            data = teeth.teeth_encode(data)

        self.port_out.send_message(
            [SYSEX_START, SYSEX_MARKER, command] + list(data) + [SYSEX_END]
        )

        if response:
            result = _wait_for_message(self.port_in)

            if decode:
                return teeth.teeth_decode(result[3:-1])

            return result
Esempio n. 5
0
 def get_serial_number(self):
     resp = self.sysex(SysExCommands.GET_SERIAL_NUMBER, response=True)
     self.serial_number = teeth.teeth_decode(resp[3:-1]).hex()