Skip to content

Commit 07b0ac0

Browse files
authored
Merge pull request #963 from pybricks/dlech
v2.0.0-beta.3
2 parents f06b7c0 + 7c62332 commit 07b0ac0

File tree

18 files changed

+175
-60
lines changed

18 files changed

+175
-60
lines changed

CHANGELOG.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,35 @@
22

33
# Changelog
44

5-
## [2.0.0-beta.2]
5+
## [Unreleased]
6+
7+
## [2.0.0-beta.3] - 2022-07-06
8+
9+
### Changed
10+
- Updated dependencies.
11+
- Updated firmware to Pybricks v3.2.0b2:
12+
13+
### Added
14+
- Added `Motor.stalled()` method.
15+
16+
### Fixed
17+
- Fixed motor not stopping at the end of `run_until_stalled` ([support#662]).
18+
- Fixed incorrect battery current reading on Technic hub ([support#665]).
19+
- Fixed non-zero speed reported when motor stalled.
20+
- Fixed I/O devices not syncing at high baud rate.
21+
- Fixed `ENODEV` error while device connection manager is busy ([support#674]).
22+
23+
### Changed
24+
- Reworked internal motor model that is used to estimate speed.
25+
- Speed methods now use estimated speed instead of reported speed.
26+
- Changed drive base default speed to go a little slower.
27+
- Updated MicroPython to v1.19.
28+
29+
[support#662]: https://github.com/pybricks/support/issues/662
30+
[support#665]: https://github.com/pybricks/support/issues/665
31+
[support#674]: https://github.com/pybricks/support/issues/674
32+
33+
## [2.0.0-beta.2] - 2022-06-24
634

735
### Added
836
- Added basic intellisense to the code editor.
@@ -281,16 +309,18 @@
281309
- Updated hub firmware to [v3.0.0].
282310
- Updated documentation.
283311

312+
[v3.0.0]: https://github.com/pybricks/pybricks-micropython/blob/master/CHANGELOG.md#300---2021-06-08
313+
284314
## Prerelease
285315

286316
Prerelease changes are documented at [support#48].
287317

288318
[support#48]: https://github.com/pybricks/support/issues/48
289-
[v3.0.0]: https://github.com/pybricks/pybricks-micropython/blob/master/CHANGELOG.md#300---2021-06-08
290319

291320
<!-- links for version headings -->
292321

293-
[Unreleased]: https://github.com/pybricks/pybricks-code/compare/v2.0.0-beta.2...HEAD
322+
[Unreleased]: https://github.com/pybricks/pybricks-code/compare/v2.0.0-beta.3...HEAD
323+
[2.0.0-beta.3]: https://github.com/pybricks/pybricks-code/compare/v2.0.0-beta.2...v2.0.0-beta.3
294324
[2.0.0-beta.2]: https://github.com/pybricks/pybricks-code/compare/v2.0.0-beta.1...v2.0.0-beta.2
295325
[2.0.0-beta.1]: https://github.com/pybricks/pybricks-code/compare/v1.2.0-beta.1...v2.0.0-beta.1
296326
[1.2.0-beta.1]: https://github.com/pybricks/pybricks-code/compare/v1.1.0...v1.2.0-beta.1

config/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ module.exports = function (webpackEnv) {
601601
new CopyPlugin({
602602
patterns: [
603603
{
604-
from: 'node_modules/@pybricks/ide-docs/html',
605-
to: 'static/docs',
604+
from: `${path.dirname(require.resolve('@pybricks/ide-docs/package.json'))}/html`,
605+
to: `static/docs/v${require('@pybricks/ide-docs/package.json').version}/`,
606606
},
607607
],
608608
}),

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pybricks/pybricks-code",
3-
"version": "2.0.0-beta.2",
3+
"version": "2.0.0-beta.3",
44
"license": "MIT",
55
"author": "The Pybricks Authors",
66
"repository": {
@@ -12,9 +12,10 @@
1212
"@blueprintjs/core": "^4.5.0",
1313
"@blueprintjs/popover2": "^1.4.1",
1414
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
15-
"@pybricks/firmware": "4.15.0",
15+
"@pybricks/firmware": "4.16.1",
1616
"@pybricks/ide-docs": "2.2.0",
1717
"@pybricks/mpy-cross-v5": "^2.0.0",
18+
"@pybricks/mpy-cross-v6": "^2.0.0",
1819
"@reduxjs/toolkit": "^1.8.3",
1920
"@shopify/react-i18n": "^7.1.3",
2021
"@svgr/webpack": "^6.2.1",

src/app/App.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// SPDX-License-Identifier: MIT
22
// Copyright (c) 2020-2022 The Pybricks Authors
33

4+
import 'react-splitter-layout/lib/index.css';
5+
import './app.scss';
46
import { Classes } from '@blueprintjs/core';
7+
import docsPackage from '@pybricks/ide-docs/package.json';
58
import { getFocusableTreeWalker } from '@react-aria/focus';
69
import React, {
710
FocusEventHandler,
@@ -20,8 +23,6 @@ import StatusBar from '../status-bar/StatusBar';
2023
import Terminal from '../terminal/Terminal';
2124
import Toolbar from '../toolbar/Toolbar';
2225
import { isMacOS } from '../utils/os';
23-
import 'react-splitter-layout/lib/index.css';
24-
import './app.scss';
2526

2627
const Docs: React.VFC = () => {
2728
const { setIsSettingShowDocsEnabled } = useSettingIsShowDocsEnabled();
@@ -119,7 +120,7 @@ const Docs: React.VFC = () => {
119120
contentWindow.document.documentElement.classList.add(Classes.DARK);
120121
}
121122
}}
122-
src="static/docs/index.html"
123+
src={`static/docs/v${docsPackage.version}/index.html`}
123124
allowFullScreen={true}
124125
role="documentation"
125126
width="100%"

src/editor/Editor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,9 @@ const Editor: React.VFC = () => {
392392
() => ({
393393
id: 'pybricks.action.check',
394394
label: i18n.translate(I18nId.Check),
395-
// REVISIT: the compile options here might need to be changed - hopefully there is
396-
// one setting that works for all hub types for cases where we aren't connected.
397395
run: (e) => {
398-
dispatch(compile(e.getValue(), []));
396+
// for checking, use the most recent compiler
397+
dispatch(compile(e.getValue(), 6, []));
399398
},
400399
keybindings: [monaco.KeyCode.F2],
401400
}),

src/firmware/sagas.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ describe('flashFirmware', () => {
107107
action = await saga.take();
108108
expect(action).toMatchInlineSnapshot(`
109109
Object {
110+
"abiVersion": 5,
110111
"options": Array [
111112
"-mno-unicode",
112113
],
@@ -622,6 +623,7 @@ describe('flashFirmware', () => {
622623
action = await saga.take();
623624
expect(action).toMatchInlineSnapshot(`
624625
Object {
626+
"abiVersion": 5,
625627
"options": Array [
626628
"-mno-unicode",
627629
],
@@ -767,6 +769,7 @@ describe('flashFirmware', () => {
767769
action = await saga.take();
768770
expect(action).toMatchInlineSnapshot(`
769771
Object {
772+
"abiVersion": 5,
770773
"options": Array [
771774
"-mno-unicode",
772775
],
@@ -861,6 +864,7 @@ describe('flashFirmware', () => {
861864
action = await saga.take();
862865
expect(action).toMatchInlineSnapshot(`
863866
Object {
867+
"abiVersion": 5,
864868
"options": Array [
865869
"-mno-unicode",
866870
],
@@ -964,6 +968,7 @@ describe('flashFirmware', () => {
964968
action = await saga.take();
965969
expect(action).toMatchInlineSnapshot(`
966970
Object {
971+
"abiVersion": 5,
967972
"options": Array [
968973
"-mno-unicode",
969974
],
@@ -1107,6 +1112,7 @@ describe('flashFirmware', () => {
11071112
action = await saga.take();
11081113
expect(action).toMatchInlineSnapshot(`
11091114
Object {
1115+
"abiVersion": 5,
11101116
"options": Array [
11111117
"-mno-unicode",
11121118
],
@@ -1236,6 +1242,7 @@ describe('flashFirmware', () => {
12361242
let action = await saga.take();
12371243
expect(action).toMatchInlineSnapshot(`
12381244
Object {
1245+
"abiVersion": 5,
12391246
"options": Array [
12401247
"-mno-unicode",
12411248
],
@@ -1477,6 +1484,7 @@ describe('flashFirmware', () => {
14771484
let action = await saga.take();
14781485
expect(action).toMatchInlineSnapshot(`
14791486
Object {
1487+
"abiVersion": 5,
14801488
"options": Array [
14811489
"-mno-unicode",
14821490
],
@@ -1536,6 +1544,7 @@ describe('flashFirmware', () => {
15361544
let action = await saga.take();
15371545
expect(action).toMatchInlineSnapshot(`
15381546
Object {
1547+
"abiVersion": 5,
15391548
"options": Array [
15401549
"-mno-unicode",
15411550
],
@@ -1596,6 +1605,7 @@ describe('flashFirmware', () => {
15961605
let action = await saga.take();
15971606
expect(action).toMatchInlineSnapshot(`
15981607
Object {
1608+
"abiVersion": 5,
15991609
"options": Array [
16001610
"-mno-unicode",
16011611
],
@@ -1659,6 +1669,7 @@ describe('flashFirmware', () => {
16591669
let action = await saga.take();
16601670
expect(action).toMatchInlineSnapshot(`
16611671
Object {
1672+
"abiVersion": 5,
16621673
"options": Array [
16631674
"-mno-unicode",
16641675
],
@@ -1759,6 +1770,7 @@ describe('flashFirmware', () => {
17591770
action = await saga.take();
17601771
expect(action).toMatchInlineSnapshot(`
17611772
Object {
1773+
"abiVersion": 5,
17621774
"options": Array [
17631775
"-mno-unicode",
17641776
],

src/firmware/sagas.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ function* loadFirmware(
207207
yield* disconnectAndCancel();
208208
}
209209

210-
yield* put(compile(program, metadata['mpy-cross-options']));
210+
yield* put(
211+
compile(program, metadata['mpy-abi-version'], metadata['mpy-cross-options']),
212+
);
211213
const { mpy, mpyFail } = yield* race({
212214
mpy: take(didCompile),
213215
mpyFail: take(didFailToCompile),

src/hub/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export const checksum = createAction((checksum: number) => ({
1313

1414
// High-level hub actions.
1515

16-
export const downloadAndRun = createAction(() => ({
16+
export const downloadAndRun = createAction((abiVersion: number) => ({
1717
type: 'hub.action.downloadAndRun',
18+
abiVersion,
1819
}));
1920

2021
export const didStartDownload = createAction(() => ({

src/hub/reducers.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021 The Pybricks Authors
2+
// Copyright (c) 2021-2022 The Pybricks Authors
33

44
import { AnyAction } from 'redux';
55
import { didReceiveStatusReport } from '../ble-pybricks-service/actions';
@@ -19,6 +19,7 @@ test('initial state', () => {
1919
expect(reducers(undefined, {} as AnyAction)).toMatchInlineSnapshot(`
2020
Object {
2121
"downloadProgress": null,
22+
"mpyAbiVersion": 6,
2223
"runtime": "hub.runtime.disconnected",
2324
}
2425
`);

src/hub/reducers.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
// Copyright (c) 2020-2022 The Pybricks Authors
33

44
import { Reducer, combineReducers } from 'redux';
5+
import * as semver from 'semver';
6+
import { bleDIServiceDidReceiveFirmwareRevision } from '../ble-device-info-service/actions';
57
import { didReceiveStatusReport } from '../ble-pybricks-service/actions';
68
import { Status, statusToFlag } from '../ble-pybricks-service/protocol';
79
import { didConnect, didDisconnect } from '../ble/actions';
10+
import { pythonVersionToSemver } from '../utils/version';
811
import {
912
didFailToFinishDownload,
1013
didFinishDownload,
@@ -118,4 +121,18 @@ const downloadProgress: Reducer<number | null> = (state = null, action) => {
118121
return state;
119122
};
120123

121-
export default combineReducers({ runtime, downloadProgress });
124+
const mpyAbiVersion: Reducer<number> = (state = 6, action) => {
125+
if (bleDIServiceDidReceiveFirmwareRevision.matches(action)) {
126+
// HACK: there is not a good way to get the supported MPY ABI version
127+
// from a running hub, so we use heuristics on the firmware version.
128+
if (semver.satisfies(pythonVersionToSemver(action.version), '>=3.2.0-beta.2')) {
129+
return 6;
130+
}
131+
132+
return 5;
133+
}
134+
135+
return state;
136+
};
137+
138+
export default combineReducers({ runtime, downloadProgress, mpyAbiVersion });

0 commit comments

Comments
 (0)