]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/adafruit_blinka/agnostic/__init__.py
orange pi GPIO led blinky
[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 platform = sys.platform
12
13 board_id = None
14
15 if platform is not None:
16     if platform == "esp8266":  # TODO more conservative board-guessing
17         board_id = "feather_huzzah"
18     elif platform == "samd21":
19         board_id = "feather_m0_express"
20     elif platform == "pyboard":
21         platform = "stm32"
22         board_id = "pyboard"
23     elif platform == "linux":
24         import re
25         # we're going to redo the Platform detection, this is a terrible hack
26         # for now.
27         try:
28             # lets see if we're an armbian board
29             for line in open("/etc/armbian-release", 'r'):
30                 #print(line)
31                 m = re.search('BOARD=(.*)', line)
32                 if m:
33                     board_id = m.group(1)
34         except:
35             from Adafruit_GPIO import Platform
36             if Platform.platform_detect() == Platform.RASPBERRY_PI:
37                 if Platform.pi_version() == 1:
38                     board_id = "raspi_1"
39                 elif Platform.pi_version() == 2:
40                     board_id = "raspi_2"
41                 elif Platform.pi_version() == 3:
42                     board_id = "raspi_3"
43             elif Platform.platform_detect() == Platform.BEAGLEBONE_BLACK:
44                 board_id = "beaglebone_black"
45
46 implementation = sys.implementation.name
47 if implementation == "micropython":
48     from utime import sleep
49 elif implementation == "circuitpython" or implementation == "cpython":
50     from time import sleep