]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Merge remote-tracking branch 'adafruit/main'
authorRyan L <ryestar101@gmail.com>
Tue, 26 Sep 2023 20:43:51 +0000 (21:43 +0100)
committerRyan L <ryestar101@gmail.com>
Tue, 26 Sep 2023 20:43:51 +0000 (21:43 +0100)
.github/ISSUE_TEMPLATE/bug_report.yml
.github/ISSUE_TEMPLATE/new_board_request.md
.readthedocs.yaml
README.rst
setup.py
src/adafruit_blinka/microcontroller/am335x/pin.py
src/adafruit_blinka/microcontroller/amlogic/meson_g12_common/pin.py
src/adafruit_blinka/microcontroller/generic_linux/i2c.py
src/adafruit_blinka/microcontroller/generic_linux/spi.py
src/busio.py

index 3e24c9c8091ccde3ca2742e98f415a64a239a9dd..2408b00b33384334054f511874be861a1c89ed5a 100644 (file)
@@ -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:
index 6190a2c02310a97c2b91d7a0a3a5aa1b1a16c4eb..02ff5150c5a76d3ffb9388817a69cc83eb229dbe 100644 (file)
@@ -1,5 +1,5 @@
 ---
-name: ð\9f\9a\80 New Board Request
+name: ð\9f\93\9f New Board Request
 about: Request Support for a New Board
 title: ''
 labels: 'New Board Request'
index b7f92082cf97c0e02cee24a6c4a7b82c7e545f98..57764a1ad05c0855c95ea922bdfcdda36c35ac5b 100644 (file)
@@ -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
index 3e21f93d5c5c086d24c3ad086335c18723fcc7b5..30c64ed22ec25b5a9aabacd352925771e5ea88c5 100755 (executable)
@@ -77,15 +77,27 @@ To install in a virtual environment in your current project:
 Usage Example
 =============
 
-At the time of writing (`git:7fc1f8ab <https://github.com/cefn/Adafruit_Micropython_Blinka/tree/7fc1f8ab477124628a5afebbf6826005955805f9>`_),
-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 <https://github.com/cefn/Adafruit_Micropython_Blinka/issues/2#issuecomment-366713394>`_ .
+    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
 ============
index aa64498086ce634ceaabd2abef4b94f7d7a68216..0e4f52e2dbc4ea47bc0a2bcab5b00eb5a5487ecc 100755 (executable)
--- 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",
index 0986849545edb59b823227b216043f340b6542e2..c6659ca25aad0ac71ffe4aa9a1ac5c5b2d3bf4bc 100644 (file)
@@ -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:
index 87f45719ac1918e5e98c40bc23cff1b71e97c931..1f9fa3c941d76b3041cdca35260eff73e2f52ee4 100644 (file)
@@ -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
index f6bee20c8f878ab18fbbb08fb620594556dc2cd5..b6f2fa36885c46a6f53c3aaceff0af42f0b7833d 100644 (file)
@@ -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)
index 50ad8c154067fd669b972f40bf69ec473ef330cf..6cce03700b5634a11281e75bbf9301b1b407f225 100755 (executable)
@@ -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)
index 2de9e60a69137419a5c734f00d9e179cf27f14c5..9d2199633823138705bee76229b901b598389f5a 100644 (file)
@@ -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: