File tree 5 files changed +79
-0
lines changed 5 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -6,3 +6,24 @@ Ensure your device works with this simple test.
6
6
.. literalinclude :: ../examples/seesaw_simpletest.py
7
7
:caption: examples/seesaw_simpletest.py
8
8
:linenos:
9
+
10
+ Other Examples
11
+ ---------------
12
+
13
+ Here are some other examples using the Seesaw library
14
+
15
+ .. literalinclude :: ../examples/seesaw_crickit_test.py
16
+ :caption: examples/seesaw_crickit_test.py
17
+ :linenos:
18
+
19
+ .. literalinclude :: ../examples/seesaw_joy_featherwing.py
20
+ :caption: examples/seesaw_joy_featherwing.py
21
+ :linenos:
22
+
23
+ .. literalinclude :: ../examples/seesaw_soil_simpletest.py
24
+ :caption: examples/seesaw_soil_simpletest.py
25
+ :linenos:
26
+
27
+ .. literalinclude :: ../examples/seesaw_minitft_featherwing.py
28
+ :caption: examples/seesaw_minitft_featherwing.py
29
+ :linenos:
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ import time
2
+
3
+ import board
4
+ from micropython import const
5
+
6
+ from adafruit_seesaw .seesaw import Seesaw
7
+
8
+ # pylint: disable=bad-whitespace
9
+ BUTTON_RIGHT = const (7 )
10
+ BUTTON_DOWN = const (4 )
11
+ BUTTON_LEFT = const (3 )
12
+ BUTTON_UP = const (2 )
13
+ BUTTON_SEL = const (11 )
14
+ BUTTON_A = const (10 )
15
+ BUTTON_B = const (9 )
16
+
17
+ # pylint: enable=bad-whitespace
18
+ button_mask = const ((1 << BUTTON_RIGHT ) |
19
+ (1 << BUTTON_DOWN ) |
20
+ (1 << BUTTON_LEFT ) |
21
+ (1 << BUTTON_UP ) |
22
+ (1 << BUTTON_SEL ) |
23
+ (1 << BUTTON_A ) |
24
+ (1 << BUTTON_B ))
25
+
26
+ i2c_bus = board .I2C ()
27
+
28
+ ss = Seesaw (i2c_bus , 0x5E )
29
+
30
+ ss .pin_mode_bulk (button_mask , ss .INPUT_PULLUP )
31
+
32
+ last_x = 0
33
+ last_y = 0
34
+
35
+ while True :
36
+ buttons = ss .digital_read_bulk (button_mask )
37
+ if not buttons & (1 << BUTTON_RIGHT ):
38
+ print ("Button RIGHT pressed" )
39
+
40
+ if not buttons & (1 << BUTTON_DOWN ):
41
+ print ("Button DOWN pressed" )
42
+
43
+ if not buttons & (1 << BUTTON_LEFT ):
44
+ print ("Button LEFT pressed" )
45
+
46
+ if not buttons & (1 << BUTTON_UP ):
47
+ print ("Button UP pressed" )
48
+
49
+ if not buttons & (1 << BUTTON_SEL ):
50
+ print ("Button SEL pressed" )
51
+
52
+ if not buttons & (1 << BUTTON_A ):
53
+ print ("Button A pressed" )
54
+
55
+ if not buttons & (1 << BUTTON_B ):
56
+ print ("Button B pressed" )
57
+
58
+ time .sleep (.01 )
File renamed without changes.
You can’t perform that action at this time.
0 commit comments