]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Added support for pyboard and future support for inverted LED
authorCefn Hoile <github.com@cefn.com>
Mon, 19 Feb 2018 15:41:03 +0000 (15:41 +0000)
committerCefn Hoile <github.com@cefn.com>
Mon, 19 Feb 2018 15:41:03 +0000 (15:41 +0000)
python/testing/board/__init__.py
python/testing/implementation/all/digitalio.py

index d05c2226405b596ef207c4c20f15049ee8ea4106..a961969657df2e9a8439e2ba420f3e9a27b72908 100644 (file)
@@ -2,13 +2,20 @@
 import agnostic
 import board
 if agnostic.board == "feather_m0_express":
-    default_pin = board.D5
-    led_pin = board.D13
+    from board import feather_m0_express
+    default_pin = feather_m0_express.D5
+    led_pin = feather_m0_express.D13
     led_hardwired = True
+    led_inverted = False
 elif agnostic.board == "feather_huzzah":
-    default_pin = board.GPIO4
-    led_pin = board.GPIO2
+    from board import feather_huzzah
+    default_pin = feather_huzzah.GPIO4
+    led_pin = feather_huzzah.GPIO0 # red led
     led_hardwired = True
-    pull_down_support = False
+    led_inverted = False
 elif agnostic.board == "pyboard":
-    raise NotImplementedError
+    from board import pyboard
+    default_pin = pyboard.X1
+    led_pin = board.pyboard.LED_BLUE
+    led_hardwired = True
+    led_inverted = False
index 87a4e1f872a972f6364e6ba5a2a6b2ed82437a81..f4426058ed685210aedfa36e2e35dae9bf084674 100644 (file)
@@ -1,6 +1,6 @@
 import unittest
 from testing import yes_no, await_true
-from testing.board import led_pin, default_pin, led_hardwired
+from testing.board import led_pin, default_pin, led_hardwired, led_inverted
 import digitalio
 from digitalio import * # TODO refactor below for wildcard import
 
@@ -41,12 +41,13 @@ class TestDigitalInOutInteractive(unittest.TestCase):
         with digitalio.DigitalInOut(led_pin) as led:
             led.direction = digitalio.Direction.OUTPUT
             # should now be OUT, PUSH_PULL, value=0, and LED should light
+            led.value = 0 if led_inverted else 1
             self.assertTrue(yes_no("Is LED lit"))
             print("Winking LED...")
             for count in range(2):
-                led.value = True
+                led.value = not(led.value)
                 sleep(0.5)
-                led.value = False
+                led.value = not(led.value)
                 sleep(0.5)
             self.assertTrue(yes_no("Did LED wink twice"))