Awesome
microbit extension for Visual Studio Code
A Visual Studio Code extension for students who code the BBC micro:bit with Python. It supports micro:bit V1 and V2 and also the 4tronix Bit:Bot XL robot.
The extension makes it easy to flash your micro:bit with your Python script. It provides type hints and easy access to warnings and errors in your script. It also provides access to runtime errors that happen on the micro:bit by accessing the REPL (Read-Evaluate-Print-Loop).
The extension is supported by Visual Studio Code on Windows only.
Table of Contents
- Features
- How to use
- Available Commands and keyboard short cuts
- Installed files
- Workspace settings
- Release Notes
Visual Studio Code with type hints for micro:bit.
Features
- Provides type hints.
- Supports both micro:bit V1 and V2.
- Supports the micro:bit accessory 4tronix Bit:Bot XL robot.
- Flashes the micro:bit with your script.
- Reads error messages from the micro:bit (REPL).
How to use
Getting started
- Install Python on your system. (You will need to Add Python to PATH.)
- Create a new folder/workspace in Visual Studio Code.
- Open Extensions view (Ctrl+Shift+X) and make sure you have the Python extension from Microsoft installed.
- From Extensions view, search for and install this extension ('microbit' from publisher Statped).
- Restart Visual Studio Code.
- Open Command Palette (Ctrl+Shift+P) and select micro:bit Prepare. This will install files to your system.
- Restart Visual Studio Code.
- Write your Python script for micro:bit or 4tronix Bit:Bot XL.
- Flash your micro:bit using Ctrl+F5 (or Command Palette micro:bit Flash).
Use the Read micro:bit (REPL) command to read errors on the micro:bit unit.
Read error messages
The Problems Panel (Ctrl+Shift+M) shows warnings and errors that happen during coding. However, there might be errors that only happen during runtime. This extension allows you to read runtime errors from the micro:bit by accessing the REPL (Read-Evaluate-Print-Loop). But first, make sure Visual Studio Code knows the micro:bit COM port:
- Open Windows Device Manager (Win+X, Device Manager) to find the micro:bit COM port.
- Open Command Palette (Ctrl+Shift+P) and select micro:bit: Set COM port.
- Enter the COM port number from the Device Manager.
- Make sure your script is running on the micro:bit, and then:
- Open Command Palette and select micro:bit: Read micro:bit (REPL) or press Ctrl+Alt+F5.
- Any error messages will be written to the Terminal panel.
Available Commands and keyboard short cuts
Command | Keyboard | Description |
---|---|---|
micro:bit: Flash | Ctrl+F5 | Flash your micro:bit with the currently open script. |
micro:bit: Prepare | N/A | Installs workspace settings and Python modules to your system. |
micro:bit: Set COM port | N/A | Set the micro:bit COM port. |
micro:bit: Read micro:bit (REPL) | Ctrl+Alt+F5 | Read error messages from the micro:bit. |
Installed files
In order to make all the features work as intended, the extension will install files to your system:
Your workspace
- .microbit-stubs (stub files for microbit)
- .env (environment file for Python)
- .vscode (settings.json)
Pythons third-party modules location
- Python module bitbotxl.py
- Other required modules
Workspace settings
The following settings are added to the workspace:
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.analysis.autoSearchPaths": true,
"python.autoComplete.extraPaths": [
".microbit-stubs/microbit/lib"
],
"python.analysis.extraPaths": [
".microbit-stubs/microbit/lib"
],
"files.exclude": {
".microbit-stubs": true,
".vscode": true,
".env": true
},
"python.envFile": "${workspacefolder}/.env",
"python.linting.pylintArgs": [
"--disable:W,C" //disables Pylint messages in the Warning and Convention categories
]
Release Notes
[1.0.10] - 2023-03-07
- Removed disabling Pylint messages by numerical IDs (e.g. W0614).
- Added disabling Pylint messages by category (e.g. W).
- Removed Show notifications list shortcut.
- Replaced icon.
- Added category Education.
- Updated Readme.
- npm updates.