Skip to content

Commit 5c9dbd3

Browse files
committed
Added dynamic support for auxillary motors;
will only attempt to initalize if in config file.
1 parent a028f60 commit 5c9dbd3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

FLLMaster/DriveLibraries.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# The program doesn't work without this. Not sure why.
2+
from time import sleep
23
from ev3dev2.motor import *
34
from ev3dev2.sensor.lego import *
45
from ev3dev2.sensor import *
@@ -79,9 +80,21 @@ def __init__(self, filename):
7980
self.AuxMotor1 = eval(conf.get('AuxMotors', 'AuxMotor1'))
8081
self.AuxMotor2 = eval(conf.get('AuxMotors', 'AuxMotor2'))
8182

82-
# Instantiate the auxillary motor objects (only if motors are connected)
83-
#self.m1 = MediumMotor(self.AuxMotor1)
84-
#self.m2 = MediumMotor(self.AuxMotor2)
83+
# Instantiate the auxillary motor objects, checking if they are connected first.
84+
if self.AuxMotor1 is not None:
85+
try:
86+
self.m1 = MediumMotor(self.AuxMotor1)
87+
except:
88+
print("Aux Motor 1 Not Connected!")
89+
self.spkr.beep('-f 220')
90+
if self.AuxMotor2 is not None:
91+
try:
92+
self.m2 = MediumMotor(self.AuxMotor2)
93+
except:
94+
print("Aux Motor 2 Not Connected!")
95+
self.spkr.beep('-f 220')
96+
sleep(0.3)
97+
self.spkr.beep('-f 220')
8598

8699

87100
# Instantiate the sensor objects

0 commit comments

Comments
 (0)