Skip to content

Commit 1d0f987

Browse files
committed
pybricks.pupdevices.Remote: Use dedicated guard.
The virtualhub has pupdevices but no Bluetooth.
1 parent 5be8751 commit 1d0f987

File tree

10 files changed

+19
-8
lines changed

10 files changed

+19
-8
lines changed

bricks/cityhub/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#define PYBRICKS_PY_PARAMETERS_ICON (0)
4040
#define PYBRICKS_PY_DEVICES (1)
4141
#define PYBRICKS_PY_PUPDEVICES (1)
42+
#define PYBRICKS_PY_PUPDEVICES_REMOTE (1)
4243
#define PYBRICKS_PY_ROBOTICS (1)
4344
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_GYRO (0)
4445
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_SPIKE (0)

bricks/essentialhub/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define PYBRICKS_PY_PARAMETERS_ICON (0)
4141
#define PYBRICKS_PY_DEVICES (1)
4242
#define PYBRICKS_PY_PUPDEVICES (1)
43+
#define PYBRICKS_PY_PUPDEVICES_REMOTE (1)
4344
#define PYBRICKS_PY_ROBOTICS (1)
4445
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_GYRO (1)
4546
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_SPIKE (1)

bricks/movehub/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define PYBRICKS_PY_PARAMETERS_ICON (0)
3636
#define PYBRICKS_PY_DEVICES (1)
3737
#define PYBRICKS_PY_PUPDEVICES (1)
38+
#define PYBRICKS_PY_PUPDEVICES_REMOTE (1)
3839
#define PYBRICKS_PY_ROBOTICS (1)
3940
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_GYRO (0)
4041
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_SPIKE (0)

bricks/primehub/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#define PYBRICKS_PY_PARAMETERS_ICON (1)
4242
#define PYBRICKS_PY_DEVICES (1)
4343
#define PYBRICKS_PY_PUPDEVICES (1)
44+
#define PYBRICKS_PY_PUPDEVICES_REMOTE (1)
4445
#define PYBRICKS_PY_ROBOTICS (1)
4546
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_GYRO (1)
4647
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_SPIKE (1)

bricks/technichub/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#define PYBRICKS_PY_PARAMETERS_ICON (0)
4040
#define PYBRICKS_PY_DEVICES (1)
4141
#define PYBRICKS_PY_PUPDEVICES (1)
42+
#define PYBRICKS_PY_PUPDEVICES_REMOTE (1)
4243
#define PYBRICKS_PY_ROBOTICS (1)
4344
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_GYRO (1)
4445
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_SPIKE (0)

bricks/virtualhub/mpconfigvariant.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define PYBRICKS_PY_PARAMETERS_BUTTON (1)
3434
#define PYBRICKS_PY_PARAMETERS_ICON (1)
3535
#define PYBRICKS_PY_PUPDEVICES (1)
36+
#define PYBRICKS_PY_PUPDEVICES_REMOTE (0)
3637
#define PYBRICKS_PY_DEVICES (1)
3738
#define PYBRICKS_PY_ROBOTICS (1)
3839
#define PYBRICKS_PY_ROBOTICS_DRIVEBASE_SPIKE (0)

pybricks/iodevices/pb_module_iodevices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ STATIC const mp_rom_map_elem_t iodevices_globals_table[] = {
1212
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_iodevices) },
1313
#if PYBRICKS_PY_PUPDEVICES
1414
{ MP_ROM_QSTR(MP_QSTR_PUPDevice), MP_ROM_PTR(&pb_type_iodevices_PUPDevice) },
15+
#if PYBRICKS_PY_PUPDEVICES_REMOTE
1516
{ MP_ROM_QSTR(MP_QSTR_LWP3Device), MP_ROM_PTR(&pb_type_iodevices_LWP3Device) },
1617
#endif
18+
#endif
1719
#if PYBRICKS_PY_IODEVICES_XBOX_CONTROLLER
1820
{ MP_ROM_QSTR(MP_QSTR_XboxController), MP_ROM_PTR(&pb_type_iodevices_XboxController) },
1921
#endif

pybricks/iodevices/pb_type_iodevices_lwp3device.c

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

44
#include "py/mpconfig.h"
55

6-
#if PYBRICKS_PY_PUPDEVICES
6+
#if PYBRICKS_PY_PUPDEVICES_REMOTE
77

88
#include <stdint.h>
99
#include <string.h>
@@ -549,4 +549,4 @@ MP_DEFINE_CONST_OBJ_TYPE(pb_type_iodevices_LWP3Device,
549549

550550
#endif // PYBRICKS_PY_IODEVICES
551551

552-
#endif // PYBRICKS_PY_PUPDEVICES
552+
#endif // PYBRICKS_PY_PUPDEVICES_REMOTE

pybricks/pupdevices/pb_module_pupdevices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ STATIC const mp_rom_map_elem_t pupdevices_globals_table[] = {
2424
{ MP_ROM_QSTR(MP_QSTR_InfraredSensor), MP_ROM_PTR(&pb_type_pupdevices_InfraredSensor) },
2525
{ MP_ROM_QSTR(MP_QSTR_Light), MP_ROM_PTR(&pb_type_pupdevices_Light) },
2626
{ MP_ROM_QSTR(MP_QSTR_PFMotor), MP_ROM_PTR(&pb_type_pupdevices_PFMotor) },
27+
#if PYBRICKS_PY_PUPDEVICES_REMOTE
2728
{ MP_ROM_QSTR(MP_QSTR_Remote), MP_ROM_PTR(&pb_type_pupdevices_Remote) },
29+
#endif
2830
{ MP_ROM_QSTR(MP_QSTR_TiltSensor), MP_ROM_PTR(&pb_type_pupdevices_TiltSensor) },
2931
{ MP_ROM_QSTR(MP_QSTR_UltrasonicSensor), MP_ROM_PTR(&pb_type_pupdevices_UltrasonicSensor) },
3032
};

pybricks/pybricks.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,15 @@ void pb_package_pybricks_deinit(void) {
138138
#if PYBRICKS_PY_COMMON_BLE
139139
pb_type_ble_start_cleanup();
140140
#endif
141-
// Disconnect from remote.
142-
#if PYBRICKS_PY_PUPDEVICES
141+
142+
#if PYBRICKS_PY_PUPDEVICES_REMOTE
143+
// Disconnect from remote or LWP3 device.
143144
pb_type_lwp3device_start_cleanup();
144-
#endif // PYBRICKS_PY_PUPDEVICES
145+
#endif // PYBRICKS_PY_PUPDEVICES_REMOTE
145146

146-
#if PYBRICKS_PY_COMMON_BLE && PYBRICKS_PY_PUPDEVICES
147+
#if PYBRICKS_PY_COMMON_BLE || PYBRICKS_PY_PUPDEVICES_REMOTE
147148
// By queueing and awaiting a task that does nothing, we know that all user
148-
// tasks and deinit tasks have completed.
149+
// tasks and deinit tasks queued before it have completed.
149150
static pbio_task_t noop_task;
150151
pbdrv_bluetooth_queue_noop(&noop_task);
151152
while (noop_task.status == PBIO_ERROR_AGAIN || !pbsys_bluetooth_tx_is_idle()) {
@@ -156,5 +157,5 @@ void pb_package_pybricks_deinit(void) {
156157
break;
157158
}
158159
}
159-
#endif
160+
#endif // PYBRICKS_PY_COMMON_BLE || PYBRICKS_PY_PUPDEVICES_REMOTE
160161
}

0 commit comments

Comments
 (0)