]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Added pyboard entry. Generalised logic
authorCefn Hoile <github.com@cefn.com>
Sun, 18 Feb 2018 01:23:30 +0000 (01:23 +0000)
committerCefn Hoile <github.com@cefn.com>
Sun, 18 Feb 2018 01:23:30 +0000 (01:23 +0000)
python/agnostic.py

index 22463262feddda43ef9cb4e70b83f18812c6a7a6..2a733477d8cc7507d1fb5faad11e4f13acb8108f 100644 (file)
@@ -1,3 +1,26 @@
-#platform = sys.implementation.platform
-platform="esp8266"
-"""Useful indirection to test Pin naming logic by switching platform in testing"""
\ No newline at end of file
+"""Allows useful indirection to test Pin naming logic by switching platform in testing
+    or where auto-detection is not feasible (e.g. multiple ESP8266 boards architecturally identical)
+"""
+import sys
+
+try:
+    platform = sys.platform
+except:
+    platform = None
+
+if platform is not None:
+    if platform == "esp8266":
+        board = "huzzah"
+    elif platform == "Atmel SAMD21":
+        board="feather_m0_express"
+    elif platform == "pyboard":
+        platform="STM32F405RG"
+        board="pyboard"
+else:
+    board = None
+
+implementation = sys.implementation.name
+if implementation == "micropython":
+    import utime as time
+elif implementation == "circuitpython":
+    import time
\ No newline at end of file