@@ -98,7 +98,8 @@ def send_angle(self, id, degree, speed):
9898
9999 '''
100100 _hex = self ._angle_to_hex (degree )
101- command = 'fefe0621{}{}{}fa' .format (id , _hex , hex (speed )[2 :])
101+ speed = self ._complement_zero (hex (speed )[2 :], digit = 2 )
102+ command = 'fefe0621{}{}{}fa' .format (id , _hex , speed )
102103 # print(command)
103104 self ._write (command )
104105
@@ -267,7 +268,7 @@ def is_moving(self):
267268
268269 def pause (self ):
269270 self ._write ('fefe0226fa' )
270-
271+
271272 def resume (self ):
272273 self ._write ('fefe0228fa' )
273274
@@ -279,7 +280,7 @@ def is_paused(self):
279280 data = self ._read ()
280281 flag = int (data .hex (), 16 )
281282 return False if flag else True
282-
283+
283284 def is_in_position (self , coords ):
284285 if len (coords ) != 6 :
285286 print ('The lenght of coords is not right' )
@@ -376,7 +377,7 @@ def _coord_to_hex(self, coord):
376377 s = str (hex (int (coord )))[2 :]
377378 s = self ._complement_zero (s )
378379 return s
379-
380+
380381 def _complement_zero (self , s , digit = 4 ):
381382 s_len = len (s )
382383 if s_len == digit :
@@ -394,3 +395,4 @@ def _write(self, data):
394395 def _read (self , size = 1024 ):
395396 data = self .serial_port .read (size )
396397 return data
398+
0 commit comments