Update hexapod.py
This commit is contained in:
parent
68ea437305
commit
3f6fc6b1e5
@ -328,6 +328,7 @@ class Hexapod(Thread):
|
|||||||
data_array = cmd_string.split(',')
|
data_array = cmd_string.split(',')
|
||||||
if len(data_array) == 4:
|
if len(data_array) == 4:
|
||||||
op = data_array[0].lstrip()
|
op = data_array[0].lstrip()
|
||||||
|
|
||||||
leg_idx = int(data_array[1])
|
leg_idx = int(data_array[1])
|
||||||
if leg_idx < 0 or leg_idx > 5:
|
if leg_idx < 0 or leg_idx > 5:
|
||||||
return
|
return
|
||||||
@ -345,6 +346,13 @@ class Hexapod(Thread):
|
|||||||
|
|
||||||
config_str = 'leg'+str(leg_idx)+'Offset'
|
config_str = 'leg'+str(leg_idx)+'Offset'
|
||||||
self.config[config_str] = self.legs[leg_idx].correction
|
self.config[config_str] = self.legs[leg_idx].correction
|
||||||
|
self.save_config()
|
||||||
|
|
||||||
|
def save_config(self):
|
||||||
|
try:
|
||||||
|
json.dump(self.config, open('config.json', 'w+'), indent=4)
|
||||||
|
except PermissionError as err:
|
||||||
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user