You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 23, 2021. It is now read-only.
Make without limit! Device Simulator Express, a Microsoft Garage project, allows you to code in CircuitPython for your awesome
8
-
Circuit Playground Express (CPX) projects! Test and debug your code on the device simulator and see the same
7
+
Make without limit! Device Simulator Express, a Microsoft Garage project, allows you to code microcontrollers without the hardware on hand! You can program your Circuit Playground Express (CPX) or your BBC micro:bit! Test and debug your code on the device simulator and see the same
9
8
result when you plug in your actual microcontroller. Curious about the output of the device, the serial
10
9
monitor allows you to observe the device output.
11
10
@@ -20,9 +19,21 @@ monitor allows you to observe the device output.
The following dependencies are required to install before launching Device Simulator Express.
25
+
You will be prompted to install the Python dependencies during the first use.
26
+
27
+
-_**[Visual Studio Code](https://code.visualstudio.com/)**_
28
+
-_**[Node](https://nodejs.org/en/download/)**_
29
+
-_**[Python 3.7+](https://www.python.org/downloads/)**_: Make sure you've added python and pip to your PATH in your environment variables. (1)
30
+
-_**[Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)**_: This will be installed automatically from the marketplace when you install Device Simulator Express.
31
+
32
+
## Circuit Playground Express (CPX) Simulator
24
33
25
-
- IntelliSense and syntax highlighting for CircuitPython code (only supports CPX Express library)
34
+
### Features
35
+
36
+
- IntelliSense and syntax highlighting for CircuitPython code
26
37
- Template file generation
27
38
- Integrated Python Debugging for the Simulator
28
39
- Serial monitor (available on Windows and Mac only)
@@ -46,27 +57,10 @@ The simulator supports most of the sensors on CPX except **IR transmitter & Rece
46
57
The code related to these sensors can still run on the actual CPX board and be deployed using Device Simulator Express.
47
58
As we only support CPX library now, other libraries (i.e. simpleio) can’t run on the simulator. But they will work on the actual device!
48
59
49
-
## Prerequisites
50
-
51
-
The following dependencies are required to install before launching Device Simulator Express.
52
-
You will be prompted to install the Python dependencies during the first use.
53
-
54
-
-_**[Visual Studio Code](https://code.visualstudio.com/)**_
55
-
-_**[Node](https://nodejs.org/en/download/)**_
56
-
-_**[Python 3.7.4](https://www.python.org/downloads/)**_: Make sure you've added python and pip to your PATH in your environment variables. (1)
57
-
-_**[Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)**_: This will be installed automatically from the marketplace when you install Device Simulator Express.
58
60
59
-
- Python Modules for Simulation
60
-
-**Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following Python modules should be downloaded when you select "yes" on the prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.**
61
-
- Playsound : `pip install playsound`
62
-
- Pywin32 : `pip install pywin32`
63
-
- On Windows, you need to use the above command in the console to manually install pywin32.
2. Name and save your file somewhere, and we’re good to go! (3)
90
-
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: New File"` Command.
82
+
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.
91
83
92
84
<img alt='How to find example code screenshot' src=https://raw.githubusercontent.com/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/findExamples.jpg>
93
85
94
-
### 2. Start from an existing python file.
86
+
####2. Start from an existing python file.
95
87
96
88
1. Open the folder or your .py file in Visual Studio Code.
97
-
2. Run `open Simulator` from the command palette or icon in the editor toolbar.
89
+
2. Run `Device Simulator Express: [Circuit Playground Express] Open Simulator` from the command palette or icon in the editor toolbar.
98
90
99
-
### 3. Run your code on the simulator.
91
+
####3. Run your code on the simulator.
100
92
101
93
<imgalt='How to run the simulator animation'src='https://github.com/microsoft/vscode-python-devicesimulator/blob/dev/assets/readmeFiles/run.gif?raw=true'>
102
94
103
95
- Run `Run Simulator` from the command palette or icon in the editor toolbar.
104
96
- You can use the `Play` or `Refresh` button on the simulator webview.
105
97
106
-
### 4. Deploy your code to the physical device
98
+
####4. Deploy your code to the physical device
107
99
108
100
Before deploying the python code to your CPX device, you need to format your device following these tutorials:
109
101
@@ -115,14 +107,14 @@ Then, if you are on Windows, you will also need to install the Python Pywin32 pa
115
107
116
108
<img alt="Deploy to Device" src=https://raw.githubusercontent.com/microsoft/vscode-python-devicesimulator/dev/assets/readmeFiles/deployToBoard.png>
117
109
118
-
### 5. Use the Serial Monitor for your Adafruit CPX device (available on Windows and Mac only)
110
+
####5. Use the Serial Monitor for your Adafruit CPX device (available on Windows and Mac only)
119
111
120
112
1. Plug in your CPX device (make sure it’s formatted properly already)
121
-
2. Run the command `"Device Simulator Express: Open Serial Monitor"`
113
+
2. Run the command `"Device Simulator Express: [Circuit Playground Express] Open Serial Monitor"`
122
114
3. Select your baud rate for the serial port
123
115
4. The print() statements in your code will show in the output console
124
116
125
-
### 6. Use the sensors in the Device Simulator Express
117
+
####6. Use the sensors in the Device Simulator Express
126
118
127
119
Generating input for the sensors can be done by interacting directly with device on the webview
128
120
or by using the toolbar.
@@ -131,25 +123,25 @@ or by using the toolbar.
131
123
-**Temperature sensor, Light sensor, acceleration:** click on the corresponding button in the toolbar and change the value using the slider or the input box attached to it.
132
124
-**Shake detection:** go to the motion sensor section in the toolbar and click on the shake button.
133
125
134
-
### 7. Debug your project on the simulator
126
+
####7. Debug your project on the simulator
135
127
136
128
1. Add breakpoints in your code
137
129
2. Press F5 to enter the debugging mode, and you can start debugging line by line!
138
130
139
-
## Commands
131
+
###Commands
140
132
141
133
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
134
143
-
-`Device Simulator Express: New File`: Opens an unsaved .py file with template code, also opens the simulator.
144
-
-`Device Simulator Express: Open Simulator`: Opens the simulator in the webView
145
-
-`Device Simulator Express: Run on Simulator`: Runs python code on the simulator
146
-
-`Device Simulator Express: Deploy to Device`: Copies & Pastes the code.py or main.py file to CIRCUITPY drive if detected a CPX is plugged in
147
-
-`Device Simulator Express: Open Serial Monitor`: Opens the serial monitor in the integrated output window.
148
-
-`Device Simulator Express: Close Serial Monitor`: Stops the serial monitor and releases the serial port.
149
-
-`Device Simulator Express: Change Baud Rate`: Changes the baud rate of the selected serial port. For Adafruit CPX, the default baud rate is 115200.
150
-
-`Device Simulator Express: Select Serial Port`: Changes the current serial port.
135
+
-`Device Simulator Express: [Circuit Playground Express] New File`: Opens an unsaved .py file with template code, also opens the simulator.
136
+
-`Device Simulator Express: [Circuit Playground Express] Open Simulator`: Opens the simulator in the webView
137
+
-`Device Simulator Express: [Circuit Playground Express] Run on Simulator`: Runs python code on the simulator
138
+
-`Device Simulator Express: [Circuit Playground Express] Deploy to Device`: Copies & Pastes the code.py or main.py file to CIRCUITPY drive if detected a CPX is plugged in
139
+
-`Device Simulator Express: [Circuit Playground Express] Open Serial Monitor`: Opens the serial monitor in the integrated output window.
140
+
-`Device Simulator Express: [Circuit Playground Express] Close Serial Monitor`: Stops the serial monitor and releases the serial port.
141
+
-`Device Simulator Express: [Circuit Playground Express] Change Baud Rate`: Changes the baud rate of the selected serial port. For Adafruit CPX, the default baud rate is 115200.
142
+
-`Device Simulator Express: [Circuit Playground Express] Select Serial Port`: Changes the current serial port.
151
143
152
-
## Keybindings
144
+
###Keybindings
153
145
154
146
In Device Simulator Express, you can use keyboard to interact with the device:
155
147
@@ -158,6 +150,37 @@ In Device Simulator Express, you can use keyboard to interact with the device:
158
150
- Slider Switch: `SHIFT + S`
159
151
- Refresh the simulator: `SHIFT + R`
160
152
153
+
154
+
## BBC micro:bit Simulator
155
+
>**NOTE 1**: this feature is hidden by default. To use it, enable the feature flag in the "deviceSimulatorExpress.previewMode" user setting.
156
+
157
+
>**NOTE 2**: micro:bit simulation is still in development. Features may not work as intended.
158
+
159
+
### Features
160
+
- IntelliSense and syntax highlighting for micro:bit code
161
+
- Template file generation
162
+
- Integrated Python Debugging for the Simulator
163
+
- Simulation of the micro:bit device, including:
164
+
- 25 LEDs
165
+
- Light sensor
166
+
- Motion sensors
167
+
- Acceleration detection
168
+
- Temperature sensor
169
+
170
+
### How to use
171
+
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:
172
+
-`Device Simulator Express: [micro:bit] Open Simulator`: Opens an unsaved .py file with template code, also opens the simulator.
173
+
-`Device Simulator Express: [micro:bit] New File`: Opens the simulator in the webView
174
+
175
+
Please review the CPX's ["How to use" guide](#How-to-use) for more info.
176
+
177
+
### Keybindings
178
+
- Push Button `A & B: A B`
179
+
- Refresh the simulator: `SHIFT + R`
180
+
181
+
## Contribute
182
+
[See here for steps to run the extension locally.](/docs/developers-setup.md)
183
+
161
184
## Provide feedback
162
185
163
186
To report issues, provide feedback or requests, please use this link: [Provide Feedback](https://aka.ms/AA5xpxx).
@@ -196,7 +219,7 @@ A `ThirdPartyNotices.txt` file is provided in the extension's source code listin
196
219
- While running a code file, if you get an error saying it can't find the file, make sure you've clicked on a valid Python code file before running it.
197
220
- To open the output panel again after closing it go to VS Code menu: `View->Output`.
198
221
- If you try to deploy to the device while it's plugged in but you still get an error saying it cannot find the board, make sure your Circuit Playground Express is formatted correctly and that its name matches `CIRCUITPY`.
199
-
- If you can't get the Simulator communication working while debugging, try to open your `Settings` and check the port used under `"Device Simulator Express: Debugger Server Port"`. You can either change it (usually ports above 5000 should work) or try to free it, then start debugging again.
222
+
- If you can't get the Simulator communication working while debugging, try to open your `Settings` and check the port used under `"Device Simulator Express: [<device_name>] Debugger Server Port"`. You can either change it (usually ports above 5000 should work) or try to free it, then start debugging again.
200
223
- When you are using the serial monitor, if you get some unusual error messages, unplug the device and reload the VS Code windows.
"info.extensionActivated": "Congratulations, your extension Adafruit_Simulator is now active!",
30
-
"info.firstTimeWebview": "To reopen the simulator click on the \"Open Simulator\" button on the upper right corner of the text editor, or select the command \"Open Simulator\" from command palette.",
30
+
"info.firstTimeWebview": "To reopen the simulator select the command \"Open Simulator\" from command palette.",
31
31
"info.installPythonDependencies": "Do you want us to try and install this extensions dependencies for you?",
32
32
"error.invalidFileExtensionDebug": "The file you tried to run isn\\'t a Python file.",
33
33
"info.newFile": "New to Python or the Circuit Playground Express? We are here to help!",
"info.thirdPartyWebsite": "By clicking \"Agree and Proceed\" you will be redirected to adafruit.com, a third party website not managed by Microsoft. Please note that your activity on adafruit.com is subject to Adafruit's privacy policy",
39
-
"info.welcomeOutputTab": "Welcome to the Adafruit Simulator output tab!\n\n",
39
+
"info.welcomeOutputTab": "Welcome to the Device Simulator Express output tab!\n\n",
"deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.",
16
+
"deviceSimulatorExpressExtension.configuration.properties.debuggerPort": "The port the Server will listen on for communication with the debugger.",
17
+
"deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask if we can download dependencies. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files."
18
+
"deviceSimulatorExpressExtension.configuration.properties.previewMode": "Enable this to test out and play with the new micro:bit simulator!"
0 commit comments