]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/adafruit_blinka/agnostic/__init__.py
start raspi compatibility
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / agnostic / __init__.py
1 """Allows useful indirection to test Pin naming logic by switching platform in testing
2     or provide bootstrapping logic for board identification where auto-detection is not
3     feasible (e.g. multiple ESP8266 boards architecturally identical). Once runtime
4     environment is established, can choose various routes to make available and re-export
5     common modules and operations, depending on platform support
6 """
7 import sys
8
9 # We intentionally are patching into this namespace as module names so skip the name check.
10 # pylint: disable=invalid-name
11 microcontroller = sys.platform
12
13 board = None
14 if microcontroller is not None:
15     if microcontroller == "esp8266":  # TODO more conservative board-guessing
16         board = "feather_huzzah"
17     elif microcontroller == "samd21":
18         board = "feather_m0_express"
19     elif microcontroller == "pyboard":
20         microcontroller = "stm32"
21         board = "pyboard"
22     elif microcontroller == "linux":
23         from Adafruit_GPIO import Platform
24         if Platform.platform_detect() == Platform.RASPBERRY_PI:
25             if Platform.pi_version() == 1:
26                 board = "raspi_1"
27             elif Platform.pi_version() == 2:
28                 board = "raspi_2"
29             elif Platform.pi_version() == 3:
30                 board = "raspi_3"
31
32 implementation = sys.implementation.name
33 if implementation == "micropython":
34     from utime import sleep
35 elif implementation == "circuitpython" or implementation == "cpython":
36     from time import sleep