]> Repositories - Adafruit_Blinka-hackapet.git/blob - python/agnostic.py
Untested draft I2C
[Adafruit_Blinka-hackapet.git] / python / agnostic.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 gc
8 import sys
9 gc.collect()
10
11 try:
12     microcontroller = sys.platform
13 except:
14     microcontroller = None
15
16 if microcontroller is not None:
17     if microcontroller == "esp8266":
18         board = "feather_huzzah"
19     elif microcontroller == "samd21":
20         board = "feather_m0_express"
21     elif microcontroller == "pyboard":
22         microcontroller = "stm32"
23         board = "pyboard"
24 else:
25     board = None
26
27 implementation = sys.implementation.name
28 if implementation == "micropython":
29     from utime import sleep
30 elif implementation == "circuitpython":
31     from time import sleep
32 gc.collect()