Skip to content

Commit

Permalink
changed stop to stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Perry committed Sep 23, 2021
1 parent 1b40f5d commit 3265901
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions dexarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def __init__(self, name, port):

#self.ser1 = serial.Serial(port, 115200, timeout=None)
#self.is_open = self.ser1.isOpen()
self.stop = False
self.name = name
self.stopped = False
self.ser1 = Runtime.start(name,"Serial")
self.ser1.connect(port, 115200, 8, 1, 0)
self.is_open = self.ser1.isConnected()
Expand All @@ -23,7 +24,8 @@ def __init__(self, name, port):
print('failed to connect to serial port')

def stop(self):
self.stop = True
print('dexarm', self.name, 'stopping')
self.stopped = True


def _send_cmd1(self, data, wait=True):
Expand Down Expand Up @@ -77,7 +79,7 @@ def strip_gcode1(self):
def process_letter(self, letter):
print('opening letter ' + letter)
f = open(letter,'r')
for line in f and not self.stop:
for line in f and not self.stopped:
if (line.isspace()==False and len(line)>0) :
self._send_cmd1(line+'\n')
print ('Dexarm1 gcode line: ' + line)
Expand Down
9 changes: 8 additions & 1 deletion joystick.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
down_dexarm2 = "Left"
up_dexarm2 = "Right"
stop = "Space"
# stop = "A"
# move_to = "C"
# runtime.setVirtual(True)

# start 2 dexarms
dexarm1 = Dexarm('serial1', dexarmPort1)
Expand All @@ -42,6 +45,7 @@
#this is the method in python which receive the data from joystick service
#it is triggered only when new data arrive, it's not a loop !
def onJoystickInput(data):
global dexarm1, dexarm2
#this print the name of the key/button you pressed (it's a String)
#this print the value of the key/button (it's a Float)
print (data)
Expand All @@ -53,8 +57,11 @@ def onJoystickInput(data):
print('moved dexarm1 to 50, 300, 0')
#print('moved dexarm1 to test1.gcode')
elif (data.id == stop):
print('stopping dexarm1')
dexarm1.stop()
print('stopping dexarm2')
dexarm2.stop()
print('stopped both arms')
elif (data.id == exec_action2):
if (data.value == 1):
print("executing action2", data.value)
Expand Down Expand Up @@ -115,4 +122,4 @@ def onJoystickInput(data):
print("Moving up dexarm1", data.value)
dexarm1.set_relativeUp1()
'''
print('example script loaded')
print('joystick.py loaded')

0 comments on commit 3265901

Please sign in to comment.