Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,24 @@ Ensure your device works with this simple test.
.. literalinclude:: ../examples/seesaw_simpletest.py
:caption: examples/seesaw_simpletest.py
:linenos:

Other Examples
---------------

Here are some other examples using the Seesaw library

.. literalinclude:: ../examples/seesaw_crickit_test.py
:caption: examples/seesaw_crickit_test.py
:linenos:

.. literalinclude:: ../examples/seesaw_joy_featherwing.py
:caption: examples/seesaw_joy_featherwing.py
:linenos:

.. literalinclude:: ../examples/seesaw_soil_simpletest.py
:caption: examples/seesaw_soil_simpletest.py
:linenos:

.. literalinclude:: ../examples/seesaw_minitft_featherwing.py
:caption: examples/seesaw_minitft_featherwing.py
:linenos:
File renamed without changes.
File renamed without changes.
58 changes: 58 additions & 0 deletions examples/seesaw_minitft_featherwing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import time

import board
from micropython import const

from adafruit_seesaw.seesaw import Seesaw

# pylint: disable=bad-whitespace
BUTTON_RIGHT = const(7)
BUTTON_DOWN = const(4)
BUTTON_LEFT = const(3)
BUTTON_UP = const(2)
BUTTON_SEL = const(11)
BUTTON_A = const(10)
BUTTON_B = const(9)

# pylint: enable=bad-whitespace
button_mask = const((1 << BUTTON_RIGHT) |
(1 << BUTTON_DOWN) |
(1 << BUTTON_LEFT) |
(1 << BUTTON_UP) |
(1 << BUTTON_SEL) |
(1 << BUTTON_A) |
(1 << BUTTON_B))

i2c_bus = board.I2C()

ss = Seesaw(i2c_bus, 0x5E)

ss.pin_mode_bulk(button_mask, ss.INPUT_PULLUP)

last_x = 0
last_y = 0

while True:
buttons = ss.digital_read_bulk(button_mask)
if not buttons & (1 << BUTTON_RIGHT):
print("Button RIGHT pressed")

if not buttons & (1 << BUTTON_DOWN):
print("Button DOWN pressed")

if not buttons & (1 << BUTTON_LEFT):
print("Button LEFT pressed")

if not buttons & (1 << BUTTON_UP):
print("Button UP pressed")

if not buttons & (1 << BUTTON_SEL):
print("Button SEL pressed")

if not buttons & (1 << BUTTON_A):
print("Button A pressed")

if not buttons & (1 << BUTTON_B):
print("Button B pressed")

time.sleep(.01)
File renamed without changes.