From b2f3210f687b64bf480a19cfb6ad5b92918f21ee Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 18 Mar 2019 21:55:11 -0700 Subject: [PATCH] Added MiniTFT FeatherWing Example and renamed files --- docs/examples.rst | 21 +++++++ ...crickit_test.py => seesaw_crickit_test.py} | 0 ...atherwing.py => seesaw_joy_featherwing.py} | 0 examples/seesaw_minitft_featherwing.py | 58 +++++++++++++++++++ ...impletest.py => seesaw_soil_simpletest.py} | 0 5 files changed, 79 insertions(+) rename examples/{crickit_test.py => seesaw_crickit_test.py} (100%) rename examples/{Joy_Featherwing.py => seesaw_joy_featherwing.py} (100%) create mode 100644 examples/seesaw_minitft_featherwing.py rename examples/{soil_simpletest.py => seesaw_soil_simpletest.py} (100%) diff --git a/docs/examples.rst b/docs/examples.rst index 3b2e7d0..b2dd1fb 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -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: diff --git a/examples/crickit_test.py b/examples/seesaw_crickit_test.py similarity index 100% rename from examples/crickit_test.py rename to examples/seesaw_crickit_test.py diff --git a/examples/Joy_Featherwing.py b/examples/seesaw_joy_featherwing.py similarity index 100% rename from examples/Joy_Featherwing.py rename to examples/seesaw_joy_featherwing.py diff --git a/examples/seesaw_minitft_featherwing.py b/examples/seesaw_minitft_featherwing.py new file mode 100644 index 0000000..fbec202 --- /dev/null +++ b/examples/seesaw_minitft_featherwing.py @@ -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) diff --git a/examples/soil_simpletest.py b/examples/seesaw_soil_simpletest.py similarity index 100% rename from examples/soil_simpletest.py rename to examples/seesaw_soil_simpletest.py