Skip to content

Commit 473a063

Browse files
committed
Move direct and system command to nxt.brick, add documentation
Use simpler code with no metaclass. Add full documentation for the Brick class.
1 parent 5a77614 commit 473a063

19 files changed

Lines changed: 1093 additions & 658 deletions

docs/api/brick.rst

Lines changed: 120 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,124 @@
11
Brick
22
=====
33

4-
Work in progress...
5-
64
.. automodule:: nxt.brick
7-
:members:
8-
:undoc-members:
5+
6+
.. autoclass:: Brick
7+
8+
Connection Management
9+
---------------------
10+
11+
.. automethod:: Brick.close
12+
13+
You can also use the context manager interface::
14+
15+
with nxt.locator.find() as b:
16+
b.play_tone(440, 1000)
17+
# Here, connection is closed automatically.
18+
19+
Brick Information
20+
-----------------
21+
22+
.. automethod:: Brick.get_device_info
23+
.. automethod:: Brick.get_battery_level
24+
.. automethod:: Brick.get_firmware_version
25+
.. automethod:: Brick.set_brick_name
26+
.. automethod:: Brick.keep_alive
27+
28+
Sound
29+
-----
30+
31+
.. automethod:: Brick.play_tone_and_wait
32+
.. automethod:: Brick.play_sound_file
33+
.. automethod:: Brick.play_tone
34+
.. automethod:: Brick.stop_sound_playback
35+
36+
Motors and Sensors
37+
------------------
38+
39+
This part is still a work in progress.
40+
41+
.. automethod:: Brick.get_sensor
42+
43+
Programs
44+
--------
45+
46+
.. automethod:: Brick.start_program
47+
.. automethod:: Brick.stop_program
48+
.. automethod:: Brick.get_current_program_name
49+
50+
File System Access
51+
------------------
52+
53+
Brick file system has no directory and file names are not case sensitive.
54+
55+
.. automethod:: Brick.open_file
56+
.. automethod:: Brick.find_files
57+
.. automethod:: Brick.file_delete
58+
.. automethod:: Brick.delete_user_flash
59+
60+
Mailboxes
61+
---------
62+
63+
Mailboxes can be used to exchange messages with the running program.
64+
65+
.. automethod:: Brick.message_write
66+
.. automethod:: Brick.message_read
67+
68+
Low Level Modules Access
69+
------------------------
70+
71+
Low level modules access allows to read and write directly in modules
72+
memory. This can be used for example to take a screenshot or to debug the
73+
virtual machine. You need to look at the firmware source code for how to
74+
use it.
75+
76+
.. automethod:: Brick.find_modules
77+
.. automethod:: Brick.read_io_map
78+
.. automethod:: Brick.write_io_map
79+
80+
Low Level Output Ports Methods
81+
------------------------------
82+
83+
These are low level methods, you can use the :mod:`nxt.motor` module for an
84+
easier interface.
85+
86+
.. automethod:: Brick.set_output_state
87+
.. automethod:: Brick.get_output_state
88+
.. automethod:: Brick.reset_motor_position
89+
90+
Low Level Intput Ports Methods
91+
------------------------------
92+
93+
This are low level methods, you can use the :mod:`nxt.sensor` module for an
94+
easier interface.
95+
96+
.. automethod:: Brick.set_input_mode
97+
.. automethod:: Brick.get_input_values
98+
.. automethod:: Brick.reset_input_scaled_value
99+
.. automethod:: Brick.ls_get_status
100+
.. automethod:: Brick.ls_write
101+
.. automethod:: Brick.ls_read
102+
103+
Low Level Methods
104+
-----------------
105+
106+
Do not use these functions unless you know exactly what you are doing.
107+
108+
.. automethod:: Brick.file_open_read
109+
.. automethod:: Brick.file_open_write
110+
.. automethod:: Brick.file_read
111+
.. automethod:: Brick.file_write
112+
.. automethod:: Brick.file_close
113+
.. automethod:: Brick.file_find_first
114+
.. automethod:: Brick.file_find_next
115+
.. automethod:: Brick.file_open_write_linear
116+
.. automethod:: Brick.file_open_write_data
117+
.. automethod:: Brick.file_open_append_data
118+
.. automethod:: Brick.module_find_first
119+
.. automethod:: Brick.module_find_next
120+
.. automethod:: Brick.module_close
121+
.. automethod:: Brick.poll_command_length
122+
.. automethod:: Brick.poll_command
123+
.. automethod:: Brick.boot
124+
.. automethod:: Brick.bluetooth_factory_reset

docs/migration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ From :class:`nxt.brick.Brick`:
156156
- :meth:`~Brick.close` now closes the connection to the NXT brick. Also
157157
:class:`Brick` now implements the context manager interface so that it can
158158
be used with the ``with`` syntax.
159+
- :meth:`~Brick.boot` now takes a argument to avoid accidental firmware
160+
erasure.
159161

160162
Sensors:
161163

0 commit comments

Comments
 (0)