]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
pylint
authorbrentru <brent@adafruit.com>
Tue, 2 Apr 2024 21:04:39 +0000 (17:04 -0400)
committerbrentru <brent@adafruit.com>
Tue, 2 Apr 2024 21:04:39 +0000 (17:04 -0400)
src/adafruit_blinka/microcontroller/fake_mcp2221/fake_mcp2221.py
src/adafruit_blinka/microcontroller/fake_mcp2221/i2c.py
src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py
src/microcontroller/__init__.py
src/microcontroller/pin.py

index 7a75dec3e229d855a73502b3d153ce9da93aadd7..5312e1af875e4a4946d087009d1630ee720c391a 100644 (file)
@@ -16,130 +16,9 @@ class MCP2221:
     def __init__(self):
         pass  # This is a "fake" implementation
 
     def __init__(self):
         pass  # This is a "fake" implementation
 
-    def close(self):
-        """Close the hid device. Does nothing if the device is not open."""
-        pass
-
     def __del__(self):
         # try to close the device before destroying the instance
     def __del__(self):
         # try to close the device before destroying the instance
-        pass
-
-    def _hid_xfer(self, report, response=True):
-        """Perform HID Transfer"""
-        return None
-
-    # ----------------------------------------------------------------
-    # MISC
-    # ----------------------------------------------------------------
-    def gp_get_mode(self, pin):
-        """Get Current Pin Mode"""
-        pass
-
-    def gp_set_mode(self, pin, mode):
-        """Set Current Pin Mode"""
-        pass
-
-    def _pretty_report(self, register):
-        pass
-
-    def _status_dump(self):
-        pass
-
-    def _sram_dump(self):
-        pass
-
-    def _reset(self):
-        pass
-
-    # ----------------------------------------------------------------
-    # GPIO
-    # ----------------------------------------------------------------
-    def gpio_set_direction(self, pin, mode):
-        """Set Current GPIO Pin Direction"""
-        pass
-
-    def gpio_set_pin(self, pin, value):
-        """Set Current GPIO Pin Value"""
-        pass
-
-    def gpio_get_pin(self, pin):
-        """Get Current GPIO Pin Value"""
-        pass
-
-    # ----------------------------------------------------------------
-    # I2C
-    # ----------------------------------------------------------------
-    def _i2c_status(self):
-        pass
-
-    def _i2c_state(self):
-        pass
-
-    def _i2c_cancel(self):
-        pass
-
-    # pylint: disable=too-many-arguments,too-many-branches
-    def _i2c_write(self, cmd, address, buffer, start=0, end=None):
-        pass
-
-    def _i2c_read(self, cmd, address, buffer, start=0, end=None):
-        pass
-
-    # pylint: enable=too-many-arguments
-    def _i2c_configure(self, baudrate=100000):
-        """Configure I2C"""
-        pass
-
-    def i2c_writeto(self, address, buffer, *, start=0, end=None):
-        """Write data from the buffer to an address"""
-        pass
-
-    def i2c_readfrom_into(self, address, buffer, *, start=0, end=None):
-        """Read data from an address and into the buffer"""
-        pass
-
-    def i2c_writeto_then_readfrom(
-        self,
-        address,
-        out_buffer,
-        in_buffer,
-        *,
-        out_start=0,
-        out_end=None,
-        in_start=0,
-        in_end=None,
-    ):
-        """Write data from buffer_out to an address and then
-        read data from an address and into buffer_in
-        """
-        pass
-
-    def i2c_scan(self, *, start=0, end=0x79):
-        """Perform an I2C Device Scan"""
-        pass
-
-    # ----------------------------------------------------------------
-    # ADC
-    # ----------------------------------------------------------------
-    def adc_configure(self, vref=0):
-        """Configure the Analog-to-Digital Converter"""
-        pass
-
-    def adc_read(self, pin):
-        """Read from the Analog-to-Digital Converter"""
-        pass
-
-    # ----------------------------------------------------------------
-    # DAC
-    # ----------------------------------------------------------------
-    def dac_configure(self, vref=0):
-        """Configure the Digital-to-Analog Converter"""
-        pass
-
-    # pylint: disable=unused-argument
-    def dac_write(self, pin, value):
-        """Write to the Digital-to-Analog Converter"""
-        pass
+        return
 
     # pylint: enable=unused-argument
 
 
     # pylint: enable=unused-argument
 
index b98c70c2255016e5183cb78230c6110790b08084..30f0b1deba34113f0787d9a36803ee8947afb9f5 100644 (file)
@@ -11,44 +11,19 @@ class I2C:
 
     def __init__(self, *, frequency=100000):
         self._mcp2221 = mcp2221
 
     def __init__(self, *, frequency=100000):
         self._mcp2221 = mcp2221
