Browse Source

Refactoring Pin, pin etc.

master^2
Cefn Hoile 3 years ago
parent
commit
b70fd42adf
2 changed files with 34 additions and 0 deletions
  1. +26
    -0
      src/microcontroller/__init__.py
  2. +8
    -0
      src/microcontroller/pin.py

+ 26
- 0
src/microcontroller/__init__.py View File

@ -0,0 +1,26 @@
from adafruit_blinka import Enum, agnostic
class Pin(Enum):
def __init__(self, id):
"""Identifier for pin, referencing platform-specific pin id"""
self.id = id
def __repr__(self):
import board
for key in dir(board):
if getattr(board, key) is self:
return "board.{}".format(key)
import microcontroller.pin as pin
for key in dir(pin):
if getattr(pin, key) is self:
return "microcontroller.pin.{}".format(key)
return repr(self)
if agnostic.microcontroller == "esp8266":
from adafruit_blinka.microcontroller.esp8266 import *
elif agnostic.microcontroller == "stm32":
from adafruit_blinka.microcontroller.stm32 import *
else:
raise NotImplementedError("Microcontroller not supported")

+ 8
- 0
src/microcontroller/pin.py View File

@ -0,0 +1,8 @@
from adafruit_blinka import agnostic
if agnostic.microcontroller == "esp8266":
from adafruit_blinka.microcontroller.esp8266.pin import *
elif agnostic.microcontroller == "stm32":
from adafruit_blinka.microcontroller.stm32.pin import *
else:
raise NotImplementedError("Microcontroller not supported")

Loading…
Cancel
Save