Skip to content

Commit e8f67d5

Browse files
committed
pybricks.common.DCMotor: Finalize settings method.
Also add test for this setting. Fixes pybricks/support#536
1 parent 35a969e commit e8f67d5

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
## [Unreleased]
66

7+
### Changed
8+
- Renamed new `DCMotor.dc_settings()` method to `DCMotor.settings()`.
9+
710
## [3.1.0c1] - 2021-11-19
811

912
### Added

pybricks/common/pb_type_dcmotor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ STATIC const mp_rom_map_elem_t common_DCMotor_locals_dict_table[] = {
159159
{ MP_ROM_QSTR(MP_QSTR_dc), MP_ROM_PTR(&common_DCMotor_duty_obj) },
160160
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&common_DCMotor_stop_obj) },
161161
{ MP_ROM_QSTR(MP_QSTR_brake), MP_ROM_PTR(&common_DCMotor_brake_obj) },
162-
{ MP_ROM_QSTR(MP_QSTR_dc_settings), MP_ROM_PTR(&common_DCMotor_dc_settings_obj) },
162+
{ MP_ROM_QSTR(MP_QSTR_settings), MP_ROM_PTR(&common_DCMotor_dc_settings_obj) },
163163
};
164164
MP_DEFINE_CONST_DICT(common_DCMotor_locals_dict, common_DCMotor_locals_dict_table);
165165

pybricks/common/pb_type_motor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ STATIC const mp_rom_map_elem_t common_Motor_locals_dict_table[] = {
326326
{ MP_ROM_QSTR(MP_QSTR_dc), MP_ROM_PTR(&common_DCMotor_duty_obj) },
327327
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&common_DCMotor_stop_obj) },
328328
{ MP_ROM_QSTR(MP_QSTR_brake), MP_ROM_PTR(&common_DCMotor_brake_obj) },
329-
{ MP_ROM_QSTR(MP_QSTR_dc_settings), MP_ROM_PTR(&common_DCMotor_dc_settings_obj) },
329+
{ MP_ROM_QSTR(MP_QSTR_settings), MP_ROM_PTR(&common_DCMotor_dc_settings_obj) },
330330
//
331331
// Methods specific to encoded motors
332332
//

tests/pup/motors/dcmotor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@
2828
motor.dc(100)
2929
wait(1000)
3030
motor.stop()
31+
wait(1000)
32+
33+
# Run with voltage limit.
34+
motor.settings(max_voltage=5000)
35+
motor.dc(100)
36+
wait(1000)
37+
motor.stop()

0 commit comments

Comments
 (0)