Skip to content

Commit

Permalink
pybricks/util_pb/pb_device_stm32: delay set values
Browse files Browse the repository at this point in the history
This adds a delay after setting values on a LUMP sensor. It may be better to fix pbio_iodev_set_data_end or the condition that says that the setting process is done.

Fixes pybricks/support#190
  • Loading branch information
laurensvalk committed Jan 5, 2021
1 parent 8b25746 commit f94ab4e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pybricks/util_pb/pb_device_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ void pb_device_set_values(pb_device_t *pbdev, uint8_t mode, int32_t *values, uin
}
pb_assert(err);
wait(pbio_iodev_set_data_end, pbio_iodev_set_data_cancel, iodev);

// Give some time for the set values to take effect
uint32_t delay = get_mode_switch_delay(iodev->info->type_id, mode);
if (delay > 0) {
mp_hal_delay_ms(delay / 10);
}
}

void pb_device_set_power_supply(pb_device_t *pbdev, int32_t duty) {
Expand Down

0 comments on commit f94ab4e

Please sign in to comment.