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

Update staging with dev branch released to VSCode Marketplace #152

Merged
merged 48 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5cc4658
Adding debugger communication (#113)
Christellah Aug 15, 2019
a3a2c98
Add telemetry to run simulator commands (#110)
LukeSlev Aug 15, 2019
041c985
Serial communication from the CPX to the extension (#97)
jonathanwangg Aug 15, 2019
e2860b6
Fix issue with tomorrow Night Blue Theme (#120)
FMounz Aug 15, 2019
cff1ce7
Remove show of channel on 'activate' (#124)
jonathanwangg Aug 16, 2019
0a7ff68
Make sure we don't run unsaved files and make sure filepicker works (…
LukeSlev Aug 19, 2019
f98f117
Fix bug occuring when value exceed bounds in slider input (#114)
FMounz Aug 19, 2019
11f37fa
Improve UI (#119)
FMounz Aug 19, 2019
48f9bb6
Use absolute path instead relative to fix permission issue (#126)
jonathanwangg Aug 19, 2019
43091a9
Adding a setting for the user to pick the port and passing it to the …
Christellah Aug 19, 2019
f9c0623
Adding telemetry for the new features (#112)
FMounz Aug 20, 2019
0ae9c00
Make CPX svg responsive (#128)
FMounz Aug 20, 2019
442569c
File dropdown on simulator (#127)
LukeSlev Aug 20, 2019
1a83967
Preprocess sound file path to allow spaces on OSX (#125)
jonathanwangg Aug 20, 2019
40f3adc
Debug configuration fix (#130)
Christellah Aug 20, 2019
b6a2320
Add new dependency to docs (#132)
LukeSlev Aug 20, 2019
556bebf
Add dependency for version-from-git to update version number in packa…
jonathanwangg Aug 21, 2019
75cea26
UI Refinement (#131)
LukeSlev Aug 21, 2019
499b232
adding .po file
Aug 21, 2019
79f0473
Localize React file for the Toolbar (#129)
FMounz Aug 21, 2019
cc1b0db
Updating the documentation (#133)
FMounz Aug 21, 2019
99756aa
Merge branch 'dev' of https://github.com/microsoft/vscode-python-embe…
Aug 21, 2019
e4e73f2
fix lack of null check on currentActiveFile (#136)
LukeSlev Aug 21, 2019
418bcd9
Install dependencies for users (#135)
LukeSlev Aug 22, 2019
0d6efe4
Add Adafruit to ThirdPartyNotices.txt (#121)
jonathanwangg Aug 22, 2019
917f0f8
Merge branch 'dev' of https://github.com/microsoft/vscode-python-embe…
Aug 22, 2019
de08372
Fix extension activation failing if no folder is opened (#138)
Christellah Aug 22, 2019
2d45a3e
Adding extension icon (#139)
FMounz Aug 22, 2019
1892c02
Merge branch 'dev' of https://github.com/microsoft/vscode-python-embe…
Aug 22, 2019
0534322
Add telemetry to serial monitor commands (#137)
LukeSlev Aug 22, 2019
7d26a83
Merge branch 'dev' of https://github.com/microsoft/vscode-python-embe…
Aug 22, 2019
46b4228
changing extension name
Aug 23, 2019
ef73290
Persist user's choice for "Don't Show Again" for "New File" command (…
jonathanwangg Aug 23, 2019
678b6ac
Update test message for serial monitor (#141)
jonathanwangg Aug 23, 2019
2dc0f75
add null check (#147)
LukeSlev Aug 23, 2019
21a234c
Change Dont show again to a setting (#148)
jonathanwangg Aug 23, 2019
757e6c4
Updating ReadMe.md (#145)
FMounz Aug 23, 2019
4b2ac51
Install dependencies into the extension folder (#144)
LukeSlev Aug 23, 2019
c49a81e
Disable telemetry for python file with vscode settings (#143)
FMounz Aug 24, 2019
32bea69
Merge branch 'dev' into users/t-famoun/change-pacifica
markAtMicrosoft Aug 27, 2019
f770030
Merge pull request #146 from microsoft/users/t-famoun/change-pacifica
markAtMicrosoft Aug 27, 2019
1bb56df
Fix Merge Conflict
markAtMicrosoft Aug 27, 2019
ce1f25b
Merge pull request #150 from microsoft/Fix-merge-issue-popup
markAtMicrosoft Aug 27, 2019
47537d8
Change naming in Readme.md for vsix details
markAtMicrosoft Aug 27, 2019
a21d967
Merge pull request #151 from microsoft/Fix-VSIX-Details-and-Readme.md
markAtMicrosoft Aug 27, 2019
974c2d6
Touch up package.json for publication
brettcannon Aug 28, 2019
96413f5
Use externally-hosted images in the README
brettcannon Aug 28, 2019
25b4c65
Drop a GIF that GitHub seems to be choking on
brettcannon Aug 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Project Pacifica
Project Device Simulator Express

Copyright (c) Microsoft Corporation. All rights reserved.

Expand Down
2 changes: 1 addition & 1 deletion PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The software may collect information about you and your use of the software and

## Disable Telemetry

The Microsoft Pacifica Extension for Visual Studio Code collects usage
The Microsoft Device Simulator Express Extension for Visual Studio Code collects usage
data and sends it to Microsoft to help improve our products and
services. Read our
[privacy statement](https://privacy.microsoft.com/privacystatement) to
Expand Down
229 changes: 209 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,222 @@
# Project Pacifica
# Device Simulator Express, a Microsoft Garage project

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

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

| Branch | Build Status |
| :------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| 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) |
| 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) |
| 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) |
## Features

## Code of conduct
- IntelliSense and syntax highlighting for CircuitPython code (only supports CPX Express library)
- Template file generation
- Integrated Python Debugging for the Simulator
- Serial monitor (available on Windows and Mac only)
- Output panel for the simulator
- Deploy CircuitPython code to the physical device.
- Simulation of the Adafruit Circuit Playground Express device, including:
- Green LED
- Red LED
- Push Buttons A and B
- Slider Switch
- Speaker: Play .wav file
- 10 NeoPixels
- Light sensor
- Motion sensors
- Acceleration detection
- Device shake detection
- Temperature sensor
- 7 Capacitive Touch sensors

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
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**.
The code related to these sensors can still run on the actual CPX board and be deployed using Device Simulator Express.
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!

## Documentation
## Prerequisites

- [Installation instructions](/docs/install.md)
- [How to use the Extension](/docs/how-to-use.md)
- [Setup for developers](/docs/developers-setup.md)
- [Contributing](CONTRIBUTING.md)
The following dependencies are required to install before launching Device Simulator Express.
You will be prompted to install the Python dependencies during the first use.

- _**[Visual Studio Code](https://code.visualstudio.com/)**_
- _**[Node](https://nodejs.org/en/download/)**_
- _**[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)
- _**[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.

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)

- _**Playsound**_
install by typing the following commands in a console: `pip install playsound`

- _**Pywin 32**_
install by typing the following commands in a console (only for Windows computers, you must run it manually): `pip install pywin32`
- _**Python-Socketio**_
install by typing the following commands in a console: `pip install python-socketio`
- _**Requests**_
install by typing the following commands in a console: `pip install requests`
- _**Application Insights**_
install by typing the following commands in a console: `pip install applicationinsights`

## Useful Links

- Tutorials and Example Code for Adafruit CPX:
- Adafruit CPX library tutorial: (https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/circuit-playground-express-library)
- Adafruit CPX Examples on GitHub: (https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/tree/master/examples)
- Adafruit CPX Guided Tour (Intro for the Hardware) (https://learn.adafruit.com/adafruit-circuit-playground-express/guided-tour)
- Format Adafruit CPX device:
- Tutorial for formatting Adafruit CPX for CircuitPython (https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)
- Download Firmware .uf2 file (https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart)
- Download the latest version of the Adafruit CPX library (link: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries)

## How to use

To use Device Simulator Express, install the extension from the marketplace and reload VS Code.

### 1. Start with the “New File” Command.

1. Type in Device Simulator Express: New File” in the command palette(`CTRL+SHIFT+P`to open the command palette).
!["New File" animation](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/newFile.gif)
2. Name and save your file somewhere, and we’re good to go!(3)
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.

![How to find example code screenshot](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/findExamples.jpg)

### 2. Start from an existing python file.

1. Open the folder or your .py file in Visual Studio Code.
2. Run `open Simulator` from the command palette or icon in the editor toolbar.

### 3. Run your code on the simulator .

![How to run the simulator animation](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/run.gif)

- Run `Run Simulator` from the command palette or icon in the editor toolbar.
- You can use the `Play` or `Refresh` button on the simulator webview.

### 4. Deploy your code to the physical device

Before deploying the python code to your CPX device, you need to format your device following these tutorials:

1. Download the firmware with the .uf2 file (link: https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart)
2. Download the lastest version of the cpx library (link: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).
**_Note:_** Make sure you name your file main.py or code.py: the device automatically runs the first file that is likely named.

!["Deploy to Device" example](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/deployToBoard.png)

### 5. Use the Serial Monitor for your Adafruit CPX device(available Windows and Mac only)

1. Plug in your CPX device (make sure it’s formatted properly already)
2. Run the command `Device Simulator Express: Open Serial Monitor`
3. Select your baud rate for the serial port
4. The print() statements in your code will show in the output console

### 6. Use the sensors in the Device Simulator Express

Generating input for the sensors can be done by interacting directly with device on the webview
or by using the toolbar.

- **Switch, push buttons and capacitive touch:** click directly on the corresponding element on the device or use the keybindings.
- **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.
- **Shake detection:** go to the motion sensor section in the toolbar and click on the shake button.

### 7. Debug your project on the simulator

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

## Commands

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:

- `Device Simulator Express: New File`: Opens an unsaved .py file with template code, also open the simulator.
- `Device Simulator Express: Open Simulator`: Opens the simulator in the webView
- `Device Simulator Express: Run on Simulator`: Runs python code on the simulator
- `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
- `Device Simulator Express: Open Serial Monitor`: Opens the serial monitor in the integrated output window.
- `Device Simulator Express: Close Serial Monitor`: Stops the serial monitor and releases the serial port.
- `Device Simulator Express: Change Baud Rate`: Changes the baud rate of the selected serial port. For Adafruit CPX, the default baud rate is 115200.
- `Device Simulator Express: Select Serial Port`: Changes the current serial port.

## Keybindings

In Device Simulator Express, you can use keyboard to interact with the device:

- Push Button `A & B: A B`
- Capacitive Touch Sensor `A1 – A7: SHIFT + 1~7`
- Slider Switch: `SHIFT + S`
- Refresh the simulator: `SHIFT + R`

## Provide feedback

To report issues, provide feedback or requests, please use this link: [Provide Feedback](https://aka.ms/AA5xpxx).
We would love to hear from you about your experience to keep improving our project.

## Privacy and Telemetry Notice

- [Data collection](PRIVACY.md)
### Data Collection

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.

### Disable Telemetry

The Microsoft Device Simulator Express Extension for Visual Studio Code collects usage
data and sends it to Microsoft to help improve our products and
services. Read our
[privacy statement](https://privacy.microsoft.com/privacystatement) to
learn more. This extension respects the `telemetry.enableTelemetry`
setting which you can learn more about at
https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting.

To disable telemetry, follow these steps:
1) Open **File** (Open **Code** on macOS)
2) Select **Preferences**
3) Select **Settings**
4) Search for `telemetry`
5) Uncheck the **Telemetry: Enable Telemetry** setting

## Third Party Notice

- [Third Party Notice](ThirdPartyNotices.txt)
A `ThirdPartyNotices.txt` file is provided in the extension's source code listing the appropriate third-party notices.

## Troubleshooting Tips

- The first time you install the extension, you'll need to execute the `run` command at least once in order to access auto-completion.
- 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.
- To open the output panel again after closing it go to VS Code menu: `View->Output`.
- If you have pylint enabled, it might underline the import of the adafruit_circuitplayground library, but it will work correctly.
- 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`.
- 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.
- When you are using the serial monitor, if you get some unusual error messages, unplug the device and reload the VS Code windows.

## License

Device Simulator Express, a Microsoft Garage project

Copyright (c) Microsoft Corporation. All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

## Notes

(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.
(2) You can chose to see to see the prompt or not by changing the extension configirations.
(3) To be able to run the file from your physical device, it should either be named code.py or main.py.
Loading