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

Commit 94019e0

Browse files
Merge branch 'dev' into users/t-xunguy/ab-fix
2 parents 49dfdae + 0b7e5b4 commit 94019e0

16 files changed

+218
-203
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ Before deploying the python code to your CPX device, you need to format your dev
101101

102102
1. Download the firmware with the .uf2 file (link: https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart)
103103
2. Download the lastest version of the cpx library (link: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries).
104-
**_Note:_** Make sure you name your file `main.py` or `code.py`: the device automatically runs the first file that is likely named. This is the convention for CircuitPython ([source](https://learn.adafruit.com/welcome-to-circuitpython/creating-and-editing-code#naming-your-program-file-7-32)).
105104

106105
Then, if you are on Windows, you will also need to install the Python Pywin32 package. Use the following command in the console: `pip install pywin32`
107106

@@ -135,7 +134,7 @@ Device Simulator Express provides several commands in the Command Palette (F1 or
135134
- `Device Simulator Express: [Circuit Playground Express] New File`: Opens an unsaved .py file with template code, also opens the simulator.
136135
- `Device Simulator Express: [Circuit Playground Express] Open Simulator`: Opens the simulator in the webView
137136
- `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
137+
- `Device Simulator Express: [Circuit Playground Express] Deploy to Device`: Copies & Pastes the current file to CIRCUITPY drive if detected a CPX is plugged in
139138
- `Device Simulator Express: [Circuit Playground Express] Open Serial Monitor`: Opens the serial monitor in the integrated output window.
140139
- `Device Simulator Express: [Circuit Playground Express] Close Serial Monitor`: Stops the serial monitor and releases the serial port.
141140
- `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.
@@ -160,6 +159,7 @@ In Device Simulator Express, you can use keyboard to interact with the device:
160159
- IntelliSense and syntax highlighting for micro:bit code
161160
- Template file generation
162161
- Integrated Python Debugging for the Simulator
162+
- Deploy MicroPython code to the physical device.
163163
- Simulation of the micro:bit device, including:
164164
- 25 LEDs
165165
- Light sensor
@@ -252,4 +252,3 @@ A `ThirdPartyNotices.txt` file is provided in the extension's source code listin
252252

253253
1. Make sure that when you type _python_ in a terminal, the command is recognized and you have the correct version. 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.
254254
2. You can choose to see the prompt or not by changing the extension configurations.
255-
3. To be able to run the file on your physical device, it should either be named code.py or main.py.

ThirdPartyNotices.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5829,6 +5829,26 @@ The above copyright notice and this permission notice shall be included in all c
58295829
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.
58305830

58315831

5832+
uflash
5833+
The MIT License (MIT)
5834+
Copyright (c) 2015-2018 Nicholas H.Tollervey and others.
5835+
5836+
Permission is hereby granted, free of charge, to any person obtaining a copy of
5837+
this software and associated documentation files (the "Software"), to deal in
5838+
the Software without restriction, including without limitation the rights to
5839+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
5840+
the Software, and to permit persons to whom the Software is furnished to do so,
5841+
subject to the following conditions:
5842+
5843+
The above copyright notice and this permission notice shall be included in all
5844+
copies or substantial portions of the Software.
5845+
5846+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5847+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
5848+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
5849+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
5850+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
5851+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58325852
-------------------------------------------------------------------
58335853

58345854
-------------------------------------------------------------------

docs/how-to-use.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Commands are accessible through :
99

1010
- **Open Simulator** : opens the webview of the simulator.
1111

12-
- **New File** : opens an unsaved file with links to help you and a code snippet that you can save as `code.py` / `main.py`.
12+
- **New File** : opens an unsaved file to help you and a code snippet that you can save and play around with.
1313
_(**Note :** will open the simulator webview if it's not open yet)_.
1414

1515
- **Run Simulator** : runs the code you have opened in the simulator (make sure you've clicked on a valid code file).

locales/en/out/constants.i18n.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
"dialogResponses.readInstall": "Read installation docs",
1313
"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.",
1414
"error.debuggingSessionInProgress": "[ERROR] A debugging session is currently in progress, please stop it before running your code. \n",
15-
"error.incorrectFileNameForDevice": "[ERROR] Can\\'t deploy to your Circuit Playground Express device, please rename your file to \"code.py\" or \"main.py\". \n",
16-
"error.incorrectFileNameForDevicePopup": "Seems like you have a different file name than what the CPX requires, please rename it to \"code.py\" or \"main.py\".",
17-
"error.incorrectFileNameForSimulatorPopup": "We want your code to work on your actual board as well. Make sure you name your file \"code.py\" or \"main.py\" to be able to run your code on an actual physical device.",
18-
"error.invalidFileNameDebug": "The file you tried to debug isn\\'t named \"code.py\" or \"main.py\\. Rename your file if you want your code to work on your actual device.",
1915
"error.noDevice": "No plugged in boards detected. Please double check if your board is connected and/or properly formatted",
2016
"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",
2117
"error.noFolderCreated": "In order to use the Serial Monitor, you need to open a folder and reload VS Code.",

locales/en/package.i18n.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
"deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File",
1010
"deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device",
1111
"deviceSimulatorExpressExtension.commands.cpx.selectSerialPort": "[Circuit Playground Express] Select Serial Port",
12+
"deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device",
1213
"deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator",
1314
"deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File",
1415
"deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration",
1516
"deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.",
1617
"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.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.",
1819
"deviceSimulatorExpressExtension.configuration.properties.previewMode": "Enable this to test out and play with the new micro:bit simulator!"
1920
}

package-lock.json

Lines changed: 4 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"onCommand:deviceSimulatorExpress.cpx.openSerialMonitor",
3838
"onCommand:deviceSimulatorExpress.cpx.openSimulator",
3939
"onCommand:deviceSimulatorExpress.cpx.selectSerialPort",
40+
"onCommand:deviceSimulatorExpress.microbit.deployToDevice",
4041
"onCommand:deviceSimulatorExpress.microbit.newFile",
4142
"onCommand:deviceSimulatorExpress.microbit.openSimulator",
4243
"onDebug"
@@ -89,6 +90,11 @@
8990
"title": "%deviceSimulatorExpressExtension.commands.cpx.selectSerialPort%",
9091
"category": "%deviceSimulatorExpressExtension.commands.common.label%"
9192
},
93+
{
94+
"command": "deviceSimulatorExpress.microbit.deployToDevice",
95+
"title": "%deviceSimulatorExpressExtension.commands.microbit.deployToDevice%",
96+
"category": "%deviceSimulatorExpressExtension.commands.common.label%"
97+
},
9298
{
9399
"command": "deviceSimulatorExpress.microbit.openSimulator",
94100
"title": "%deviceSimulatorExpressExtension.commands.microbit.openSimulator%",
@@ -102,6 +108,12 @@
102108
],
103109
"menus": {
104110
"commandPalette": [
111+
{
112+
"command": "deviceSimulatorExpress.microbit.deployToDevice",
113+
"title": "%deviceSimulatorExpressExtension.commands.microbit.deployToDevice%",
114+
"category": "%deviceSimulatorExpressExtension.commands.common.label%",
115+
"when": "config.deviceSimulatorExpress.previewMode"
116+
},
105117
{
106118
"command": "deviceSimulatorExpress.microbit.openSimulator",
107119
"title": "%deviceSimulatorExpressExtension.commands.microbit.openSimulator%",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File",
1010
"deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device",
1111
"deviceSimulatorExpressExtension.commands.cpx.selectSerialPort": "[Circuit Playground Express] Select Serial Port",
12+
"deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device",
1213
"deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator",
1314
"deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File",
1415
"deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration",

src/constants.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ export const CONSTANTS = {
6565
`[ERROR] Failed to open serial port ${port} due to error: ${error}. \n`
6666
);
6767
},
68-
INCORRECT_FILE_NAME_FOR_DEVICE: localize(
69-
"error.incorrectFileNameForDevice",
70-
'[ERROR] Can\'t deploy to your Circuit Playground Express device, please rename your file to "code.py" or "main.py". \n'
71-
),
72-
INCORRECT_FILE_NAME_FOR_DEVICE_POPUP: localize(
73-
"error.incorrectFileNameForDevicePopup",
74-
'Seems like you have a different file name than what CPX requires, please rename it to "code.py" or "main.py".'
75-
),
7668
INSTALLATION_ERROR: localize(
7769
"error.installationError",
7870
"Installation Error"
@@ -85,6 +77,10 @@ export const CONSTANTS = {
8577
"error.invalidPythonPath",
8678
'We found that your selected Python interpreter version is too low to run the extension. Please upgrade to version 3.7+ or select a different interpreter (CTRL+SHIFT+P and type "python.selectInterpreter") and restart the application.'
8779
),
80+
LOW_PYTHON_VERSION_FOR_MICROBIT_DEPLOYMENT: localize(
81+
"error.lowPythonVersionForMicrobitDeployment",
82+
"To deploy your code to the micro:bit, you must be using Python 3.3+"
83+
),
8884
NO_DEVICE: localize(
8985
"error.noDevice",
9086
"No plugged in boards detected. Please double check if your board is connected and/or properly formatted"
@@ -155,11 +151,11 @@ export const CONSTANTS = {
155151
),
156152
DEPLOY_SUCCESS: localize(
157153
"info.deploySuccess",
158-
"\n[INFO] Code successfully copied! Your Circuit Playground Express should be loading and ready to go shortly.\n"
154+
"\n[INFO] Code successfully copied! Your device should be loading and ready to go shortly.\n"
159155
),
160156
EXTENSION_ACTIVATED: localize(
161157
"info.extensionActivated",
162-
"Congratulations, your extension Adafruit_Simulator is now active!"
158+
"Congratulations, your extension Device Simulator Express is now active!"
163159
),
164160
FILE_SELECTED: (filePath: string) => {
165161
return localize(
@@ -171,10 +167,6 @@ export const CONSTANTS = {
171167
"info.firstTimeWebview",
172168
'To reopen the simulator select the command "Open Simulator" from command palette.'
173169
),
174-
INCORRECT_FILE_NAME_FOR_SIMULATOR_POPUP: localize(
175-
"info.incorrectFileNameForSimulatorPopup",
176-
'We want your code to work on your actual board as well. Make sure you name your file "code.py" or "main.py" to be able to run your code on an actual physical device'
177-
),
178170
INSTALLING_PYTHON_VENV: localize(
179171
"info.installingPythonVenv",
180172
"A virtual environment is currently being created. The required Python packages will be installed. You will be prompted a message telling you when the installation is done."
@@ -187,10 +179,6 @@ export const CONSTANTS = {
187179
"info.installPythonVenv",
188180
"Do you want us to try and install this extension's dependencies via virtual environment for you?"
189181
),
190-
INVALID_FILE_NAME_DEBUG: localize(
191-
"info.invalidFileNameDebug",
192-
'The file you tried to debug isn\'t named "code.py" or "main.py". Rename your file if you want your code to work on your actual device.'
193-
),
194182
NEW_FILE: localize(
195183
"info.newFile",
196184
"New to Python or the Circuit Playground Express? We are here to help!"
@@ -336,6 +324,7 @@ export enum TelemetryEventName {
336324
CPX_COMMAND_SERIAL_MONITOR_BAUD_RATE = "CPX.COMMAND.SERIAL_MONITOR.BAUD_RATE",
337325
CPX_COMMAND_SERIAL_MONITOR_CLOSE = "CPX.COMMAND.SERIAL_MONITOR.CLOSE",
338326

327+
MICROBIT_COMMAND_DEPLOY_DEVICE = "MICROBIT.COMMAND.DEPLOY.DEVICE",
339328
MICROBIT_COMMAND_NEW_FILE = "MICROBIT.COMMAND.NEW.FILE",
340329
MICROBIT_COMMAND_OPEN_SIMULATOR = "MICROBIT.COMMAND.OPEN.SIMULATOR",
341330

@@ -373,12 +362,16 @@ export enum TelemetryEventName {
373362
CPX_SUCCESS_COMMAND_DEPLOY_DEVICE = "CPX.SUCCESS.COMMAND.DEPLOY.DEVICE",
374363

375364
MICROBIT_ERROR_COMMAND_NEW_FILE = "MICROBIT.ERROR.COMMAND.NEW.FILE",
365+
MICROBIT_ERROR_DEPLOY_WITHOUT_DEVICE = "MICROBIT.ERROR.DEPLOY.WITHOUT.DEVICE",
366+
MICROBIT_ERROR_PYTHON_DEVICE_PROCESS = "MICROBIT.ERROR.PYTHON.DEVICE.PROCESS",
367+
MICROBIT_SUCCESS_COMMAND_DEPLOY_DEVICE = "MICROBIT.SUCCESS.COMMAND.DEPLOY.DEVICE",
376368

377369
// Performance
378370
CPX_PERFORMANCE_DEPLOY_DEVICE = "CPX.PERFORMANCE.DEPLOY.DEVICE",
379371
CPX_PERFORMANCE_NEW_FILE = "CPX.PERFORMANCE.NEW.FILE",
380372
CPX_PERFORMANCE_OPEN_SIMULATOR = "CPX.PERFORMANCE.OPEN.SIMULATOR",
381373

374+
MICROBIT_PERFORMANCE_DEPLOY_DEVICE = "MICROBIT.PERFORMANCE.DEPLOY.DEVICE",
382375
MICROBIT_PERFORMANCE_NEW_FILE = "MICROBIT.PERFORMANCE.NEW.FILE",
383376
MICROBIT_PERFORMANCE_OPEN_SIMULATOR = "MICROBIT.PERFORMANCE.OPEN.SIMULATOR",
384377
}
@@ -450,11 +443,6 @@ export namespace DialogResponses {
450443

451444
export const CPX_CONFIG_FILE = path.join(".vscode", "cpx.json");
452445

453-
export const USER_CODE_NAMES = {
454-
CODE_PY: "code.py",
455-
MAIN_PY: "main.py",
456-
};
457-
458446
export const STATUS_BAR_PRIORITY = {
459447
PORT: 20,
460448
OPEN_PORT: 30,

0 commit comments

Comments
 (0)