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

Commit 1d83a72

Browse files
Merge pull request #152 from microsoft/dev
Update staging with dev branch released to VSCode Marketplace
2 parents 3bceb79 + 25b4c65 commit 1d83a72

File tree

130 files changed

+13066
-1500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+13066
-1500
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Project Pacifica
1+
Project Device Simulator Express
22

33
Copyright (c) Microsoft Corporation. All rights reserved.
44

PRIVACY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The software may collect information about you and your use of the software and
66

77
## Disable Telemetry
88

9-
The Microsoft Pacifica Extension for Visual Studio Code collects usage
9+
The Microsoft Device Simulator Express Extension for Visual Studio Code collects usage
1010
data and sends it to Microsoft to help improve our products and
1111
services. Read our
1212
[privacy statement](https://privacy.microsoft.com/privacystatement) to

README.md

Lines changed: 209 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,222 @@
1-
# Project Pacifica
1+
# Device Simulator Express, a Microsoft Garage project
22

3-
This project is a VS Code extension for makers to write for their microcontrollers and provide them a simulator to test their code.
4-
This extension currently supports some features of the Adafruit Circuit Playground Express.
3+
Make without limit! Device Simulator Express, a Microsoft Garage project, allows you to code in CircuitPython for your awesome
4+
Circuit Playground Express (CPX) projects! Test and debug your code on the device simulator and see the same
5+
result when you plug in your actual microcontroller. Curious about the output of the device, the serial
6+
monitor allows you to observe the device output.
57

6-
## Build Status
8+
![CircuitPlayground Express](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/cpx.jpg)
79

8-
| Branch | Build Status |
9-
| :------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
10-
| dev | [![Build status](https://microsoftgarage.visualstudio.com/Intern%20GitHub/_apis/build/status/Adafruit/Intern%20GitHub-CI?branchName=dev)](https://microsoftgarage.visualstudio.com/Intern%20GitHub/_build/latest?definitionId=304&branchName=dev) |
11-
| staging | [![Build Status](https://microsoftgarage.visualstudio.com/Intern%20GitHub/_apis/build/status/Adafruit/Intern%20GitHub-CI?branchName=staging)](https://microsoftgarage.visualstudio.com/Intern%20GitHub/_build/latest?definitionId=304&branchName=staging) |
12-
| master | [![Build Status](https://microsoftgarage.visualstudio.com/Intern%20GitHub/_apis/build/status/Adafruit/Intern%20GitHub-CI?branchName=master)](https://microsoftgarage.visualstudio.com/Intern%20GitHub/_build/latest?definitionId=304&branchName=master) |
10+
## Features
1311

14-
## Code of conduct
12+
- IntelliSense and syntax highlighting for CircuitPython code (only supports CPX Express library)
13+
- Template file generation
14+
- Integrated Python Debugging for the Simulator
15+
- Serial monitor (available on Windows and Mac only)
16+
- Output panel for the simulator
17+
- Deploy CircuitPython code to the physical device.
18+
- Simulation of the Adafruit Circuit Playground Express device, including:
19+
- Green LED
20+
- Red LED
21+
- Push Buttons A and B
22+
- Slider Switch
23+
- Speaker: Play .wav file
24+
- 10 NeoPixels
25+
- Light sensor
26+
- Motion sensors
27+
- Acceleration detection
28+
- Device shake detection
29+
- Temperature sensor
30+
- 7 Capacitive Touch sensors
1531

16-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
17-
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
18-
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
32+
The simulator supports most of the sensors on CPX except **IR transmitter & Receiver**, **Sound Sensor (microphone)**, **Speaker (Play Tone)** and the **“tap” on Motion Sensor**.
33+
The code related to these sensors can still run on the actual CPX board and be deployed using Device Simulator Express.
34+
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!
1935

20-
## Documentation
36+
## Prerequisites
2137

22-
- [Installation instructions](/docs/install.md)
23-
- [How to use the Extension](/docs/how-to-use.md)
24-
- [Setup for developers](/docs/developers-setup.md)
25-
- [Contributing](CONTRIBUTING.md)
38+
The following dependencies are required to install before launching Device Simulator Express.
39+
You will be prompted to install the Python dependencies during the first use.
40+
41+
- _**[Visual Studio Code](https://code.visualstudio.com/)**_
42+
- _**[Node](https://nodejs.org/en/download/)**_
43+
- _**[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)
44+
- _**[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.
45+
46+
The following dependecies can be installed for you by the extension by clicking yes when you are prompted to (**except** `pywin32` which is needed only on Windows platform). (2)
47+
48+
- _**Playsound**_
49+
install by typing the following commands in a console: `pip install playsound`
50+
51+
- _**Pywin 32**_
52+
install by typing the following commands in a console (only for Windows computers, you must run it manually): `pip install pywin32`
53+
- _**Python-Socketio**_
54+
install by typing the following commands in a console: `pip install python-socketio`
55+
- _**Requests**_
56+
install by typing the following commands in a console: `pip install requests`
57+
- _**Application Insights**_
58+
install by typing the following commands in a console: `pip install applicationinsights`
59+
60+
## Useful Links
61+
62+
- Tutorials and Example Code for Adafruit CPX:
63+
- Adafruit CPX library tutorial: (https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/circuit-playground-express-library)
64+
- Adafruit CPX Examples on GitHub: (https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/tree/master/examples)
65+
- Adafruit CPX Guided Tour (Intro for the Hardware) (https://learn.adafruit.com/adafruit-circuit-playground-express/guided-tour)
66+
- Format Adafruit CPX device:
67+
- Tutorial for formatting Adafruit CPX for CircuitPython (https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)
68+
- Download Firmware .uf2 file (https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart)
69+
- Download the latest version of the Adafruit CPX library (link: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries)
70+
71+
## How to use
72+
73+
To use Device Simulator Express, install the extension from the marketplace and reload VS Code.
74+
75+
### 1. Start with the “New File” Command.
76+
77+
1. Type in Device Simulator Express: New File” in the command palette(`CTRL+SHIFT+P`to open the command palette).
78+
!["New File" animation](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/newFile.gif)
79+
2. Name and save your file somewhere, and we’re good to go!(3)
80+
3. Start with some examples: you can find examples files and tutorials inside the comments,
81+
as well as in the notification pop up when you run the `“Device Simulator Express: New File”` Command.
82+
83+
![How to find example code screenshot](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/findExamples.jpg)
84+
85+
### 2. Start from an existing python file.
86+
87+
1. Open the folder or your .py file in Visual Studio Code.
88+
2. Run `open Simulator` from the command palette or icon in the editor toolbar.
89+
90+
### 3. Run your code on the simulator .
91+
92+
![How to run the simulator animation](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/run.gif)
93+
94+
- Run `Run Simulator` from the command palette or icon in the editor toolbar.
95+
- You can use the `Play` or `Refresh` button on the simulator webview.
96+
97+
### 4. Deploy your code to the physical device
98+
99+
Before deploying the python code to your CPX device, you need to format your device following these tutorials:
100+
101+
1. Download the firmware with the .uf2 file (link: https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart)
102+
2. Download the lastest version of the cpx library (link: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).
103+
**_Note:_** Make sure you name your file main.py or code.py: the device automatically runs the first file that is likely named.
104+
105+
!["Deploy to Device" example](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/deployToBoard.png)
106+
107+
### 5. Use the Serial Monitor for your Adafruit CPX device(available Windows and Mac only)
108+
109+
1. Plug in your CPX device (make sure it’s formatted properly already)
110+
2. Run the command `Device Simulator Express: Open Serial Monitor`
111+
3. Select your baud rate for the serial port
112+
4. The print() statements in your code will show in the output console
113+
114+
### 6. Use the sensors in the Device Simulator Express
115+
116+
Generating input for the sensors can be done by interacting directly with device on the webview
117+
or by using the toolbar.
118+
119+
- **Switch, push buttons and capacitive touch:** click directly on the corresponding element on the device or use the keybindings.
120+
- **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.
121+
- **Shake detection:** go to the motion sensor section in the toolbar and click on the shake button.
122+
123+
### 7. Debug your project on the simulator
124+
125+
1. Add breakpoints in your code
126+
2. Press F5 to enter the debugging mode, and you can start debugging line by line!
127+
128+
## Commands
129+
130+
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:
131+
132+
- `Device Simulator Express: New File`: Opens an unsaved .py file with template code, also open the simulator.
133+
- `Device Simulator Express: Open Simulator`: Opens the simulator in the webView
134+
- `Device Simulator Express: Run on Simulator`: Runs python code on the simulator
135+
- `Device Simulator Express: Deploy to Board`: Copies & Pastes the code.py or main.py file to CIRCUITPY drive if detected a CPX is plugged in
136+
- `Device Simulator Express: Open Serial Monitor`: Opens the serial monitor in the integrated output window.
137+
- `Device Simulator Express: Close Serial Monitor`: Stops the serial monitor and releases the serial port.
138+
- `Device Simulator Express: Change Baud Rate`: Changes the baud rate of the selected serial port. For Adafruit CPX, the default baud rate is 115200.
139+
- `Device Simulator Express: Select Serial Port`: Changes the current serial port.
140+
141+
## Keybindings
142+
143+
In Device Simulator Express, you can use keyboard to interact with the device:
144+
145+
- Push Button `A & B: A B`
146+
- Capacitive Touch Sensor `A1 – A7: SHIFT + 1~7`
147+
- Slider Switch: `SHIFT + S`
148+
- Refresh the simulator: `SHIFT + R`
149+
150+
## Provide feedback
151+
152+
To report issues, provide feedback or requests, please use this link: [Provide Feedback](https://aka.ms/AA5xpxx).
153+
We would love to hear from you about your experience to keep improving our project.
26154

27155
## Privacy and Telemetry Notice
28156

29-
- [Data collection](PRIVACY.md)
157+
### Data Collection
158+
159+
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
160+
161+
### Disable Telemetry
162+
163+
The Microsoft Device Simulator Express Extension for Visual Studio Code collects usage
164+
data and sends it to Microsoft to help improve our products and
165+
services. Read our
166+
[privacy statement](https://privacy.microsoft.com/privacystatement) to
167+
learn more. This extension respects the `telemetry.enableTelemetry`
168+
setting which you can learn more about at
169+
https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting.
170+
171+
To disable telemetry, follow these steps:
172+
1) Open **File** (Open **Code** on macOS)
173+
2) Select **Preferences**
174+
3) Select **Settings**
175+
4) Search for `telemetry`
176+
5) Uncheck the **Telemetry: Enable Telemetry** setting
30177

31178
## Third Party Notice
32179

33-
- [Third Party Notice](ThirdPartyNotices.txt)
180+
A `ThirdPartyNotices.txt` file is provided in the extension's source code listing the appropriate third-party notices.
181+
182+
## Troubleshooting Tips
183+
184+
- The first time you install the extension, you'll need to execute the `run` command at least once in order to access auto-completion.
185+
- 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.
186+
- To open the output panel again after closing it go to VS Code menu: `View->Output`.
187+
- If you have pylint enabled, it might underline the import of the adafruit_circuitplayground library, but it will work correctly.
188+
- 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`.
189+
- 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.
190+
- When you are using the serial monitor, if you get some unusual error messages, unplug the device and reload the VS Code windows.
191+
192+
## License
193+
194+
Device Simulator Express, a Microsoft Garage project
195+
196+
Copyright (c) Microsoft Corporation. All rights reserved.
197+
198+
MIT License
199+
200+
Permission is hereby granted, free of charge, to any person obtaining a copy
201+
of this software and associated documentation files (the "Software"), to deal
202+
in the Software without restriction, including without limitation the rights
203+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
204+
copies of the Software, and to permit persons to whom the Software is
205+
furnished to do so, subject to the following conditions:
206+
207+
The above copyright notice and this permission notice shall be included in all
208+
copies or substantial portions of the Software.
209+
210+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
211+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
212+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
213+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
214+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
215+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
216+
SOFTWARE.
217+
218+
## Notes
219+
220+
(1) Note: the easiest way to do it is to select the "Add to PATH" option directly when you install Python. Otherwise you can search how to insert it manually, but make sure that when you type _python_ in a terminal, the command is recognized and have the correct version.
221+
(2) You can chose to see to see the prompt or not by changing the extension configirations.
222+
(3) To be able to run the file from your physical device, it should either be named code.py or main.py.

0 commit comments

Comments
 (0)