File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 13
13
14
14
class ArduinoAlvik :
15
15
16
+ _update_thread_running = False
17
+
16
18
def __init__ (self ):
17
19
self .packeter = ucPack (200 )
18
20
self .left_wheel = _ArduinoAlvikWheel (self .packeter , ord ('L' ))
@@ -64,15 +66,17 @@ def _begin_update_thread(self):
64
66
Runs robot background operations (e.g. threaded update)
65
67
:return:
66
68
"""
67
- self ._update_thread_running = True
68
- self ._update_thread_id = _thread .start_new_thread (self ._update , (1 ,))
69
+
70
+ if not ArduinoAlvik ._update_thread_running :
71
+ ArduinoAlvik ._update_thread_running = True
72
+ self ._update_thread_id = _thread .start_new_thread (self ._update , (1 ,))
69
73
70
74
def _stop_update_thread (self ):
71
75
"""
72
76
Stops the background operations
73
77
:return:
74
78
"""
75
- self ._update_thread_running = False
79
+ ArduinoAlvik ._update_thread_running = False
76
80
77
81
def stop (self ):
78
82
"""
@@ -220,7 +224,7 @@ def _update(self, delay_=1):
220
224
:return:
221
225
"""
222
226
while True :
223
- if not self ._update_thread_running :
227
+ if not ArduinoAlvik ._update_thread_running :
224
228
break
225
229
if self ._read_message ():
226
230
self ._parse_message ()
Original file line number Diff line number Diff line change 23
23
except KeyboardInterrupt as e :
24
24
print ('over' )
25
25
alvik .stop ()
26
- break
27
- sys . exit ()
26
+ sys . exit ()
27
+
You can’t perform that action at this time.
0 commit comments