Skip to content
This repository was archived by the owner on Nov 23, 2019. It is now read-only.

Commit 5534818

Browse files
committed
Fix one typo
Add port parameter to lego devices
1 parent 063b90a commit 5534818

File tree

6 files changed

+34
-40
lines changed

6 files changed

+34
-40
lines changed

build_egg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python setup.py bdist_egg
1+
python setup.py bdist_egg upload

ev3/lego.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class ColorSensor(Msensor):
1616
colors = (None, 'black', 'blue', 'green',
1717
'yellow', 'red', 'white', 'brown')
1818

19-
def __init__(self):
20-
Msensor.__init__(self, type_id=29)
19+
def __init__(self, port=-1):
20+
Msensor.__init__(self, port, type_id=29)
2121

2222
@property
2323
def rgb(self):
@@ -47,8 +47,8 @@ def ref_raw(self):
4747

4848
class InfraredSensor(Msensor):
4949

50-
def __init__(self):
51-
Msensor.__init__(self, type_id=33)
50+
def __init__(self, port=-1):
51+
Msensor.__init__(self, port, type_id=33)
5252

5353
@property
5454
def remote(self):
@@ -76,8 +76,8 @@ def seek(self):
7676

7777
class GyroSensor(Msensor):
7878

79-
def __init__(self):
80-
Msensor.__init__(self, type_id=32)
79+
def __init__(self, port=-1):
80+
Msensor.__init__(self, port, type_id=32)
8181

8282
@property
8383
def ang(self):
@@ -97,8 +97,8 @@ def ang_and_rate(self):
9797

9898
class UltrasonicSensor(Msensor):
9999

100-
def __init__(self):
101-
Msensor.__init__(self, type_id=30)
100+
def __init__(self, port=-1):
101+
Msensor.__init__(self, port, type_id=30)
102102

103103
@property
104104
def dist_cm(self):
@@ -128,11 +128,11 @@ def si_in(self):
128128

129129
class LargeMotor(Motor):
130130

131-
def __init__(self):
132-
Motor.__init__(self, _type='tacho')
131+
def __init__(self, port=''):
132+
Motor.__init__(self, port, _type='tacho')
133133

134134

135-
class MidiumMotor(Motor):
135+
class MediumMotor(Motor):
136136

137-
def __init__(self):
138-
Motor.__init__(self, _type='minitacho')
137+
def __init__(self, port=''):
138+
Motor.__init__(self, port, _type='minitacho')

test/test_ev3_motor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
class TestMotor(unittest.TestCase):
7+
raw_input('Attach a motor on port A then continue')
78
def __init__(self,*args, **kwargs):
8-
super(TestMotor, self).__init__(*args, **kwargs)
9-
raw_input('Attach a motor on port A then continue')
9+
super(TestMotor, self).__init__(*args, **kwargs)
1010
self.d=Motor(port=Motor.PORT.A)
1111

1212
def setUp(self):

test/test_lego_large_motor.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ def test_large_motor(self):
99
raw_input('Attach a LargeMotor then continue')
1010
d = LargeMotor()
1111
print(d.type)
12-
d.run_mode='forever'
13-
d.regulation_mode=True
14-
d.pulses_per_second_sp=200
15-
d.start()
12+
d.run_forever(100, regulation_mode=False)
1613
print(d.run)
1714
time.sleep(5)
1815
d.stop()

test/test_lego_medium_motor.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from ev3.lego import MediumMotor
2+
import unittest
3+
import time
4+
5+
6+
7+
class TesMediumMotor(unittest.TestCase):
8+
def test_medium_motor(self):
9+
raw_input('Attach a MediumMotor then continue')
10+
d = MediumMotor()
11+
print(d.type)
12+
d.run_forever(100, regulation_mode=False)
13+
print(d.run)
14+
time.sleep(5)
15+
d.stop()
16+
if __name__ == '__main__':
17+
unittest.main()

test/test_lego_midium_motor.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)