Skip to content

Commit

Permalink
drv/ioport_lpf2: add move hub shutdown quirk
Browse files Browse the repository at this point in the history
This adds a configuration option to handle a quirk of the BOOST Move
hub. For some reason, this hub turns back on when the power button is
released after shutdown if the port VCC is turned off.

Also added PROCESS_EXIT() to the exit handler just to be safe while we
are touching this (otherwise device connection manager might run one
more iteration).

Fixes: pybricks/support#386
Fixes: 1473c4b
  • Loading branch information
dlech committed Jul 19, 2021
1 parent b7cc563 commit 2f52c34
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## [Unreleased]

### Added
- Added `reset_angle=False` keyword argument to `Motor()` class.
- Added `reset_angle=False` keyword argument to `Motor()` class.
This makes resetting the angle optional, allowing to maintain absolute
positioning for robots with gears ([support#389]).

Expand All @@ -16,6 +16,7 @@

### Fixed
- Fixed City hub not always powering off on shutdown ([support#385]).
- Fixed Move hub turning back on after shutdown ([support#386]).

## [3.1.0a2] - 2021-07-06

Expand Down Expand Up @@ -95,6 +96,7 @@ Prerelease changes are documented at [support#48].
[support#361]: https://github.com/pybricks/support/issues/361
[support#379]: https://github.com/pybricks/support/issues/379
[support#385]: https://github.com/pybricks/support/issues/385
[support#386]: https://github.com/pybricks/support/issues/386
[support#389]: https://github.com/pybricks/support/issues/389

[Unreleased]: https://github.com/pybricks/pybricks-micropython/compare/v3.1.0a2...HEAD
Expand Down
8 changes: 8 additions & 0 deletions lib/pbio/drv/ioport/ioport_lpf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,16 @@ PROCESS_THREAD(pbdrv_ioport_lpf2_process, ev, data) {
// TODO: we need to ensure H-bridge power is off here to avoid potentially
// damaging custom I/O devices.

#if PBDRV_CONFIG_IOPORT_LPF2_BOOST_SHUTDOWN_QUIRK
// The LEGO BOOST Move hub will turn right back on when the power button
// is released if we turn off VCC at shutdown for some reason (hardware bug?).
pbdrv_gpio_out_high(&pbdrv_ioport_lpf2_platform_data.port_vcc);
#else
// Turn off power on pin 4 on all ports
pbdrv_gpio_out_low(&pbdrv_ioport_lpf2_platform_data.port_vcc);
#endif

PROCESS_EXIT();
});

PROCESS_BEGIN();
Expand Down
1 change: 1 addition & 0 deletions lib/pbio/platform/move_hub/pbdrvconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#define PBDRV_CONFIG_IOPORT (1)
#define PBDRV_CONFIG_IOPORT_LPF2 (1)
#define PBDRV_CONFIG_IOPORT_LPF2_BOOST_SHUTDOWN_QUIRK (1)
#define PBDRV_CONFIG_IOPORT_LPF2_NUM_PORTS (2)
#define PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT PBIO_PORT_ID_C
#define PBDRV_CONFIG_IOPORT_LPF2_LAST_PORT PBIO_PORT_ID_D
Expand Down

0 comments on commit 2f52c34

Please sign in to comment.