Skip to content

Commit 9fbf037

Browse files
committed
pybricks/util_pb/pb_device_stm32: fix pb_device_set_power_supply port offset
This was using the I/O port offset instead of using the motor port offset. Since it controls the motors, it needs to use the motor port numbering. This was only noticed on move hub since it is the only hub where there are motor ports without I/O ports. Fixes: pybricks/support#913
1 parent 4a8a99d commit 9fbf037

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66

77
### Added
88
- Added `close()` method to `DCMotor` and `Motor` so they can be closed and
9-
re-initialized later.
9+
re-initialized later ([support#904]).
10+
11+
### Fixed
12+
- Fixed `Light` controlling wrong ports on Move hub ([support#913]).
1013

1114
[support#904]: https://github.com/pybricks/support/issues/904
15+
[support#913]: https://github.com/pybricks/support/issues/913
1216

1317
## [3.2.2] - 2023-01-06
1418

pybricks/util_pb/pb_device_stm32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ void pb_device_set_power_supply(pb_device_t *pbdev, int32_t duty) {
201201
// is only valid on Powered Up platforms and it assumes that motor driver
202202
// id corresponds to the port.
203203

204-
#ifdef PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT
204+
#ifdef PBDRV_CONFIG_FIRST_MOTOR_PORT
205205
pbdrv_motor_driver_dev_t *motor_driver;
206-
pb_assert(pbdrv_motor_driver_get_dev(pbdev->iodev.port - PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT, &motor_driver));
206+
pb_assert(pbdrv_motor_driver_get_dev(pbdev->iodev.port - PBDRV_CONFIG_FIRST_MOTOR_PORT, &motor_driver));
207207

208208
// Apply duty cycle in reverse to activate power
209209
pb_assert(pbdrv_motor_driver_set_duty_cycle(motor_driver, -PBDRV_MOTOR_DRIVER_MAX_DUTY * duty / 100));

0 commit comments

Comments
 (0)