Skip to content

Commit

Permalink
Added MicroPico Device Controller
Browse files Browse the repository at this point in the history
Signed-off-by: paulober <[email protected]>
  • Loading branch information
paulober committed Dec 27, 2023
1 parent 1995c2f commit f2c7548
Show file tree
Hide file tree
Showing 16 changed files with 813 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"out",
"dist",
"**/*.d.ts",
"./vscodeUninstall.mjs"
"./vscodeUninstall.mjs",
"web"
],
"env": {
"node": true,
Expand Down
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rollup.config.mjs

.github/**
scripts/**
images/*.xcf

# instance files
connection_state.json
Expand All @@ -26,3 +27,4 @@ azure-pipelines.yml
!dist/scripts/*.py
dist/scripts/__pycache__
!mpy_stubs/
!web/
Binary file added images/logo-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions images/logo-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/logo-black.xcf
Binary file not shown.
1 change: 1 addition & 0 deletions images/refresh-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/refresh-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions images/wifi-connected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions images/wifi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,20 @@
"command": "micropico.rtc.sync",
"title": "Sync RTC",
"category": "MicroPico"
},
{
"command": "micropico.device-wifi.itemClicked",
"title": "Wifi > Connect",
"category": "MicroPico"
},
{
"command": "micropico.device-wifi.refresh",
"title": "Scan",
"icon": {
"dark": "images/refresh-dark.svg",
"light": "images/refresh-light.svg"
},
"enablement": "view == micropico-device-wifi"
}
],
"menus": {
Expand Down Expand Up @@ -263,6 +277,13 @@
"group": "micropico",
"when": "micropico.isActivated && resourceScheme == pico"
}
],
"view/title": [
{
"command": "micropico.device-wifi.refresh",
"when": "view == micropico-device-wifi",
"group": "navigation@0"
}
]
},
"configuration": {
Expand Down Expand Up @@ -414,6 +435,29 @@
"id": "micropico.vrepl"
}
]
},
"viewsContainers": {
"activitybar": [
{
"id": "micropico-device-controller",
"title": "MicroPico Device Controller (experimental)",
"icon": "images/logo-black.png"
}
]
},
"views": {
"micropico-device-controller": [
{
"id": "micropico-device-wifi",
"name": "Wifi",
"type": "tree"
},
{
"id": "micropico-device-packages",
"name": "Packages",
"type": "webview"
}
]
}
},
"statusBar": [
Expand Down
37 changes: 37 additions & 0 deletions src/activator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import { PicoWFs } from "./filesystem.mjs";
import { Terminal } from "./terminal.mjs";
import { fileURLToPath } from "url";
import { ContextKeys } from "./models/contextKeys.mjs";
import DeviceWifiProvider, {
type Wifi,
} from "./activitybar/deviceWifiTree.mjs";
import PackagesWebviewProvider from "./activitybar/packagesWebview.mjs";

/*const pkg: {} | undefined = vscode.extensions.getExtension("paulober.pico-w-go")
?.packageJSON as object;*/
Expand Down Expand Up @@ -615,6 +619,7 @@ export default class Activator {
"import gc as __pico_gc; __pico_gc.collect(); del __pico_gc"
);
}

void vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
Expand Down Expand Up @@ -1145,6 +1150,38 @@ export default class Activator {
);
context.subscriptions.push(disposable);

const packagesWebviewProvider = new PackagesWebviewProvider(
this.pyb,
context.extensionUri
);
const deviceWifiProvider = new DeviceWifiProvider(
this.pyb,
packagesWebviewProvider,
// TODO: maybe use extensionUri
context.extensionPath
);
disposable = vscode.commands.registerCommand(
commandPrefix + "device-wifi.refresh",
async () => {
await deviceWifiProvider.checkConnection();
}
);
context.subscriptions.push(disposable);
disposable = vscode.commands.registerCommand(
commandPrefix + "device-wifi.itemClicked",
deviceWifiProvider.elementSelected.bind(deviceWifiProvider)
);
context.subscriptions.push(disposable);

vscode.window.registerWebviewViewProvider(
PackagesWebviewProvider.viewType,
packagesWebviewProvider
);
vscode.window.registerTreeDataProvider(
DeviceWifiProvider.viewType,
deviceWifiProvider
);

return this.ui;
}

Expand Down
Loading

0 comments on commit f2c7548

Please sign in to comment.