Skip to content

Commit 0bb88e8

Browse files
author
marcusw
committed
Added a tag for v2.0-beta-1 from the v2 branch.
1 parent cfd98dd commit 0bb88e8

35 files changed

+2124
-2200
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Wed, 18 Nov 2009 19:05:49 +0100 by rhn:
2+
* Created this changelog
3+
* Changed set_input_mode behaviour to take parameters. TODO: Make it remember last mode for analog sensors
4+
* Made get_input_values() return RawReading, and added get_reading() returning named values.
5+
* Changed the way digital sensors work, partially getting rid of metaclasses and breaking everything in the process (no access to hardware)

docs/nxt_python.css

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

docs/nxt_python.html

Lines changed: 0 additions & 225 deletions
This file was deleted.
File renamed without changes.

examples/latency.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,20 @@
44
import nxt.locator
55
from nxt.sensor import *
66

7-
def time_touch(b):
8-
touch = TouchSensor(b, PORT_1)
9-
start = time.time()
10-
for i in range(100):
11-
touch.get_sample()
12-
stop = time.time()
13-
print 'touch latency: %d ms' % (1000 * (stop - start) / 100.)
7+
b = nxt.locator.find_one_brick()
148

15-
def time_ultrasonic(b):
16-
ultrasonic = UltrasonicSensor(b, PORT_4)
17-
start = time.time()
18-
for i in range(100):
19-
ultrasonic.get_sample()
20-
stop = time.time()
21-
print 'ultrasonic latency: %d ms' % (1000 * (stop - start) / 100.)
9+
#Touch sensor latency test
10+
touch = Touch(b, PORT_1)
11+
start = time.time()
12+
for i in range(100):
13+
touch.get_sample()
14+
stop = time.time()
15+
print 'touch latency: %s ms' % (1000 * (stop - start) / 100.0)
2216

23-
sock = nxt.locator.find_one_brick()
24-
if sock:
25-
b = sock.connect()
26-
time_touch(b)
27-
time_ultrasonic(b)
28-
sock.close()
29-
else:
30-
print 'No NXT bricks found'
17+
#Ultrasonic sensor latency test
18+
ultrasonic = Ultrasonic(b, PORT_4)
19+
start = time.time()
20+
for i in range(100):
21+
ultrasonic.get_sample()
22+
stop = time.time()
23+
print 'ultrasonic latency: %s ms' % (1000 * (stop - start) / 100.0)

examples/mary.py

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,34 @@
1212
FREQ_E = 659
1313
FREQ_G = 784
1414

15-
def play_song(b):
16-
b.play_tone_and_wait(FREQ_E, 500)
17-
b.play_tone_and_wait(FREQ_D, 500)
18-
b.play_tone_and_wait(FREQ_C, 500)
19-
b.play_tone_and_wait(FREQ_D, 500)
20-
b.play_tone_and_wait(FREQ_E, 500)
21-
b.play_tone_and_wait(FREQ_E, 500)
22-
b.play_tone_and_wait(FREQ_E, 500)
23-
sleep(0.5)
24-
b.play_tone_and_wait(FREQ_D, 500)
25-
b.play_tone_and_wait(FREQ_D, 500)
26-
b.play_tone_and_wait(FREQ_D, 500)
27-
sleep(0.5)
28-
b.play_tone_and_wait(FREQ_E, 500)
29-
b.play_tone_and_wait(FREQ_G, 500)
30-
b.play_tone_and_wait(FREQ_G, 500)
31-
sleep(0.5)
32-
b.play_tone_and_wait(FREQ_E, 500)
33-
b.play_tone_and_wait(FREQ_D, 500)
34-
b.play_tone_and_wait(FREQ_C, 500)
35-
b.play_tone_and_wait(FREQ_D, 500)
36-
b.play_tone_and_wait(FREQ_E, 500)
37-
b.play_tone_and_wait(FREQ_E, 500)
38-
b.play_tone_and_wait(FREQ_E, 500)
39-
b.play_tone_and_wait(FREQ_E, 500)
40-
b.play_tone_and_wait(FREQ_D, 500)
41-
b.play_tone_and_wait(FREQ_D, 500)
42-
b.play_tone_and_wait(FREQ_E, 500)
43-
b.play_tone_and_wait(FREQ_D, 500)
44-
b.play_tone_and_wait(FREQ_C, 750)
45-
sleep(1)
15+
b = nxt.locator.find_one_brick()
4616

47-
sock = nxt.locator.find_one_brick()
48-
if sock:
49-
play_song(sock.connect())
50-
sock.close()
51-
else:
52-
print 'No NXT bricks found'
17+
b.play_tone_and_wait(FREQ_E, 500)
18+
b.play_tone_and_wait(FREQ_D, 500)
19+
b.play_tone_and_wait(FREQ_C, 500)
20+
b.play_tone_and_wait(FREQ_D, 500)
21+
b.play_tone_and_wait(FREQ_E, 500)
22+
b.play_tone_and_wait(FREQ_E, 500)
23+
b.play_tone_and_wait(FREQ_E, 500)
24+
sleep(0.5)
25+
b.play_tone_and_wait(FREQ_D, 500)
26+
b.play_tone_and_wait(FREQ_D, 500)
27+
b.play_tone_and_wait(FREQ_D, 500)
28+
sleep(0.5)
29+
b.play_tone_and_wait(FREQ_E, 500)
30+
b.play_tone_and_wait(FREQ_G, 500)
31+
b.play_tone_and_wait(FREQ_G, 500)
32+
sleep(0.5)
33+
b.play_tone_and_wait(FREQ_E, 500)
34+
b.play_tone_and_wait(FREQ_D, 500)
35+
b.play_tone_and_wait(FREQ_C, 500)
36+
b.play_tone_and_wait(FREQ_D, 500)
37+
b.play_tone_and_wait(FREQ_E, 500)
38+
b.play_tone_and_wait(FREQ_E, 500)
39+
b.play_tone_and_wait(FREQ_E, 500)
40+
b.play_tone_and_wait(FREQ_E, 500)
41+
b.play_tone_and_wait(FREQ_D, 500)
42+
b.play_tone_and_wait(FREQ_D, 500)
43+
b.play_tone_and_wait(FREQ_E, 500)
44+
b.play_tone_and_wait(FREQ_D, 500)
45+
b.play_tone_and_wait(FREQ_C, 750)

examples/message_test.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/usr/bin/env python
22

3+
#During this test you need to run any program on the brick
4+
#which doesn't use the messaging system. Most programs fit
5+
#this requirement.
6+
37
import nxt.locator
48

5-
s = nxt.locator.find_one_brick()
6-
b = s.connect()
9+
b = nxt.locator.find_one_brick()
710
for box in range(10):
8-
b.message_write(box, 'message test %d' % box)
11+
b.message_write(box, 'message test %d' % box)
912
for box in range(10):
10-
local_box, message = b.message_read(box, box, True)
11-
print local_box, message
13+
local_box, message = b.message_read(box, box, True)
14+
print local_box, message
1215
print 'Test succeeded!'

0 commit comments

Comments
 (0)