+        self._freq = frequency
 
     def scan(self, address_list=None):
         """Mocks an I2C scan.
 
     def scan(self, address_list=None):
         """Mocks an I2C scan.
-        If address_list is not provided, this function returns a list of 3 randomly generated I2C addresses from 0x0 to 0x79.
-        For a stimulus-driven test: If address_list is provided, this function returns the provided address_list.
+        If address_list is not provided, this function returns a
+        list of 3 randomly generated I2C addresses from 0x0 to 0x79.
+        For a stimulus-driven test: If address_list is provided,
+        this function returns the provided address_list.
         """
         """
-        if address_list == None:
+        if address_list is None:
             # Generate a list of 3 randomly generated addresses from 0x0 to 0x79
             address_list = []
             for _ in range(3):
                 address_list.append(random.randint(0x0, 0x79))
             return address_list
         return address_list
             # Generate a list of 3 randomly generated addresses from 0x0 to 0x79
             address_list = []
             for _ in range(3):
                 address_list.append(random.randint(0x0, 0x79))
             return address_list
         return address_list
-
-    # pylint: disable=unused-argument
-    def writeto(self, address, buffer, *, start=0, end=None, stop=True):
-        """Write data from the buffer to an address"""
-        pass
-
-    def readfrom_into(self, address, buffer, *, start=0, end=None, stop=True):
-        """Read data from an address and into the buffer"""
-        pass
-
-    def writeto_then_readfrom(
-        self,
-        address,
-        buffer_out,
-        buffer_in,
-        *,
-        out_start=0,
-        out_end=None,
-        in_start=0,
-        in_end=None,
-        stop=False,
-    ):
-        """Write data from buffer_out to an address and then
-        read data from an address and into buffer_in
-        """
-        pass
-
-    # pylint: enable=unused-argument
index f4e1b94ad312a6e65ada65a91472cf16c89c8815..f3b6b1fb5e5b17fdc80fcf02b981b4be7c20c265 100644 (file)
@@ -3,7 +3,6 @@
 # SPDX-License-Identifier: MIT
 """fake_mcp2221 pin names"""
 import random
 # SPDX-License-Identifier: MIT
 """fake_mcp2221 pin names"""
 import random
-from .fake_mcp2221 import mcp2221
 
 
 class Pin:
 
 
 class Pin:
@@ -31,20 +30,15 @@ class Pin:
             raise NotImplementedError(
                 "Internal pullups and pulldowns not supported on the MCP2221"
             )
             raise NotImplementedError(
                 "Internal pullups and pulldowns not supported on the MCP2221"
             )
-        if mode in (Pin.IN, Pin.OUT):
-            # All pins can do GPIO
-            pass
-        elif mode == Pin.ADC:
+        if mode == Pin.ADC:
             # ADC only available on these pins
             if self.id not in (1, 2, 3):
                 raise ValueError("Pin does not have ADC capabilities")
             # ADC only available on these pins
             if self.id not in (1, 2, 3):
                 raise ValueError("Pin does not have ADC capabilities")
-            pass
             # Do nothing
         elif mode == Pin.DAC:
             # DAC only available on these pins
             if self.id not in (2, 3):
                 raise ValueError("Pin does not have DAC capabilities")
             # Do nothing
         elif mode == Pin.DAC:
             # DAC only available on these pins
             if self.id not in (2, 3):
                 raise ValueError("Pin does not have DAC capabilities")
-            pass
         else:
             raise ValueError("Incorrect pin mode: {}".format(mode))
         self._mode = mode
         else:
             raise ValueError("Incorrect pin mode: {}".format(mode))
         self._mode = mode
index 785e0bc4c3dac1aeececa468f1bc16c7487f8f99..b381b6f7c6fce58af3f0e36a46a0bcde0c83d746 100644 (file)
@@ -7,7 +7,7 @@
 
 * Author(s): Melissa LeBlanc-Williams
 """
 
 * Author(s): Melissa LeBlanc-Williams
 """
-
+import os
 import sys
 import time
 
 import sys
 import time
 
index 911eefe6bc3acf038b802d7995ff1c651a2c4aa1..0a33ec6a0bd9ac4c7bb1c21afea684e74583f0f0 100644 (file)
@@ -2,7 +2,7 @@
 #
 # SPDX-License-Identifier: MIT
 """Pins named after their chip name."""
 #
 # SPDX-License-Identifier: MIT
 """Pins named after their chip name."""
-
+import os
 import sys
 from adafruit_platformdetect.constants import chips as ap_chip, boards as ap_boards
 from adafruit_blinka.agnostic import board_id, chip_id
 import sys
 from adafruit_platformdetect.constants import chips as ap_chip, boards as ap_boards
 from adafruit_blinka.agnostic import board_id, chip_id