mirror of
https://github.com/We-Dont-Byte/Mind_Reader.git
synced 2024-11-15 03:35:59 +00:00
ev3Manager:
- Start work on ev3 support - Explore functionality of ev3dev-Browser - Realize it's super limited
This commit is contained in:
parent
388cf1dfcf
commit
de3c9bf435
@ -224,6 +224,10 @@
|
|||||||
"command": "mind-reader.openKeybinds",
|
"command": "mind-reader.openKeybinds",
|
||||||
"key": "Ctrl+Shift+/ K",
|
"key": "Ctrl+Shift+/ K",
|
||||||
"mac": "Cmd+Shift+[Slash] K"
|
"mac": "Cmd+Shift+[Slash] K"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mind-reader.ev3.test",
|
||||||
|
"key": "Ctrl+E Ctrl+V"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"menus": {
|
"menus": {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import HubManager from '../hubManager';
|
import HubManager from '../hubManager';
|
||||||
|
import EV3Manager from '../ev3Manager';
|
||||||
|
|
||||||
import { CommandEntry } from './commandEntry';
|
import { CommandEntry } from './commandEntry';
|
||||||
|
|
||||||
@ -34,10 +35,20 @@ export const hubCommands: CommandEntry[] = [
|
|||||||
name: 'mind-reader.deleteProgram',
|
name: 'mind-reader.deleteProgram',
|
||||||
callback: deleteProgram
|
callback: deleteProgram
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'mind-reader.ev3.test',
|
||||||
|
callback: ev3test
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// Current connected hub
|
// Current connected hub
|
||||||
let hub: HubManager | null = null;
|
let hub: HubManager | null = null;
|
||||||
|
let ev3: EV3Manager | null = null;
|
||||||
|
|
||||||
|
async function ev3test(): Promise<void> {
|
||||||
|
ev3 = await EV3Manager.activate();
|
||||||
|
ev3.test();
|
||||||
|
}
|
||||||
|
|
||||||
async function connectHub(): Promise<void> {
|
async function connectHub(): Promise<void> {
|
||||||
if (hub && hub.isOpen()) {
|
if (hub && hub.isOpen()) {
|
||||||
|
31
src/ev3Manager.ts
Normal file
31
src/ev3Manager.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
//import * as fs from 'fs';
|
||||||
|
//import { logger } from './extension';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default class EV3Manager {
|
||||||
|
private ev3devBrowser: vscode.Extension<any> | undefined = vscode.extensions.getExtension("ev3dev.ev3dev-browser");
|
||||||
|
|
||||||
|
private constructor() {}
|
||||||
|
public test() {
|
||||||
|
//console.log(this.ev3devBrowser);
|
||||||
|
// This seems to be the only thing we, as an extension,
|
||||||
|
// are allowed to do with this other extension.
|
||||||
|
vscode.commands.executeCommand("ev3devBrowser.action.pickDevice", null);
|
||||||
|
}
|
||||||
|
public static activate(): Promise<EV3Manager> {
|
||||||
|
return new Promise (async (resolve) => {
|
||||||
|
try {
|
||||||
|
let mgr = new EV3Manager();
|
||||||
|
// Wait for ev3devBrowser to start
|
||||||
|
await mgr.ev3devBrowser?.activate();
|
||||||
|
// Return ev3Manager
|
||||||
|
return resolve(mgr);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user