Skip to content

Commit

Permalink
Don't overwrite eeprom for free command
Browse files Browse the repository at this point in the history
  • Loading branch information
iory committed Dec 23, 2024
1 parent 4fd056e commit d6b8a51
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rcb4/ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,12 @@ def set_reverse(self, reverse=None, servo_id=None):
def set_free(self, free, servo_id=None):
if servo_id is None:
servo_id = self.get_servo_id()

if free:
self.ics.write(bytes([
0x80 | (0x1F & servo_id), 0, 0]))
time.sleep(0.01)
v = self.ics.read(6)
return ((v[3 + 1] << 7) & 0x3F80) | (v[3 + 2] & 0x007F)
ics_param64, _ = self.read_param()
if free is None or free == 0:
ics_param64[15] = ics_param64[15] & 0xD
Expand Down Expand Up @@ -661,7 +666,7 @@ def read_angle(self, servo_id=None):
if servo_id is None:
servo_id = self.get_servo_id()
self.ics.write(bytes([0xA0 | (servo_id & 0x1F), 5]))
time.sleep(0.1)
time.sleep(0.01)
v = self.ics.read(6)
angle = ((v[4] & 0x7F) << 7) | (v[5] & 0x7F)
return angle
Expand Down

0 comments on commit d6b8a51

Please sign in to comment.