├── src
├── uio
│ └── py.typed
├── umath
│ └── py.typed
├── usys
│ └── py.typed
├── pybricks
│ ├── py.typed
│ ├── media
│ │ ├── py.typed
│ │ └── __init__.py
│ └── __init__.py
├── ubuiltins
│ └── py.typed
├── uerrno
│ └── py.typed
├── urandom
│ └── py.typed
├── uselect
│ └── py.typed
└── micropython
│ └── py.typed
├── .github
├── FUNDING.yml
└── workflows
│ ├── publish-jedi.yml
│ ├── publish-images.yml
│ └── jedi.yml
├── poetry.toml
├── jedi
├── poetry.toml
├── pyproject.toml
├── tests
│ ├── test_complete_local_private.py
│ ├── conftest.py
│ └── test_complete_inventor_hub.py
└── LICENSE
├── examples
├── ev3
│ ├── buttons
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── ps4
│ │ ├── .gitignore
│ │ └── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ ├── datalog
│ │ ├── .gitignore
│ │ └── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ ├── ev3devsensor
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── extensions.json
│ │ │ └── launch.json
│ │ └── main.py
│ ├── i2c_basics
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── i2c_extra
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── light_color
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── rcx_touch
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── screen_draw
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── uart_basics
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── bluetooth_client
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── client.py
│ ├── bluetooth_server
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── server.py
│ ├── datalog_extra
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── getting_started
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── screen_extra
│ │ ├── .gitignore
│ │ ├── sprite.png
│ │ ├── background.png
│ │ └── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ ├── screen_image
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── screen_print
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ ├── speaker_basics
│ │ ├── .gitignore
│ │ └── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ ├── bluetooth_read_spike
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ ├── README.md
│ │ ├── main.py
│ │ └── rover.py
│ ├── buttons_quickstart
│ │ ├── .gitignore
│ │ ├── buttons.png
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ ├── main.py
│ │ └── menu.py
│ ├── vernier_surface_temperature
│ │ ├── .gitignore
│ │ ├── .vscode
│ │ │ ├── settings.json
│ │ │ ├── launch.json
│ │ │ └── extensions.json
│ │ └── main.py
│ └── bluetooth_pc
│ │ ├── pybricks
│ │ └── README.md
│ │ ├── .vscode
│ │ └── launch.json
│ │ └── pcserver.py
├── micropython
│ ├── memuse.py
│ ├── usys
│ │ ├── pybricks_version.py
│ │ └── micropython_version.py
│ ├── const.py
│ ├── system_exit.py
│ ├── oserror.py
│ ├── memstat.py
│ └── keyboard_interrupt.py
└── pup
│ ├── remote
│ ├── timeout_none.py
│ ├── use_name.py
│ ├── set_name.py
│ ├── set_color_basic.py
│ ├── timeout_exception.py
│ └── basics.py
│ ├── hub_primehub
│ ├── display_number.py
│ ├── display_text.py
│ ├── display_orientation.py
│ ├── display_pixel.py
│ ├── display_image.py
│ ├── display_orientation_imu.py
│ ├── button_stop.py
│ ├── display_animate.py
│ ├── button_main.py
│ ├── display_matrix.py
│ └── display_expression.py
│ ├── hub_common
│ ├── imu_tilt.py
│ ├── system_shutdown.py
│ ├── light_off.py
│ ├── imu_read_vector.py
│ ├── light_blink.py
│ ├── light_hsv.py
│ ├── imu_read_scalar.py
│ ├── light_animate.py
│ ├── imu_tilt_blast.py
│ ├── button_single.py
│ ├── imu_up.py
│ └── ble_broadcast.py
│ ├── light
│ ├── basics.py
│ └── math.py
│ ├── motor_dc
│ ├── motor_dc_battery_box.py
│ ├── motor_dc_stop.py
│ ├── motor_dc_init_basic.py
│ └── motor_dc_init_direction.py
│ ├── motor
│ ├── motor_init_multiple.py
│ ├── motor_action_wait.py
│ ├── motor_init_basic.py
│ ├── motor_reset_angle.py
│ ├── motor_absolute.py
│ ├── motor_action_wait_advanced.py
│ ├── motor_measure.py
│ ├── motor_init_gears.py
│ ├── motor_init_direction.py
│ ├── motor_stop.py
│ ├── motor_action_then.py
│ ├── motor_until_stalled_center.py
│ └── motor_until_stalled.py
│ ├── hub_movehub
│ ├── imu_read_acceleration.py
│ └── randint_implementation.py
│ ├── sensor_tilt
│ └── basics.py
│ ├── sensor_color_distance
│ ├── color_print.py
│ ├── hsv.py
│ ├── distance_blink.py
│ ├── wait_for_color.py
│ └── detectable_colors.py
│ ├── tools
│ └── hub_menu.py
│ ├── motor_pf
│ ├── motor_pf_basics.py
│ └── motor_pf_pwm.py
│ ├── sensor_color
│ ├── color_print.py
│ ├── cleanup.py
│ ├── hsv.py
│ ├── lights_blink.py
│ ├── wait_for_color.py
│ ├── color_ambient.py
│ └── detectable_colors.py
│ ├── sensor_ultrasonic
│ ├── basics.py
│ └── math.py
│ ├── sensor_infrared
│ └── basics.py
│ ├── sensor_force
│ └── basics.py
│ ├── robotics
│ ├── drivebase_async.py
│ ├── drivebase_basics.py
│ └── car_remote.py
│ └── parameters
│ ├── color_basics.py
│ └── color_advanced.py
├── doc
├── main
│ ├── blockimg
│ │ └── LICENSE
│ ├── diagrams
│ │ ├── sd.png
│ │ ├── etcher.png
│ │ ├── files.png
│ │ ├── onoff.png
│ │ ├── store.png
│ │ ├── movehub.png
│ │ ├── overview.png
│ │ ├── running.png
│ │ ├── terminal.png
│ │ ├── connecting.png
│ │ ├── ev3motors.png
│ │ ├── icon_ev3hub.png
│ │ ├── icon_nxthub.png
│ │ ├── imuexamples.png
│ │ ├── manualrun.png
│ │ ├── messaging.png
│ │ ├── newproject.png
│ │ ├── pupdcmotors.png
│ │ ├── pupmotors.png
│ │ ├── bluetooth_on.png
│ │ ├── devicebrowser.png
│ │ ├── firstprogram.png
│ │ ├── icon_cityhub.png
│ │ ├── icon_movehub.png
│ │ ├── icon_primehub.png
│ │ ├── bluetooth_pair.png
│ │ ├── compat_cityhub.png
│ │ ├── compat_movehub.png
│ │ ├── compat_primehub.png
│ │ ├── existingproject.png
│ │ ├── icon_inventorhub.png
│ │ ├── icon_technichub.png
│ │ ├── primehub_buttons.png
│ │ ├── primehub_display.png
│ │ ├── primehub_light.png
│ │ ├── projectoverview.png
│ │ ├── projectstructure.png
│ │ ├── compat_inventorhub.png
│ │ ├── compat_technichub.png
│ │ ├── icon_essentialhub.png
│ │ ├── messaging_network.png
│ │ ├── compat_essentialhub.png
│ │ ├── orientation_movehub.png
│ │ ├── orientation_primehub.png
│ │ ├── sensor_color_lights.png
│ │ ├── orientation_inventorhub.png
│ │ ├── orientation_technichub.png
│ │ ├── orientation_tiltsensor.png
│ │ ├── sensor_colorlightmatrix.png
│ │ ├── orientation_essentialhub.png
│ │ ├── sensor_ultrasonic_lights.png
│ │ ├── dfu_windows_1_open_device_manager.png
│ │ ├── dfu_windows_3_large_hub_properties.png
│ │ ├── dfu_windows_3_small_hub_properties.png
│ │ ├── dfu_windows_8_update_driver_warning.png
│ │ ├── dfu_windows_4_large_hub_update_driver.png
│ │ ├── dfu_windows_4_small_hub_update_driver.png
│ │ ├── dfu_windows_2_large_hub_open_properties.png
│ │ ├── dfu_windows_2_small_hub_open_properties.png
│ │ ├── dfu_windows_5_large_hub_update_driver_pick.png
│ │ ├── dfu_windows_5_small_hub_update_driver_pick.png
│ │ ├── dfu_windows_9_large_hub_update_driver_done.png
│ │ ├── dfu_windows_9_small_hub_update_driver_done.png
│ │ ├── dfu_windows_6_large_hub_update_driver_select_type.png
│ │ ├── dfu_windows_6_small_hub_update_driver_select_type.png
│ │ ├── dfu_windows_7_large_hub_update_driver_select_driver.png
│ │ └── dfu_windows_7_small_hub_update_driver_select_driver.png
│ ├── cad
│ │ └── output
│ │ │ ├── all.png
│ │ │ ├── hub-all.png
│ │ │ ├── hub-city.png
│ │ │ ├── hub-lwp3.png
│ │ │ ├── hub-move.png
│ │ │ ├── hub-prime.png
│ │ │ ├── hub-technic.png
│ │ │ ├── ev3device-all.png
│ │ │ ├── ev3device-ev3.png
│ │ │ ├── ev3device-gyro.png
│ │ │ ├── hub-essential.png
│ │ │ ├── hub-inventor.png
│ │ │ ├── iodevice-all.png
│ │ │ ├── nxtdevice-all.png
│ │ │ ├── nxtdevice-nxt.png
│ │ │ ├── pupdevice-all.png
│ │ │ ├── pupdevice-tilt.png
│ │ │ ├── ev3device-color.png
│ │ │ ├── ev3device-motors.png
│ │ │ ├── ev3device-touch.png
│ │ │ ├── hub-move-motor-a.png
│ │ │ ├── hub-move-motor-b.png
│ │ │ ├── imu-orientation.png
│ │ │ ├── iodevice-dcmotor.png
│ │ │ ├── nxtdevice-color.png
│ │ │ ├── nxtdevice-energy.png
│ │ │ ├── nxtdevice-light.png
│ │ │ ├── nxtdevice-sound.png
│ │ │ ├── nxtdevice-touch.png
│ │ │ ├── pupdevice-color.png
│ │ │ ├── pupdevice-force.png
│ │ │ ├── pupdevice-light.png
│ │ │ ├── pupdevice-motors.png
│ │ │ ├── pupdevice-remote.png
│ │ │ ├── ev3device-infrared.png
│ │ │ ├── hub-prime-display.png
│ │ │ ├── hub-spike-inventor.png
│ │ │ ├── iodevice-pupdevice.png
│ │ │ ├── iodevice-rj12blue.png
│ │ │ ├── iodevice-rj12brown.png
│ │ │ ├── iodevice-rj12cyan.png
│ │ │ ├── iodevice-rj12green.png
│ │ │ ├── iodevice-rj12grey.png
│ │ │ ├── iodevice-rj12pcbbox.png
│ │ │ ├── pupdevice-dcmotors.png
│ │ │ ├── pupdevice-infrared.png
│ │ │ ├── pupdevice-pfmotor.png
│ │ │ ├── ev3device-ultrasonic.png
│ │ │ ├── hub-move-orientation.png
│ │ │ ├── hub-prime-orientation.png
│ │ │ ├── nxtdevice-temperature.png
│ │ │ ├── nxtdevice-ultrasonic.png
│ │ │ ├── pupdevice-color-front.png
│ │ │ ├── pupdevice-lightmatrix.png
│ │ │ ├── pupdevice-ultrasonic.png
│ │ │ ├── hub-inventor-orientation.png
│ │ │ ├── hub-technic-orientation.png
│ │ │ ├── pupdevice-colordistance.png
│ │ │ ├── hub-essential-orientation.png
│ │ │ ├── pupdevice-tilt-orientation.png
│ │ │ └── pupdevice-ultrasonic-front.png
│ ├── diagrams_source
│ │ ├── sd1.jpg
│ │ ├── sd2.png
│ │ ├── etcher.png
│ │ ├── files.png
│ │ ├── onoff0.png
│ │ ├── screen.png
│ │ ├── store0.png
│ │ ├── overview.jpg
│ │ ├── running.png
│ │ ├── terminal.png
│ │ ├── connecting.png
│ │ ├── manualrun1.png
│ │ ├── manualrun2.png
│ │ ├── manualrun3.png
│ │ ├── newproject.png
│ │ ├── bluetooth_on1.png
│ │ ├── bluetooth_on2.png
│ │ ├── bluetooth_on3.png
│ │ ├── bluetooth_on4.png
│ │ ├── devicebrowser0.png
│ │ ├── devicebrowser1.png
│ │ ├── devicebrowser2.png
│ │ ├── devicebrowser3.png
│ │ ├── devicebrowser4.png
│ │ ├── firstprogram1.jpg
│ │ ├── firstprogram2.png
│ │ ├── xboxcontroller.png
│ │ ├── bluetooth_pair1.png
│ │ ├── bluetooth_pair2.png
│ │ ├── bluetooth_pair3.png
│ │ ├── bluetooth_pair4.png
│ │ ├── existingproject.png
│ │ ├── projectoverview.png
│ │ ├── dfu_windows_1_open_device_manager.png
│ │ ├── dfu_windows_3_large_hub_properties.png
│ │ ├── dfu_windows_3_small_hub_properties.png
│ │ ├── dfu_windows_8_update_driver_warning.png
│ │ ├── dfu_windows_2_large_hub_open_properties.png
│ │ ├── dfu_windows_2_small_hub_open_properties.png
│ │ ├── dfu_windows_4_large_hub_update_driver.png
│ │ ├── dfu_windows_4_small_hub_update_driver.png
│ │ ├── dfu_windows_5_large_hub_update_driver_pick.png
│ │ ├── dfu_windows_5_small_hub_update_driver_pick.png
│ │ ├── dfu_windows_9_large_hub_update_driver_done.png
│ │ ├── dfu_windows_9_small_hub_update_driver_done.png
│ │ ├── dfu_windows_6_large_hub_update_driver_select_type.png
│ │ ├── dfu_windows_6_small_hub_update_driver_select_type.png
│ │ ├── dfu_windows_7_large_hub_update_driver_select_driver.png
│ │ ├── dfu_windows_7_small_hub_update_driver_select_driver.png
│ │ └── Makefile
│ ├── images
│ │ ├── datalog_graph.png
│ │ └── pybrickscode.png
│ ├── micropython
│ │ ├── uio.rst
│ │ ├── ujson.rst
│ │ ├── uerrno.rst
│ │ ├── urandom.rst
│ │ └── uselect.rst
│ ├── parameters
│ │ ├── icon.rst
│ │ ├── axis.rst
│ │ ├── port.rst
│ │ ├── index.rst
│ │ └── direction.rst
│ ├── iodevices
│ │ ├── lumpdevice.rst
│ │ ├── analogsensor.rst
│ │ ├── lwp3device.rst
│ │ ├── dcmotor.rst
│ │ ├── uartdevice.rst
│ │ ├── pupdevice.rst
│ │ └── index.rst
│ └── pupdevices
│ │ ├── tiltsensor.rst
│ │ ├── colorlightmatrix.rst
│ │ ├── light.rst
│ │ ├── infraredsensor.rst
│ │ └── forcesensor.rst
├── common
│ ├── images
│ │ ├── favicon.ico
│ │ ├── pybricks-logo-rtd.png
│ │ ├── pybricks-logo-large.png
│ │ └── pybricks-logo-small.png
│ ├── _templates
│ │ ├── footer.html
│ │ └── layout.html
│ ├── _static
│ │ ├── css
│ │ │ └── blocks.css
│ │ └── js
│ │ │ └── ide.js
│ └── extensions
│ │ ├── versionchanged.py
│ │ ├── classlink.py
│ │ └── blockimg.py
├── Makefile
└── make.bat
├── npm
├── ide-docs
│ ├── .gitignore
│ ├── .yarnrc
│ ├── README.md
│ ├── package.json
│ └── LICENSE
├── jedi
│ ├── .yarnrc
│ └── README.md
└── images
│ ├── .yarnrc
│ ├── README.md
│ ├── CHANGELOG.md
│ └── LICENSE
├── .gitattributes
├── .gitmodules
├── AUTHORS.md
├── setup.cfg
├── .vscode
├── extensions.json
└── spellright.dict
├── .readthedocs.yml
├── .gitignore
└── LICENSE
/src/uio/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/umath/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/usys/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/pybricks/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/ubuiltins/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/uerrno/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/urandom/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/uselect/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/micropython/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/pybricks/media/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/pybricks/media/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 |
2 | github: [pybricks]
3 |
--------------------------------------------------------------------------------
/poetry.toml:
--------------------------------------------------------------------------------
1 | [virtualenvs]
2 | in-project = true
3 |
--------------------------------------------------------------------------------
/jedi/poetry.toml:
--------------------------------------------------------------------------------
1 | [virtualenvs]
2 | in-project = true
3 |
--------------------------------------------------------------------------------
/examples/ev3/buttons/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/ps4/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/datalog/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/ev3devsensor/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_basics/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_extra/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/light_color/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/rcx_touch/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/screen_draw/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/uart_basics/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_client/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_server/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/datalog_extra/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/getting_started/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/screen_extra/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/screen_image/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/screen_print/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/speaker_basics/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_read_spike/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/buttons_quickstart/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/examples/ev3/vernier_surface_temperature/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/doc/main/blockimg/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2024 The Pybricks Authors - All rights reserved
2 |
--------------------------------------------------------------------------------
/npm/ide-docs/.gitignore:
--------------------------------------------------------------------------------
1 | # build directory
2 | html/
3 |
4 | # yarn pack output
5 | *.tgz
6 |
--------------------------------------------------------------------------------
/npm/jedi/.yarnrc:
--------------------------------------------------------------------------------
1 | version-tag-prefix "@pybricks/jedi/v"
2 | version-git-message "@pybricks/jedi v%s"
3 |
--------------------------------------------------------------------------------
/doc/main/diagrams/sd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/sd.png
--------------------------------------------------------------------------------
/doc/main/cad/output/all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/all.png
--------------------------------------------------------------------------------
/doc/main/diagrams/etcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/etcher.png
--------------------------------------------------------------------------------
/doc/main/diagrams/files.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/files.png
--------------------------------------------------------------------------------
/doc/main/diagrams/onoff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/onoff.png
--------------------------------------------------------------------------------
/doc/main/diagrams/store.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/store.png
--------------------------------------------------------------------------------
/examples/micropython/memuse.py:
--------------------------------------------------------------------------------
1 | from micropython import mem_info
2 |
3 | # Print memory usage.
4 | mem_info()
5 |
--------------------------------------------------------------------------------
/npm/images/.yarnrc:
--------------------------------------------------------------------------------
1 | version-tag-prefix "@pybricks/images/v"
2 | version-git-message "@pybricks/images v%s"
3 |
--------------------------------------------------------------------------------
/npm/images/README.md:
--------------------------------------------------------------------------------
1 | @pybricks/images
2 | ================
3 |
4 | Image resource for Pybricks Code.
5 |
6 |
--------------------------------------------------------------------------------
/doc/common/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/common/images/favicon.ico
--------------------------------------------------------------------------------
/doc/main/diagrams/movehub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/movehub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/overview.png
--------------------------------------------------------------------------------
/doc/main/diagrams/running.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/running.png
--------------------------------------------------------------------------------
/doc/main/diagrams/terminal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/terminal.png
--------------------------------------------------------------------------------
/npm/ide-docs/.yarnrc:
--------------------------------------------------------------------------------
1 | version-tag-prefix "@pybricks/ide-docs/v"
2 | version-git-message "@pybricks/ide-docs v%s"
3 |
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-all.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-city.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-city.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-lwp3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-lwp3.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-move.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-move.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-prime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-prime.png
--------------------------------------------------------------------------------
/doc/main/diagrams/connecting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/connecting.png
--------------------------------------------------------------------------------
/doc/main/diagrams/ev3motors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/ev3motors.png
--------------------------------------------------------------------------------
/doc/main/diagrams/icon_ev3hub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/icon_ev3hub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/icon_nxthub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/icon_nxthub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/imuexamples.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/imuexamples.png
--------------------------------------------------------------------------------
/doc/main/diagrams/manualrun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/manualrun.png
--------------------------------------------------------------------------------
/doc/main/diagrams/messaging.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/messaging.png
--------------------------------------------------------------------------------
/doc/main/diagrams/newproject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/newproject.png
--------------------------------------------------------------------------------
/doc/main/diagrams/pupdcmotors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/pupdcmotors.png
--------------------------------------------------------------------------------
/doc/main/diagrams/pupmotors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/pupmotors.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/sd1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/sd1.jpg
--------------------------------------------------------------------------------
/doc/main/diagrams_source/sd2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/sd2.png
--------------------------------------------------------------------------------
/doc/main/images/datalog_graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/images/datalog_graph.png
--------------------------------------------------------------------------------
/doc/main/images/pybrickscode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/images/pybrickscode.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-technic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-technic.png
--------------------------------------------------------------------------------
/doc/main/diagrams/bluetooth_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/bluetooth_on.png
--------------------------------------------------------------------------------
/doc/main/diagrams/devicebrowser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/devicebrowser.png
--------------------------------------------------------------------------------
/doc/main/diagrams/firstprogram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/firstprogram.png
--------------------------------------------------------------------------------
/doc/main/diagrams/icon_cityhub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/icon_cityhub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/icon_movehub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/icon_movehub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/icon_primehub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/icon_primehub.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/etcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/etcher.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/files.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/files.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/onoff0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/onoff0.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/screen.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/store0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/store0.png
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
3 | *.ico binary
4 | *.icns binary
5 | *.gif binary
6 | *.jpg binary
7 | *.png binary
8 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "media/ev3dev-media"]
2 | path = media/ev3dev-media
3 | url = https://github.com/ev3dev/ev3dev-media.git
4 |
--------------------------------------------------------------------------------
/doc/main/cad/output/ev3device-all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/ev3device-all.png
--------------------------------------------------------------------------------
/doc/main/cad/output/ev3device-ev3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/ev3device-ev3.png
--------------------------------------------------------------------------------
/doc/main/cad/output/ev3device-gyro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/ev3device-gyro.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-essential.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-essential.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-inventor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-inventor.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-all.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-all.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-nxt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-nxt.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-all.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-tilt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-tilt.png
--------------------------------------------------------------------------------
/doc/main/diagrams/bluetooth_pair.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/bluetooth_pair.png
--------------------------------------------------------------------------------
/doc/main/diagrams/compat_cityhub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/compat_cityhub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/compat_movehub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/compat_movehub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/compat_primehub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/compat_primehub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/existingproject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/existingproject.png
--------------------------------------------------------------------------------
/doc/main/diagrams/icon_inventorhub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/icon_inventorhub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/icon_technichub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/icon_technichub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/primehub_buttons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/primehub_buttons.png
--------------------------------------------------------------------------------
/doc/main/diagrams/primehub_display.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/primehub_display.png
--------------------------------------------------------------------------------
/doc/main/diagrams/primehub_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/primehub_light.png
--------------------------------------------------------------------------------
/doc/main/diagrams/projectoverview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/projectoverview.png
--------------------------------------------------------------------------------
/doc/main/diagrams/projectstructure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/projectstructure.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/overview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/overview.jpg
--------------------------------------------------------------------------------
/doc/main/diagrams_source/running.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/running.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/terminal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/terminal.png
--------------------------------------------------------------------------------
/examples/ev3/screen_extra/sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/examples/ev3/screen_extra/sprite.png
--------------------------------------------------------------------------------
/doc/common/images/pybricks-logo-rtd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/common/images/pybricks-logo-rtd.png
--------------------------------------------------------------------------------
/doc/main/cad/output/ev3device-color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/ev3device-color.png
--------------------------------------------------------------------------------
/doc/main/cad/output/ev3device-motors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/ev3device-motors.png
--------------------------------------------------------------------------------
/doc/main/cad/output/ev3device-touch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/ev3device-touch.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-move-motor-a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-move-motor-a.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-move-motor-b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-move-motor-b.png
--------------------------------------------------------------------------------
/doc/main/cad/output/imu-orientation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/imu-orientation.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-dcmotor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-dcmotor.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-color.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-energy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-energy.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-light.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-sound.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-sound.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-touch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-touch.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-color.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-force.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-force.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-light.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-motors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-motors.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-remote.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-remote.png
--------------------------------------------------------------------------------
/doc/main/diagrams/compat_inventorhub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/compat_inventorhub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/compat_technichub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/compat_technichub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/icon_essentialhub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/icon_essentialhub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/messaging_network.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/messaging_network.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/connecting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/connecting.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/manualrun1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/manualrun1.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/manualrun2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/manualrun2.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/manualrun3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/manualrun3.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/newproject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/newproject.png
--------------------------------------------------------------------------------
/examples/ev3/screen_extra/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/examples/ev3/screen_extra/background.png
--------------------------------------------------------------------------------
/doc/common/images/pybricks-logo-large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/common/images/pybricks-logo-large.png
--------------------------------------------------------------------------------
/doc/common/images/pybricks-logo-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/common/images/pybricks-logo-small.png
--------------------------------------------------------------------------------
/doc/main/cad/output/ev3device-infrared.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/ev3device-infrared.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-prime-display.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-prime-display.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-spike-inventor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-spike-inventor.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-pupdevice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-pupdevice.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-rj12blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-rj12blue.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-rj12brown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-rj12brown.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-rj12cyan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-rj12cyan.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-rj12green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-rj12green.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-rj12grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-rj12grey.png
--------------------------------------------------------------------------------
/doc/main/cad/output/iodevice-rj12pcbbox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/iodevice-rj12pcbbox.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-dcmotors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-dcmotors.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-infrared.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-infrared.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-pfmotor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-pfmotor.png
--------------------------------------------------------------------------------
/doc/main/diagrams/compat_essentialhub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/compat_essentialhub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/orientation_movehub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/orientation_movehub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/orientation_primehub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/orientation_primehub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/sensor_color_lights.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/sensor_color_lights.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/bluetooth_on1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/bluetooth_on1.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/bluetooth_on2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/bluetooth_on2.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/bluetooth_on3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/bluetooth_on3.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/bluetooth_on4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/bluetooth_on4.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/devicebrowser0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/devicebrowser0.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/devicebrowser1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/devicebrowser1.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/devicebrowser2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/devicebrowser2.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/devicebrowser3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/devicebrowser3.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/devicebrowser4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/devicebrowser4.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/firstprogram1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/firstprogram1.jpg
--------------------------------------------------------------------------------
/doc/main/diagrams_source/firstprogram2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/firstprogram2.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/xboxcontroller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/xboxcontroller.png
--------------------------------------------------------------------------------
/examples/ev3/buttons_quickstart/buttons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/examples/ev3/buttons_quickstart/buttons.png
--------------------------------------------------------------------------------
/doc/main/cad/output/ev3device-ultrasonic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/ev3device-ultrasonic.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-move-orientation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-move-orientation.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-prime-orientation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-prime-orientation.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-temperature.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-temperature.png
--------------------------------------------------------------------------------
/doc/main/cad/output/nxtdevice-ultrasonic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/nxtdevice-ultrasonic.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-color-front.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-color-front.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-lightmatrix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-lightmatrix.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-ultrasonic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-ultrasonic.png
--------------------------------------------------------------------------------
/doc/main/diagrams/orientation_inventorhub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/orientation_inventorhub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/orientation_technichub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/orientation_technichub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/orientation_tiltsensor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/orientation_tiltsensor.png
--------------------------------------------------------------------------------
/doc/main/diagrams/sensor_colorlightmatrix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/sensor_colorlightmatrix.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/bluetooth_pair1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/bluetooth_pair1.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/bluetooth_pair2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/bluetooth_pair2.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/bluetooth_pair3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/bluetooth_pair3.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/bluetooth_pair4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/bluetooth_pair4.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/existingproject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/existingproject.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/projectoverview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/projectoverview.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-inventor-orientation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-inventor-orientation.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-technic-orientation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-technic-orientation.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-colordistance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-colordistance.png
--------------------------------------------------------------------------------
/doc/main/diagrams/orientation_essentialhub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/orientation_essentialhub.png
--------------------------------------------------------------------------------
/doc/main/diagrams/sensor_ultrasonic_lights.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/sensor_ultrasonic_lights.png
--------------------------------------------------------------------------------
/doc/main/cad/output/hub-essential-orientation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/hub-essential-orientation.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-tilt-orientation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-tilt-orientation.png
--------------------------------------------------------------------------------
/doc/main/cad/output/pupdevice-ultrasonic-front.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/cad/output/pupdevice-ultrasonic-front.png
--------------------------------------------------------------------------------
/examples/micropython/usys/pybricks_version.py:
--------------------------------------------------------------------------------
1 | from pybricks import version
2 |
3 | # ('essentialhub', '3.2.0b5', 'v3.2.0b5 on 2022-11-11')
4 | print(version)
5 |
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_1_open_device_manager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_1_open_device_manager.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_3_large_hub_properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_3_large_hub_properties.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_3_small_hub_properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_3_small_hub_properties.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_8_update_driver_warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_8_update_driver_warning.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_4_large_hub_update_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_4_large_hub_update_driver.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_4_small_hub_update_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_4_small_hub_update_driver.png
--------------------------------------------------------------------------------
/src/pybricks/__init__.py:
--------------------------------------------------------------------------------
1 | from typing import Tuple
2 |
3 |
4 | version: Tuple[str, str, str] = (
5 | "hub",
6 | "3.X.YbZ",
7 | "v3.X.YbZ-GIT_HASH on DATE",
8 | )
9 |
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_2_large_hub_open_properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_2_large_hub_open_properties.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_2_small_hub_open_properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_2_small_hub_open_properties.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_1_open_device_manager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_1_open_device_manager.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_3_large_hub_properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_3_large_hub_properties.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_3_small_hub_properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_3_small_hub_properties.png
--------------------------------------------------------------------------------
/doc/main/micropython/uio.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: stm32-extra
2 |
3 | :mod:`uio` -- Input/output streams
4 | ==================================
5 |
6 | .. automodule:: uio
7 |
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_5_large_hub_update_driver_pick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_5_large_hub_update_driver_pick.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_5_small_hub_update_driver_pick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_5_small_hub_update_driver_pick.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_9_large_hub_update_driver_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_9_large_hub_update_driver_done.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_9_small_hub_update_driver_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_9_small_hub_update_driver_done.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_8_update_driver_warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_8_update_driver_warning.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_2_large_hub_open_properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_2_large_hub_open_properties.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_2_small_hub_open_properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_2_small_hub_open_properties.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_4_large_hub_update_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_4_large_hub_update_driver.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_4_small_hub_update_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_4_small_hub_update_driver.png
--------------------------------------------------------------------------------
/npm/jedi/README.md:
--------------------------------------------------------------------------------
1 | @pybricks/jedi
2 | ==============
3 |
4 | Binary distribution of the `pybricks-jedi` Python package and its dependencies
5 | for using in JavaScript/WASM, e.g. via Pyodide.
6 |
--------------------------------------------------------------------------------
/doc/common/_templates/footer.html:
--------------------------------------------------------------------------------
1 | {% extends '!footer.html' %}
2 |
3 | {% block extrafooter %}
4 | {% if disclaimer %}
{{ disclaimer }}
{% endif %}
5 | {% endblock %}
6 |
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_6_large_hub_update_driver_select_type.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_6_large_hub_update_driver_select_type.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_6_small_hub_update_driver_select_type.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_6_small_hub_update_driver_select_type.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_7_large_hub_update_driver_select_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_7_large_hub_update_driver_select_driver.png
--------------------------------------------------------------------------------
/doc/main/diagrams/dfu_windows_7_small_hub_update_driver_select_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams/dfu_windows_7_small_hub_update_driver_select_driver.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_5_large_hub_update_driver_pick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_5_large_hub_update_driver_pick.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_5_small_hub_update_driver_pick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_5_small_hub_update_driver_pick.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_9_large_hub_update_driver_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_9_large_hub_update_driver_done.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_9_small_hub_update_driver_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_9_small_hub_update_driver_done.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_6_large_hub_update_driver_select_type.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_6_large_hub_update_driver_select_type.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_6_small_hub_update_driver_select_type.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_6_small_hub_update_driver_select_type.png
--------------------------------------------------------------------------------
/examples/pup/remote/timeout_none.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Remote
2 |
3 | # Connect to any remote. Search forever until we find one.
4 | my_remote = Remote(timeout=None)
5 |
6 | print("Connected!")
7 |
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_7_large_hub_update_driver_select_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_7_large_hub_update_driver_select_driver.png
--------------------------------------------------------------------------------
/doc/main/diagrams_source/dfu_windows_7_small_hub_update_driver_select_driver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-api/HEAD/doc/main/diagrams_source/dfu_windows_7_small_hub_update_driver_select_driver.png
--------------------------------------------------------------------------------
/doc/common/_templates/layout.html:
--------------------------------------------------------------------------------
1 | {% extends "!layout.html" %}
2 | {% block extrahead %}
3 |
4 | {% endblock %}
5 |
--------------------------------------------------------------------------------
/doc/main/parameters/icon.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: light-matrix
2 |
3 | Icon
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. autoclass:: pybricks.parameters.Icon
7 |
8 | See the :ref:`make_icons` section for examples.
9 |
--------------------------------------------------------------------------------
/examples/ev3/buttons/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/ev3devsensor/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_basics/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_extra/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/light_color/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/screen_draw/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/screen_extra/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/screen_image/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/screen_print/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/uart_basics/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_client/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_server/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/getting_started/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/examples/ev3/speaker_basics/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/npm/ide-docs/README.md:
--------------------------------------------------------------------------------
1 | # @pybricks/ide-docs
2 |
3 | This is a Node.js package for distributing the version of the Pybricks API
4 | docs that is embedded in IDEs.
5 |
6 | It contains all of the files needed to serve a static web site.
7 |
--------------------------------------------------------------------------------
/examples/ev3/vernier_surface_temperature/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/doc/common/_static/css/blocks.css:
--------------------------------------------------------------------------------
1 | .svg-container {
2 | display: inline-block;
3 | width: 100%;
4 | height: auto;
5 | }
6 |
7 | .svg-container svg {
8 | position: relative;
9 | height: auto;
10 | max-width: 100%;
11 | }
12 |
--------------------------------------------------------------------------------
/examples/ev3/ps4/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "python.languageServer": "None"
7 | }
8 |
--------------------------------------------------------------------------------
/examples/pup/remote/use_name.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Remote
2 | from pybricks.tools import wait
3 |
4 | # Connect to a remote called truck2.
5 | truck_remote = Remote("truck2", timeout=None)
6 |
7 | print("Connected!")
8 |
9 | wait(2000)
10 |
--------------------------------------------------------------------------------
/examples/ev3/datalog/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "python.languageServer": "None"
7 | }
8 |
--------------------------------------------------------------------------------
/examples/ev3/rcx_touch/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "python.languageServer": "None"
7 | }
8 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 | **Project:** `pybricks-api`
2 |
3 | **The Pybricks Authors (copyright holders of this project):**
4 | - Laurens Valk
5 | - David Lechner
6 | - LEGO System A/S
7 |
8 | **Maintainers:**
9 | - Laurens Valk (@laurensvalk)
10 | - David Lechner (@dlech)
11 |
--------------------------------------------------------------------------------
/examples/ev3/datalog_extra/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "python.languageServer": "None"
7 | }
8 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_number.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.tools import wait
3 |
4 | # Initialize the hub.
5 | hub = PrimeHub()
6 |
7 | # Count from 0 to 99.
8 | for i in range(100):
9 | hub.display.number(i)
10 | wait(200)
11 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 |
2 | [flake8]
3 | exclude = .venv/,*.pyi,jedi/,examples/pup/tools/hub_menu.py
4 | max-line-length = 88
5 | ignore = E203,E501,W503,E701,E704
6 |
7 | [doc8]
8 | ignore-path = jedi/,.venv/,doc/main/build/,doc/api/build/,pybricks.egg-info/,npm/
9 | max-line-length = 88
10 |
--------------------------------------------------------------------------------
/doc/main/iodevices/lumpdevice.rst:
--------------------------------------------------------------------------------
1 | EV3 UART Device
2 | ^^^^^^^^^^^^^^^^^
3 |
4 | .. note::
5 |
6 | This class is only available on EV3.
7 |
8 | .. figure:: ../../main/cad/output/iodevice-rj12green.png
9 | :width: 25 %
10 |
11 | .. autoclass:: pybricks.iodevices.LUMPDevice
12 |
--------------------------------------------------------------------------------
/doc/main/iodevices/analogsensor.rst:
--------------------------------------------------------------------------------
1 | EV3 Analog Sensor
2 | ^^^^^^^^^^^^^^^^^
3 |
4 | .. note::
5 |
6 | This class is only available on EV3.
7 |
8 | .. figure:: ../../main/cad/output/iodevice-rj12brown.png
9 | :width: 25 %
10 |
11 | .. autoclass:: pybricks.iodevices.AnalogSensor
12 |
--------------------------------------------------------------------------------
/doc/main/iodevices/lwp3device.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: pybricks-iodevices
2 |
3 | LEGO Wireless Protocol v3 device
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. figure:: ../../main/cad/output/hub-lwp3.png
7 | :width: 80 %
8 |
9 | .. autoclass:: pybricks.iodevices.LWP3Device
10 |
--------------------------------------------------------------------------------
/examples/ev3/buttons_quickstart/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "ev3devBrowser.download.exclude": "{**/.*,**/*.svg}"
7 | }
8 |
--------------------------------------------------------------------------------
/examples/pup/remote/set_name.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Remote
2 |
3 | # Connect to any remote.
4 | my_remote = Remote()
5 |
6 | # Print the current name of the remote.
7 | print(my_remote.name())
8 |
9 | # Choose a new name.
10 | my_remote.name("truck2")
11 |
12 | print("Done!")
13 |
--------------------------------------------------------------------------------
/doc/common/_static/js/ide.js:
--------------------------------------------------------------------------------
1 | // Since Pybricks Code is an "app", all external links get opened in new tab/window
2 | // https://stackoverflow.com/a/62742435/1976323
3 | $(document).ready(function () {
4 | $('a[href^="http://"], a[href^="https://"]').not('a[class*=internal]').attr('target', '_blank');
5 | });
6 |
--------------------------------------------------------------------------------
/examples/micropython/usys/micropython_version.py:
--------------------------------------------------------------------------------
1 | import usys
2 |
3 | # ('micropython', (1, 19, 1), 'SPIKE Essential Hub with STM32F413RG', 6)
4 | print(usys.implementation)
5 |
6 | # '3.4.0; Pybricks MicroPython v3.2.0b5 on 2022-11-11'
7 | print(usys.version)
8 |
9 | # (3, 4, 0)
10 | print(usys.version_info)
11 |
--------------------------------------------------------------------------------
/doc/main/parameters/axis.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: stm32-float
2 |
3 | Axis
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. autoclass:: pybricks.parameters.Axis
7 | :no-members:
8 |
9 | On Move Hub, doing math with these vectors is not supported. The axes can still
10 | be used to set up the hub orientation.
11 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_read_spike/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "python.languageServer": "None",
7 | "ev3devBrowser.download.exclude": "{**/.*,**/*.md}"
8 | }
9 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_text.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.tools import wait
3 |
4 | # Initialize the hub.
5 | hub = PrimeHub()
6 |
7 | # Display the letter A for two seconds.
8 | hub.display.char("A")
9 | wait(2000)
10 |
11 | # Display text, one letter at a time.
12 | hub.display.text("Hello, world!")
13 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_read_spike/README.md:
--------------------------------------------------------------------------------
1 | To find the SPIKE Prime Bluetooth address:
2 | - Press the Bluetooth button on SPIKE to make it discoverable.
3 | - Use the menu on the EV3 screen and go to:
4 | Wireless and Networks > Bluetooth > Start Scan.
5 | - Scroll down the list and choose your SPIKE hub.
6 | - No need to pair or connect! Just write down the address you see.
7 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/imu_tilt.py:
--------------------------------------------------------------------------------
1 | # ThisHub = TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.tools import wait
4 |
5 | # Initialize the hub.
6 | hub = ThisHub()
7 |
8 | while True:
9 | # Read the tilt values.
10 | pitch, roll = hub.imu.tilt()
11 |
12 | # Print the result.
13 | print(pitch, roll)
14 | wait(200)
15 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/system_shutdown.py:
--------------------------------------------------------------------------------
1 | # ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.tools import wait
4 |
5 | # Initialize the hub.
6 | hub = ThisHub()
7 |
8 | # Say goodbye and give some time to send it.
9 | print("Goodbye!")
10 | wait(100)
11 |
12 | # Shut the hub down.
13 | hub.system.shutdown()
14 |
--------------------------------------------------------------------------------
/doc/main/micropython/ujson.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: stm32-extra
2 |
3 | :mod:`ujson` -- JSON encoding and decoding
4 | ===========================================
5 |
6 | .. automodule:: ujson
7 | :no-members:
8 |
9 | .. autofunction:: ujson.dump
10 |
11 | .. autofunction:: ujson.dumps
12 |
13 | .. autofunction:: ujson.load
14 |
15 | .. autofunction:: ujson.loads
16 |
--------------------------------------------------------------------------------
/examples/ev3/light_color/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | from pybricks.hubs import EV3Brick
4 | from pybricks.tools import wait
5 | from pybricks.parameters import Color
6 |
7 | # Initialize the EV3
8 | ev3 = EV3Brick()
9 |
10 | # Turn on a red light
11 | ev3.light.on(Color.RED)
12 |
13 | # Wait
14 | wait(1000)
15 |
16 | # Turn the light off
17 | ev3.light.off()
18 |
--------------------------------------------------------------------------------
/examples/pup/remote/set_color_basic.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Remote
2 | from pybricks.parameters import Color
3 | from pybricks.tools import wait
4 |
5 | # Connect to the remote.
6 | remote = Remote()
7 |
8 | while True:
9 | # Set the color to red.
10 | remote.light.on(Color.RED)
11 | wait(1000)
12 |
13 | # Set the color to blue.
14 | remote.light.on(Color.BLUE)
15 | wait(1000)
16 |
--------------------------------------------------------------------------------
/examples/pup/light/basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Light
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the light.
6 | light = Light(Port.A)
7 |
8 | # Blink the light forever.
9 | while True:
10 | # Turn the light on at 100% brightness.
11 | light.on(100)
12 | wait(500)
13 |
14 | # Turn the light off.
15 | light.off()
16 | wait(500)
17 |
--------------------------------------------------------------------------------
/examples/pup/motor_dc/motor_dc_battery_box.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import DCMotor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the motor.
6 | train_motor = DCMotor(Port.A)
7 |
8 | # Choose the "power" level for your train. Negative means reverse.
9 | train_motor.dc(50)
10 |
11 | # Keep doing nothing. The train just keeps going.
12 | while True:
13 | wait(1000)
14 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_init_multiple.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize motors on port A and B.
6 | track_motor = Motor(Port.A)
7 | gripper_motor = Motor(Port.B)
8 |
9 | # Make both motors run at 500 degrees per second.
10 | track_motor.run(500)
11 | gripper_motor.run(500)
12 |
13 | # Wait for three seconds.
14 | wait(3000)
15 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/light_off.py:
--------------------------------------------------------------------------------
1 | # ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.parameters import Color
4 | from pybricks.tools import wait
5 |
6 | # Initialize the hub.
7 | hub = ThisHub()
8 |
9 | # Turn the light on and off 5 times.
10 | for i in range(5):
11 |
12 | hub.light.on(Color.RED)
13 | wait(1000)
14 |
15 | hub.light.off()
16 | wait(500)
17 |
--------------------------------------------------------------------------------
/examples/pup/remote/timeout_exception.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Remote
2 |
3 | try:
4 | # Search for a remote for 5 seconds.
5 | my_remote = Remote(timeout=5000)
6 |
7 | print("Connected!")
8 |
9 | # Here you can write code that uses the remote.
10 |
11 | except OSError:
12 |
13 | print("Could not find the remote.")
14 |
15 | # Here you can make your robot do something
16 | # without the remote.
17 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/imu_read_vector.py:
--------------------------------------------------------------------------------
1 | # ThisHub = TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.tools import wait
4 |
5 | # Initialize the hub.
6 | hub = ThisHub()
7 |
8 | # Get the acceleration vector in g's.
9 | print(hub.imu.acceleration() / 9810)
10 |
11 | # Get the angular velocity vector.
12 | print(hub.imu.angular_velocity())
13 |
14 | # Wait so we can see what we printed
15 | wait(5000)
16 |
--------------------------------------------------------------------------------
/examples/pup/hub_movehub/imu_read_acceleration.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import MoveHub
2 | from pybricks.tools import wait
3 |
4 | # Initialize the hub.
5 | hub = MoveHub()
6 |
7 | # Get the acceleration tuple.
8 | print(hub.imu.acceleration())
9 |
10 | while True:
11 | # Get individual acceleration values.
12 | x, y, z = hub.imu.acceleration()
13 | print(x, y, z)
14 |
15 | # Wait so we can see what we printed.
16 | wait(100)
17 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_orientation.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.tools import wait
3 | from pybricks.parameters import Side
4 |
5 | # Initialize the hub.
6 | hub = PrimeHub()
7 |
8 | # Rotate the display. Now right is up.
9 | hub.display.orientation(up=Side.RIGHT)
10 |
11 | # Display a number. This will be shown sideways.
12 | hub.display.number(23)
13 |
14 | # Wait so we can see what is displayed.
15 | wait(10000)
16 |
--------------------------------------------------------------------------------
/examples/micropython/const.py:
--------------------------------------------------------------------------------
1 | from micropython import const
2 |
3 | # This value can be used here. Other files can import it too.
4 | APPLES = const(123)
5 |
6 | # These values can only be used within this file.
7 | _ORANGES = const(1 << 8)
8 | _BANANAS = const(789 + _ORANGES)
9 |
10 | # You can read the constants as normal values. The compiler
11 | # will just insert the numeric values for you.
12 | fruit = APPLES + _ORANGES + _BANANAS
13 | print(fruit)
14 |
--------------------------------------------------------------------------------
/examples/pup/motor_dc/motor_dc_stop.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import DCMotor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor without rotation sensors on port A.
6 | example_motor = DCMotor(Port.A)
7 |
8 | # Start and stop 10 times.
9 | for count in range(10):
10 | print("Counter:", count)
11 |
12 | example_motor.dc(70)
13 | wait(1000)
14 |
15 | example_motor.stop()
16 | wait(1000)
17 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_pixel.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.tools import wait
3 |
4 | # Initialize the hub.
5 | hub = PrimeHub()
6 |
7 | # Turn on the pixel at row 1, column 2.
8 | hub.display.pixel(1, 2)
9 | wait(2000)
10 |
11 | # Turn on the pixel at row 2, column 4, at 50% brightness.
12 | hub.display.pixel(2, 4, 50)
13 | wait(2000)
14 |
15 | # Turn off the pixel at row 1, column 2.
16 | hub.display.pixel(1, 2, 0)
17 | wait(2000)
18 |
--------------------------------------------------------------------------------
/examples/ev3/buttons/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_extra/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_basics/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/light_color/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/screen_draw/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/screen_extra/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/screen_image/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/screen_print/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/speaker_basics/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/uart_basics/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_action_wait.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 |
4 | # Initialize motors on port A and B.
5 | track_motor = Motor(Port.A)
6 | gripper_motor = Motor(Port.B)
7 |
8 | # Make the track motor start moving,
9 | # but don't wait for it to finish.
10 | track_motor.run_angle(500, 360, wait=False)
11 |
12 | # Now make the gripper motor rotate. This
13 | # means they move at the same time.
14 | gripper_motor.run_angle(200, 720)
15 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_client/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/client.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_server/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/server.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/buttons_quickstart/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_image.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.tools import wait
3 | from pybricks.parameters import Icon
4 |
5 | # Initialize the hub.
6 | hub = PrimeHub()
7 |
8 | # Display a big arrow pointing up.
9 | hub.display.icon(Icon.UP)
10 |
11 | # Wait so we can see what is displayed.
12 | wait(2000)
13 |
14 | # Display a heart at half brightness.
15 | hub.display.icon(Icon.HEART / 2)
16 |
17 | # Wait so we can see what is displayed.
18 | wait(2000)
19 |
--------------------------------------------------------------------------------
/doc/main/diagrams_source/Makefile:
--------------------------------------------------------------------------------
1 |
2 | SRC_DIR = .
3 | OUT_DIR = ../diagrams
4 | SVG := $(wildcard $(SRC_DIR)/*.svg)
5 | DIAGRAMS := $(patsubst $(SRC_DIR)/%.svg,$(OUT_DIR)/%$(POSTFIX).png,$(SVG))
6 | DIR := ${CURDIR}
7 |
8 | all: $(DIAGRAMS)
9 |
10 | clean:
11 | rm -f $(DIAGRAMS)
12 |
13 | $(OUT_DIR)/%.png: $(SRC_DIR)/%.svg
14 | inkscape \
15 | --export-area-page \
16 | --export-background=none \
17 | --export-background-opacity=0.0 \
18 | --export-filename=$(DIR)/$@ \
19 | $(DIR)/$<; \
20 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/light_blink.py:
--------------------------------------------------------------------------------
1 | # ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.parameters import Color
4 | from pybricks.tools import wait
5 |
6 | # Initialize the hub
7 | hub = ThisHub()
8 |
9 | # Keep blinking red on and off.
10 | hub.light.blink(Color.RED, [500, 500])
11 |
12 | wait(10000)
13 |
14 | # Keep blinking green slowly and then quickly.
15 | hub.light.blink(Color.GREEN, [500, 500, 50, 900])
16 |
17 | wait(10000)
18 |
--------------------------------------------------------------------------------
/examples/pup/sensor_tilt/basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import TiltSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | accel = TiltSensor(Port.A)
7 |
8 | while True:
9 | # Read the tilt angles relative to the horizontal plane.
10 | pitch, roll = accel.tilt()
11 |
12 | # Print the values
13 | print("Pitch:", pitch, "Roll:", roll)
14 |
15 | # Wait some time so we can read what is printed.
16 | wait(100)
17 |
--------------------------------------------------------------------------------
/examples/ev3/vernier_surface_temperature/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/ev3/ps4/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/examples/ev3/datalog/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/examples/ev3/rcx_touch/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/examples/micropython/system_exit.py:
--------------------------------------------------------------------------------
1 | from pybricks.tools import wait
2 |
3 | print("Started!")
4 |
5 | try:
6 |
7 | # Run your script here as you normally would. In this
8 | # example we just wait forever and do nothing.
9 | while True:
10 | wait(1000)
11 |
12 | except SystemExit:
13 | # This code will run when you press the stop button.
14 | # This can be useful to "clean up", such as to move
15 | # the motors back to their starting positions.
16 | print("You pressed the stop button!")
17 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_init_basic.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor on port A.
6 | example_motor = Motor(Port.A)
7 |
8 | # Make the motor run clockwise at 500 degrees per second.
9 | example_motor.run(500)
10 |
11 | # Wait for three seconds.
12 | wait(3000)
13 |
14 | # Make the motor run counterclockwise at 500 degrees per second.
15 | example_motor.run(-500)
16 |
17 | # Wait for three seconds.
18 | wait(3000)
19 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_read_spike/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.hubs import EV3Brick
3 | from pybricks.tools import wait
4 |
5 | from connection import SpikePrimeStreamReader
6 |
7 | # Beep!
8 | ev3 = EV3Brick()
9 | ev3.speaker.beep()
10 |
11 | # Create the connection. See README.md to find the address for your SPIKE hub.
12 | spike = SpikePrimeStreamReader("F4:84:4C:AA:C8:A4")
13 |
14 | # Now you can simply read values!
15 | for i in range(100):
16 | print(spike.values())
17 | wait(100)
18 |
--------------------------------------------------------------------------------
/examples/ev3/datalog_extra/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/examples/ev3/getting_started/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_orientation_imu.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.parameters import Icon
3 | from pybricks.tools import wait
4 |
5 | # Initialize the hub.
6 | hub = PrimeHub()
7 |
8 | while True:
9 |
10 | # Check which side of the hub is up.
11 | up_side = hub.imu.up()
12 |
13 | # Use this side to set the display orientation.
14 | hub.display.orientation(up_side)
15 |
16 | # Display something, like an arrow.
17 | hub.display.icon(Icon.UP)
18 |
19 | wait(10)
20 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_read_spike/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "ms-python.python",
8 | "ms-python.black-formatter"
9 | ],
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_pc/pybricks/README.md:
--------------------------------------------------------------------------------
1 | This is a partial implementation of the pybricks package that is normally
2 | included in Pybricks MicroPython for EV3. It makes the PC look like an EV3 so
3 | other EV3 bricks can connect to it and vice versa.
4 |
5 | It has the same end user API, so the same documentation applies:
6 | https://docs.pybricks.com/en/latest/messaging.html
7 |
8 | This is a Python3 modification of the original Pybricks MicroPython version:
9 | https://github.com/pybricks/pybricks-micropython/tree/master/bricks/ev3dev
10 |
--------------------------------------------------------------------------------
/examples/pup/hub_movehub/randint_implementation.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import MoveHub
2 |
3 | # Initialize the hub.
4 | hub = MoveHub()
5 |
6 | # Initialize "random" seed.
7 | _rand = hub.battery.voltage() + hub.battery.current()
8 |
9 |
10 | # Return a random integer N such that a <= N <= b.
11 | def randint(a, b):
12 | global _rand
13 | _rand = 75 * _rand % 65537 # Lehmer
14 | return _rand * (b - a + 1) // 65537 + a
15 |
16 |
17 | # Generate a few example numbers.
18 | for i in range(5):
19 | print(randint(0, 1000))
20 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_reset_angle.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 |
4 | # Initialize a motor on port A.
5 | example_motor = Motor(Port.A)
6 |
7 | # Reset the angle to 0.
8 | example_motor.reset_angle(0)
9 |
10 | # Reset the angle to 1234.
11 | example_motor.reset_angle(1234)
12 |
13 | # Reset the angle to the absolute angle.
14 | # This is only supported on motors that have
15 | # an absolute encoder. For other motors, this
16 | # will raise an error.
17 | example_motor.reset_angle()
18 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color_distance/color_print.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorDistanceSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorDistanceSensor(Port.A)
7 |
8 | while True:
9 | # Read the color.
10 | color = sensor.color()
11 |
12 | # Print the measured color.
13 | print(color)
14 |
15 | # Move the sensor around and see how
16 | # well you can detect colors.
17 |
18 | # Wait so we can read the value.
19 | wait(100)
20 |
--------------------------------------------------------------------------------
/examples/pup/tools/hub_menu.py:
--------------------------------------------------------------------------------
1 | from pybricks.tools import hub_menu
2 |
3 | # This example assumes that you have three other programs in Pybricks Code,
4 | # called "fly_mission", "drive_mission", and "zigzag". This example creates a
5 | # menu that lets you pick which one to run.
6 |
7 | # Choose a letter.
8 | selected = hub_menu("F", "D", "Z")
9 |
10 | # Based on the selection, run a program.
11 | if selected == "F":
12 | import fly_mission
13 | elif selected == "D":
14 | import drive_mission
15 | elif selected == "Z":
16 | import zigzag
17 |
--------------------------------------------------------------------------------
/examples/ev3/ps4/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/buttons/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/datalog/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/ev3devsensor/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 | from pybricks.iodevices import Ev3devSensor
5 |
6 | # Initialize an Ev3devSensor.
7 | # In this example we use the
8 | # LEGO MINDSTORMS EV3 Color Sensor.
9 | sensor = Ev3devSensor(Port.S3)
10 |
11 | while True:
12 | # Read the raw RGB values
13 | r, g, b = sensor.read("RGB-RAW")
14 |
15 | # Print results
16 | print("R: {0}\t G: {1}\t B: {2}".format(r, g, b))
17 |
18 | # Wait
19 | wait(200)
20 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_basics/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/i2c_extra/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/light_color/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/rcx_touch/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/screen_draw/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/uart_basics/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_client/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_pc/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "PC Bluetooth Example",
9 | "type": "python",
10 | "request": "launch",
11 | "program": "pcclient.py",
12 | "console": "integratedTerminal"
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_server/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/datalog_extra/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/ev3devsensor/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/getting_started/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/screen_extra/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/screen_image/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/screen_print/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/speaker_basics/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_read_spike/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/buttons_quickstart/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/screen_image/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | from pybricks.hubs import EV3Brick
4 | from pybricks.tools import wait
5 | from pybricks.media.ev3dev import Image, ImageFile
6 |
7 | # It takes some time to load images from the SD card, so it is best to load
8 | # them once at the beginning of a program like this:
9 | ev3_img = Image(ImageFile.EV3_ICON)
10 |
11 |
12 | # Initialize the EV3
13 | ev3 = EV3Brick()
14 |
15 |
16 | # Show an image
17 | ev3.screen.load_image(ev3_img)
18 |
19 | # Wait some time to look at the image
20 | wait(5000)
21 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/light_hsv.py:
--------------------------------------------------------------------------------
1 | # ThisHub = CityHub TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.parameters import Color
4 | from pybricks.tools import wait
5 |
6 | # Initialize the hub.
7 | hub = ThisHub()
8 |
9 | # Show the color at 30% brightness.
10 | hub.light.on(Color.RED * 0.3)
11 |
12 | wait(2000)
13 |
14 | # Use your own custom color.
15 | hub.light.on(Color(h=30, s=100, v=50))
16 |
17 | wait(2000)
18 |
19 | # Go through all the colors.
20 | for hue in range(360):
21 | hub.light.on(Color(hue))
22 | wait(10)
23 |
--------------------------------------------------------------------------------
/examples/pup/motor_dc/motor_dc_init_basic.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import DCMotor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor without rotation sensors on port A.
6 | example_motor = DCMotor(Port.A)
7 |
8 | # Make the motor go clockwise (forward) at 70% duty cycle ("70% power").
9 | example_motor.dc(70)
10 |
11 | # Wait for three seconds.
12 | wait(3000)
13 |
14 | # Make the motor go counterclockwise (backward) at 70% duty cycle.
15 | example_motor.dc(-70)
16 |
17 | # Wait for three seconds.
18 | wait(3000)
19 |
--------------------------------------------------------------------------------
/doc/main/iodevices/dcmotor.rst:
--------------------------------------------------------------------------------
1 | EV3 DC Motor
2 | ^^^^^^^^^^^^^^^^^^
3 |
4 | .. note::
5 |
6 | This class is specifically for on EV3. For Powered Up DC Motors, just use
7 | the :class:`DCMotor ` class.
8 |
9 | .. figure:: ../../main/cad/output/iodevice-dcmotor.png
10 | :width: 40 %
11 |
12 | .. autoclass:: pybricks.iodevices.DCMotor
13 | :noindex:
14 | :no-members:
15 |
16 | .. automethod:: pybricks.iodevices.DCMotor.dc
17 | :noindex:
18 |
19 | .. automethod:: pybricks.iodevices.DCMotor.stop
20 | :noindex:
21 |
--------------------------------------------------------------------------------
/examples/ev3/rcx_touch/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.hubs import EV3Brick
3 | from pybricks.iodevices import AnalogSensor
4 | from pybricks.parameters import Port, Color
5 | from pybricks.tools import wait
6 |
7 |
8 | class RCXTouchSensor(AnalogSensor):
9 | def pressed(self):
10 | return self.resistance() < 50 * 1000
11 |
12 |
13 | ev3 = EV3Brick()
14 | btn = RCXTouchSensor(Port.S1)
15 |
16 | while True:
17 | if btn.pressed():
18 | ev3.light.on(Color.ORANGE)
19 | else:
20 | ev3.light.off()
21 | wait(10)
22 |
--------------------------------------------------------------------------------
/examples/pup/motor_pf/motor_pf_basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorDistanceSensor, PFMotor
2 | from pybricks.parameters import Port, Color
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorDistanceSensor(Port.B)
7 |
8 | # Initialize a motor on channel 1, on the red output.
9 | motor = PFMotor(sensor, 1, Color.RED)
10 |
11 | # Rotate and then stop.
12 | motor.dc(100)
13 | wait(1000)
14 | motor.stop()
15 | wait(1000)
16 |
17 | # Rotate the other way at half speed, and then stop.
18 | motor.dc(-50)
19 | wait(1000)
20 | motor.stop()
21 |
--------------------------------------------------------------------------------
/examples/pup/remote/basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Remote
2 | from pybricks.parameters import Button
3 | from pybricks.tools import wait
4 |
5 | # Connect to the remote.
6 | my_remote = Remote()
7 |
8 | while True:
9 | # Check which buttons are pressed.
10 | pressed = my_remote.buttons.pressed()
11 |
12 | # Show the result.
13 | print("pressed:", pressed)
14 |
15 | # Check a specific button.
16 | if Button.CENTER in pressed:
17 | print("You pressed the center button!")
18 |
19 | # Wait so we can see the result.
20 | wait(100)
21 |
--------------------------------------------------------------------------------
/examples/ev3/vernier_surface_temperature/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/examples/ev3/buttons/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | from pybricks.hubs import EV3Brick
4 | from pybricks.tools import wait
5 | from pybricks.parameters import Button
6 |
7 | # Initialize the EV3
8 | ev3 = EV3Brick()
9 |
10 | # Wait until any of the buttons are pressed
11 | while not any(ev3.buttons.pressed()):
12 | wait(10)
13 |
14 | # Do something if the left button is pressed
15 | if Button.LEFT in ev3.buttons.pressed():
16 | print("The left button is pressed.")
17 |
18 | # Wait until all buttons are released
19 | while any(ev3.buttons.pressed()):
20 | wait(10)
21 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/button_stop.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.parameters import Button
3 |
4 | # Initialize the hub.
5 | hub = PrimeHub()
6 |
7 | # Configure the stop button combination. Now, your program stops
8 | # if you press the center and Bluetooth buttons simultaneously.
9 | hub.system.set_stop_button((Button.CENTER, Button.BLUETOOTH))
10 |
11 | # Now we can use the center button as a normal button.
12 | while True:
13 |
14 | # Play a sound if the center button is pressed.
15 | if Button.CENTER in hub.buttons.pressed():
16 | hub.speaker.beep()
17 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color/color_print.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorSensor(Port.A)
7 |
8 | while True:
9 | # Read the color and reflection
10 | color = sensor.color()
11 | reflection = sensor.reflection()
12 |
13 | # Print the measured color and reflection.
14 | print(color, reflection)
15 |
16 | # Move the sensor around and see how
17 | # well you can detect colors.
18 |
19 | # Wait so we can read the value.
20 | wait(100)
21 |
--------------------------------------------------------------------------------
/examples/micropython/oserror.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 |
4 | from uerrno import ENODEV
5 |
6 | try:
7 | # Try to initialize a motor.
8 | my_motor = Motor(Port.A)
9 |
10 | # If all goes well, you'll see this message.
11 | print("Detected a motor.")
12 | except OSError as ex:
13 | # If an OSError was raised, we can check what
14 | # kind of error this was, like ENODEV.
15 | if ex.errno == ENODEV:
16 | # ENODEV is short for "Error, no device."
17 | print("There is no motor this port.")
18 | else:
19 | print("Another error occurred.")
20 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color/cleanup.py:
--------------------------------------------------------------------------------
1 | from pybricks.parameters import Port
2 | from pybricks.pupdevices import ColorSensor
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorSensor(Port.A)
7 |
8 |
9 | def main():
10 | # Run the main code.
11 | while True:
12 | print(sensor.color())
13 | wait(500)
14 |
15 |
16 | # Wrap the main code in try/finally so that the cleanup code always runs
17 | # when the program ends, even if an exception was raised.
18 | try:
19 | main()
20 | finally:
21 | # The cleanup code goes here.
22 | print("Cleaning up.")
23 | sensor.lights.off()
24 |
--------------------------------------------------------------------------------
/examples/pup/sensor_ultrasonic/basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import UltrasonicSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | eyes = UltrasonicSensor(Port.A)
7 |
8 | while True:
9 | # Print the measured distance.
10 | print(eyes.distance())
11 |
12 | # If an object is detected closer than 500mm:
13 | if eyes.distance() < 500:
14 | # Turn the lights on.
15 | eyes.lights.on(100)
16 | else:
17 | # Turn the lights off.
18 | eyes.lights.off()
19 |
20 | # Wait some time so we can read what is printed.
21 | wait(100)
22 |
--------------------------------------------------------------------------------
/.github/workflows/publish-jedi.yml:
--------------------------------------------------------------------------------
1 | name: Release @pybricks/jedi
2 |
3 | on:
4 | push:
5 | tags:
6 | - '@pybricks/jedi/**'
7 |
8 | jobs:
9 | publish_jedi:
10 | runs-on: ubuntu-22.04
11 | steps:
12 | - uses: actions/checkout@v3
13 | # Setup .npmrc file to publish to npm
14 | - uses: actions/setup-node@v3
15 | with:
16 | node-version: '16.x'
17 | registry-url: 'https://registry.npmjs.org'
18 | - run: ./build.py
19 | working-directory: npm/jedi
20 | - run: yarn publish
21 | working-directory: npm/jedi/build
22 | env:
23 | NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
24 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_absolute.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor on port A.
6 | example_motor = Motor(Port.A)
7 |
8 | while True:
9 |
10 | # Get the default angle value.
11 | angle = example_motor.angle()
12 |
13 | # Get the angle between 0 and 360.
14 | absolute_angle = example_motor.angle() % 360
15 |
16 | # Get the angle between -180 and 179.
17 | wrapped_angle = (example_motor.angle() + 180) % 360 - 180
18 |
19 | # Print the results.
20 | print(angle, absolute_angle, wrapped_angle)
21 | wait(100)
22 |
--------------------------------------------------------------------------------
/doc/main/iodevices/uartdevice.rst:
--------------------------------------------------------------------------------
1 | Generic UART Device
2 | ^^^^^^^^^^^^^^^^^^^
3 |
4 | .. note::
5 |
6 | This class is **only supported on the EV3** at this time. It could be added
7 | to Powered Up hubs in a future release. If you'd like to see this happen,
8 | be sure to ask us on our `support page`_.
9 |
10 | .. _support page: https://github.com/pybricks/support/issues/
11 |
12 | .. figure:: ../../main/cad/output/iodevice-rj12grey.png
13 | :width: 25 %
14 |
15 | .. autoclass:: pybricks.iodevices.UARTDevice
16 |
17 | **Example: Read and write to a UART device**
18 |
19 | .. literalinclude::
20 | ../../../examples/ev3/uart_basics/main.py
21 |
--------------------------------------------------------------------------------
/examples/ev3/getting_started/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.hubs import EV3Brick
3 | from pybricks.ev3devices import Motor
4 | from pybricks.parameters import Port
5 |
6 | # Create your objects here
7 |
8 | # Initialize the EV3 Brick.
9 | ev3 = EV3Brick()
10 |
11 | # Initialize a motor at port B.
12 | test_motor = Motor(Port.B)
13 |
14 | # Write your program here
15 |
16 | # Play a sound.
17 | ev3.speaker.beep()
18 |
19 | # Run the motor up to 500 degrees per second. To a target angle of 90 degrees.
20 | test_motor.run_target(500, 90)
21 |
22 | # Play another beep sound.
23 | ev3.speaker.beep(frequency=1000, duration=500)
24 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_animate.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.parameters import Icon
3 | from pybricks.tools import wait
4 |
5 | # Initialize the hub.
6 | hub = PrimeHub()
7 |
8 | # Turn the hub light off (optional).
9 | hub.light.off()
10 |
11 | # Create a list of intensities from 0 to 100 and back.
12 | brightness = list(range(0, 100, 4)) + list(range(100, 0, -4))
13 |
14 | # Create an animation of the heart icon with changing brightness.
15 | hub.display.animate([Icon.HEART * i / 100 for i in brightness], 30)
16 |
17 | # The animation repeats in the background. Here we just wait.
18 | while True:
19 | wait(100)
20 |
--------------------------------------------------------------------------------
/examples/ev3/datalog_extra/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.parameters import Color
3 | from pybricks.tools import DataLog
4 |
5 | # Create a data log file called my_file.txt
6 | data = DataLog("time", "angle", name="my_file", timestamp=False, extension="txt")
7 |
8 | # The log method uses the print() method to add a line of text.
9 | # So, you can do much more than saving numbers. For example:
10 | data.log("Temperature", 25)
11 | data.log("Sunday", "Monday", "Tuesday")
12 | data.log({"Kiwi": Color.GREEN}, {"Banana": Color.YELLOW})
13 |
14 | # You can upload the file to your computer, but you can also print the data:
15 | print(data)
16 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color/hsv.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorSensor(Port.A)
7 |
8 | while True:
9 | # The standard color() method always "rounds" the
10 | # measurement to the nearest "whole" color.
11 | # That's useful for most applications.
12 |
13 | # But you can get the original hue, saturation,
14 | # and value without "rounding", as follows:
15 | color = sensor.hsv()
16 |
17 | # Print the results.
18 | print(color)
19 |
20 | # Wait so we can read the value.
21 | wait(500)
22 |
--------------------------------------------------------------------------------
/.github/workflows/publish-images.yml:
--------------------------------------------------------------------------------
1 | name: Release @pybricks/images
2 |
3 | on:
4 | push:
5 | tags:
6 | - '@pybricks/images/**'
7 |
8 | jobs:
9 | publish_ide_docs:
10 | runs-on: ubuntu-22.04
11 | steps:
12 | - uses: actions/checkout@v3
13 | # Setup .npmrc file to publish to npm
14 | - uses: actions/setup-node@v3
15 | with:
16 | node-version: '16.x'
17 | registry-url: 'https://registry.npmjs.org'
18 | - run: ./build.py
19 | working-directory: npm/images
20 | - run: yarn publish
21 | working-directory: npm/images/build
22 | env:
23 | NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
24 |
--------------------------------------------------------------------------------
/.readthedocs.yml:
--------------------------------------------------------------------------------
1 | # .readthedocs.yaml
2 | # Read the Docs configuration file
3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4 |
5 | # Required
6 | version: 2
7 |
8 | build:
9 | os: "ubuntu-22.04"
10 | tools:
11 | python: "3.10"
12 | jobs:
13 | post_create_environment:
14 | - pip install poetry
15 | post_install:
16 | - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only=doc
17 |
18 | # Build documentation in the doc/main/ directory with Sphinx
19 | sphinx:
20 | configuration: doc/main/conf.py
21 |
22 | # Optionally build your docs in additional formats such as PDF
23 | formats:
24 | - pdf
25 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_action_wait_advanced.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize motors on port A and B.
6 | track_motor = Motor(Port.A)
7 | gripper_motor = Motor(Port.B)
8 |
9 | # Make both motors perform an action with wait=False
10 | track_motor.run_angle(500, 360, wait=False)
11 | gripper_motor.run_angle(200, 720, wait=False)
12 |
13 | # While one or both of the motors are not done yet,
14 | # do something else. In this example, just wait.
15 | while not track_motor.done() or not gripper_motor.done():
16 | wait(10)
17 |
18 | print("Both motors are done!")
19 |
--------------------------------------------------------------------------------
/doc/main/iodevices/pupdevice.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: pybricks-iodevices
2 |
3 | Powered Up Device
4 | ^^^^^^^^^^^^^^^^^
5 |
6 | .. figure:: ../cad/output/iodevice-pupdevice.png
7 | :width: 60 %
8 |
9 | .. autoclass:: pybricks.iodevices.PUPDevice
10 | :no-members:
11 |
12 | .. automethod:: pybricks.iodevices.PUPDevice.info
13 |
14 | .. automethod:: pybricks.iodevices.PUPDevice.read
15 |
16 | .. automethod:: pybricks.iodevices.PUPDevice.write
17 |
18 | Examples
19 | -------------------
20 |
21 | Detecting devices
22 | ******************************
23 |
24 | .. literalinclude::
25 | ../../../examples/pup/iodevices_pupdevice/port_info.py
26 |
--------------------------------------------------------------------------------
/examples/ev3/ev3devsensor/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Main Example",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py"
12 | },
13 | {
14 | "name": "Class Example",
15 | "type": "ev3devBrowser",
16 | "request": "launch",
17 | "program": "/home/robot/${workspaceRootFolderName}/class_example.py"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_measure.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor on port A.
6 | example_motor = Motor(Port.A)
7 |
8 | # Start moving at 300 degrees per second.
9 | example_motor.run(300)
10 |
11 | # Display the angle and speed 50 times.
12 | for i in range(100):
13 |
14 | # Read the angle (degrees) and speed (degrees per second).
15 | angle = example_motor.angle()
16 | speed = example_motor.speed()
17 |
18 | # Print the values.
19 | print(angle, speed)
20 |
21 | # Wait some time so we can read what is displayed.
22 | wait(200)
23 |
--------------------------------------------------------------------------------
/doc/main/parameters/port.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements::
2 |
3 | Port
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. class:: Port
7 |
8 | Input and output ports:
9 |
10 | .. autoattribute:: pybricks.parameters.Port.A
11 | :annotation:
12 |
13 | .. autoattribute:: pybricks.parameters.Port.B
14 | :annotation:
15 |
16 | .. autoattribute:: pybricks.parameters.Port.C
17 | :annotation:
18 |
19 | .. autoattribute:: pybricks.parameters.Port.D
20 | :annotation:
21 |
22 | .. autoattribute:: pybricks.parameters.Port.E
23 | :annotation:
24 |
25 | .. autoattribute:: pybricks.parameters.Port.F
26 | :annotation:
27 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/imu_read_scalar.py:
--------------------------------------------------------------------------------
1 | # ThisHub = TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.tools import wait
4 | from pybricks.parameters import Axis
5 |
6 | # Initialize the hub.
7 | hub = ThisHub()
8 |
9 | # Get the acceleration or angular_velocity along a single axis.
10 | # If you need only one value, this is more memory efficient.
11 | while True:
12 |
13 | # Read the forward acceleration.
14 | forward_acceleration = hub.imu.acceleration(Axis.X)
15 |
16 | # Read the yaw rate.
17 | yaw_rate = hub.imu.angular_velocity(Axis.Z)
18 |
19 | # Print the yaw rate.
20 | print(yaw_rate)
21 | wait(100)
22 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color_distance/hsv.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorDistanceSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorDistanceSensor(Port.A)
7 |
8 | while True:
9 | # The standard color() method always "rounds" the
10 | # measurement to the nearest "whole" color.
11 | # That's useful for most applications.
12 |
13 | # But you can get the original hue, saturation,
14 | # and value without "rounding", as follows:
15 | color = sensor.hsv()
16 |
17 | # Print the results.
18 | print(color)
19 |
20 | # Wait so we can read the value.
21 | wait(500)
22 |
--------------------------------------------------------------------------------
/doc/main/pupdevices/tiltsensor.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements::
2 |
3 | Tilt Sensor
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. figure:: ../../main/cad/output/pupdevice-tilt.png
7 | :width: 35 %
8 |
9 | .. blockimg:: pybricks_variables_set_tilt_sensor
10 |
11 | .. autoclass:: pybricks.pupdevices.TiltSensor
12 | :no-members:
13 |
14 | .. blockimg:: pybricks_blockTilt_TiltSensor_imu.tilt.pitch
15 |
16 | .. blockimg:: pybricks_blockTilt_TiltSensor_imu.tilt.roll
17 |
18 | .. automethod:: tilt
19 |
20 | Examples
21 | -------------------
22 |
23 | Measuring pitch and roll
24 | ************************
25 |
26 | .. literalinclude::
27 | ../../../examples/pup/sensor_tilt/basics.py
28 |
--------------------------------------------------------------------------------
/examples/pup/light/math.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Light
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait, StopWatch
4 |
5 | from umath import pi, cos
6 |
7 | # Initialize the light and a StopWatch.
8 | light = Light(Port.A)
9 | watch = StopWatch()
10 |
11 | # Cosine pattern properties.
12 | PERIOD = 2000
13 | MAX = 100
14 |
15 | # Make the brightness fade in and out.
16 | while True:
17 | # Get phase of the cosine.
18 | phase = watch.time() / PERIOD * 2 * pi
19 |
20 | # Evaluate the brightness.
21 | brightness = (0.5 - 0.5 * cos(phase)) * MAX
22 |
23 | # Set light brightness and wait a bit.
24 | light.on(brightness)
25 | wait(10)
26 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_init_gears.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port, Direction
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor on port A with the positive direction as counterclockwise.
6 | # Also specify one gear train with a 12-tooth and a 36-tooth gear. The 12-tooth
7 | # gear is attached to the motor axle. The 36-tooth gear is at the output axle.
8 | geared_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE, [12, 36])
9 |
10 | # Make the output axle run at 100 degrees per second. The motor speed
11 | # is automatically increased to compensate for the gears.
12 | geared_motor.run(100)
13 |
14 | # Wait for three seconds.
15 | wait(3000)
16 |
--------------------------------------------------------------------------------
/examples/pup/sensor_infrared/basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import InfraredSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | ir = InfraredSensor(Port.A)
7 |
8 | while True:
9 | # Read all the information we can get from this sensor.
10 | dist = ir.distance()
11 | count = ir.count()
12 | ref = ir.reflection()
13 |
14 | # Print the values
15 | print("Distance:", dist, "Count:", count, "Reflection:", ref)
16 |
17 | # Move the sensor around and move your hands in front
18 | # of it to see what happens to the values.
19 |
20 | # Wait some time so we can read what is printed.
21 | wait(200)
22 |
--------------------------------------------------------------------------------
/examples/pup/sensor_force/basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ForceSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | button = ForceSensor(Port.A)
7 |
8 | while True:
9 | # Read all the information we can get from this sensor.
10 | force = button.force()
11 | dist = button.distance()
12 | press = button.pressed()
13 | touch = button.touched()
14 |
15 | # Print the values
16 | print("Force", force, "Dist:", dist, "Pressed:", press, "Touched:", touch)
17 |
18 | # Push the sensor button see what happens to the values.
19 |
20 | # Wait some time so we can read what is printed.
21 | wait(200)
22 |
--------------------------------------------------------------------------------
/examples/micropython/memstat.py:
--------------------------------------------------------------------------------
1 | from micropython import const, opt_level, mem_info, qstr_info, stack_use
2 |
3 | # Get stack at start.
4 | stack_start = stack_use()
5 |
6 | # Print REPL compiler optimization level.
7 | print("level", opt_level())
8 |
9 | # Print memory usage.
10 | mem_info()
11 |
12 | # Print memory usage and a memory map.
13 | mem_info(True)
14 |
15 | # Print interned string information.
16 | qstr_info()
17 |
18 | # Print interned string information and their names.
19 | APPLES = const(123)
20 | _ORANGES = const(456)
21 | qstr_info(True)
22 |
23 |
24 | def test_stack():
25 | return stack_use()
26 |
27 |
28 | # Check the stack.
29 | print("Stack diff: ", test_stack() - stack_start)
30 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_init_direction.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port, Direction
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor on port A with the positive direction as counterclockwise.
6 | example_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
7 |
8 | # When we choose a positive speed value, the motor now goes counterclockwise.
9 | example_motor.run(500)
10 |
11 | # This is useful when your motor is mounted in reverse or upside down.
12 | # By changing the positive direction, your script will be easier to read,
13 | # because a positive value now makes your robot/mechanism go forward.
14 |
15 | # Wait for three seconds.
16 | wait(3000)
17 |
--------------------------------------------------------------------------------
/npm/images/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 |
4 |
5 | ## 1.4.0 - 2022-12-19
6 |
7 | ### Added
8 | - Added existing NXT and EV3 hub images to published package.
9 |
10 | ## 1.3.0 - 2022-12-19
11 |
12 | ### Added
13 | - Added DFU Windows driver images.
14 |
15 | ## 1.2.1 - 2022-11-08
16 |
17 | ### Changed
18 | - Changed size of some icons.
19 |
20 | ## 1.2.0 - 2022-10-28
21 |
22 | ### Changed
23 | - Changed all icon files to have the same dimensions.
24 |
25 | ## 1.1.0 - 2022-10-28
26 |
27 | ### Added
28 | - Added MINDSTORMS Robot Inventor hub image.
29 |
30 | ## 1.0.0 - 2022-10-28
31 |
32 | ### Added
33 | - Added new @pybricks/images package.
34 |
--------------------------------------------------------------------------------
/doc/main/pupdevices/colorlightmatrix.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements::
2 |
3 | Color Light Matrix
4 | ^^^^^^^^^^^^^^^^^^
5 |
6 | .. figure:: ../../main/diagrams/sensor_colorlightmatrix.png
7 | :width: 35 %
8 |
9 | .. blockimg:: pybricks_variables_set_color_light_matrix
10 |
11 | .. autoclass:: pybricks.pupdevices.ColorLightMatrix
12 | :no-members:
13 |
14 | .. blockimg:: pybricks_blockLightOnColor_colorlightmatrix_on
15 |
16 | .. blockimg:: pybricks_blockLightOnColor_colorlightmatrix_on_list
17 |
18 | .. automethod:: pybricks.pupdevices.ColorLightMatrix.on
19 |
20 | .. blockimg:: pybricks_blockLightOnColor_colorlightmatrix_off
21 |
22 | .. automethod:: pybricks.pupdevices.ColorLightMatrix.off
23 |
--------------------------------------------------------------------------------
/examples/micropython/keyboard_interrupt.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the motor.
6 | test_motor = Motor(Port.A)
7 |
8 | # Start moving at 500 deg/s.
9 | test_motor.run(500)
10 |
11 | # If you click on the terminal window and press CTRL+C,
12 | # you can continue debugging in this terminal.
13 | wait(5000)
14 |
15 | # You can also do this to exit the script and enter the
16 | # terminal. Variables in the global scope are still available.
17 | raise KeyboardInterrupt
18 |
19 | # For example, you can copy the following line to the terminal
20 | # to get the angle, because test_motor is still available.
21 | test_motor.angle()
22 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color_distance/distance_blink.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorDistanceSensor
2 | from pybricks.parameters import Port, Color
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorDistanceSensor(Port.A)
7 |
8 | # Repeat forever.
9 | while True:
10 |
11 | # If the sensor sees an object nearby.
12 | if sensor.distance() <= 40:
13 |
14 | # Then blink the light red/blue 5 times.
15 | for i in range(5):
16 | sensor.light.on(Color.RED)
17 | wait(30)
18 | sensor.light.on(Color.BLUE)
19 | wait(30)
20 | else:
21 | # If the sensor sees nothing
22 | # nearby, just wait briefly.
23 | wait(10)
24 |
--------------------------------------------------------------------------------
/jedi/pyproject.toml:
--------------------------------------------------------------------------------
1 | [tool.poetry]
2 | name = "pybricks_jedi"
3 | version = "1.17.0"
4 | description = "Code completion for Pybricks."
5 | authors = ["The Pybricks Authors "]
6 | license = "MIT"
7 |
8 | [tool.poetry.dependencies]
9 | python = ">= 3.10, < 3.12"
10 | pybricks = "3.6.0b5"
11 | jedi = "0.18.1"
12 | typing-extensions = "4.2.0"
13 | docstring-parser = "0.14.1"
14 |
15 | [tool.poetry.dev-dependencies]
16 | pytest = "^7.1.2"
17 | black = "^22.3.0"
18 | flake8 = "^4.0.1"
19 | pybricks = { path = "../", develop = true }
20 |
21 | [build-system]
22 | requires = ["poetry-core>=1.0.0"]
23 | build-backend = "poetry.core.masonry.api"
24 |
25 | [tool.pytest.ini_options]
26 | pythonpath = ["src"]
27 | testpaths = ["tests"]
28 |
--------------------------------------------------------------------------------
/npm/ide-docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@pybricks/ide-docs",
3 | "version": "2.20.0",
4 | "description": "Special build of Pybricks API docs for embedding in an IDE.",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/pybricks/pybricks-api",
8 | "directory": "npm/ide-docs"
9 | },
10 | "publishConfig": {
11 | "registry": "https://registry.npmjs.org",
12 | "access": "public"
13 | },
14 | "author": "The Pybricks Authors",
15 | "license": "MIT",
16 | "files": [
17 | "html"
18 | ],
19 | "scripts": {
20 | "clean": "poetry run make -C ../../doc clean",
21 | "build": "poetry run make -C ../../doc TAG=ide html && rm -rf html && cp -R ../../doc/main/build/html html"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/doc/main/micropython/uerrno.rst:
--------------------------------------------------------------------------------
1 | :mod:`uerrno ` -- Error codes
2 | ============================================================
3 |
4 | .. module:: uerrno
5 |
6 | The ``errno`` attribute of an :ref:`OSError ` indicates why this
7 | exception was raised. This attribute has one of the following values.
8 | See also :ref:`this example `.
9 |
10 | .. autodata:: uerrno.EAGAIN
11 |
12 | .. autodata:: uerrno.EBUSY
13 |
14 | .. autodata:: uerrno.ECANCELED
15 |
16 | .. autodata:: uerrno.EINVAL
17 |
18 | .. autodata:: uerrno.EIO
19 |
20 | .. autodata:: uerrno.ENODEV
21 |
22 | .. autodata:: uerrno.EOPNOTSUPP
23 |
24 | .. autodata:: uerrno.EPERM
25 |
26 | .. autodata:: uerrno.ETIMEDOUT
27 |
28 | .. autodata:: uerrno.errorcode
29 |
--------------------------------------------------------------------------------
/examples/pup/motor_dc/motor_dc_init_direction.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import DCMotor
2 | from pybricks.parameters import Port, Direction
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor without rotation sensors on port A,
6 | # with the positive direction as counterclockwise.
7 | example_motor = DCMotor(Port.A, Direction.COUNTERCLOCKWISE)
8 |
9 | # When we choose a positive duty cycle, the motor now goes counterclockwise.
10 | example_motor.dc(70)
11 |
12 | # This is useful when your (train) motor is mounted in reverse or upside down.
13 | # By changing the positive direction, your script will be easier to read,
14 | # because a positive value now makes your train/robot go forward.
15 |
16 | # Wait for three seconds.
17 | wait(3000)
18 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_basics/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.hubs import EV3Brick
3 | from pybricks.iodevices import I2CDevice
4 | from pybricks.parameters import Port
5 |
6 | # Initialize the EV3
7 | ev3 = EV3Brick()
8 |
9 | # Initialize I2C Sensor
10 | device = I2CDevice(Port.S2, 0xD2 >> 1)
11 |
12 | # Read one byte from the device.
13 | # For this device, we can read the Who Am I
14 | # register (0x0F) for the expected value: 211.
15 | if 211 not in device.read(0x0F):
16 | raise ValueError("Unexpected I2C device ID")
17 |
18 | # To write data, create a bytes object of one
19 | # or more bytes. For example:
20 | # data = bytes((1, 2, 3))
21 |
22 | # Write one byte (value 0x08) to register 0x22
23 | device.write(0x22, bytes((0x08,)))
24 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/light_animate.py:
--------------------------------------------------------------------------------
1 | # ThisHub = CityHub TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.parameters import Color
4 | from pybricks.tools import wait
5 | from umath import sin, pi
6 |
7 | # Initialize the hub.
8 | hub = ThisHub()
9 |
10 | # Make an animation with multiple colors.
11 | hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
12 |
13 | wait(10000)
14 |
15 | # Make the color RED grow faint and bright using a sine pattern.
16 | hub.light.animate([Color.RED * (0.5 * sin(i / 15 * pi) + 0.5) for i in range(30)], 40)
17 |
18 | wait(10000)
19 |
20 | # Cycle through a rainbow of colors.
21 | hub.light.animate([Color(h=i * 8) for i in range(45)], interval=40)
22 |
23 | wait(10000)
24 |
--------------------------------------------------------------------------------
/doc/main/micropython/urandom.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: stm32-extra
2 |
3 | :mod:`urandom` -- Pseudo-random numbers
4 | ================================================
5 |
6 | .. automodule:: urandom
7 | :no-members:
8 |
9 | .. rubric:: Basic random numbers
10 |
11 | .. blockimg:: pybricks_blockRandInt
12 |
13 | .. autofunction:: randint
14 |
15 | .. autofunction:: random
16 |
17 | .. rubric:: Random numbers from a range
18 |
19 | .. autofunction:: getrandbits
20 |
21 | .. autofunction:: randrange
22 |
23 | .. autofunction:: uniform
24 |
25 | .. rubric:: Random elements from a sequence
26 |
27 | .. autofunction:: choice
28 |
29 | .. rubric:: Updating the random seed
30 |
31 | .. autofunction:: seed
32 |
33 |
--------------------------------------------------------------------------------
/doc/main/parameters/index.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements::
2 |
3 | :mod:`parameters ` -- Parameters and constants
4 | ===================================================================
5 |
6 | .. automodule:: pybricks.parameters
7 | :no-members:
8 |
9 | .. toctree::
10 | :maxdepth: 1
11 | :hidden:
12 |
13 | axis
14 | button
15 | color
16 | direction
17 | icon
18 | port
19 | side
20 | stop
21 |
22 | .. pybricks-classlink:: Axis
23 |
24 | .. pybricks-classlink:: Button
25 |
26 | .. pybricks-classlink:: Color
27 |
28 | .. pybricks-classlink:: Direction
29 |
30 | .. pybricks-classlink:: Icon
31 |
32 | .. pybricks-classlink:: Port
33 |
34 | .. pybricks-classlink:: Side
35 |
36 | .. pybricks-classlink:: Stop
37 |
38 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/imu_tilt_blast.py:
--------------------------------------------------------------------------------
1 | # ThisHub = TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.tools import wait
4 | from pybricks.parameters import Axis
5 |
6 | # Initialize the hub. In this case, specify that the hub is mounted with the
7 | # top side facing forward and the front side facing to the right.
8 | # For example, this is how the hub is mounted in BLAST in the 51515 set.
9 | hub = ThisHub(top_side=Axis.X, front_side=-Axis.Y)
10 |
11 | while True:
12 | # Read the tilt values. Now, the values are 0 when BLAST stands upright.
13 | # Leaning forward gives positive pitch. Leaning right gives positive roll.
14 | pitch, roll = hub.imu.tilt()
15 |
16 | # Print the result.
17 | print(pitch, roll)
18 | wait(200)
19 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/button_single.py:
--------------------------------------------------------------------------------
1 | # ThisHub = MoveHub CityHub TechnicHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.parameters import Color, Button
4 | from pybricks.tools import wait, StopWatch
5 |
6 | # Initialize the hub.
7 | hub = ThisHub()
8 |
9 | # Disable the stop button.
10 | hub.system.set_stop_button(None)
11 |
12 | # Check the button for 5 seconds.
13 | watch = StopWatch()
14 | while watch.time() < 5000:
15 |
16 | # Set light to green if pressed, else red.
17 | if hub.buttons.pressed():
18 | hub.light.on(Color.GREEN)
19 | else:
20 | hub.light.on(Color.RED)
21 |
22 | # Enable the stop button again.
23 | hub.system.set_stop_button(Button.CENTER)
24 |
25 | # Now you can press the stop button as usual.
26 | wait(5000)
27 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_stop.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor on port A.
6 | example_motor = Motor(Port.A)
7 |
8 | # Run at 500 deg/s and then stop by coasting.
9 | example_motor.run(500)
10 | wait(1500)
11 | example_motor.stop()
12 | wait(1500)
13 |
14 | # Run at 500 deg/s and then stop by braking.
15 | example_motor.run(500)
16 | wait(1500)
17 | example_motor.brake()
18 | wait(1500)
19 |
20 | # Run at 500 deg/s and then stop by holding.
21 | example_motor.run(500)
22 | wait(1500)
23 | example_motor.hold()
24 | wait(1500)
25 |
26 | # Run at 500 deg/s and then stop by running at 0 speed.
27 | example_motor.run(500)
28 | wait(1500)
29 | example_motor.run(0)
30 | wait(1500)
31 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color/lights_blink.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorSensor(Port.A)
7 |
8 | # Repeat forever.
9 | while True:
10 |
11 | # Turn on one light at a time, at half the brightness.
12 | # Do this for all 3 lights and repeat that 5 times.
13 | for i in range(5):
14 | sensor.lights.on([50, 0, 0])
15 | wait(100)
16 | sensor.lights.on([0, 50, 0])
17 | wait(100)
18 | sensor.lights.on([0, 0, 50])
19 | wait(100)
20 |
21 | # Turn all lights on at maximum brightness.
22 | sensor.lights.on(100)
23 | wait(500)
24 |
25 | # Turn all lights off.
26 | sensor.lights.off()
27 | wait(500)
28 |
--------------------------------------------------------------------------------
/examples/ev3/screen_draw/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | from pybricks.hubs import EV3Brick
4 | from pybricks.tools import wait
5 |
6 |
7 | # Initialize the EV3
8 | ev3 = EV3Brick()
9 |
10 |
11 | # Draw a rectangle
12 | ev3.screen.draw_box(10, 10, 40, 40)
13 |
14 | # Draw a solid rectangle
15 | ev3.screen.draw_box(20, 20, 30, 30, fill=True)
16 |
17 | # Draw a rectangle with rounded corners
18 | ev3.screen.draw_box(50, 10, 80, 40, 5)
19 |
20 | # Draw a circle
21 | ev3.screen.draw_circle(25, 75, 20)
22 |
23 | # Draw a triangle using lines
24 | x1, y1 = 65, 55
25 | x2, y2 = 50, 95
26 | x3, y3 = 80, 95
27 | ev3.screen.draw_line(x1, y1, x2, y2)
28 | ev3.screen.draw_line(x2, y2, x3, y3)
29 | ev3.screen.draw_line(x3, y3, x1, y1)
30 |
31 | # Wait some time to look at the shapes
32 | wait(5000)
33 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_action_then.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port, Stop
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor on port A.
6 | example_motor = Motor(Port.A)
7 |
8 | # By default, the motor holds the position. It keeps
9 | # correcting the angle if you move it.
10 | example_motor.run_angle(500, 360)
11 | wait(1000)
12 |
13 | # This does exactly the same as above.
14 | example_motor.run_angle(500, 360, then=Stop.HOLD)
15 | wait(1000)
16 |
17 | # You can also brake. This applies some resistance
18 | # but the motor does not move back if you move it.
19 | example_motor.run_angle(500, 360, then=Stop.BRAKE)
20 | wait(1000)
21 |
22 | # This makes the motor coast freely after it stops.
23 | example_motor.run_angle(500, 360, then=Stop.COAST)
24 | wait(1000)
25 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_server/server.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | # Before running this program, make sure the client and server EV3 bricks are
4 | # paired using Bluetooth, but do NOT connect them. The program will take care
5 | # of establishing the connection.
6 |
7 | # The server must be started before the client!
8 |
9 | from pybricks.messaging import BluetoothMailboxServer, TextMailbox
10 |
11 | server = BluetoothMailboxServer()
12 | mbox = TextMailbox("greeting", server)
13 |
14 | # The server must be started before the client!
15 | print("waiting for connection...")
16 | server.wait_for_connection()
17 | print("connected!")
18 |
19 | # In this program, the server waits for the client to send the first message
20 | # and then sends a reply.
21 | mbox.wait()
22 | print(mbox.read())
23 | mbox.send("hello to you!")
24 |
--------------------------------------------------------------------------------
/examples/ev3/uart_basics/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.hubs import EV3Brick
3 | from pybricks.iodevices import UARTDevice
4 | from pybricks.parameters import Port
5 | from pybricks.media.ev3dev import SoundFile
6 |
7 | # Initialize the EV3
8 | ev3 = EV3Brick()
9 |
10 | # Initialize sensor port 2 as a uart device
11 | ser = UARTDevice(Port.S2, baudrate=115200)
12 |
13 | # Write some data
14 | ser.write(b"\r\nHello, world!\r\n")
15 |
16 | # Play a sound while we wait for some data
17 | for i in range(3):
18 | ev3.speaker.play_file(SoundFile.HELLO)
19 | ev3.speaker.play_file(SoundFile.GOOD)
20 | ev3.speaker.play_file(SoundFile.MORNING)
21 | print("Bytes waiting to be read:", ser.waiting())
22 |
23 | # Read all data received while the sound was playing
24 | data = ser.read_all()
25 | print(data)
26 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color/wait_for_color.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorSensor
2 | from pybricks.parameters import Port, Color
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorSensor(Port.A)
7 |
8 |
9 | # This is a function that waits for a desired color.
10 | def wait_for_color(desired_color):
11 | # While the color is not the desired color, we keep waiting.
12 | while sensor.color() != desired_color:
13 | wait(20)
14 |
15 |
16 | # Now we use the function we just created above.
17 | while True:
18 |
19 | # Here you can make your train/vehicle go forward.
20 |
21 | print("Waiting for red ...")
22 | wait_for_color(Color.RED)
23 |
24 | # Here you can make your train/vehicle go backward.
25 |
26 | print("Waiting for blue ...")
27 | wait_for_color(Color.BLUE)
28 |
--------------------------------------------------------------------------------
/jedi/tests/test_complete_local_private.py:
--------------------------------------------------------------------------------
1 | import json
2 | from pybricks_jedi import CompletionItem, complete
3 |
4 |
5 | def test_get_completion_for_private_globals():
6 | code = """
7 | _X = 0
8 |
9 | _
10 | """
11 | completions: list[CompletionItem] = json.loads(complete(code, 4, 2))
12 | assert [c["insertText"] for c in completions] == ["_X", "__name__"]
13 |
14 |
15 | def test_get_completion_for_private_attributes():
16 | code = """
17 | class X:
18 | def __init__(self):
19 | self.public = 0
20 | self._protected = 0
21 | self.__private = 0
22 |
23 | x = X()
24 |
25 | x.
26 | """
27 | completions: list[CompletionItem] = json.loads(complete(code, 10, 3))
28 | assert [c["insertText"] for c in completions] == [
29 | "public",
30 | "_protected",
31 | "__init__",
32 | ]
33 |
--------------------------------------------------------------------------------
/jedi/tests/conftest.py:
--------------------------------------------------------------------------------
1 | import pybricks_jedi
2 |
3 |
4 | def pytest_configure(config):
5 | """
6 | Allows plugins and conftest files to perform initial configuration.
7 | This hook is called for every plugin and initial conftest
8 | file after command line options have been parsed.
9 | """
10 |
11 |
12 | def pytest_sessionstart(session):
13 | """
14 | Called after the Session object has been created and
15 | before performing collection and entering the run test loop.
16 | """
17 | pybricks_jedi.initialize()
18 |
19 |
20 | def pytest_sessionfinish(session, exitstatus):
21 | """
22 | Called after whole test run finished, right before
23 | returning the exit status to the system.
24 | """
25 |
26 |
27 | def pytest_unconfigure(config):
28 | """
29 | called before test process is exited.
30 | """
31 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_client/client.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | # Before running this program, make sure the client and server EV3 bricks are
4 | # paired using Bluetooth, but do NOT connect them. The program will take care
5 | # of establishing the connection.
6 |
7 | # The server must be started before the client!
8 |
9 | from pybricks.messaging import BluetoothMailboxClient, TextMailbox
10 |
11 | # This is the name of the remote EV3 or PC we are connecting to.
12 | SERVER = "ev3dev"
13 |
14 | client = BluetoothMailboxClient()
15 | mbox = TextMailbox("greeting", client)
16 |
17 | print("establishing connection...")
18 | client.connect(SERVER)
19 | print("connected!")
20 |
21 | # In this program, the client sends the first message and then waits for the
22 | # server to reply.
23 | mbox.send("hello!")
24 | mbox.wait()
25 | print(mbox.read())
26 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/imu_up.py:
--------------------------------------------------------------------------------
1 | # ThisHub = TechnicHub PrimeHub MoveHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.parameters import Color, Side
4 | from pybricks.tools import wait
5 |
6 | # Initialize the hub.
7 | hub = ThisHub()
8 |
9 | # Define colors for each side in a dictionary.
10 | SIDE_COLORS = {
11 | Side.TOP: Color.RED,
12 | Side.BOTTOM: Color.BLUE,
13 | Side.LEFT: Color.GREEN,
14 | Side.RIGHT: Color.YELLOW,
15 | Side.FRONT: Color.MAGENTA,
16 | Side.BACK: Color.BLACK,
17 | }
18 |
19 | # Keep updating the color based on detected up side.
20 | while True:
21 |
22 | # Check which side of the hub is up.
23 | up_side = hub.imu.up()
24 |
25 | # Change the color based on the side.
26 | hub.light.on(SIDE_COLORS[up_side])
27 |
28 | # Also print the result.
29 | print(up_side)
30 | wait(50)
31 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color_distance/wait_for_color.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorDistanceSensor
2 | from pybricks.parameters import Port, Color
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorDistanceSensor(Port.A)
7 |
8 |
9 | # This is a function that waits for a desired color.
10 | def wait_for_color(desired_color):
11 | # While the color is not the desired color, we keep waiting.
12 | while sensor.color() != desired_color:
13 | wait(20)
14 |
15 |
16 | # Now we use the function we just created above.
17 | while True:
18 |
19 | # Here you can make your train/vehicle go forward.
20 |
21 | print("Waiting for red ...")
22 | wait_for_color(Color.RED)
23 |
24 | # Here you can make your train/vehicle go backward.
25 |
26 | print("Waiting for blue ...")
27 | wait_for_color(Color.BLUE)
28 |
--------------------------------------------------------------------------------
/doc/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS = -W
6 | SPHINXBUILD = sphinx-build
7 | SPHINXPROJ = Pybricks
8 | SOURCEDIR = main
9 | BUILDDIR = "$(SOURCEDIR)"/build
10 | TAG = main
11 |
12 | # Put it first so that "make" without argument is like "make help".
13 | help:
14 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(TAG) $(O)
15 |
16 | .PHONY: help Makefile
17 |
18 | diagrams:
19 | @$(MAKE) -C "$(SOURCEDIR)"/diagrams_source clean
20 | @$(MAKE) -C "$(SOURCEDIR)"/diagrams_source
21 |
22 | # Catch-all target: route all unknown targets to Sphinx using the new
23 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
24 | %: Makefile
25 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) -t $(TAG) $(O)
26 |
--------------------------------------------------------------------------------
/doc/main/pupdevices/light.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements::
2 |
3 | Light
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. figure:: ../../main/cad/output/pupdevice-light.png
7 | :width: 35 %
8 |
9 | .. blockimg:: pybricks_variables_set_light
10 |
11 | .. autoclass:: pybricks.pupdevices.Light
12 | :no-members:
13 |
14 | .. blockimg:: pybricks_blockLightOn_light_on
15 |
16 | .. automethod:: pybricks.pupdevices.Light.on
17 |
18 | .. blockimg:: pybricks_blockLightOn_light_off
19 |
20 | .. automethod:: pybricks.pupdevices.Light.off
21 |
22 | Examples
23 | -------------------
24 |
25 | Making the light blink
26 | **********************
27 |
28 | .. literalinclude::
29 | ../../../examples/pup/light/basics.py
30 |
31 | Gradually change the brightness
32 | *******************************
33 |
34 | .. literalinclude::
35 | ../../../examples/pup/light/math.py
36 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/button_main.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.parameters import Button, Icon
3 | from pybricks.tools import wait
4 |
5 | # Initialize the hub.
6 | hub = PrimeHub()
7 |
8 | # Wait for any button to be pressed, and save the result.
9 | pressed = []
10 | while not any(pressed):
11 | pressed = hub.buttons.pressed()
12 | wait(10)
13 |
14 | # Display a circle.
15 | hub.display.icon(Icon.CIRCLE)
16 |
17 | # Wait for all buttons to be released.
18 | while any(hub.buttons.pressed()):
19 | wait(10)
20 |
21 | # Display an arrow to indicate which button was pressed.
22 | if Button.LEFT in pressed:
23 | hub.display.icon(Icon.ARROW_LEFT_DOWN)
24 | elif Button.RIGHT in pressed:
25 | hub.display.icon(Icon.ARROW_RIGHT_DOWN)
26 | elif Button.BLUETOOTH in pressed:
27 | hub.display.icon(Icon.ARROW_RIGHT_UP)
28 |
29 | wait(3000)
30 |
--------------------------------------------------------------------------------
/examples/ev3/buttons_quickstart/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | from pybricks.hubs import EV3Brick
4 | from pybricks.parameters import Button
5 |
6 | from menu import wait_for_button
7 |
8 | # Initialize the EV3.
9 | ev3 = EV3Brick()
10 |
11 | while True:
12 | # Show the menu and wait for one button to be selected.
13 | button = wait_for_button(ev3)
14 |
15 | # Now you can do something, based on which button was pressed.
16 |
17 | # In this demo, we just play a different sound for each button.
18 | if button == Button.LEFT:
19 | ev3.speaker.beep(200)
20 | elif button == Button.RIGHT:
21 | ev3.speaker.beep(400)
22 | elif button == Button.UP:
23 | ev3.speaker.beep(600)
24 | elif button == Button.DOWN:
25 | ev3.speaker.beep(800)
26 | elif button == Button.CENTER:
27 | ev3.speaker.beep(1000)
28 |
--------------------------------------------------------------------------------
/examples/pup/robotics/drivebase_async.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Direction, Port
3 | from pybricks.robotics import DriveBase
4 | from pybricks.tools import multitask, run_task
5 |
6 | # Set up all devices.
7 | left = Motor(Port.A, Direction.COUNTERCLOCKWISE)
8 | right = Motor(Port.B)
9 | gripper = Motor(Port.C)
10 | drive_base = DriveBase(left, right, 56, 114)
11 |
12 |
13 | # Move the gripper up and down.
14 | async def move_gripper():
15 | await gripper.run_angle(500, -90)
16 | await gripper.run_angle(500, 90)
17 |
18 |
19 | # Drive forward, turn move gripper at the same time, and drive backward.
20 | async def main():
21 | await drive_base.straight(250)
22 | await multitask(drive_base.turn(90), move_gripper())
23 | await drive_base.straight(-250)
24 |
25 |
26 | # Runs the main program from start to finish.
27 | run_task(main())
28 |
--------------------------------------------------------------------------------
/examples/pup/motor_pf/motor_pf_pwm.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorDistanceSensor, PFMotor
2 | from pybricks.parameters import Port, Color, Direction
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorDistanceSensor(Port.B)
7 |
8 | # You can use multiple motors on different channels.
9 | arm = PFMotor(sensor, 1, Color.BLUE)
10 | wheel = PFMotor(sensor, 4, Color.RED, Direction.COUNTERCLOCKWISE)
11 |
12 | # Accelerate both motors. Only these values are available.
13 | # Other values will be rounded down to the nearest match.
14 | for duty in [15, 30, 45, 60, 75, 90, 100]:
15 | arm.dc(duty)
16 | wheel.dc(duty)
17 | wait(1000)
18 |
19 | # To make the signal more reliable, there is a short
20 | # pause between commands. So, they change speed and
21 | # stop at a slightly different time.
22 |
23 | # Brake both motors.
24 | arm.brake()
25 | wheel.brake()
26 |
--------------------------------------------------------------------------------
/.github/workflows/jedi.yml:
--------------------------------------------------------------------------------
1 | name: pybricks_jedi
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | test:
7 | if: github.ref_type != 'tag'
8 | runs-on: ubuntu-22.04
9 | steps:
10 | - uses: actions/checkout@v3
11 | - run: pipx install poetry
12 | - run: poetry install
13 | working-directory: ./jedi
14 | - run: poetry run pytest -vv
15 | working-directory: ./jedi
16 |
17 | publish:
18 | if: github.ref_type == 'tag' && startsWith(github.ref_name, 'pybricks_jedi/')
19 | runs-on: ubuntu-22.04
20 | steps:
21 | - uses: actions/checkout@v3
22 | - run: pipx install poetry
23 | - run: poetry install
24 | working-directory: ./jedi
25 | - run: poetry build
26 | working-directory: ./jedi
27 | - run: poetry publish
28 | working-directory: ./jedi
29 | env:
30 | POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_PYBRICKS_JEDI_TOKEN }}
31 |
--------------------------------------------------------------------------------
/examples/ev3/screen_print/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | from pybricks.hubs import EV3Brick
4 | from pybricks.tools import wait
5 | from pybricks.media.ev3dev import Font
6 |
7 | # It takes some time for fonts to load from file, so it is best to only
8 | # load them once at the beginning of the program like this:
9 | tiny_font = Font(size=6)
10 | big_font = Font(size=24, bold=True)
11 | chinese_font = Font(size=24, lang="zh-cn")
12 |
13 |
14 | # Initialize the EV3
15 | ev3 = EV3Brick()
16 |
17 |
18 | # Say hello
19 | ev3.screen.print("Hello!")
20 |
21 | # Say tiny hello
22 | ev3.screen.set_font(tiny_font)
23 | ev3.screen.print("hello")
24 |
25 | # Say big hello
26 | ev3.screen.set_font(big_font)
27 | ev3.screen.print("HELLO")
28 |
29 | # Say Chinese hello
30 | ev3.screen.set_font(chinese_font)
31 | ev3.screen.print("你好")
32 |
33 | # Wait some time to look at the screen
34 | wait(5000)
35 |
--------------------------------------------------------------------------------
/examples/pup/hub_common/ble_broadcast.py:
--------------------------------------------------------------------------------
1 | # ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
2 | from pybricks.hubs import ThisHub
3 | from pybricks.pupdevices import Motor
4 | from pybricks.parameters import Port
5 | from pybricks.tools import wait
6 |
7 | # Initialize the hub.
8 | hub = ThisHub(broadcast_channel=1)
9 |
10 | # Initialize the motors.
11 | left_motor = Motor(Port.A)
12 | right_motor = Motor(Port.B)
13 |
14 | while True:
15 | # Read the motor angles to be sent to the other hub.
16 | left_angle = left_motor.angle()
17 | right_angle = right_motor.angle()
18 |
19 | # Set the broadcast data and start broadcasting if not already doing so.
20 | data = (left_angle, right_angle)
21 | hub.ble.broadcast(data)
22 |
23 | # Broadcasts are only sent every 100 milliseconds, so there is no reason
24 | # to call the broadcast() method more often than that.
25 | wait(100)
26 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color/color_ambient.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorSensor(Port.A)
7 |
8 | # Repeat forever.
9 | while True:
10 |
11 | # Get the ambient color values. Instead of scanning the color of a surface,
12 | # this lets you scan the color of light sources like lamps or screens.
13 | hsv = sensor.hsv(surface=False)
14 | color = sensor.color(surface=False)
15 |
16 | # Get the ambient light intensity.
17 | ambient = sensor.ambient()
18 |
19 | # Print the measurements.
20 | print(hsv, color, ambient)
21 |
22 | # Point the sensor at a computer screen or colored light. Watch the color.
23 | # Also, cover the sensor with your hands and watch the ambient value.
24 |
25 | # Wait so we can read the printed line
26 | wait(100)
27 |
--------------------------------------------------------------------------------
/doc/main/iodevices/index.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: pybricks-iodevices
2 |
3 | :mod:`iodevices ` -- Custom devices
4 | ============================================================
5 |
6 | .. module:: pybricks.iodevices
7 |
8 | .. toctree::
9 | :maxdepth: 1
10 | :hidden:
11 |
12 | pupdevice
13 | lwp3device
14 | xboxcontroller
15 |
16 | This module has classes for generic and custom input/output devices.
17 |
18 | .. pybricks-classlink:: PUPDevice
19 |
20 | .. figure:: ../../main/cad/output/iodevice-pupdevice.png
21 | :width: 50 %
22 | :target: pupdevice.html
23 |
24 | .. pybricks-classlink:: LWP3Device
25 |
26 | .. figure:: ../../main/cad/output/hub-lwp3.png
27 | :width: 80 %
28 | :target: lwp3device.html
29 |
30 | .. pybricks-classlink:: XboxController
31 |
32 | .. figure:: ../../main/diagrams_source/xboxcontroller.png
33 | :width: 40 %
34 | :target: xboxcontroller.html
35 |
--------------------------------------------------------------------------------
/doc/main/pupdevices/infraredsensor.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements::
2 |
3 | Infrared Sensor
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. figure:: ../../main/cad/output/pupdevice-infrared.png
7 | :width: 35 %
8 |
9 | .. blockimg:: pybricks_variables_set_infrared_sensor
10 |
11 | .. autoclass:: pybricks.pupdevices.InfraredSensor
12 | :no-members:
13 |
14 | .. blockimg:: pybricks_blockDistance_InfraredSensor
15 |
16 | .. automethod:: pybricks.pupdevices.InfraredSensor.distance
17 |
18 | .. blockimg:: pybricks_blockLightReflection_InfraredSensor
19 |
20 | .. automethod:: pybricks.pupdevices.InfraredSensor.reflection
21 |
22 | .. automethod:: pybricks.pupdevices.InfraredSensor.count
23 |
24 | Examples
25 | -------------------
26 |
27 | Measuring distance, object count, and reflection
28 | ************************************************
29 |
30 | .. literalinclude::
31 | ../../../examples/pup/sensor_infrared/basics.py
32 |
--------------------------------------------------------------------------------
/examples/pup/parameters/color_basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.parameters import Color
2 |
3 | # You can print colors. Colors may be obtained from the Color class, or
4 | # from sensors that return color measurements.
5 | print(Color.RED)
6 |
7 | # You can read hue, saturation, and value properties.
8 | print(Color.RED.h, Color.RED.s, Color.RED.v)
9 |
10 | # You can make your own colors. Saturation and value are 100 by default.
11 | my_green = Color(h=125)
12 | my_dark_green = Color(h=125, s=80, v=30)
13 |
14 | # When you print custom colors, you see exactly how they were defined.
15 | print(my_dark_green)
16 |
17 | # You can also add colors to the builtin colors.
18 | Color.MY_DARK_BLUE = Color(h=235, s=80, v=30)
19 |
20 | # When you add them like this, printing them only shows its name. But you can
21 | # still read h, s, v by reading its attributes.
22 | print(Color.MY_DARK_BLUE)
23 | print(Color.MY_DARK_BLUE.h, Color.MY_DARK_BLUE.s, Color.MY_DARK_BLUE.v)
24 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_read_spike/rover.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.hubs import EV3Brick
3 | from pybricks.tools import wait
4 | from pybricks.ev3devices import Motor
5 | from pybricks.robotics import DriveBase
6 | from pybricks.parameters import Port
7 |
8 | from connection import SpikePrimeStreamReader
9 |
10 | # Beep!
11 | ev3 = EV3Brick()
12 | ev3.speaker.beep()
13 |
14 | # Create the connection. See README.md to find the address for your SPIKE hub.
15 | spike = SpikePrimeStreamReader("F4:84:4C:AA:C8:A4")
16 |
17 | # Initialize the motors and drive base
18 | left_motor = Motor(Port.B)
19 | right_motor = Motor(Port.C)
20 | robot = DriveBase(left_motor, right_motor, wheel_diameter=55.5, axle_track=104)
21 |
22 | while True:
23 | # Read the orientation
24 | yaw, pitch, roll = spike.orientation()
25 |
26 | # Set speed and turn rate based on orientation
27 | robot.drive(-pitch * 6, roll * 2)
28 | wait(20)
29 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_matrix.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.tools import wait, Matrix
3 |
4 | # Initialize the hub.
5 | hub = PrimeHub()
6 |
7 | # Make a square that is bright on the outside and faint in the middle.
8 | SQUARE = Matrix(
9 | [
10 | [100, 100, 100, 100, 100],
11 | [100, 50, 50, 50, 100],
12 | [100, 50, 0, 50, 100],
13 | [100, 50, 50, 50, 100],
14 | [100, 100, 100, 100, 100],
15 | ]
16 | )
17 |
18 | # Display the square.
19 | hub.display.icon(SQUARE)
20 | wait(3000)
21 |
22 | # Make an image using a Python list comprehension. In this image, the
23 | # brightness of each pixel is the sum of the row and column index. So the
24 | # light is faint in the top left and bright in the bottom right.
25 | GRADIENT = Matrix([[(r + c) for c in range(5)] for r in range(5)]) * 12.5
26 |
27 | # Display the generated gradient.
28 | hub.display.icon(GRADIENT)
29 | wait(3000)
30 |
--------------------------------------------------------------------------------
/doc/main/micropython/uselect.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements:: stm32-extra
2 |
3 | :mod:`uselect` -- Wait for events
4 | =================================
5 |
6 | .. automodule:: uselect
7 | :no-members:
8 |
9 | .. rubric:: Poll instance and class
10 |
11 | .. autofunction:: poll
12 |
13 | .. autoclass:: Poll
14 | :no-members:
15 |
16 | .. automethod:: register
17 |
18 | .. automethod:: unregister
19 |
20 | .. automethod:: modify
21 |
22 | .. automethod:: poll
23 |
24 | .. automethod:: ipoll
25 |
26 | .. rubric:: Event mask flags
27 |
28 | .. autodata:: POLLIN
29 |
30 | .. autodata:: POLLOUT
31 |
32 | .. autodata:: POLLERR
33 |
34 | .. autodata:: POLLHUP
35 |
36 | Examples
37 | ---------------
38 |
39 | See the `projects website`_ for a demo that uses this module.
40 |
41 | .. _projects website: https://pybricks.com/projects/tutorials/wireless/hub-to-device/pc-keyboard/
42 |
--------------------------------------------------------------------------------
/examples/ev3/buttons_quickstart/menu.py:
--------------------------------------------------------------------------------
1 | def wait_for_button(ev3):
2 | """
3 | This function shows a picture of the buttons on the EV3 screen.
4 |
5 | Then it waits until you press a button.
6 |
7 | It returns which button was pressed.
8 | """
9 |
10 | # Show a picture of the buttons on the screen.
11 | ev3.screen.load_image("buttons.png")
12 |
13 | # Tip: add text or icons to the image to help you
14 | # remember what each button will do in your program.
15 |
16 | # Wait for a single button to be pressed and save the result.
17 | pressed = []
18 | while len(pressed) != 1:
19 | pressed = ev3.buttons.pressed()
20 | button = pressed[0]
21 |
22 | # Print which button was pressed
23 | ev3.screen.draw_text(2, 100, button)
24 |
25 | # Now wait for the button to be released.
26 | while any(ev3.buttons.pressed()):
27 | pass
28 |
29 | # Return which button was pressed.
30 | return button
31 |
--------------------------------------------------------------------------------
/doc/common/extensions/versionchanged.py:
--------------------------------------------------------------------------------
1 | """This directive hides the builtin directives
2 | * versionchanged
3 | * versionadded
4 | * deprecated
5 | when building documentation with the 'ide' tag.
6 | """
7 | from docutils import nodes
8 | from docutils.parsers.rst import Directive
9 |
10 |
11 | class PybricksVersionDirective(Directive):
12 |
13 | has_content = True
14 |
15 | def run(self):
16 | html = ""
17 | node = nodes.raw("", html, format="html")
18 | return [node]
19 |
20 |
21 | def setup(app):
22 | if "ide" in app.tags.tags:
23 | app.add_directive_to_domain(
24 | "py", "deprecated", PybricksVersionDirective, override=True
25 | )
26 | app.add_directive_to_domain(
27 | "py", "versionadded", PybricksVersionDirective, override=True
28 | )
29 | app.add_directive_to_domain(
30 | "py", "versionchanged", PybricksVersionDirective, override=True
31 | )
32 |
--------------------------------------------------------------------------------
/examples/pup/sensor_ultrasonic/math.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import UltrasonicSensor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait, StopWatch
4 |
5 | from umath import pi, sin
6 |
7 | # Initialize the sensor.
8 | eyes = UltrasonicSensor(Port.A)
9 |
10 | # Initialize a timer.
11 | watch = StopWatch()
12 |
13 | # We want one full light cycle to last three seconds.
14 | PERIOD = 3000
15 |
16 | while True:
17 | # The phase is where we are in the unit circle now.
18 | phase = watch.time() / PERIOD * 2 * pi
19 |
20 | # Each light follows a sine wave with a mean of 50, with an amplitude of 50.
21 | # We offset this sine wave by 90 degrees for each light, so that all the
22 | # lights do something different.
23 | brightness = [sin(phase + offset * pi / 2) * 50 + 50 for offset in range(4)]
24 |
25 | # Set the brightness values for all lights.
26 | eyes.lights.on(brightness)
27 |
28 | # Wait some time.
29 | wait(50)
30 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_until_stalled_center.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize a motor on port A.
6 | example_motor = Motor(Port.A)
7 |
8 | # Please have a look at the previous example first. This example
9 | # finds two endspoints and then makes the middle the zero point.
10 |
11 | # The run_until_stalled gives us the angle at which it stalled.
12 | # We want to know this value for both endpoints.
13 | left_end = example_motor.run_until_stalled(-200, duty_limit=30)
14 | right_end = example_motor.run_until_stalled(200, duty_limit=30)
15 |
16 | # We have just moved to the rightmost endstop. So, we can reset
17 | # this angle to be half the distance between the two endpoints.
18 | # That way, the middle corresponds to 0 degrees.
19 | example_motor.reset_angle((right_end - left_end) / 2)
20 |
21 | # From now on we can simply run towards zero to reach the middle.
22 | example_motor.run_target(200, 0)
23 |
24 | wait(1000)
25 |
--------------------------------------------------------------------------------
/.vscode/spellright.dict:
--------------------------------------------------------------------------------
1 | °C
2 | °F
3 | Ω
4 | accelerometer
5 | Aragonese
6 | autoattribute
7 | autoclass
8 | autofunction
9 | automethod
10 | automodule
11 | baudrate
12 | bool
13 | booleans
14 | builtins
15 | cdot
16 | Celcius
17 | cityhub
18 | technichub
19 | de
20 | dev
21 | en
22 | ev
23 | EV3
24 | ev3brick
25 | ev3dev
26 | ev3devices
27 | Ev3devSensor
28 | fb
29 | Franca
30 | func
31 | i2caddress
32 | int
33 | iodevices
34 | iter
35 | kd
36 | ki
37 | kp
38 | lbf
39 | Huế
40 | LEGO
41 | LEGO®
42 | linacceleration
43 | linspeed
44 | Lingua
45 | literalinclude
46 | Lojban
47 | Lucida
48 | maxdepth
49 | microSDHC
50 | milliampere
51 | millivolt
52 | milliwatt
53 | MINDSTORMS
54 | MINDSTORMS®
55 | movehub
56 | noindex
57 | newproject
58 | numref
59 | NXT
60 | nxtdevices
61 | PCM
62 | pid
63 | png
64 | pupdevices
65 | py
66 | Pybricks
67 | pybricks.ev3devices
68 | relativedistance
69 | rgb
70 | robotframe
71 | rtype
72 | sep
73 | signaltypes
74 | startinstall
75 | str
76 | submodules
77 | thermistor
78 | toctree
79 | TODO
80 | UART
81 | utf-8
82 |
--------------------------------------------------------------------------------
/doc/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SPHINXOPTS=-W
11 | set SOURCEDIR=main
12 | set BUILDDIR=%SOURCEDIR%/build
13 | set SPHINXPROJ=Pybricks
14 | if "%TAG%" == "" (
15 | set TAG=main
16 | )
17 |
18 | if "%1" == "" goto help
19 |
20 | %SPHINXBUILD% >NUL 2>NUL
21 | if errorlevel 9009 (
22 | echo.
23 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
24 | echo.installed, then set the SPHINXBUILD environment variable to point
25 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
26 | echo.may add the Sphinx directory to PATH.
27 | echo.
28 | echo.If you don't have Sphinx installed, grab it from
29 | echo.http://sphinx-doc.org/
30 | exit /b 1
31 | )
32 |
33 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -t %TAG%
34 | goto end
35 |
36 | :help
37 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -t %TAG%
38 |
39 | :end
40 | popd
41 |
--------------------------------------------------------------------------------
/examples/pup/motor/motor_until_stalled.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 |
4 | # Initialize a motor on port A.
5 | example_motor = Motor(Port.A)
6 |
7 | # We'll use a speed of 200 deg/s in all our commands.
8 | speed = 200
9 |
10 | # Run the motor in reverse until it hits a mechanical stop.
11 | # The duty_limit=30 setting means that it will apply only 30%
12 | # of the maximum torque against the mechanical stop. This way,
13 | # you don't push against it with too much force.
14 | example_motor.run_until_stalled(-speed, duty_limit=30)
15 |
16 | # Reset the angle to 0. Now whenever the angle is 0, you know
17 | # that it has reached the mechanical endpoint.
18 | example_motor.reset_angle(0)
19 |
20 | # Now make the motor go back and forth in a loop.
21 | # This will now work the same regardless of the
22 | # initial motor angle, because we always start
23 | # from the mechanical endpoint.
24 | for count in range(10):
25 | example_motor.run_target(speed, 180)
26 | example_motor.run_target(speed, 90)
27 |
--------------------------------------------------------------------------------
/doc/main/pupdevices/forcesensor.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements::
2 |
3 | Force Sensor
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. figure:: ../../main/cad/output/pupdevice-force.png
7 | :width: 35 %
8 |
9 | .. blockimg:: pybricks_variables_set_force_sensor
10 |
11 | .. autoclass:: pybricks.pupdevices.ForceSensor
12 | :no-members:
13 |
14 | .. blockimg:: pybricks_blockForce_ForceSensor
15 |
16 | .. automethod:: pybricks.pupdevices.ForceSensor.force
17 |
18 | .. blockimg:: pybricks_blockDistance_ForceSensor
19 |
20 | .. automethod:: pybricks.pupdevices.ForceSensor.distance
21 |
22 | .. automethod:: pybricks.pupdevices.ForceSensor.pressed
23 |
24 | .. automethod:: pybricks.pupdevices.ForceSensor.touched
25 |
26 | Examples
27 | -------------------
28 |
29 | Measuring force and movement
30 | ****************************
31 |
32 | .. literalinclude::
33 | ../../../examples/pup/sensor_force/basics.py
34 |
35 | Measuring peak force
36 | ********************
37 |
38 | .. literalinclude::
39 | ../../../examples/pup/sensor_force/peak.py
40 |
--------------------------------------------------------------------------------
/examples/ev3/vernier_surface_temperature/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.parameters import Port
3 | from pybricks.nxtdevices import VernierAdapter
4 |
5 | from math import log
6 |
7 |
8 | # Conversion formula for Surface Temperature Sensor
9 | def convert_raw_to_temperature(voltage):
10 |
11 | # Convert the raw voltage to the NTC resistance
12 | # according to the Vernier Adapter EV3 block.
13 | counts = voltage / 5000 * 4096
14 | ntc = 15000 * (counts) / (4130 - counts)
15 |
16 | # Handle log(0) safely: make sure that ntc value is positive.
17 | if ntc <= 0:
18 | ntc = 1
19 |
20 | # Apply Steinhart-Hart equation as given in the sensor documentation.
21 | K0 = 1.02119e-3
22 | K1 = 2.22468e-4
23 | K2 = 1.33342e-7
24 | return 1 / (K0 + K1 * log(ntc) + K2 * log(ntc) ** 3)
25 |
26 |
27 | # Initialize the adapter on port 1
28 | thermometer = VernierAdapter(Port.S1, convert_raw_to_temperature)
29 |
30 | # Get the measured value and print it
31 | temp = thermometer.value()
32 | print(temp)
33 |
--------------------------------------------------------------------------------
/examples/pup/hub_primehub/display_expression.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import PrimeHub
2 | from pybricks.parameters import Icon, Side
3 | from pybricks.tools import wait
4 |
5 | from urandom import randint
6 |
7 | # Initialize the hub.
8 | hub = PrimeHub()
9 | hub.display.orientation(up=Side.RIGHT)
10 |
11 | while True:
12 |
13 | # Start with random left brow: up or down.
14 | if randint(0, 100) < 70:
15 | brows = Icon.EYE_LEFT_BROW * 0.5
16 | else:
17 | brows = Icon.EYE_LEFT_BROW_UP * 0.5
18 |
19 | # Add random right brow: up or down.
20 | if randint(0, 100) < 70:
21 | brows += Icon.EYE_RIGHT_BROW * 0.5
22 | else:
23 | brows += Icon.EYE_RIGHT_BROW_UP * 0.5
24 |
25 | for i in range(3):
26 | # Display eyes open plus the random brows.
27 | hub.display.icon(Icon.EYE_LEFT + Icon.EYE_RIGHT + brows)
28 | wait(2000)
29 |
30 | # Display eyes blinked plus the random brows.
31 | hub.display.icon(Icon.EYE_LEFT_BLINK * 0.7 + Icon.EYE_RIGHT_BLINK * 0.7 + brows)
32 | wait(200)
33 |
--------------------------------------------------------------------------------
/examples/pup/robotics/drivebase_basics.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port, Direction
3 | from pybricks.robotics import DriveBase
4 |
5 | # Initialize both motors. In this example, the motor on the
6 | # left must turn counterclockwise to make the robot go forward.
7 | left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
8 | right_motor = Motor(Port.B)
9 |
10 | # Initialize the drive base. In this example, the wheel diameter is 56mm.
11 | # The distance between the two wheel-ground contact points is 112mm.
12 | drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112)
13 |
14 | # Optionally, uncomment the line below to use the gyro for improved accuracy.
15 | # drive_base.use_gyro(True)
16 |
17 | # Drive forward by 500mm (half a meter).
18 | drive_base.straight(500)
19 |
20 | # Turn around clockwise by 180 degrees.
21 | drive_base.turn(180)
22 |
23 | # Drive forward again to get back to the start.
24 | drive_base.straight(500)
25 |
26 | # Turn around counterclockwise.
27 | drive_base.turn(-180)
28 |
--------------------------------------------------------------------------------
/doc/common/extensions/classlink.py:
--------------------------------------------------------------------------------
1 | from docutils import nodes
2 | from docutils.parsers.rst import Directive
3 |
4 |
5 | class PybricksClasslinkDirective(Directive):
6 |
7 | required_arguments = 1
8 | optional_arguments = 1
9 |
10 | def run(self):
11 | # Get link and name from sphinx-directive
12 | name = self.arguments[0]
13 | link = name if len(self.arguments) == 1 else self.arguments[1]
14 |
15 | html = (
16 | ''.format(link.lower())
17 | + ''
18 | + ""
19 | + 'class '
20 | + ''
21 | + name
22 | + ""
23 | + " "
24 | + " "
25 | + " "
26 | + " "
27 | )
28 |
29 | # Return the node
30 | node = nodes.raw("", html, format="html")
31 | return [node]
32 |
33 |
34 | def setup(app):
35 | app.add_directive_to_domain("py", "pybricks-classlink", PybricksClasslinkDirective)
36 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Sources
2 | ###################
3 | *.o
4 | *.a
5 | *.elf
6 | *.bin
7 | *.map
8 | *.hex
9 | *.dis
10 | *.exe
11 |
12 | # Packages
13 | ############
14 |
15 | # Logs and Databases
16 | ######################
17 | *.log
18 |
19 | # VIM Swap Files
20 | ######################
21 | *.swp
22 |
23 | # Build directory
24 | ######################
25 | build/
26 | build-*/
27 | _build/
28 |
29 | # Tests
30 | ######################
31 | .pytest_cache/
32 | tests/*.exp
33 | tests/*.out
34 |
35 | # Python cache files
36 | ######################
37 | __pycache__/
38 | *.pyc
39 |
40 | # PyPi build files
41 | ######################
42 | *.egg-info/
43 | dist/
44 |
45 | # Customized Makefile/project overrides
46 | ######################
47 | GNUmakefile
48 | user.props
49 |
50 | # Generated rst files
51 | ######################
52 | genrst/
53 |
54 | # Mac OS cache
55 | ######################
56 | .DS_Store
57 |
58 | # Virtual environment
59 | ######################
60 | .venv/
61 | .python-version
62 |
63 | # Generated LDRAW output
64 | ######################
65 | stderr-ldview
66 | stdout-ldview
67 | LPub3D/
68 |
--------------------------------------------------------------------------------
/examples/ev3/i2c_extra/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 | from pybricks.hubs import EV3Brick
3 | from pybricks.iodevices import I2CDevice
4 | from pybricks.parameters import Port
5 |
6 | # Initialize the EV3
7 | ev3 = EV3Brick()
8 |
9 | # Initialize I2C Sensor
10 | device = I2CDevice(Port.S2, 0xD2 >> 1)
11 |
12 | # Recommended for reading
13 | (result,) = device.read(reg=0x0F, length=1)
14 |
15 | # Read 1 byte from no particular register:
16 | device.read(reg=None, length=1)
17 |
18 | # Read 0 bytes from no particular register:
19 | device.read(reg=None, length=0)
20 |
21 | # I2C write operations consist of a register byte followed
22 | # by a series of data bytes. Depending on your device, you
23 | # can choose to skip the register or data as follows:
24 |
25 | # Recommended for writing:
26 | device.write(reg=0x22, data=b"\x08")
27 |
28 | # Write 1 byte to no particular register:
29 | device.write(reg=None, data=b"\x08")
30 |
31 | # Write 0 bytes to a particular register:
32 | device.write(reg=0x08, data=None)
33 |
34 | # Write 0 bytes to no particular register:
35 | device.write(reg=None, data=None)
36 |
--------------------------------------------------------------------------------
/examples/pup/parameters/color_advanced.py:
--------------------------------------------------------------------------------
1 | from pybricks.parameters import Color
2 |
3 | # Two colors are equal if their h, s, and v attributes are equal.
4 | if Color.BLUE == Color(240, 100, 100):
5 | print("Yes, these colors are the same.")
6 |
7 | # You can scale colors to change their brightness value.
8 | red_dark = Color.RED * 0.5
9 |
10 | # You can shift colors to change their hue.
11 | red_shifted = Color.RED >> 30
12 |
13 | # Colors are immutable, so you can't change h, s, or v of an existing object.
14 | try:
15 | Color.GREEN.h = 125
16 | except AttributeError:
17 | print("Sorry, can't change the hue of an existing color object!")
18 |
19 | # But you can override builtin colors by defining a whole new color.
20 | Color.GREEN = Color(h=125)
21 |
22 | # You can access and store colors as class attributes, or as a dictionary.
23 | print(Color.BLUE)
24 | print(Color["BLUE"])
25 | print(Color["BLUE"] is Color.BLUE)
26 | print(Color)
27 | print([c for c in Color])
28 |
29 | # This allows you to update existing colors in a loop.
30 | for name in ("BLUE", "RED", "GREEN"):
31 | Color[name] = Color(1, 2, 3)
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-2022 The Pybricks Authors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/jedi/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 The Pybricks Authors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/jedi/tests/test_complete_inventor_hub.py:
--------------------------------------------------------------------------------
1 | # SPDX-License-Identifier: MIT
2 | # Copyright (c) 2022 The Pybricks Authors
3 |
4 | """
5 | Tests for correct code completion of the InventorHub class.
6 | """
7 |
8 |
9 | import json
10 | from pybricks_jedi import complete, CompletionItem
11 |
12 | IMPORT = "from pybricks.hubs import InventorHub"
13 | CREATE_INSTANCE = "hub = InventorHub()"
14 |
15 |
16 | def _create_snippet(line: str) -> str:
17 | """
18 | Creates a code snippet::
19 |
20 | from pybricks.hubs import InventorHub
21 | hub = InventorHub()
22 | {line}
23 |
24 | Args:
25 | line: The value substituted for ``{line}``
26 | """
27 | return "\n".join((IMPORT, CREATE_INSTANCE, line))
28 |
29 |
30 | # Everything else is the same as the Prime Hub.
31 |
32 | from test_complete_prime_hub import ( # noqa F401
33 | test_hub_dot,
34 | test_hub_dot_battery_dot,
35 | test_hub_dot_buttons_dot,
36 | test_hub_dot_charger_dot,
37 | test_hub_dot_display_dot,
38 | test_hub_dot_imu_dot,
39 | test_hub_dot_light_dot,
40 | test_hub_dot_speaker_dot,
41 | test_hub_dot_system_dot,
42 | )
43 |
--------------------------------------------------------------------------------
/examples/ev3/bluetooth_pc/pcserver.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | from pybricks.messaging import BluetoothMailboxServer, TextMailbox
3 |
4 | # This demo makes your PC talk to an EV3 over Bluetooth.
5 | #
6 | # This is identical to the EV3 server example in ../bluetooth_server
7 | #
8 | # The only difference is that it runs in Python3 on your computer, thanks to
9 | # the Python3 implementation of the messaging module that is included here.
10 | # As far as the EV3 is concerned, it thinks it just talks to an EV3 client.
11 | #
12 | # So, the EV3 client example needs no further modifications. The connection
13 | # procedure is also the same as documented in the messaging module docs:
14 | # https://docs.pybricks.com/en/latest/messaging.html
15 |
16 | server = BluetoothMailboxServer()
17 | mbox = TextMailbox("greeting", server)
18 |
19 | # The server must be started before the client!
20 | print("waiting for connection...")
21 | server.wait_for_connection()
22 | print("connected!")
23 |
24 | # In this program, the server waits for the client to send the first message
25 | # and then sends a reply.
26 | mbox.wait()
27 | print(mbox.read())
28 | mbox.send("hello to you!")
29 |
--------------------------------------------------------------------------------
/npm/ide-docs/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-2023 The Pybricks Authors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/npm/images/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-2022 The Pybricks Authors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/doc/common/extensions/blockimg.py:
--------------------------------------------------------------------------------
1 | from docutils.parsers.rst import Directive
2 | from docutils import nodes
3 | from pathlib import Path
4 |
5 | SPHINX_IMAGE_PATH = "blockimg"
6 |
7 |
8 | def get_svg_content(file_path):
9 | with open(file_path, "r", encoding="utf-8") as file:
10 | return file.read()
11 |
12 |
13 | # Global variable to store the app object
14 | app = None
15 |
16 |
17 | class BlockImageDirective(Directive):
18 | has_content = False
19 | required_arguments = 1
20 | optional_arguments = 0
21 |
22 | def run(self):
23 | # Adjust the image path
24 | file_name = self.arguments[0] + ".svg"
25 | file_path = Path(app.srcdir) / SPHINX_IMAGE_PATH / file_name
26 |
27 | # Read the SVG content
28 | svg_content = get_svg_content(file_path)
29 |
30 | # Create a raw HTML node with the SVG content
31 | raw_html = f'{svg_content}
'
32 | raw_node = nodes.raw("", raw_html, format="html")
33 |
34 | return [raw_node]
35 |
36 |
37 | def setup(apparg):
38 | global app
39 | app = apparg
40 | app.add_directive("blockimg", BlockImageDirective)
41 |
--------------------------------------------------------------------------------
/doc/main/parameters/direction.rst:
--------------------------------------------------------------------------------
1 | .. pybricks-requirements::
2 |
3 | Direction
4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | .. class:: Direction
7 |
8 | Rotational direction for positive speed or angle values.
9 |
10 | .. autoattribute:: pybricks.parameters.Direction.CLOCKWISE
11 | :annotation:
12 |
13 | .. autoattribute:: pybricks.parameters.Direction.COUNTERCLOCKWISE
14 | :annotation:
15 |
16 | +--------------------------------+-------------------+-----------------+
17 | | ``positive_direction =`` | Positive speed: | Negative speed: |
18 | +================================+===================+=================+
19 | | ``Direction.CLOCKWISE`` | clockwise | counterclockwise|
20 | +--------------------------------+-------------------+-----------------+
21 | | ``Direction.COUNTERCLOCKWISE`` | counterclockwise | clockwise |
22 | +--------------------------------+-------------------+-----------------+
23 |
24 | In general, clockwise is defined by **looking at the motor shaft, just
25 | like looking at a clock**. Some motors have two shafts. If in doubt,
26 | refer to the diagram in the ``Motor`` class documentation.
27 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color/detectable_colors.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorSensor
2 | from pybricks.parameters import Port, Color
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorSensor(Port.A)
7 |
8 | # First, decide which objects you want to detect, and measure their HSV values.
9 | # You can do that with the hsv() method as shown in the previous example.
10 | #
11 | # Use your measurements to override the default colors, or add new colors:
12 | Color.GREEN = Color(h=132, s=94, v=26)
13 | Color.MAGENTA = Color(h=348, s=96, v=40)
14 | Color.BROWN = Color(h=17, s=78, v=15)
15 | Color.RED = Color(h=359, s=97, v=39)
16 |
17 | # Put your colors in a list or tuple.
18 | my_colors = (Color.GREEN, Color.MAGENTA, Color.BROWN, Color.RED, Color.NONE)
19 |
20 | # Save your colors.
21 | sensor.detectable_colors(my_colors)
22 |
23 | # color() works as usual, but now it returns one of your specified colors.
24 | while True:
25 | color = sensor.color()
26 |
27 | # Print the color.
28 | print(color)
29 |
30 | # Check which one it is.
31 | if color == Color.MAGENTA:
32 | print("It works!")
33 |
34 | # Wait so we can read it.
35 | wait(100)
36 |
--------------------------------------------------------------------------------
/examples/pup/robotics/car_remote.py:
--------------------------------------------------------------------------------
1 | from pybricks.parameters import Direction, Port, Button
2 | from pybricks.pupdevices import Motor, Remote
3 | from pybricks.robotics import Car
4 | from pybricks.tools import wait
5 |
6 | # Set up motors.
7 | front = Motor(Port.A, Direction.COUNTERCLOCKWISE)
8 | rear = Motor(Port.B, Direction.COUNTERCLOCKWISE)
9 | steer = Motor(Port.C, Direction.CLOCKWISE)
10 |
11 | # Connect to the remote.
12 | remote = Remote()
13 |
14 | # Set up the car.
15 | car = Car(steer, [front, rear])
16 |
17 | # The main program starts here.
18 | while True:
19 | # Read remote state.
20 | pressed = remote.buttons.pressed()
21 |
22 | # Steer using the left pad. Steering is the percentage
23 | # of the angle determined while initializing.
24 | steering = 0
25 | if Button.LEFT_PLUS in pressed:
26 | steering += 100
27 | elif Button.LEFT_MINUS in pressed:
28 | steering -= 100
29 | car.steer(steering)
30 |
31 | # Drive using the right pad.
32 | power = 0
33 | if Button.RIGHT_PLUS in pressed:
34 | power += 100
35 | elif Button.RIGHT_MINUS in pressed:
36 | power -= 100
37 | car.drive_power(power)
38 |
39 | # Wait briefly.
40 | wait(10)
41 |
--------------------------------------------------------------------------------
/examples/pup/sensor_color_distance/detectable_colors.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import ColorDistanceSensor
2 | from pybricks.parameters import Port, Color
3 | from pybricks.tools import wait
4 |
5 | # Initialize the sensor.
6 | sensor = ColorDistanceSensor(Port.A)
7 |
8 | # First, decide which objects you want to detect, and measure their HSV values.
9 | # You can do that with the hsv() method as shown in the previous example.
10 | #
11 | # Use your measurements to override the default colors, or add new colors:
12 | Color.GREEN = Color(h=132, s=94, v=26)
13 | Color.MAGENTA = Color(h=348, s=96, v=40)
14 | Color.BROWN = Color(h=17, s=78, v=15)
15 | Color.RED = Color(h=359, s=97, v=39)
16 |
17 | # Put your colors in a list or tuple.
18 | my_colors = (Color.GREEN, Color.MAGENTA, Color.BROWN, Color.RED, Color.NONE)
19 |
20 | # Save your colors.
21 | sensor.detectable_colors(my_colors)
22 |
23 | # color() works as usual, but now it returns one of your specified colors.
24 | while True:
25 | color = sensor.color()
26 |
27 | # Print the color.
28 | print(color)
29 |
30 | # Check which one it is.
31 | if color == Color.MAGENTA:
32 | print("It works!")
33 |
34 | # Wait so we can read it.
35 | wait(100)
36 |
--------------------------------------------------------------------------------