@@ -325,6 +325,20 @@ static mp_obj_t pb_type_DriveBase_brake(mp_obj_t self_in) {
325325}
326326MP_DEFINE_CONST_FUN_OBJ_1 (pb_type_DriveBase_brake_obj , pb_type_DriveBase_brake );
327327
328+ // pybricks.robotics.DriveBase.hold
329+ static mp_obj_t pb_type_DriveBase_hold (mp_obj_t self_in ) {
330+
331+ // Cancel awaitables.
332+ pb_type_DriveBase_obj_t * self = MP_OBJ_TO_PTR (self_in );
333+ pb_type_async_schedule_stop_iteration (self -> last_awaitable );
334+
335+ // Stop hardware.
336+ pb_assert (pbio_drivebase_stop (self -> db , PBIO_CONTROL_ON_COMPLETION_HOLD ));
337+
338+ return mp_const_none ;
339+ }
340+ MP_DEFINE_CONST_FUN_OBJ_1 (pb_type_DriveBase_hold_obj , pb_type_DriveBase_hold );
341+
328342// pybricks.robotics.DriveBase.distance
329343static mp_obj_t pb_type_DriveBase_distance (mp_obj_t self_in ) {
330344 pb_type_DriveBase_obj_t * self = MP_OBJ_TO_PTR (self_in );
@@ -467,6 +481,7 @@ static const mp_rom_map_elem_t pb_type_DriveBase_locals_dict_table[] = {
467481 { MP_ROM_QSTR (MP_QSTR_drive ), MP_ROM_PTR (& pb_type_DriveBase_drive_obj ) },
468482 { MP_ROM_QSTR (MP_QSTR_stop ), MP_ROM_PTR (& pb_type_DriveBase_stop_obj ) },
469483 { MP_ROM_QSTR (MP_QSTR_brake ), MP_ROM_PTR (& pb_type_DriveBase_brake_obj ) },
484+ { MP_ROM_QSTR (MP_QSTR_hold ), MP_ROM_PTR (& pb_type_DriveBase_hold_obj ) },
470485 { MP_ROM_QSTR (MP_QSTR_distance ), MP_ROM_PTR (& pb_type_DriveBase_distance_obj ) },
471486 { MP_ROM_QSTR (MP_QSTR_angle ), MP_ROM_PTR (& pb_type_DriveBase_angle_obj ) },
472487 { MP_ROM_QSTR (MP_QSTR_done ), MP_ROM_PTR (& pb_type_DriveBase_done_obj ) },
0 commit comments