File tree Expand file tree Collapse file tree 7 files changed +81
-0
lines changed Expand file tree Collapse file tree 7 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 1+ # Pybricks MicroPython tests
2+
3+ Currently, the tests in the ` ev3dev ` folder are automated while the remaining
4+ folders contain tests that must be run manually.
5+
6+ Use ` ./test-ev3dev.sh ` in the top-level directory to run the automated tests
7+ (requires Linux).
Original file line number Diff line number Diff line change 1+ # Should be able to print forever in a tight loop.
2+
3+ # Used to reproduce bug on https://github.com/pybricks/support/issues/163
4+ # and https://github.com/pybricks/support/issues/36
5+
6+ # If it gets to at least 100000, things are looking good.
7+
8+
9+ def count ():
10+ n = 0
11+ while True :
12+ yield n
13+ n += 1
14+
15+
16+ for n in count ():
17+ print ("count:" , n )
Original file line number Diff line number Diff line change 1+ # Should be able to handle an empty program.
Original file line number Diff line number Diff line change 1+ # Should be able to do a simple hello world.
2+ print ("Hello world!" )
Original file line number Diff line number Diff line change 1+ # Should be able to catch SystemExit from the stop button.
2+
3+ from pybricks .tools import wait
4+
5+ for i in range (3 ):
6+ print ("press stop button..." )
7+ try :
8+ while True :
9+ wait (10 )
10+ except SystemExit :
11+ print ("caught SystemExit" , i )
12+
13+ # Should print this after pressing the stop button 3 times.
14+ print ("...done" )
Original file line number Diff line number Diff line change 1+ # Should be able to display each color (note: colors without 100% saturation
2+ # will not appear correctly due to physics).
3+
4+ # Press the stop button to advance to the next color
5+
6+ from pybricks .hubs import *
7+ from pybricks .parameters import Color
8+ from pybricks .tools import wait
9+
10+ # sneaky way to get XyzHub class without knowning which hub
11+ hub = next (v for k , v in globals ().items () if k .endswith ("Hub" ))()
12+
13+ for c in Color :
14+ print ("Color:" , c )
15+ hub .light .on (Color [c ])
16+ try :
17+ while True :
18+ wait (10 )
19+ except SystemExit :
20+ continue
21+
22+ hub .light .off ()
23+ print ("...done" )
Original file line number Diff line number Diff line change 1+ # Should be able to smoothly transition between all colors.
2+
3+ from pybricks .hubs import *
4+ from pybricks .parameters import Color
5+ from pybricks .tools import wait
6+
7+ # sneaky way to get XyzHub class without knowning which hub
8+ hub = next (v for k , v in globals ().items () if k .endswith ("Hub" ))()
9+
10+ # Every possible hue with 100% saturation, 100% brightness.
11+ # Note: In real programs, use every 2 or 3 degrees to save memory.
12+ rainbow = [Color .BLUE >> d for d in range (360 )]
13+
14+ hub .light .animate (rainbow , 100 )
15+
16+ while True :
17+ wait (10 )
You can’t perform that action at this time.
0 commit comments