Skip to content

Commit c7d49b6

Browse files
committed
update set_servo_data function
1 parent d1a8717 commit c7d49b6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ get command refresh mode
798798

799799
### set_servo_data
800800

801-
- **Prototype**: `set_servo_data(servo_no, data_id, value)`
801+
- **Prototype**: `set_servo_data(servo_no, data_id, value, mode=None)`
802802
- **Description**: Set the data parameters of the specified address of the steering gear.
803803

804804
- **Parameters**:
@@ -808,6 +808,7 @@ get command refresh mode
808808
- for myArm: int 1 - 7.
809809
- `data_id`: Data address.
810810
- `value`: 0 - 4096
811+
- `mode`: 0 - indicates that value is one byte(default), 1 - 1 represents a value of two bytes.
811812

812813
### get_servo_data
813814

pymycobot/generate.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def is_all_servo_enable(self):
562562
"""
563563
return self._mesg(ProtocolCode.IS_ALL_SERVO_ENABLE, has_reply=True)
564564

565-
def set_servo_data(self, servo_id, data_id, value):
565+
def set_servo_data(self, servo_id, data_id, value, mode=None):
566566
"""Set the data parameters of the specified address of the steering gear
567567
568568
Args:
@@ -572,9 +572,14 @@ def set_servo_data(self, servo_id, data_id, value):
572572
for myArm: joint id 1 - 7
573573
data_id: Data address.
574574
value: 0 - 4096
575+
mode: 0 - indicates that value is one byte(default), 1 - 1 represents a value of two bytes.
575576
"""
576-
self.calibration_parameters(class_name = self.__class__.__name__, id=servo_id, address=data_id, value=value)
577-
return self._mesg(ProtocolCode.SET_SERVO_DATA, servo_id, data_id, value)
577+
if mode is not None:
578+
self.calibration_parameters(class_name = self.__class__.__name__, id=servo_id, address=data_id, value=value)
579+
return self._mesg(ProtocolCode.SET_SERVO_DATA, servo_id, data_id, value)
580+
else:
581+
self.calibration_parameters(class_name = self.__class__.__name__, id=servo_id, address=data_id, value=value, mode=mode)
582+
return self._mesg(ProtocolCode.SET_SERVO_DATA, servo_id, data_id, [value], mode)
578583

579584
def get_servo_data(self, servo_id, data_id):
580585
"""Read the data parameter of the specified address of the steering gear.

0 commit comments

Comments
 (0)