コード例 #1
0
ファイル: brick.py プロジェクト: Eelviny/nxt-python
    def play_sound_file(self, loop, name):
        """Play a sound file on the brick.

        :param bool loop: Loop mode, play continuously.
        :param str name: Sound file name.
        """
        tgram = Telegram(Opcode.DIRECT_PLAY_SOUND_FILE, reply_req=False)
        tgram.add_bool(loop)
        tgram.add_filename(name)
        self._cmd(tgram)
コード例 #2
0
ファイル: brick.py プロジェクト: Eelviny/nxt-python
    def reset_motor_position(self, port, relative):
        """Reset block or program motor position for a brick output port.

        :param nxt.motor.Port port: Output port identifier.
        :param bool relative: If ``True``, reset block position, if ``False``, reset
           program position.

        .. warning:: This is a low level function, prefer to use
           :meth:`nxt.motor.Motor`, you can get one from :meth:`get_motor`.
        """
        tgram = Telegram(Opcode.DIRECT_RESET_POSITION)
        tgram.add_u8(port.value)
        tgram.add_bool(relative)
        self._cmd(tgram)
コード例 #3
0
ファイル: brick.py プロジェクト: Eelviny/nxt-python
    def message_read(self, remote_inbox, local_inbox, remove):
        """Read a message from a brick mailbox.

        :param int remote_inbox: Mailbox number (0 to 19).
        :param int local_inbox: Local mailbox, not used by brick.
        :param bool remove: Whether to remove the message from the mailbox.
        :return: The read message.
        :rtype: bytes
        :raises nxt.error.DirectProtocolError: When mailbox is empty.
        """
        tgram = Telegram(Opcode.DIRECT_MESSAGE_READ)
        tgram.add_u8(remote_inbox)
        tgram.add_u8(local_inbox)
        tgram.add_bool(remove)
        tgram = self._cmd(tgram)
        local_inbox = tgram.parse_u8()
        size = tgram.parse_u8()
        message = tgram.parse_bytes(size)
        return local_inbox, message