1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
3 # SPDX-License-Identifier: MIT
4 """Allows useful indirection to test Pin naming logic by switching platform in testing
5 or provide bootstrapping logic for board identification where auto-detection is not
6 feasible (e.g. multiple ESP8266 boards architecturally identical). Once runtime
7 environment is established, can choose various routes to make available and re-export
8 common modules and operations, depending on platform support
11 import adafruit_platformdetect
13 # We intentionally are patching into this namespace as module names so skip the name check.
14 # pylint: disable=invalid-name
16 # We'll define board and chip id values in agnostic rather than accessing
17 # detector directly elsewhere, just in case additional indirection is necessary
18 # at some later point:
20 detector = adafruit_platformdetect.Detector()
21 chip_id = detector.chip.id
22 board_id = detector.board.id
24 implementation = sys.implementation.name
25 if implementation == "micropython":
26 from utime import sleep
27 elif implementation in ("circuitpython", "cpython"):
28 from time import sleep