From f94ab4e3117fcce2815e0b5e9460c2e0a3dfea47 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Tue, 5 Jan 2021 08:41:08 +0100 Subject: [PATCH] pybricks/util_pb/pb_device_stm32: delay set values 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 https://github.com/pybricks/support/issues/190 --- pybricks/util_pb/pb_device_stm32.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pybricks/util_pb/pb_device_stm32.c b/pybricks/util_pb/pb_device_stm32.c index 271edac6f..97fb6ff73 100644 --- a/pybricks/util_pb/pb_device_stm32.c +++ b/pybricks/util_pb/pb_device_stm32.c @@ -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) {