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:
@ -64,7 +64,6 @@ class WebSerialPackageIO implements pxt.HF2.PacketIO {
|
||||
private _writer: any;
|
||||
|
||||
constructor(private port: SerialPort, private options: SerialOptions) {
|
||||
this.openAsync();
|
||||
}
|
||||
|
||||
async readSerialAsync() {
|
||||
@ -173,7 +172,7 @@ export function initAsync(): Promise<void> {
|
||||
}
|
||||
|
||||
if (WebSerialPackageIO.isSupported())
|
||||
pxt.tickEvent("bluetooth.supported");
|
||||
pxt.tickEvent("webserial.supported");
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
@ -274,7 +273,7 @@ export function deployCoreAsync(resp: pxtc.CompileResult) {
|
||||
|
||||
if (!useHID) return saveUF2Async()
|
||||
|
||||
pxt.tickEvent("bluetooth.flash");
|
||||
pxt.tickEvent("webserial.flash");
|
||||
let w: Ev3Wrapper;
|
||||
return initHidAsync()
|
||||
.then(w_ => {
|
||||
@ -291,12 +290,14 @@ export function deployCoreAsync(resp: pxtc.CompileResult) {
|
||||
`<ul>
|
||||
<li>${lf("Make sure to stop your program or exit portview on the EV3.")}</li>
|
||||
<li>${lf("Check your battery level.")}</li>
|
||||
<li>${lf("Close EV3 LabView or other MakeCode editor tabs.")}
|
||||
</ul>`,
|
||||
hasCloseIcon: true,
|
||||
hideCancel: true,
|
||||
hideAgree: false,
|
||||
agreeLbl: lf("Try again"),
|
||||
}).then(() => w.disconnectAsync())
|
||||
.then(() => Promise.delay(1000))
|
||||
.then(() => w.reconnectAsync());
|
||||
|
||||
// nothing we can do
|
||||
@ -309,11 +310,11 @@ export function deployCoreAsync(resp: pxtc.CompileResult) {
|
||||
.then(() => w.flashAsync(rbfPath, rbfBIN))
|
||||
.then(() => w.runAsync(rbfPath))
|
||||
.then(() => {
|
||||
pxt.tickEvent("bluetooth.success");
|
||||
pxt.tickEvent("webserial.success");
|
||||
return w.disconnectAsync()
|
||||
//return Promise.delay(1000).then(() => w.dmesgAsync())
|
||||
}).catch(e => {
|
||||
pxt.tickEvent("bluetooth.fail");
|
||||
pxt.tickEvent("webserial.fail");
|
||||
useHID = false;
|
||||
useWebSerial = false;
|
||||
// if we failed to initalize, tell the user to retry
|
||||
|
Reference in New Issue
Block a user