Browse Source

Renaming and refactoring typos. Experimental logic for board-based Pin naming, falling back on microcontroller-based Pin naming

master^2
Cefn Hoile 3 years ago
parent
commit
5f6bb4e415
7 changed files with 21 additions and 13 deletions
  1. +1
    -1
      src/adafruit_blinka/__init__.py
  2. +0
    -0
      src/adafruit_blinka/board/feather_m0_express.py
  3. +2
    -2
      src/adafruit_blinka/board/nodemcu.py
  4. +1
    -1
      src/adafruit_blinka/board/pyboard.py
  5. +0
    -1
      src/bitbangio.py
  6. +3
    -5
      src/board.py
  7. +14
    -3
      src/microcontroller.py

+ 1
- 1
src/adafruit_blinka/__init__.py View File

@ -37,7 +37,7 @@ class ContextManaged:
def __exit__(self, exc_type, exc_value, traceback):
self.deinit()
def Lockable(ContextManaged):
class Lockable(ContextManaged):
_locked = False
def try_lock(self):


+ 0
- 0
src/adafruit_blinka/board/feather_m0_express.py View File


+ 2
- 2
src/adafruit_blinka/board/nodemcu.py View File

@ -1,4 +1,4 @@
from microcontroller import pin
from adafruit_blinka.microcontroller.esp8266 import pin
D0 = pin.GPIO16
D1 = pin.GPIO5
@ -26,4 +26,4 @@ RX0 = D9
TX0 = D10
# GPIO0 and GPIO2 have built-in pull-ups on common ESP8266
# breakout boards making them suitable for I2C SDA and SCL
# breakout boards making them suitable for I2C SDA and SCL

+ 1
- 1
src/adafruit_blinka/board/pyboard.py View File

@ -1,4 +1,4 @@
from microcontroller import pin
from adafruit_blinka.microcontroller.stm32 import pin
X1=pin.A0
X2=pin.A1


+ 0
- 1
src/bitbangio.py View File

@ -5,7 +5,6 @@ from machine import Pin
class I2C(Lockable):
def __init__(self, scl, sda, frequency=400000):
super().__init()
self.init(scl, sda, frequency)
def init(self, scl, sda, frequency):


+ 3
- 5
src/board.py View File

@ -39,13 +39,11 @@ __repo__ = "https://github.com/adafruit/Adafruit_Micropython_Blinka.git"
if board == "feather_huzzah":
pass
elif board == "feather_m0_express":
pass
from adafruit_blinka.board.feather_huzzah import *
elif board == "nodemcu":
pass
from adafruit_blinka.board.nodemcu import *
elif board == "pyboard":
pass
fromn> <span class="nn">adafruit_blinka.board.pyboard import *
else:
raise NotImplementedError("Board not supported")
gc.collect()

+ 14
- 3
src/microcontroller.py View File

@ -5,11 +5,22 @@ class Pin(Enum):
def __init__(self, id):
"""Identifier for pin, referencing platform-specific pin id"""
self.id = id
pass
def __repr__(self):
import board
for key in dir(board):
if getattr(board, key) is self:
return "board.{}".format(key)
import microcontroller
for key in dir(microcontroller):
if getattr(microcontroller, key) is self:
return "microcontroller.{}".format(key)
return repr(self)
if agnostic.microcontroller == "esp8266":
pass
fromn> <span class="nn">adafruit_blinka.microcontroller.esp8266 import *
elif agnostic.microcontroller == "stm32":
pass
fromn> <span class="nn">adafruit_blinka.microcontroller.stm32 import *
else:
raise NotImplementedError("Microcontroller not supported")

Loading…
Cancel
Save