Browse Source

Moves the U2IF constant definitions to a single file so they are not repeated. (Closes #174)

This gets "pylint $( find . -path './adafruit*.py' )" to 10/10.
This will also enable pre-commit to succeed when it is installed.
pull/175/head
James Carr 11 months ago
parent
commit
ff9d00d1d0
No known key found for this signature in database GPG Key ID: 80CB6FA3D0BD1EDB
5 changed files with 35 additions and 34 deletions
  1. +16
    -16
      adafruit_platformdetect/board.py
  2. +6
    -5
      adafruit_platformdetect/chip.py
  3. +0
    -8
      adafruit_platformdetect/constants/boards.py
  4. +0
    -5
      adafruit_platformdetect/constants/chips.py
  5. +13
    -0
      adafruit_platformdetect/constants/u2if.py

+ 16
- 16
adafruit_platformdetect/board.py View File

@ -39,7 +39,7 @@ Implementation Notes
# imports
import os
import re
from adafruit_platformdetect.constants import boards, chips
from adafruit_platformdetect.constants import boards, chips, u2if
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PlatformDetect.git"
@ -159,16 +159,16 @@ class Board:
board_id = self._stm32mp1_id()
elif chip_id == chips.MT8167:
board_id = boards.CORAL_EDGE_TPU_DEV_MINI
elif chip_id == chips.PICO_U2IF:
board_id = boards.PICO_U2IF
elif chip_id == chips.FEATHER_U2IF:
board_id = boards.FEATHER_U2IF
elif chip_id == chips.ITSYBITSY_U2IF:
board_id = boards.ITSYBITSY_U2IF
elif chip_id == chips.QTPY_U2IF:
board_id = boards.QTPY_U2IF
elif chip_id == chips.QT2040_TRINKEY_U2IF:
board_id = boards.QT2040_TRINKEY_U2IF
elif chip_id == u2if.PICO_U2IF:
board_id = u2if.PICO_U2IF
elif chip_id == u2if.FEATHER_U2IF:
board_id = u2if.FEATHER_U2IF
elif chip_id == u2if.ITSYBITSY_U2IF:
board_id = u2if.ITSYBITSY_U2IF
elif chip_id ==u2if.QTPY_U2IF:
board_id = u2if.QTPY_U2IF
elif chip_id == u2if.QT2040_TRINKEY_U2IF:
board_id = u2if.QT2040_TRINKEY_U2IF
self._board_id = board_id
return board_id
@ -618,27 +618,27 @@ class Board:
@property
def pico_u2if(self):
"""Check whether the current board is a RPi Pico w/ u2if."""
return self.id == boards.PICO_U2IF
return self.id == u2if.PICO_U2IF
@property
def feather_u2if(self):
"""Check whether the current board is a Feather RP2040 w/ u2if."""
return self.id == boards.FEATHER_U2IF
return self.id == u2if.FEATHER_U2IF
@property
def itsybitsy_u2if(self):
"""Check whether the current board is a Itsy Bitsy w/ u2if."""
return self.id == boards.ITSYBITSY_U2IF
return self.id == u2if.ITSYBITSY_U2IF
@property
def qtpy_u2if(self):
"""Check whether the current board is a QT Py w/ u2if."""
return self.id == boards.QTPY_U2IF
return self.id == u2if.QTPY_U2IF
@property
def qt2040_trinkey_u2if(self):
"""Check whether the current board is a QT Py w/ u2if."""
return self.id == boards.QT2040_TRINKEY_U2IF
return self.id == u2if.QT2040_TRINKEY_U2IF
@property
def binho_nova(self):


+ 6
- 5
adafruit_platformdetect/chip.py View File

@ -110,28 +110,29 @@ class Chip:
)
if os.environ.get("BLINKA_U2IF"):
import hid
from adafruit_platformdetect.constants import u2if
# look for it based on PID/VID
for dev in hid.enumerate():
# Raspberry Pi Pico
if dev["vendor_id"] == 0xCAFE and dev["product_id"] == 0x4005:
self._chip_id = chips.PICO_U2IF
self._chip_id = u2if.PICO_U2IF
return self._chip_id
# Feather RP2040
if dev["vendor_id"] == 0x239A and dev["product_id"] == 0x00F1:
self._chip_id = chips.FEATHER_U2IF
self._chip_id = u2if.FEATHER_U2IF
return self._chip_id
# Itsy Bitsy RP2040
if dev["vendor_id"] == 0x239A and dev["product_id"] == 0x00FD:
self._chip_id = chips.ITSYBITSY_U2IF
self._chip_id = u2if.ITSYBITSY_U2IF
return self._chip_id
# QT Py RP2040
if dev["vendor_id"] == 0x239A and dev["product_id"] == 0x00F7:
self._chip_id = chips.QTPY_U2IF
self._chip_id = u2if.QTPY_U2IF
return self._chip_id
# QT2040 Trinkey
if dev["vendor_id"] == 0x239A and dev["product_id"] == 0x0109:
self._chip_id = chips.QT2040_TRINKEY_U2IF
self._chip_id = u2if.QT2040_TRINKEY_U2IF
return self._chip_id
raise RuntimeError(
"BLINKA_U2IF environment variable "


+ 0
- 8
adafruit_platformdetect/constants/boards.py View File

@ -115,14 +115,6 @@ ALLWINER_D1 = "ALLWINER_D1"
MICROCHIP_MCP2221 = "MICROCHIP_MCP2221"
# Boards with u2if firmware
# https://github.com/execuc/u2if
PICO_U2IF = "PICO_U2IF"
FEATHER_U2IF = "FEATHER_U2IF"
ITSYBITSY_U2IF = "ITSYBITSY_U2IF"
QTPY_U2IF = "QTPY_U2IF"
QT2040_TRINKEY_U2IF = "QT2040_TRINKEY_U2IF"
BINHO_NOVA = "BINHO_NOVA"
ONION_OMEGA = "ONION_OMEGA"


+ 0
- 5
adafruit_platformdetect/constants/chips.py View File

@ -46,11 +46,6 @@ RP2040 = "RP2040"
STM32MP157 = "STM32MP157"
MT8167 = "MT8167"
ATOM_X5_Z8350 = "X5-Z8350"
PICO_U2IF = "PICO_U2IF"
FEATHER_U2IF = "FEATHER_U2IF"
ITSYBITSY_U2IF = "ITSYBITSY_U2IF"
QTPY_U2IF = "QTPY_U2IF"
QT2040_TRINKEY_U2IF = "QT2040_TRINKEY_U2IF"
BCM_RANGE = {"BCM2708", "BCM2709", "BCM2711", "BCM2835", "BCM2837"}

+ 13
- 0
adafruit_platformdetect/constants/u2if.py View File

@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""Definition for U2IF devices. They share the same name for board and chip."""
# Boards with u2if firmware
# https://github.com/execuc/u2if
PICO_U2IF = "PICO_U2IF"
FEATHER_U2IF = "FEATHER_U2IF"
ITSYBITSY_U2IF = "ITSYBITSY_U2IF"
QTPY_U2IF = "QTPY_U2IF"
QT2040_TRINKEY_U2IF = "QT2040_TRINKEY_U2IF"

Loading…
Cancel
Save