diff --git a/README.md b/README.md index 7e23d1935..5580104cc 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ Then, if you are on Windows, you will also need to install the Python Pywin32 pa #### 5. Use the Serial Monitor for your Adafruit CPX device (available on Windows and Mac only) 1. Plug in your CPX device (make sure it’s formatted properly already) -2. Run the command `"Device Simulator Express: [Circuit Playground Express] Open Serial Monitor"` +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 @@ -135,10 +135,10 @@ Device Simulator Express provides several commands in the Command Palette (F1 or - `Device Simulator Express: [Circuit Playground Express] Open Simulator`: Opens the simulator in the webView - `Device Simulator Express: [Circuit Playground Express] Run on Simulator`: Runs python code on the simulator - `Device Simulator Express: [Circuit Playground Express] Deploy to Device`: Copies & Pastes the current file to CIRCUITPY drive if detected a CPX is plugged in -- `Device Simulator Express: [Circuit Playground Express] Open Serial Monitor`: Opens the serial monitor in the integrated output window. -- `Device Simulator Express: [Circuit Playground Express] Close Serial Monitor`: Stops the serial monitor and releases the serial port. -- `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. -- `Device Simulator Express: [Circuit Playground Express] Select Serial Port`: Changes the current serial port. +- `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 and the BBC micro:bit, the default baud rate is 115200. +- `Device Simulator Express: Select Serial Port`: Changes the current serial port. ### Keybindings @@ -159,7 +159,8 @@ In Device Simulator Express, you can use keyboard to interact with the device: - IntelliSense and syntax highlighting for micro:bit code - Template file generation - Integrated Python Debugging for the Simulator -- Deploy MicroPython code to the physical device. +- Deploy MicroPython code to the physical device +- Serial monitor (available on Windows and Mac only) - Simulation of the micro:bit device, including: - 25 LEDs - Light sensor diff --git a/docs/how-to-use.md b/docs/how-to-use.md index 7c7b9a9ae..d94b4987c 100644 --- a/docs/how-to-use.md +++ b/docs/how-to-use.md @@ -15,8 +15,8 @@ Commands are accessible through : - **Run Simulator** : runs the code you have opened in the simulator (make sure you've clicked on a valid code file). _(**Note :** will open the simulator webview if it's not open yet)_. -- **Deploy to Device** : saves the code to a Circuit Playground Express. - _(**Note :** the board needs to be correctly formatted to a `CIRCUITPY` drive first. If that's not the case check [Installing CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython) to correctly format it)_. +- **Deploy to Device** : saves the code to the connected device. + _(**Note :** For the Circuit Playground Express, the board needs to be correctly formatted to a `CIRCUITPY` drive first. If that's not the case check [Installing CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython) to correctly format it)_. * **Select Serial Port** : selects the serial port of the board you want the serial monitor to interact with. (2) _(**Note :** USB detection must be enabled in the extension settings.)_ @@ -82,7 +82,7 @@ Here are the settings you can change in the Device Simulator Express configurati - 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 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`. +- For the Circuit Playground Express, 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 you `Settings` and check the port used under `'Device Simulator Express: Debugger Server Port'`. You can either change it (usually ports above 5000 could work) or try to free it, then start debugging again. ### Notes diff --git a/locales/en/package.i18n.json b/locales/en/package.i18n.json index 9ed84c5ab..6681f33da 100644 --- a/locales/en/package.i18n.json +++ b/locales/en/package.i18n.json @@ -2,13 +2,13 @@ "deviceSimulatorExpressExtension.commands.common.installDependencies": "Install Extension Dependencies", "deviceSimulatorExpressExtension.commands.common.label": "Device Simulator Express", "deviceSimulatorExpressExtension.commands.common.runSimulator": "Run Simulator", - "deviceSimulatorExpressExtension.commands.cpx.changeBaudRate": "[Circuit Playground Express] Change Baud Rate", - "deviceSimulatorExpressExtension.commands.cpx.closeSerialMonitor": "[Circuit Playground Express] Close Serial Monitor", - "deviceSimulatorExpressExtension.commands.cpx.openSerialMonitor": "[Circuit Playground Express] Open Serial Monitor", + "deviceSimulatorExpressExtension.commands.common.changeBaudRate": "Change Baud Rate", + "deviceSimulatorExpressExtension.commands.common.closeSerialMonitor": "Close Serial Monitor", + "deviceSimulatorExpressExtension.commands.common.openSerialMonitor": "Open Serial Monitor", + "deviceSimulatorExpressExtension.commands.common.selectSerialPort": "Select Serial Port", "deviceSimulatorExpressExtension.commands.cpx.openSimulator": "[Circuit Playground Express] Open Simulator", "deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File", "deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device", - "deviceSimulatorExpressExtension.commands.cpx.selectSerialPort": "[Circuit Playground Express] Select Serial Port", "deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device", "deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator", "deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File", diff --git a/package.json b/package.json index 9dfcf51cf..59e9b4417 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,12 @@ ], "activationEvents": [ "onCommand:deviceSimulatorExpress.common.installDependencies", + "onCommand:deviceSimulatorExpress.common.openSerialMonitor", "onCommand:deviceSimulatorExpress.common.runSimulator", + "onCommand:deviceSimulatorExpress.common.selectSerialPort", "onCommand:deviceSimulatorExpress.cpx.deployToDevice", "onCommand:deviceSimulatorExpress.cpx.newFile", - "onCommand:deviceSimulatorExpress.cpx.openSerialMonitor", "onCommand:deviceSimulatorExpress.cpx.openSimulator", - "onCommand:deviceSimulatorExpress.cpx.selectSerialPort", "onCommand:deviceSimulatorExpress.microbit.deployToDevice", "onCommand:deviceSimulatorExpress.microbit.newFile", "onCommand:deviceSimulatorExpress.microbit.openSimulator", @@ -51,43 +51,44 @@ "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { - "command": "deviceSimulatorExpress.common.runSimulator", - "title": "%deviceSimulatorExpressExtension.commands.common.runSimulator%", + "command": "deviceSimulatorExpress.common.changeBaudRate", + "title": "%deviceSimulatorExpressExtension.commands.common.changeBaudRate%", "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { - "command": "deviceSimulatorExpress.cpx.changeBaudRate", - "title": "%deviceSimulatorExpressExtension.commands.cpx.changeBaudRate%", + "command": "deviceSimulatorExpress.common.closeSerialMonitor", + "title": "%deviceSimulatorExpressExtension.commands.common.closeSerialMonitor%", "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { - "command": "deviceSimulatorExpress.cpx.closeSerialMonitor", - "title": "%deviceSimulatorExpressExtension.commands.cpx.closeSerialMonitor%", + + "command": "deviceSimulatorExpress.common.openSerialMonitor", + "title": "%deviceSimulatorExpressExtension.commands.common.openSerialMonitor%", "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { - "command": "deviceSimulatorExpress.cpx.deployToDevice", - "title": "%deviceSimulatorExpressExtension.commands.cpx.deployToDevice%", + "command": "deviceSimulatorExpress.common.selectSerialPort", + "title": "%deviceSimulatorExpressExtension.commands.common.selectSerialPort%", "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { - "command": "deviceSimulatorExpress.cpx.newFile", - "title": "%deviceSimulatorExpressExtension.commands.cpx.newFile%", + "command": "deviceSimulatorExpress.common.runSimulator", + "title": "%deviceSimulatorExpressExtension.commands.common.runSimulator%", "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { - "command": "deviceSimulatorExpress.cpx.openSerialMonitor", - "title": "%deviceSimulatorExpressExtension.commands.cpx.openSerialMonitor%", + "command": "deviceSimulatorExpress.cpx.deployToDevice", + "title": "%deviceSimulatorExpressExtension.commands.cpx.deployToDevice%", "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { - "command": "deviceSimulatorExpress.cpx.openSimulator", - "title": "%deviceSimulatorExpressExtension.commands.cpx.openSimulator%", + "command": "deviceSimulatorExpress.cpx.newFile", + "title": "%deviceSimulatorExpressExtension.commands.cpx.newFile%", "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { - "command": "deviceSimulatorExpress.cpx.selectSerialPort", - "title": "%deviceSimulatorExpressExtension.commands.cpx.selectSerialPort%", + "command": "deviceSimulatorExpress.cpx.openSimulator", + "title": "%deviceSimulatorExpressExtension.commands.cpx.openSimulator%", "category": "%deviceSimulatorExpressExtension.commands.common.label%" }, { diff --git a/package.nls.json b/package.nls.json index 0a2483f0d..2f574c7eb 100644 --- a/package.nls.json +++ b/package.nls.json @@ -2,13 +2,13 @@ "deviceSimulatorExpressExtension.commands.common.installDependencies": "Install Extension Dependencies", "deviceSimulatorExpressExtension.commands.common.label": "Device Simulator Express", "deviceSimulatorExpressExtension.commands.common.runSimulator": "Run Simulator", - "deviceSimulatorExpressExtension.commands.cpx.changeBaudRate": "[Circuit Playground Express] Change Baud Rate", - "deviceSimulatorExpressExtension.commands.cpx.closeSerialMonitor": "[Circuit Playground Express] Close Serial Monitor", - "deviceSimulatorExpressExtension.commands.cpx.openSerialMonitor": "[Circuit Playground Express] Open Serial Monitor", + "deviceSimulatorExpressExtension.commands.common.changeBaudRate": "Change Baud Rate", + "deviceSimulatorExpressExtension.commands.common.closeSerialMonitor": "Close Serial Monitor", + "deviceSimulatorExpressExtension.commands.common.openSerialMonitor": "Open Serial Monitor", + "deviceSimulatorExpressExtension.commands.common.selectSerialPort": "Select Serial Port", "deviceSimulatorExpressExtension.commands.cpx.openSimulator": "[Circuit Playground Express] Open Simulator", "deviceSimulatorExpressExtension.commands.cpx.newFile": "[Circuit Playground Express] New File", "deviceSimulatorExpressExtension.commands.cpx.deployToDevice": "[Circuit Playground Express] Deploy to Device", - "deviceSimulatorExpressExtension.commands.cpx.selectSerialPort": "[Circuit Playground Express] Select Serial Port", "deviceSimulatorExpressExtension.commands.microbit.deployToDevice": "[micro:bit] Deploy to Device", "deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator", "deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File", diff --git a/src/constants.ts b/src/constants.ts index 1be7ca4c8..16910c4f2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -315,14 +315,14 @@ export enum TelemetryEventName { COMMAND_RUN_SIMULATOR_BUTTON = "COMMAND.RUN.SIMULATOR_BUTTON", COMMAND_RUN_PALETTE = "COMMAND.RUN.PALETTE", COMMAND_INSTALL_EXTENSION_DEPENDENCIES = "COMMAND.INSTALL.EXTENSION.DEPENDENCIES", + COMMAND_SERIAL_MONITOR_CHOOSE_PORT = "COMMAND.SERIAL_MONITOR.CHOOSE_PORT", + COMMAND_SERIAL_MONITOR_OPEN = "COMMAND.SERIAL_MONITOR.OPEN", + COMMAND_SERIAL_MONITOR_BAUD_RATE = "COMMAND.SERIAL_MONITOR.BAUD_RATE", + COMMAND_SERIAL_MONITOR_CLOSE = "COMMAND.SERIAL_MONITOR.CLOSE", CPX_COMMAND_DEPLOY_DEVICE = "CPX.COMMAND.DEPLOY.DEVICE", CPX_COMMAND_NEW_FILE = "CPX.COMMAND.NEW.FILE.CPX", CPX_COMMAND_OPEN_SIMULATOR = "CPX.COMMAND.OPEN.SIMULATOR", - CPX_COMMAND_SERIAL_MONITOR_CHOOSE_PORT = "CPX.COMMAND.SERIAL_MONITOR.CHOOSE_PORT", - CPX_COMMAND_SERIAL_MONITOR_OPEN = "CPX.COMMAND.SERIAL_MONITOR.OPEN", - CPX_COMMAND_SERIAL_MONITOR_BAUD_RATE = "CPX.COMMAND.SERIAL_MONITOR.BAUD_RATE", - CPX_COMMAND_SERIAL_MONITOR_CLOSE = "CPX.COMMAND.SERIAL_MONITOR.CLOSE", MICROBIT_COMMAND_DEPLOY_DEVICE = "MICROBIT.COMMAND.DEPLOY.DEVICE", MICROBIT_COMMAND_NEW_FILE = "MICROBIT.COMMAND.NEW.FILE", diff --git a/src/extension.ts b/src/extension.ts index 57ad859c3..4d636caa8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -860,13 +860,13 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push(serialMonitor); } - const cpxSelectSerialPort: vscode.Disposable = vscode.commands.registerCommand( - "deviceSimulatorExpress.cpx.selectSerialPort", + const selectSerialPort: vscode.Disposable = vscode.commands.registerCommand( + "deviceSimulatorExpress.common.selectSerialPort", () => { if (serialMonitor) { telemetryAI.runWithLatencyMeasure(() => { serialMonitor.selectSerialPort(null, null); - }, TelemetryEventName.CPX_COMMAND_SERIAL_MONITOR_CHOOSE_PORT); + }, TelemetryEventName.COMMAND_SERIAL_MONITOR_CHOOSE_PORT); } else { vscode.window.showErrorMessage( CONSTANTS.ERROR.NO_FOLDER_OPENED @@ -876,13 +876,13 @@ export async function activate(context: vscode.ExtensionContext) { } ); - const cpxOpenSerialMonitor: vscode.Disposable = vscode.commands.registerCommand( - "deviceSimulatorExpress.cpx.openSerialMonitor", + const openSerialMonitor: vscode.Disposable = vscode.commands.registerCommand( + "deviceSimulatorExpress.common.openSerialMonitor", () => { if (serialMonitor) { telemetryAI.runWithLatencyMeasure( serialMonitor.openSerialMonitor.bind(serialMonitor), - TelemetryEventName.CPX_COMMAND_SERIAL_MONITOR_OPEN + TelemetryEventName.COMMAND_SERIAL_MONITOR_OPEN ); } else { vscode.window.showErrorMessage( @@ -893,13 +893,13 @@ export async function activate(context: vscode.ExtensionContext) { } ); - const cpxChangeBaudRate: vscode.Disposable = vscode.commands.registerCommand( - "deviceSimulatorExpress.cpx.changeBaudRate", + const changeBaudRate: vscode.Disposable = vscode.commands.registerCommand( + "deviceSimulatorExpress.common.changeBaudRate", () => { if (serialMonitor) { telemetryAI.runWithLatencyMeasure( serialMonitor.changeBaudRate.bind(serialMonitor), - TelemetryEventName.CPX_COMMAND_SERIAL_MONITOR_BAUD_RATE + TelemetryEventName.COMMAND_SERIAL_MONITOR_BAUD_RATE ); } else { vscode.window.showErrorMessage( @@ -910,13 +910,13 @@ export async function activate(context: vscode.ExtensionContext) { } ); - const cpxCloseSerialMonitor: vscode.Disposable = vscode.commands.registerCommand( - "deviceSimulatorExpress.cpx.closeSerialMonitor", + const closeSerialMonitor: vscode.Disposable = vscode.commands.registerCommand( + "deviceSimulatorExpress.common.closeSerialMonitor", (port, showWarning = true) => { if (serialMonitor) { telemetryAI.runWithLatencyMeasure(() => { serialMonitor.closeSerialMonitor(port, showWarning); - }, TelemetryEventName.CPX_COMMAND_SERIAL_MONITOR_CLOSE); + }, TelemetryEventName.COMMAND_SERIAL_MONITOR_CLOSE); } else { vscode.window.showErrorMessage( CONSTANTS.ERROR.NO_FOLDER_OPENED @@ -1036,13 +1036,13 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push( installDependencies, runSimulator, - cpxChangeBaudRate, - cpxCloseSerialMonitor, + changeBaudRate, + closeSerialMonitor, cpxDeployToDevice, cpxNewFile, - cpxOpenSerialMonitor, + openSerialMonitor, cpxOpenSimulator, - cpxSelectSerialPort, + selectSerialPort, microbitOpenSimulator, microbitNewFile, microbitDeployToDevice, diff --git a/src/serialMonitor.ts b/src/serialMonitor.ts index 2fd01588f..17144eeb6 100644 --- a/src/serialMonitor.ts +++ b/src/serialMonitor.ts @@ -77,7 +77,7 @@ export class SerialMonitor implements vscode.Disposable { STATUS_BAR_PRIORITY.PORT ); this._portsStatusBar.command = - "deviceSimulatorExpress.cpx.selectSerialPort"; + "deviceSimulatorExpress.common.selectSerialPort"; this._portsStatusBar.tooltip = "Select Serial Port"; this._portsStatusBar.show(); @@ -86,7 +86,7 @@ export class SerialMonitor implements vscode.Disposable { STATUS_BAR_PRIORITY.OPEN_PORT ); this._openPortStatusBar.command = - "deviceSimulatorExpress.cpx.openSerialMonitor"; + "deviceSimulatorExpress.common.openSerialMonitor"; this._openPortStatusBar.text = `$(plug)`; this._openPortStatusBar.tooltip = "Open Serial Monitor"; this._openPortStatusBar.show(); @@ -96,7 +96,7 @@ export class SerialMonitor implements vscode.Disposable { STATUS_BAR_PRIORITY.BAUD_RATE ); this._baudRateStatusBar.command = - "deviceSimulatorExpress.cpx.changeBaudRate"; + "deviceSimulatorExpress.common.changeBaudRate"; this._baudRateStatusBar.tooltip = "Baud Rate"; this._baudRateStatusBar.text = defaultBaudRate.toString(); this.updatePortListStatus(null); @@ -281,13 +281,13 @@ export class SerialMonitor implements vscode.Disposable { private updatePortStatus(isOpened: boolean) { if (isOpened) { this._openPortStatusBar.command = - "deviceSimulatorExpress.cpx.closeSerialMonitor"; + "deviceSimulatorExpress.common.closeSerialMonitor"; this._openPortStatusBar.text = `$(x)`; this._openPortStatusBar.tooltip = "Close Serial Monitor"; this._baudRateStatusBar.show(); } else { this._openPortStatusBar.command = - "deviceSimulatorExpress.cpx.openSerialMonitor"; + "deviceSimulatorExpress.common.openSerialMonitor"; this._openPortStatusBar.text = `$(plug)`; this._openPortStatusBar.tooltip = "Open Serial Monitor"; this._baudRateStatusBar.hide();