Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 98f5ec0

Browse files
committed
Merge branch 'users/t-xunguy/neopixels' of https://github.com/microsoft/vscode-python-devicesimulator into users/t-xunguy/neopixels
2 parents f23844d + 94b5f07 commit 98f5ec0

File tree

14 files changed

+668
-592
lines changed

14 files changed

+668
-592
lines changed

README.md

Lines changed: 50 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -78,78 +78,6 @@ As we only support CPX library now, other libraries (i.e. simpleio) can’t run
7878
- [Download Firmware .uf2 file](https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart)
7979
- [Download the latest version of the Adafruit CPX library](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries)
8080

81-
### How to use
82-
83-
To use Device Simulator Express, install the extension from the marketplace and reload VS Code.
84-
85-
#### I. Take a look at the "Device Simulator Express: Getting Started" Command.
86-
1. Type in `"Device Simulator Express: [Circuit Playground Express] New File"` in the command palette (`CTRL + SHIFT + P` / `CMD + SHIFT + P` to open the command palette).
87-
<img alt='Getting Started' src='https://github.com/raw/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/getting_started.png'>
88-
2. Choose the `CPX` option from the dropdown.
89-
3. Read, copy and learn some of the things you can do with the simulator!
90-
91-
#### II. Start with the "Device Simulator Express [Circuit Playground Express]: New File" Command.
92-
93-
1. Type in `"Device Simulator Express: [Circuit Playground Express] New File"` in the command palette (`CTRL + SHIFT + P` / `CMD + SHIFT + P` to open the command palette).
94-
<img alt='"New CPX File" animation' src='https://github.com/raw/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/cpx/cpx-new-file.gif'>
95-
2. Name and save your file somewhere, and we’re good to go!
96-
3. Start with some examples: you can find examples files and tutorials inside the comments, as well as in the notification pop up when you run the `"Device Simulator Express: [Circuit Playground Express] New File"` Command.
97-
98-
#### III. Start from an existing Python file.
99-
100-
1. Open the folder or your .py file in Visual Studio Code.
101-
2. Run `Device Simulator Express: [Circuit Playground Express] Open Simulator` from the command palette or icon in the editor toolbar.
102-
103-
#### IV. Run your code on the simulator.
104-
105-
<img alt='How to run the CPX simulator animation' src='https://github.com/raw/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/cpx/cpx-run.gif'>
106-
107-
1. Run `Run Simulator` from the command palette or use the `Play` button on the simulator webview.
108-
109-
#### V. Deploy your code to the physical device
110-
111-
Before deploying the Python code to your CPX device, you need to format your device by following these tutorials:
112-
113-
1. Download the firmware with the .uf2 file (link: https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart).
114-
2. Download the lastest version of the cpx library (link: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).
115-
116-
<img alt='Deploy to CPX Device' src='https://github.com/raw/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/cpx/cpx-deploy.png'>
117-
118-
#### VI. Use the Serial Monitor for your Adafruit CPX device (available on Windows and Mac only)
119-
120-
1. Plug in your CPX device (make sure it’s formatted properly already).
121-
2. Run the command `"Device Simulator Express: Open Serial Monitor"`.
122-
3. Select your baud rate for the serial port.
123-
4. The `print()` statements in your code will show in the output console.
124-
125-
#### VII. Use the sensors in the Device Simulator Express
126-
127-
Generating input for the sensors can be done by interacting directly with device on the webview
128-
or by using the toolbar.
129-
130-
- **Switch, push buttons and capacitive touch:** click directly on the corresponding element on the device or use the keybindings.
131-
- **Temperature sensor, Light sensor, Acceleration sensor:** click on the corresponding button in the toolbar and change the value using the slider or the input box attached to it.
132-
- **Shake detection:** go to the motion sensor section in the toolbar and click on the shake button.
133-
134-
#### VIII. Debug your project on the simulator
135-
136-
1. Add breakpoints in your code
137-
2. Press F5 to enter the debugging mode, and you can start debugging line by line!
138-
139-
### Commands
140-
141-
Device Simulator Express provides several commands in the Command Palette (`F1` or `CTRL + SHIFT + P` / `CMD + SHIFT + P` for Mac OS) for working with \*.py files:
142-
143-
- `Device Simulator Express: Getting Started`: Opens a page in VS Code that helps users get started with the extension. Here, users can browse through code that they can use to play with the simulators.
144-
- `Device Simulator Express: Run Simulator`: Runs Python code on the simulator.
145-
- `Device Simulator Express: [Circuit Playground Express] New File`: Opens an unsaved .py file with template code, also opens the simulator.
146-
- `Device Simulator Express: [Circuit Playground Express] Open Simulator`: Opens the simulator in the webView
147-
- `Device Simulator Express: [Circuit Playground Express] Deploy to Device`: Copies the current file to CIRCUITPY drive if detected a CPX is plugged in.
148-
- `Device Simulator Express: Open Serial Monitor`: Opens the serial monitor in the integrated output window.
149-
- `Device Simulator Express: Close Serial Monitor`: Stops the serial monitor and releases the serial port.
150-
- `Device Simulator Express: Change Baud Rate`: Changes the baud rate of the selected serial port. For Adafruit CPX, the default baud rate is 115200.
151-
- `Device Simulator Express: Select Serial Port`: Changes the current serial port.
152-
15381
### Keybindings
15482

