From: Ryan L Date: Tue, 26 Sep 2023 20:43:51 +0000 (+0100) Subject: Merge remote-tracking branch 'adafruit/main' X-Git-Tag: 8.23.0~1^2 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/0f4b5cd2ef846e482f1ddbaa2a0dbc8bd11412df?hp=5436e48a04eed54db245563efcdd23afa13b1544 Merge remote-tracking branch 'adafruit/main' --- diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 3e24c9c..2408b00 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT name: 🐞 Bug Report -description: Create a bug report to help us improve +description: Create a bug report to help us improve. Use New Board Request if your board isn't being detected. labels: - bug body: diff --git a/.github/ISSUE_TEMPLATE/new_board_request.md b/.github/ISSUE_TEMPLATE/new_board_request.md index 6190a2c..02ff515 100644 --- a/.github/ISSUE_TEMPLATE/new_board_request.md +++ b/.github/ISSUE_TEMPLATE/new_board_request.md @@ -1,5 +1,5 @@ --- -name: 🚀 New Board Request +name: 📟 New Board Request about: Request Support for a New Board title: '' labels: 'New Board Request' diff --git a/.readthedocs.yaml b/.readthedocs.yaml index b7f9208..57764a1 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,8 +8,12 @@ # Required version: 2 +build: + os: "ubuntu-20.04" + tools: + python: "3.7" + python: - version: "3.7" install: - requirements: docs/requirements.txt - requirements: requirements.txt diff --git a/README.rst b/README.rst index 3e21f93..30c64ed 100755 --- a/README.rst +++ b/README.rst @@ -77,15 +77,27 @@ To install in a virtual environment in your current project: Usage Example ============= -At the time of writing (`git:7fc1f8ab `_), -the following sequence runs through some basic testing of the digitalio compatibility layer... +The pin names may vary by board, so you may need to change the pin names in the code. This +example runs on the Raspberry Pi boards to blink an LED connected to GPIO 18 (Pin 12): .. code-block:: python - from testing import test_module_name - test_module_name("testing.universal.digitalio") + import time + import board + import digitalio -An example log from running the suites is `here `_ . + PIN = board.D18 + + print("hello blinky!") + + led = digitalio.DigitalInOut(PIN) + led.direction = digitalio.Direction.OUTPUT + + while True: + led.value = True + time.sleep(0.5) + led.value = False + time.sleep(0.5) Contributing ============ diff --git a/setup.py b/setup.py index aa64498..0e4f52e 100755 --- a/setup.py +++ b/setup.py @@ -35,6 +35,10 @@ if os.path.exists("/proc/device-tree/compatible"): or b"brcm,bcm2711" in compat ): board_reqs = ["RPi.GPIO", "rpi_ws281x>=4.0.0", "sysv_ipc>=1.1.0"] + if ( + b"ti,am335x" in compat + ): # BeagleBone Black, Green, PocketBeagle, BeagleBone AI, etc. + board_reqs = ["Adafruit_BBIO"] setup( name="Adafruit-Blinka", diff --git a/src/adafruit_blinka/microcontroller/am335x/pin.py b/src/adafruit_blinka/microcontroller/am335x/pin.py index 0986849..c6659ca 100644 --- a/src/adafruit_blinka/microcontroller/am335x/pin.py +++ b/src/adafruit_blinka/microcontroller/am335x/pin.py @@ -2,7 +2,13 @@ # # SPDX-License-Identifier: MIT """AM335x pin names""" -from Adafruit_BBIO import GPIO +try: + from Adafruit_BBIO import GPIO +except ImportError as error: + raise RuntimeError( + "The library 'Adafruit_BBIO' was not found. To install, try typing: " + "pip install Adafruit_BBIO" + ) from error class Pin: diff --git a/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py b/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py index 87f4571..1f9fa3c 100644 --- a/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py +++ b/src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py @@ -30,15 +30,24 @@ else: chip0 = gpiod.chip("0") chip1 = gpiod.chip("1") +if callable(chip0.num_lines): + chip0lines = chip0.num_lines() +else: + chip0lines = chip0.num_lines + +if callable(chip1.num_lines): + chip1lines = chip1.num_lines() +else: + chip1lines = chip1.num_lines -if chip0.num_lines < 20: +if chip0lines < 20: aobus = 0 periphs = 1 - periphs_offset = chip1.num_lines - 85 + periphs_offset = chip1lines - 85 else: aobus = 1 periphs = 0 - periphs_offset = chip0.num_lines - 85 + periphs_offset = chip0lines - 85 del chip0 del chip1 diff --git a/src/adafruit_blinka/microcontroller/generic_linux/i2c.py b/src/adafruit_blinka/microcontroller/generic_linux/i2c.py index f6bee20..b6f2fa3 100644 --- a/src/adafruit_blinka/microcontroller/generic_linux/i2c.py +++ b/src/adafruit_blinka/microcontroller/generic_linux/i2c.py @@ -2,11 +2,17 @@ # # SPDX-License-Identifier: MIT """Generic Linux I2C class using PureIO's smbus class""" + +import warnings from Adafruit_PureIO import smbus class I2C: - """I2C class""" + """ + I2C class + + Baudrate has no effect on Linux systems. The argument is only there for compatibility. + """ MASTER = 0 SLAVE = 1 @@ -20,8 +26,10 @@ class I2C: raise NotImplementedError("Only I2C Master supported!") _mode = self.MASTER - # if baudrate != None: - # print("I2C frequency is not settable in python, ignoring!") + if baudrate is not None: + warnings.warn( + "I2C frequency is not settable in python, ignoring!", RuntimeWarning + ) try: self._i2c_bus = smbus.SMBus(bus_num) diff --git a/src/adafruit_blinka/microcontroller/generic_linux/spi.py b/src/adafruit_blinka/microcontroller/generic_linux/spi.py index 50ad8c1..6cce037 100755 --- a/src/adafruit_blinka/microcontroller/generic_linux/spi.py +++ b/src/adafruit_blinka/microcontroller/generic_linux/spi.py @@ -73,7 +73,7 @@ class SPI: def write(self, buf, start=0, end=None): """Write data from the buffer to SPI""" - if not buf: + if buf is None or len(buf) < 1: return if end is None: end = len(buf) @@ -91,7 +91,7 @@ class SPI: def readinto(self, buf, start=0, end=None, write_value=0): """Read data from SPI and into the buffer""" - if not buf: + if buf is None or len(buf) < 1: return if end is None: end = len(buf) @@ -116,7 +116,9 @@ class SPI: """Perform a half-duplex write from buffer_out and then read data into buffer_in """ - if not buffer_out or not buffer_in: + if buffer_out is None or buffer_in is None: + return + if len(buffer_out) < 1 or len(buffer_in) < 1: return if out_end is None: out_end = len(buffer_out) diff --git a/src/busio.py b/src/busio.py index 2de9e60..9d21996 100644 --- a/src/busio.py +++ b/src/busio.py @@ -29,6 +29,8 @@ class I2C(Lockable): """ Busio I2C Class for CircuitPython Compatibility. Used for both MicroPython and Linux. + + NOTE: Frequency has no effect on Linux systems. The argument is only there for compatibility. """ def __init__(self, scl, sda, frequency=100000): @@ -136,6 +138,9 @@ class I2C(Lockable): if detector.board.any_embedded_linux: from adafruit_blinka.microcontroller.generic_linux.i2c import I2C as _I2C + + if frequency == 100000: + frequency = None # Set to None if default to avoid triggering warning elif detector.board.ftdi_ft2232h: from adafruit_blinka.microcontroller.ftdi_mpsse.mpsse.i2c import I2C as _I2C else: