web serial cleanup (#928)
* updated ticks * fix enable and compile * add debug mode * don't try to change UI while downloading * cleanup * don't double open * use cu * add delay before reconnecting * support for 200 ragne in field turn ratio * updated docs * fix docs
This commit is contained in:
@ -7,6 +7,13 @@ let bluetoothDialogShown = false;
|
||||
pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
||||
const projectView = opts.projectView;
|
||||
pxt.debug('loading pxt-ev3 target extensions...')
|
||||
|
||||
function enableWebSerialAndCompileAsync() {
|
||||
return enableWebSerialAsync()
|
||||
.then(() => Promise.delay(500))
|
||||
.then(() => projectView.compile());
|
||||
}
|
||||
|
||||
const res: pxt.editor.ExtensionResult = {
|
||||
deployCoreAsync,
|
||||
showUploadInstructionsAsync: (fn: string, url: string, confirmAsync: (options: any) => Promise<number>) => {
|
||||
@ -84,7 +91,7 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
onclick: () => {
|
||||
pxt.tickEvent("bluetooth.enable");
|
||||
if (bluetoothDialogShown) {
|
||||
enableWebSerialAsync().done();
|
||||
enableWebSerialAndCompileAsync().done();
|
||||
} else {
|
||||
bluetoothDialogShown = true;
|
||||
confirmAsync({
|
||||
@ -99,13 +106,13 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
}],
|
||||
htmlBody: `<p>
|
||||
${lf("You will be prompted to select a serial port.")}
|
||||
${pxt.BrowserUtils.isWindows() ? lf("Look for 'Standard Serial over Bluetooth link'.") : lf("Loop for 'tty.EV3-SerialPort' or 'cu.EV3-SerialPort'")}
|
||||
${pxt.BrowserUtils.isWindows()
|
||||
? lf("Look for 'Standard Serial over Bluetooth link'.")
|
||||
: lf("Loop for 'cu.EV3-SerialPort'.")}
|
||||
${lf("If you have paired multiple EV3, you might have to try out multiple ports until you find the correct one.")}
|
||||
</p>
|
||||
`
|
||||
}).then(() => enableWebSerialAsync())
|
||||
.then(() => Promise.delay(500))
|
||||
.then(() => projectView.compile())
|
||||
}).then(() => enableWebSerialAndCompileAsync())
|
||||
}
|
||||
}
|
||||
} : undefined, downloadAgain ? {
|
||||
|
Reference in New Issue
Block a user