Better bt download flow (#927)

* round the drif

* restart compile automatically

* add settle
This commit is contained in:
Peli de Halleux 2019-09-29 23:08:46 -07:00 committed by GitHub
parent 6c9ff804c8
commit 4dc2872286
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 16 deletions

View File

@ -289,7 +289,7 @@ export function deployCoreAsync(resp: pxtc.CompileResult) {
header: lf("Bluetooth download failed..."),
htmlBody:
`<ul>
<li>${lf("Make sure to stop your program on the EV3.")}</li>
<li>${lf("Make sure to stop your program or exit portview on the EV3.")}</li>
<li>${lf("Check your battery level.")}</li>
</ul>`,
hasCloseIcon: true,

View File

@ -5,6 +5,7 @@ import { deployCoreAsync, initAsync, canUseWebSerial, enableWebSerialAsync, setC
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...')
const res: pxt.editor.ExtensionResult = {
deployCoreAsync,
@ -103,15 +104,8 @@ ${lf("If you have paired multiple EV3, you might have to try out multiple ports
</p>
`
}).then(() => enableWebSerialAsync())
.then(() => confirmAsync({
header: lf("Bluetooth is ready!"),
hasCloseIcon: true,
hideCancel: true,
htmlBody: `<p>
${lf("Click Download again to send your code to the EV3 over Bluetooth.")}
</p>
`
}))
.then(() => Promise.delay(500))
.then(() => projectView.compile())
}
}
} : undefined, downloadAgain ? {

View File

@ -77,8 +77,6 @@ export class FieldSpeed extends Blockly.FieldSlider implements Blockly.FieldCust
setReadout_(readout: Element, value: string) {
let x = parseFloat(value) || 0;
// snap on multiple of 5
x = Math.round(x / 5) * 5;
this.updateSpeed(x);
// Update reporter
this.reporter.textContent = `${x}%`;

View File

@ -179,6 +179,7 @@ namespace sensors {
computeDrift() {
if (this.calibrating)
pauseUntil(() => !this.calibrating, 2000);
pause(1000); // let the robot settle
this.computeDriftNoCalibration();
}
@ -192,7 +193,7 @@ namespace sensors {
d += this._query();
pause(4);
}
this._drift = d / n;
this._drift = Math.round(d / n);
}
_info(): string {
@ -203,8 +204,8 @@ namespace sensors {
case GyroSensorMode.Angle:
return `${this._query()}>`;
case GyroSensorMode.Rate:
let r = `${this._query()}>/s`;
if (this._drift)
let r = `${this._query()}r`;
if (this._drift != 0)
r += `-${this._drift | 0}`;
return r;
}

View File

@ -40,7 +40,7 @@
},
"dependencies": {
"pxt-common-packages": "0.23.61",
"pxt-core": "4.0.10"
"pxt-core": "4.0.11"
},
"scripts": {
"test": "node node_modules/pxt-core/built/pxt.js travis"