From 4dc28722863bf298ef4548b4194e34598359f9bd Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Sun, 29 Sep 2019 23:08:46 -0700 Subject: [PATCH] Better bt download flow (#927) * round the drif * restart compile automatically * add settle --- editor/deploy.ts | 2 +- editor/extension.ts | 12 +++--------- fieldeditors/field_speed.ts | 2 -- libs/gyro-sensor/gyro.ts | 7 ++++--- package.json | 2 +- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/editor/deploy.ts b/editor/deploy.ts index 09ba4619..ba15a19f 100644 --- a/editor/deploy.ts +++ b/editor/deploy.ts @@ -289,7 +289,7 @@ export function deployCoreAsync(resp: pxtc.CompileResult) { header: lf("Bluetooth download failed..."), htmlBody: ``, hasCloseIcon: true, diff --git a/editor/extension.ts b/editor/extension.ts index 0d55a999..fd2ef320 100644 --- a/editor/extension.ts +++ b/editor/extension.ts @@ -5,6 +5,7 @@ import { deployCoreAsync, initAsync, canUseWebSerial, enableWebSerialAsync, setC let bluetoothDialogShown = false; pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise { + 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

` }).then(() => enableWebSerialAsync()) - .then(() => confirmAsync({ - header: lf("Bluetooth is ready!"), - hasCloseIcon: true, - hideCancel: true, - htmlBody: `

- ${lf("Click Download again to send your code to the EV3 over Bluetooth.")} -

- ` - })) + .then(() => Promise.delay(500)) + .then(() => projectView.compile()) } } } : undefined, downloadAgain ? { diff --git a/fieldeditors/field_speed.ts b/fieldeditors/field_speed.ts index 727928f5..cd095485 100644 --- a/fieldeditors/field_speed.ts +++ b/fieldeditors/field_speed.ts @@ -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}%`; diff --git a/libs/gyro-sensor/gyro.ts b/libs/gyro-sensor/gyro.ts index c9cdf25a..fc88bc02 100644 --- a/libs/gyro-sensor/gyro.ts +++ b/libs/gyro-sensor/gyro.ts @@ -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; } diff --git a/package.json b/package.json index 7e88c77a..d28ce318 100644 --- a/package.json +++ b/package.json @@ -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"