Skip to content

Commit

Permalink
Merge pull request #62 from paulober/develop
Browse files Browse the repository at this point in the history
v3.0.1 Hot fix
  • Loading branch information
paulober authored Apr 10, 2023
2 parents 59c5981 + e2c7898 commit bc27761
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 43 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ All notable changes to the "pico-w-go" extension will be documented in this file
## Known issues
- Run current file does not include modules that are localy imported and in current workspace, unless you upload the python file containing the module via the upload file or project feature first. (since ever)
- Mounting virtual workspace causes existing vREPLs to freeze so they need to be disposed manually for some reason. (maybe cauaused by vscode)
- `autoConnect` is currently not working

---

## [3.0.1] - 2023-04-11

# Changed
- Small UX improvements
- Fixes [#58](https://github.com/paulober/Pico-W-Go/issues/58), Run button no stop option

# Removes
- Artificial upload constraint ([#61](https://github.com/paulober/Pico-W-Go/issues/61))

## [3.0.0] - 2023-04-10

# Added
Expand All @@ -29,7 +39,7 @@ to cope with the bottleneck of a *serial* connection. For stability reasons, I t
- Better detection for OS and hardware
- Improved stability for file transfers
- Updated stubs for 'Firmware v1.19.1-1009 nightly'
- Shrunk extension file size because it's not required to bundle serialport package anymore within the extn
- Shrunk extension file size because it's not required to bundle serialport package anymore within the extension

# Removed
- `ctrlCOnConnect` setting, because its now the default
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pico-w-go",
"displayName": "Pico-W-Go",
"description": "Autocompletion, remote Workspace and a REPL console for the Raspberry Pi Pico (W).",
"version": "3.0.0",
"version": "3.0.1",
"publisher": "paulober",
"license": "MPL-2.0",
"homepage": "https://github.com/paulober/Pico-W-Go/blob/main/README.md",
Expand Down Expand Up @@ -80,7 +80,7 @@
{
"command": "picowgo.uploadFile",
"title": "Pico-W-Go > Upload current file",
"enablement": "resourceScheme != pico && isFileSystemResource && editorLangId == python && resourceExtname == .py"
"enablement": "resourceScheme != pico && isFileSystemResource"
},
{
"command": "picowgo.download",
Expand All @@ -99,7 +99,7 @@
{
"command": "picowgo.runselection",
"title": "Pico-W-Go > Run current selection",
"enablement": "!inQuickOpen && !listFocus && isFileSystemResource && editorLangId == python && resourceExtname == .py"
"enablement": "!inQuickOpen && !listFocus && isFileSystemResource && editorLangId == python"
},
{
"command": "picowgo.deleteAllFiles",
Expand Down Expand Up @@ -308,7 +308,7 @@
"type": "string",
"default": null,
"title": "Python Path",
"description": "Path to the Python interpreter. Defaults to null.",
"description": "Path to the Python interpreter. Default for Windows is 'python.exe' and 'python3' for Linux and MacOS.",
"order": 12
}
}
Expand Down Expand Up @@ -424,7 +424,7 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@paulober/pyboard-serial-com": "^1.4.15",
"@paulober/pyboard-serial-com": "^1.4.19",
"fs-extra": "^11.1.1",
"lodash": "^4.17.21",
"uuid": "^9.0.0"
Expand Down
92 changes: 64 additions & 28 deletions src/activator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ export default class Activator {
}

if (!isPyserialInstalled(pyCommand)) {
// TODO: maybe add a progress bar after choosing the install option
const response = await vscode.window.showQuickPick(
["Install pyserial (required)", "Stop Pico-W-Go"],
[
"Auto install pyserial (required)",
"Stop Pico-W-Go (doing it manually)",
],
{
canPickMany: false,
placeHolder: "pyserial pip package is not installed",
Expand Down Expand Up @@ -111,20 +115,20 @@ export default class Activator {
if (comDevice === undefined || comDevice === "") {
comDevice = undefined;

const choice = await vscode.window.showErrorMessage(
"No COM device found. Please check your connection or ports and try again. Alternatively you can set the manualComDevice setting to the path of your COM device in the settings but make sure to deactivate autoConnect. For Linux users: make sure your user is in dialout group: sudo usermod -a -G dialout $USER",
"Open Settings"
);

if (choice === "Open Settings") {
openSettings();
}
vscode.window
.showErrorMessage(
"No COM device found. Please check your connection or ports and try again. Alternatively you can set the manualComDevice setting to the path of your COM device in the settings but make sure to deactivate autoConnect. For Linux users: make sure your user is in dialout group: sudo usermod -a -G dialout $USER",
"Open Settings"
)
.then(choice => {
if (choice === "Open Settings") {
openSettings();
}
});
}

this.ui = new UI(settings);
if (comDevice !== undefined) {
this.ui.init();
}
this.ui.init();

this.pyb = new PyboardRunner(
comDevice ?? "default",
Expand Down Expand Up @@ -289,18 +293,23 @@ export default class Activator {

// [Command] Run File
// TODO: !IMPORTANT! sometimes not all is run or shown to the terminal
// TODO: open terminal on freeze in UI
disposable = vscode.commands.registerCommand("picowgo.run", async () => {
if (!this.pyb?.isPipeConnected()) {
vscode.window.showWarningMessage("Please connect to the Pico first.");
return;
}

const file = await getFocusedFile();
let file = await getFocusedFile();

if (file === undefined) {
vscode.window.showWarningMessage("No file open and focused.");
return;
file = await getFocusedFile(true);
if (file === undefined) {
vscode.window.showWarningMessage("No file open and focused.");
return;
} else {
vscode.commands.executeCommand("picowgo.remote.run");
return;
}
}

let frozen = false;
Expand All @@ -310,10 +319,12 @@ export default class Activator {
if (!frozen) {
terminal?.freeze();
terminal?.write("\r\n");
this.ui?.userOperationStarted();
frozen = true;
}
terminal?.write(data);
});
this.ui?.userOperationStopped();
if (data.type === PyOutType.commandResult) {
const result = data as PyOutCommandResult;
// TODO: reflect result.result somehow
Expand Down Expand Up @@ -353,11 +364,14 @@ export default class Activator {
if (!frozen) {
terminal?.freeze();
terminal?.write("\r\n");
this.ui?.userOperationStarted();
frozen = true;
}
terminal?.write(data);
}
},
true
);
this.ui?.userOperationStopped();
terminal?.melt();
terminal?.write("\r\n");
terminal?.prompt();
Expand All @@ -382,24 +396,27 @@ export default class Activator {
} else {
let frozen = false;
await focusTerminal();
this.pyb
.executeCommand(code, (data: string) => {
const data = await this.pyb.executeCommand(
code,
(data: string) => {
// only freeze after operation has started
if (!frozen) {
terminal?.freeze();
terminal?.write("\r\n");
this.ui?.userOperationStarted();
frozen = true;
}
terminal?.write(data);
})
.then((data: PyOut) => {
if (data.type === PyOutType.commandResult) {
const result = data as PyOutCommandResult;
// TODO: reflect result.result in status bar
}
terminal?.melt();
terminal?.prompt();
});
},
true
);
this.ui?.userOperationStopped();
if (data.type === PyOutType.commandResult) {
const result = data as PyOutCommandResult;
// TODO: reflect result.result in status bar
}
terminal?.melt();
terminal?.prompt();
}
}
);
Expand Down Expand Up @@ -806,6 +823,25 @@ export default class Activator {
);
context.subscriptions.push(disposable);

disposable = vscode.commands.registerCommand(
"picowgo.universalStop",
async () => {
if (
!this.pyb?.isPipeConnected() ||
!this.ui?.isUserOperationOngoing()
) {
vscode.window.showInformationMessage("Nothing to stop.");
return;
}

// double ctrl+c to stop any running program
await this.pyb?.writeToPyboard("\x03\x03\n");

// wait for the program to stop
await new Promise(resolve => setTimeout(resolve, 100));
}
);

// [Command] Check for firmware updates
disposable = vscode.commands.registerCommand(
"picowgo.extra.firmwareUpdates",
Expand Down
21 changes: 21 additions & 0 deletions src/ui.mts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class UI {
private logger: Logger;
private visible: boolean = false;
private initialized: boolean = false;
private userOperationOngoing: boolean = false;

private items: { [key: string]: StatusBarItem } = {};

Expand Down Expand Up @@ -126,6 +127,26 @@ export default class UI {
return item;
}

public userOperationStarted(): void {
this.userOperationOngoing = true;
this.logger.debug("User operation started");

this.items["run"].hide();
this.items["stop"].show();
}

public userOperationStopped(): void {
this.userOperationOngoing = false;
this.logger.debug("User operation stopped");

this.items["stop"].hide();
this.items["run"].show();
}

public isUserOperationOngoing(): boolean {
return this.userOperationOngoing;
}

public async destroy(): Promise<void> {
for (const item of Object.values(this.items)) {
item.dispose();
Expand Down

0 comments on commit bc27761

Please sign in to comment.