Skip to content

Commit fb73270

Browse files
committed
bricks/ev3: Add alias to pupdevices for easy testing.
The block coding editor has not yet been updated. By adding some aliases we can use the EV3 brick light, sound, motors, and some sensors. This is suitable for most demos.
1 parent b1fd671 commit fb73270

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

bricks/_common/qstrdefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Q(pybricks.nxtdevices)
3939
Q(pybricks.parameters)
4040
#endif
4141

42-
#if PYBRICKS_PY_PUPDEVICES
42+
#if PYBRICKS_PY_PUPDEVICES || PYBRICKS_PY_EV3_PUP_ALIAS
4343
Q(pybricks.pupdevices)
4444
#endif
4545

bricks/ev3/mpconfigport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#define PYBRICKS_HUB_CLASS_NAME (MP_QSTR_EV3Brick)
1010
#define PYBRICKS_HUB_EV3BRICK (1)
1111

12+
// On EV3, allow PUP imports for easy beta testing
13+
#define PYBRICKS_PY_EV3_PUP_ALIAS (1)
14+
#define PYBRICKS_HUB_CLASS_NAME_ALIAS (MP_QSTR_PrimeHub)
15+
1216
// Pybricks modules
1317
#define PYBRICKS_PY_COMMON (1)
1418
#define PYBRICKS_PY_COMMON_BLE (0)

pybricks/ev3devices/pb_module_ev3devices.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ static const mp_rom_map_elem_t ev3devices_globals_table[] = {
1818
{ MP_ROM_QSTR(MP_QSTR_InfraredSensor), MP_ROM_PTR(&pb_type_ev3devices_InfraredSensor) },
1919
{ MP_ROM_QSTR(MP_QSTR_TouchSensor), MP_ROM_PTR(&pb_type_ev3devices_TouchSensor) },
2020
{ MP_ROM_QSTR(MP_QSTR_UltrasonicSensor), MP_ROM_PTR(&pb_type_ev3devices_UltrasonicSensor)},
21+
#if PYBRICKS_PY_EV3_PUP_ALIAS
22+
{ MP_ROM_QSTR(MP_QSTR_ForceSensor), MP_ROM_PTR(&pb_type_ev3devices_TouchSensor) },
23+
#endif
2124
};
2225
static MP_DEFINE_CONST_DICT(pb_module_ev3devices_globals, ev3devices_globals_table);
2326

@@ -28,6 +31,9 @@ const mp_obj_module_t pb_module_ev3devices = {
2831

2932
#if !MICROPY_MODULE_BUILTIN_SUBPACKAGES
3033
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_ev3devices, pb_module_ev3devices);
34+
#if PYBRICKS_PY_EV3_PUP_ALIAS
35+
MP_REGISTER_MODULE(MP_QSTR_pybricks_dot_pupdevices, pb_module_ev3devices);
36+
#endif
3137
#endif
3238

3339
#endif // PYBRICKS_PY_EV3DEVICES

pybricks/parameters/pb_type_port.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ static const mp_rom_map_elem_t pb_enum_Port_table[] = {
124124
#if PBDRV_CONFIG_HAS_PORT_4
125125
{ MP_ROM_QSTR(MP_QSTR_S4), MP_ROM_PTR(&pb_Port_4_obj)},
126126
#endif
127+
#if PYBRICKS_PY_EV3_PUP_ALIAS
128+
{ MP_ROM_QSTR(MP_QSTR_E), MP_ROM_PTR(&pb_Port_1_obj)},
129+
{ MP_ROM_QSTR(MP_QSTR_F), MP_ROM_PTR(&pb_Port_2_obj)},
130+
#endif
127131
};
128132
static MP_DEFINE_CONST_DICT(pb_enum_type_Port_locals_dict, pb_enum_Port_table);
129133

0 commit comments

Comments
 (0)