]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/adafruit_blinka/agnostic/__init__.py
1f6eb4c300537ea219a81014c254f32acddcf4fb
[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 import adafruit_platformdetect
9
10 # We intentionally are patching into this namespace as module names so skip the name check.
11 # pylint: disable=invalid-name
12
13 # We'll define board and chip id values in agnostic rather than accessing
14 # detector directly elsewhere, just in case additional indirection is necessary
15 # at some later point:
16
17 detector = adafruit_platformdetect.Detector()
18 chip_id = detector.chip.id
19 board_id = detector.board.id
20
21 implementation = sys.implementation.name
22 if implementation == "micropython":
23     from utime import sleep
24 elif implementation in ("circuitpython", "cpython"):
25     from time import sleep