15583
In Device Simulator Express, you can use keyboard to interact with the device:
@@ -172,82 +100,92 @@ In Device Simulator Express, you can use keyboard to interact with the device:
172100
- 25 LEDs
173101
- Light sensor
174102
- Motion sensors
175-
- Acceleration detection
103+
- Acceleration detection including gesture detection
176104
- Temperature sensor
177105

178106
### Useful Links
179107
- Tutorials and Example Code for BBC micro:bit:
180108
- [MicroPython documentation](https://microbit-micropython.readthedocs.io/en/latest/)
181109
- [BBC micro:bit examples on the official micro:bit website](https://microbit.org/projects/make-it-code-it/?filters=python)
182110

183-
### How to use
111+
### Keybindings
112+
- Push Button `A for A, B for B, C for A & B`
113+
- Refresh the simulator: `SHIFT + R`
114+
- Run the simulator: `SHIFT + F`
115+
116+
## How to use
184117

185-
#### I. Take a look at the "Device Simulator Express: Getting Started" Command.
186-
1. Type in `"Device Simulator Express: [Circuit Playground Express] New File"` in the command palette (`CTRL + SHIFT + P` / `CMD + SHIFT + P` to open the command palette).
187-
<img alt='Getting Started' src='https://github.com/raw/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/getting_started.png'>
188-
2. Choose the `micro:bit` option from the dropdown.
118+
To use Device Simulator Express, install the extension from the marketplace and reload VS Code.
119+
120+
### I. Take a look at the "Device Simulator Express: Getting Started" Command.
121+
1. Type in `"Device Simulator Express: Getting Started"` in the command palette (`CTRL + SHIFT + P` / `CMD + SHIFT + P` to open the command palette).
122+
2. Choose the the device you want to play with from the dropdown.
189123
3. Read, copy and learn some of the things you can do with the simulator!
190-
191-
#### II. Start with the "Device Simulator Express [micro:bit]: New File" Command.
192124

193-
1. Type in `"Device Simulator Express: [micro:bit] New File"` in the command palette (`CTRL + SHFT + P / CMD + SHIFT + P` to open the command palette).
194-
<img alt='"New micro:bit File" animation' src='https://github.com/microsoft/vscode-python-devicesimulator/blob/dev/assets/readmeFiles/microbit/microbit-new-file.gif'>
195-
2. Name and save your file somewhere, and we’re good to go!
125+
<img alt='Getting Started' src='https://github.com/raw/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/getting_started.png'>
126+
127+
### II. Start with the "Device Simulator Express: New File" Command.
128+
1. Type in `"Device Simulator Express: New File"` in the command palette (`CTRL + SHIFT + P` / `CMD + SHIFT + P` to open the command palette).
129+
2. Select the device you want to use.
130+
3. Name and save your file somewhere, and we’re good to go!
131+
4. Start with some examples: you can find examples files and tutorials inside the comments at the top of the file.
196132

197-
#### III. Start from an existing Python file.
133+
<img alt='"New File" animation' src='assets/readmeFiles/new_file.gif'>
198134

199-
1. Open the folder or your .py file in Visual Studio Code.
200-
2. Run `Device Simulator Express: [micro:bit] Open Simulator` from the command palette or icon in the editor toolbar.
135+
### III. Start from an existing Python file.
201136

202-
#### IV. Run your code on the simulator.
137+
1. Open the folder or your .py file in Visual Studio Code.
138+
2. Run `Device Simulator Express: Open Simulator` from the command palette or icon in the editor toolbar.
139+
3. Select the device you want to use.
203140

204-
<img alt='How to run the micro:bit simulator animation' src='https://github.com/raw/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/microbit/microbit-run.gif'>
141+
### IV. Run your code on the simulator.
205142

206143
1. Run `Run Simulator` from the command palette or use the `Play` button on the simulator webview.
207144

208-
#### V. Deploy your code to the physical device
145+
<img alt='How to run the simulator animation' src='assets/readmeFiles/run.gif'>
209146

210-
1. Run `[micro:bit] Deploy to Device` from the command palette
147+
### V. Deploy your code to the physical device
211148

212-
<img alt='Deploy to micro:bit device' src='https://github.com/microsoft/vscode-python-devicesimulator/blob/dev/assets/readmeFiles/microbit/microbit-deploy.png'>
149+
Before deploying the Python code to your CPX device, you need to format your device by following these tutorials:
213150

214-
#### VI. Use the Serial Monitor for your BBC micro:bit device (available on Windows and Mac only)
151+
- *For the CPX*:
152+
- Download the firmware with the .uf2 file (link: https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart).
153+
- Download the lastest versions of the cpx libraries (link: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).
215154

216-
1. Plug in your BBC micro:bit.
217-
2. Run the command `"Device Simulator Express: Open Serial Monitor"`.
218-
3. Select your baud rate for the serial port.
219-
4. The `print()` statements in your code will show in the output console.
155+
- *For the micro:bit*:
156+
- Download the firmware with the .hex file (link: https://microbit.org/get-started/user-guide/firmware/).
220157

221-
#### VII. Use the sensors in the Device Simulator Express
158+
1. Plug in your device (make sure it’s formatted properly already).
159+
2. Run the command `"Device Simulator Express: Deploy to Device"`.
222160

223-
Generating input for the sensors can be done by interacting directly with device on the webview
224-
or by using the toolbar.
161+
<img alt='Deploy to Device' src='assets/readmeFiles/deploy.png'>
225162

226-
- **Push buttons:** click directly on the buttons on the device or use the keybindings.
227-
- **Temperature sensor, Light sensor, Acceleration sensor:** click on the corresponding button in the toolbar and change the value using the slider or the input box attached to it.
163+
### VI. Use the Serial Monitor for your device (available on Windows and Mac only)
164+
165+
1. Plug in your device (make sure it’s formatted properly already).
166+
2. Run the command `"Device Simulator Express: Open Serial Monitor"`.
167+
3. Select your baud rate for the serial port.
168+
4. The `print()` statements in your code will show in the output console.
228169

229-
#### VIII. Debug your project on the simulator
170+
### VII. Debug your project on the simulator
230171

231172
1. Add breakpoints in your code
232173
2. Press F5 to enter the debugging mode, and you can start debugging line by line!
233174

234175
### Commands
235-
Using the simulator for the micro:bit is similar to using the one for the CPX. The only difference is that the commands in the command palette display `Device Simulator Express: [micro:bit] <command>` instead of `Device Simulator Express: [Circuit Playground Express] <command>`. Currently, we support the following commands for micro:bit:
176+
177+
Device Simulator Express provides several commands in the Command Palette (`F1` or `CTRL + SHIFT + P` / `CMD + SHIFT + P` for Mac OS) for working with \*.py files:
178+
236179
- `Device Simulator Express: Getting Started`: Opens a page in VS Code that helps users get started with the extension. Here, users can browse through code that they can use to play with the simulators.
237180
- `Device Simulator Express: Run Simulator`: Runs Python code on the simulator.
238-
- `Device Simulator Express: [micro:bit] Open Simulator`: Opens an unsaved .py file with template code, also opens the simulator.
239-
- `Device Simulator Express: [micro:bit] New File`: Opens the simulator in the webView.
240-
- `Device Simulator Express: [micro:bit] Deploy to Device`: Copies the current file to the micro:bit if the device is detected.
181+
- `Device Simulator Express: New File`: Opens an unsaved .py file with template code, also opens the simulator for the selected device.
182+
- `Device Simulator Express: Open Simulator`: Opens the simulator in the simulator window for the selected device
183+
- `Device Simulator Express: Deploy to Device`: Copies the current file to the selected device.
241184
- `Device Simulator Express: Open Serial Monitor`: Opens the serial monitor in the integrated output window.
242185
- `Device Simulator Express: Close Serial Monitor`: Stops the serial monitor and releases the serial port.
243-
- `Device Simulator Express: Change Baud Rate`: Changes the baud rate of the selected serial port. For BBC micro:bit, the default baud rate is 115200.
186+
- `Device Simulator Express: Change Baud Rate`: Changes the baud rate of the selected serial port. For Adafruit CPX, the default baud rate is 115200.
244187
- `Device Simulator Express: Select Serial Port`: Changes the current serial port.
245188

246-
### Keybindings
247-
- Push Button `A for A, B for B, C for A & B`
248-
- Refresh the simulator: `SHIFT + R`
249-
- Run the simulator: `SHIFT + F`
250-
251189
## Contribute
252190
[See here for steps to run the extension locally.](https://github.com/microsoft/vscode-python-devicesimulator/blob/dev/docs/developers-setup.md)
253191

assets/readmeFiles/deploy.png

4 KB
Loading

assets/readmeFiles/new_file.gif

367 KB
Loading

assets/readmeFiles/run.gif

-6.89 MB
Loading

locales/en/out/constants.i18n.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"error.debuggerServerInitFailed": "Warning : The Debugger Server cannot be opened. Please try to free the port {0} if it's already in use or select another one in your Settings 'Device Simulator Express: Debugger Server Port' and start another debug session.\n You can still debug your code but you won't be able to use the Simulator.",
1515
"error.debuggingSessionInProgress": "[ERROR] A debugging session is currently in progress, please stop it before running your code. \n",
1616
"error.noDevice": "No plugged in boards detected. Please double check if your board is connected and/or properly formatted",
17-
"error.noFileToRun": "\n[ERROR] We can't find the .py file to run on simulator. Open up a new .py file, or browse through some examples\n",
17+
"error.noFileToRun": "\n[ERROR] We can't find the .py file to run. Open up a new .py file, or browse through some examples\n",
18+
"error.noFileToDeploy": "\n[ERROR] We can't find a Python file to deploy to your device.\n",
1819
"error.noFolderCreated": "In order to use the Serial Monitor, you need to open a folder and reload VS Code.",
1920
"error.noProgramFoundDebug": "Cannot find a program to debug.",
2021
"error.noPythonPath": "We found that you don't have Python 3 installed on your computer, please install the latest version, add it to your PATH and try again.",
@@ -28,6 +29,9 @@
2829
"info.installPythonDependencies": "Do you want us to try and install this extensions dependencies for you?",
2930
"error.invalidFileExtensionDebug": "The file you tried to run isn\\'t a Python file.",
3031
"info.newFile": "New to Python or the Circuit Playground Express? We are here to help!",
32+
"info.noDeviceChosenToDeployTo": "\n[INFO] No device was selected to deploy to.\n",
33+
"info.noDeviceChosenToSimulateTo": "\n[INFO] No device was selected to simulate.\n",
34+
"info.noDeviceChosenForNewFile": "\n[INFO] No device was selected to open a template file for.\n",
3135
"info.redirect": "You are being redirected.",
3236
"info.runningCode": "Running user code",
3337
"info.privacyStatement": "Privacy Statement",

locales/en/package.i18n.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@
77
"deviceSimulatorExpressExtension.commands.common.closeSerialMonitor": "Close Serial Monitor",
88
"deviceSimulatorExpressExtension.commands.common.openSerialMonitor": "Open Serial Monitor",
99
"deviceSimulatorExpressExtension.commands.common.selectSerialPort": "Select Serial Port",
10-
"deviceSimulatorExpressExtension.commands.cpx.openSimulator": "[Circuit Playground Express] Open Simulator",
11-
"deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File",
12-
"deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device",
13-
"deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device",
14-
"deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator",
15-
"deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File",
16-
"deviceSimulatorExpressExtension.commands.clue.openSimulator": "[Clue] Open Simulator",
17-
"deviceSimulatorExpressExtension.commands.clue.newFile": "[Clue] New File",
10+
"deviceSimulatorExpressExtension.commands.common.deployToDevice": "Deploy to Device",
11+
"deviceSimulatorExpressExtension.commands.common.openSimulator": "Open Simulator",
12+
"deviceSimulatorExpressExtension.commands.common.newFile": "New File",
1813
"deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration",
1914
"deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.",
2015
"deviceSimulatorExpressExtension.configuration.properties.debuggerPort": "The port the Server will listen on for communication with the debugger.",

0 commit comments

Comments
 (0)