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..."), header: lf("Bluetooth download failed..."),
htmlBody: htmlBody:
`<ul> `<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> <li>${lf("Check your battery level.")}</li>
</ul>`, </ul>`,
hasCloseIcon: true, hasCloseIcon: true,

View File

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

View File

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

View File

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

View File

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