Skip to content

Latest commit

 

History

History
126 lines (96 loc) · 5.7 KB

README.md

File metadata and controls

126 lines (96 loc) · 5.7 KB

microbit extension for Visual Studio Code

Version Latest Downloads Repo size

V1 V2 4tronix Bit:Bot XL V2

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

Visual Studio Code screen shot with a Python example 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

  1. Install Python on your system. (You will need to Add Python to PATH.)
  2. Create a new folder/workspace in Visual Studio Code.
  3. Open Extensions view (Ctrl+Shift+X) and make sure you have the Python extension from Microsoft installed.
  4. From Extensions view, search for and install this extension ('microbit' from publisher Statped).
  5. Restart Visual Studio Code.
  6. Open Command Palette (Ctrl+Shift+P) and select micro:bit Prepare. This will install files to your system.
  7. Restart Visual Studio Code.
  8. Write your Python script for micro:bit or 4tronix Bit:Bot XL.
  9. Flash your micro:bit using Ctrl+F5 (or Command Palette micro:bit Flash).

Visual Studio Code screen shot after using the Read micro:bit (REPL) command 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:

  1. Open Windows Device Manager (Win+X, Device Manager) to find the micro:bit COM port.
  2. Open Command Palette (Ctrl+Shift+P) and select micro:bit: Set COM port.
  3. Enter the COM port number from the Device Manager.
  4. Make sure your script is running on the micro:bit, and then:
  5. Open Command Palette and select micro:bit: Read micro:bit (REPL) or press Ctrl+Alt+F5.
  6. 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

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.