Skip to content

Ran black, updated to pylint 2.x #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx
run: |
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
- name: Library version
run: git describe --dirty --always --tags
- name: PyLint
Expand Down
31 changes: 18 additions & 13 deletions adafruit_boardtest/boardtest_gpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git"

# Constants
LED_ON_DELAY_TIME = 0.2 # Seconds
LED_OFF_DELAY_TIME = 0.2 # Seconds
LED_PIN_NAMES = ['L', 'LED', 'RED_LED', 'GREEN_LED', 'BLUE_LED']
LED_ON_DELAY_TIME = 0.2 # Seconds
LED_OFF_DELAY_TIME = 0.2 # Seconds
LED_PIN_NAMES = ["L", "LED", "RED_LED", "GREEN_LED", "BLUE_LED"]

# Test result strings
PASS = "PASS"
Expand All @@ -67,11 +67,13 @@ def _is_number(val):
except ValueError:
return False


# Release pins
def _deinit_pins(gpios):
for g in gpios:
g.deinit()


# Toggle IO pins while waiting for answer
def _toggle_wait(gpios):

Expand All @@ -91,7 +93,8 @@ def _toggle_wait(gpios):
gpio.value = led_state
if supervisor.runtime.serial_bytes_available:
answer = input()
return bool(answer == 'y')
return bool(answer == "y")


def run_test(pins):

Expand All @@ -103,10 +106,10 @@ def run_test(pins):
"""

# Create a list of analog GPIO pins
analog_pins = [p for p in pins if p[0] == 'A' and _is_number(p[1])]
analog_pins = [p for p in pins if p[0] == "A" and _is_number(p[1])]

# Create a list of digital GPIO
digital_pins = [p for p in pins if p[0] == 'D' and _is_number(p[1])]
digital_pins = [p for p in pins if p[0] == "D" and _is_number(p[1])]

# Toggle LEDs if we find any
gpio_pins = analog_pins + digital_pins
Expand All @@ -116,10 +119,10 @@ def run_test(pins):
gpios = [digitalio.DigitalInOut(getattr(board, p)) for p in gpio_pins]

# Print out the LEDs found
print("GPIO pins found:", end=' ')
print("GPIO pins found:", end=" ")
for pin in gpio_pins:
print(pin, end=' ')
print('\n')
print(pin, end=" ")
print("\n")

# Set all IO to output
for gpio in gpios:
Expand All @@ -140,24 +143,26 @@ def run_test(pins):
print("No GPIO pins found")
return NA, []


def _main():

# List out all the pins available to us
pins = [p for p in dir(board)]
pins = list(dir(board))
print()
print("All pins found:", end=' ')
print("All pins found:", end=" ")

# Print pins
for pin in pins:
print(pin, end=' ')
print('\n')
print(pin, end=" ")
print("\n")

# Run test
result = run_test(pins)
print()
print(result[0])
print("Pins tested: " + str(result[1]))


# Execute only if run as main.py or code.py
if __name__ == "__main__":
_main()
27 changes: 17 additions & 10 deletions adafruit_boardtest/boardtest_i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git"

# Constants
SDA_PIN_NAME = 'SDA'
SCL_PIN_NAME = 'SCL'
NUM_I2C_TESTS = 10 # Number of times to write and read EEPROM values
EEPROM_I2C_MAX_ADDR = 255 # Self-imposed max memory address
SDA_PIN_NAME = "SDA"
SCL_PIN_NAME = "SCL"
NUM_I2C_TESTS = 10 # Number of times to write and read EEPROM values
EEPROM_I2C_MAX_ADDR = 255 # Self-imposed max memory address

# Microchip AT24HC04B EEPROM I2C address
EEPROM_I2C_ADDR = 0x50
Expand All @@ -81,6 +81,7 @@ def _eeprom_i2c_wait(i2c, i2c_addr, mem_addr, timeout=1.0):

return False


# Write to address. Returns status (True for successful write, False otherwise)
def _eeprom_i2c_write_byte(i2c, i2c_addr, mem_addr, mem_data):

Expand All @@ -100,6 +101,7 @@ def _eeprom_i2c_write_byte(i2c, i2c_addr, mem_addr, mem_data):

return True


# Read from address. Returns tuple [status, result]
def _eeprom_i2c_read_byte(i2c, i2c_addr, mem_addr, timeout=1.0):

Expand All @@ -117,6 +119,7 @@ def _eeprom_i2c_read_byte(i2c, i2c_addr, mem_addr, timeout=1.0):

return True, buf


def run_test(pins, sda_pin=SDA_PIN_NAME, scl_pin=SCL_PIN_NAME):

"""
Expand All @@ -132,8 +135,10 @@ def run_test(pins, sda_pin=SDA_PIN_NAME, scl_pin=SCL_PIN_NAME):
if list(set(pins).intersection(set([sda_pin, scl_pin]))):

# Tell user to connect EEPROM chip
print("Connect a Microchip AT24HC04B EEPROM I2C chip. " +
"Press enter to continue.")
print(
"Connect a Microchip AT24HC04B EEPROM I2C chip. "
+ "Press enter to continue."
)
input()

# Set up I2C
Expand Down Expand Up @@ -188,24 +193,26 @@ def run_test(pins, sda_pin=SDA_PIN_NAME, scl_pin=SCL_PIN_NAME):
print("No I2C pins found")
return NA, []


def _main():

# List out all the pins available to us
pins = [p for p in dir(board)]
pins = list(dir(board))
print()
print("All pins found:", end=' ')
print("All pins found:", end=" ")

# Print pins
for pin in pins:
print(pin, end=' ')
print('\n')
print(pin, end=" ")
print("\n")

# Run test
result = run_test(pins)
print()
print(result[0])
print("Pins tested: " + str(result[1]))


# Execute only if run as main.py or code.py
if __name__ == "__main__":
_main()
25 changes: 14 additions & 11 deletions adafruit_boardtest/boardtest_led.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git"

# Constants
LED_ON_DELAY_TIME = 0.2 # Seconds
LED_OFF_DELAY_TIME = 0.2 # Seconds
LED_PIN_NAMES = ['L', 'LED', 'RED_LED', 'YELLOW_LED', 'GREEN_LED', 'BLUE_LED']
LED_ON_DELAY_TIME = 0.2 # Seconds
LED_OFF_DELAY_TIME = 0.2 # Seconds
LED_PIN_NAMES = ["L", "LED", "RED_LED", "YELLOW_LED", "GREEN_LED", "BLUE_LED"]

# Test result strings
PASS = "PASS"
Expand Down Expand Up @@ -89,10 +89,11 @@ def _toggle_wait(led_pins):
# Look for user input
if supervisor.runtime.serial_bytes_available:
answer = input()
if answer == 'y':
if answer == "y":
return True
return False


def run_test(pins):

"""
Expand All @@ -109,10 +110,10 @@ def run_test(pins):
if led_pins:

# Print out the LEDs found
print("LEDs found:", end=' ')
print("LEDs found:", end=" ")
for pin in led_pins:
print(pin, end=' ')
print('\n')
print(pin, end=" ")
print("\n")

# Blink LEDs and wait for user to verify test
result = _toggle_wait(led_pins)
Expand All @@ -126,24 +127,26 @@ def run_test(pins):
print("No LED pins found")
return NA, []


def _main():

# List out all the pins available to us
pins = [p for p in dir(board)]
pins = list(dir(board))
print()
print("All pins found:", end=' ')
print("All pins found:", end=" ")

# Print pins
for pin in pins:
print(pin, end=' ')
print('\n')
print(pin, end=" ")
print("\n")

# Run test
result = run_test(pins)
print()
print(result[0])
print("Pins tested: " + str(result[1]))


# Execute only if run as main.py or code.py
if __name__ == "__main__":
_main()
54 changes: 30 additions & 24 deletions adafruit_boardtest/boardtest_sd.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,39 @@
"""
import random

import adafruit_sdcard
import board
import busio
import digitalio
import adafruit_sdcard
import storage

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git"

# Constants
MOSI_PIN_NAME = 'SD_MOSI'
MISO_PIN_NAME = 'SD_MISO'
SCK_PIN_NAME = 'SD_SCK'
CS_PIN_NAME = 'SD_CS'
FILENAME = "test.txt" # File that will be written to
BAUD_RATE = 100000 # Bits per second
NUM_UART_BYTES = 40 # Number of bytes to transmit over UART
ASCII_MIN = 0x21 # '!' Lowest ASCII char in random range (inclusive)
ASCII_MAX = 0x7E # '~' Highest ASCII char in random range (inclusive)
MOSI_PIN_NAME = "SD_MOSI"
MISO_PIN_NAME = "SD_MISO"
SCK_PIN_NAME = "SD_SCK"
CS_PIN_NAME = "SD_CS"
FILENAME = "test.txt" # File that will be written to
BAUD_RATE = 100000 # Bits per second
NUM_UART_BYTES = 40 # Number of bytes to transmit over UART
ASCII_MIN = 0x21 # '!' Lowest ASCII char in random range (inclusive)
ASCII_MAX = 0x7E # '~' Highest ASCII char in random range (inclusive)

# Test result strings
PASS = "PASS"
FAIL = "FAIL"
NA = "N/A"

def run_test(pins,
mosi_pin=MOSI_PIN_NAME,
miso_pin=MISO_PIN_NAME,
sck_pin=SCK_PIN_NAME,
cs_pin=CS_PIN_NAME):

def run_test(
pins,
mosi_pin=MOSI_PIN_NAME,
miso_pin=MISO_PIN_NAME,
sck_pin=SCK_PIN_NAME,
cs_pin=CS_PIN_NAME,
):

"""
Performs random writes and reads to file on attached SD card.
Expand All @@ -96,8 +99,7 @@ def run_test(pins,

# Tell user to connect SD card
print("Insert SD card into holder and connect SPI lines to holder.")
print("Connect " + cs_pin + " to the CS (DAT3) pin on the SD " +
"card holder.")
print("Connect " + cs_pin + " to the CS (DAT3) pin on the SD " + "card holder.")
print("WARNING: " + FILENAME + " will be created or overwritten.")
print("Press enter to continue.")
input()
Expand All @@ -108,9 +110,11 @@ def run_test(pins,
csel.value = True

# Set up SPI
spi = busio.SPI(getattr(board, sck_pin),
MOSI=getattr(board, mosi_pin),
MISO=getattr(board, miso_pin))
spi = busio.SPI(
getattr(board, sck_pin),
MOSI=getattr(board, mosi_pin),
MISO=getattr(board, miso_pin),
)

# Try to connect to the card and mount the filesystem
try:
Expand Down Expand Up @@ -160,24 +164,26 @@ def run_test(pins,
print("No SD card pins found")
return NA, []


def _main():

# List out all the pins available to us
pins = [p for p in dir(board)]
pins = list(dir(board))
print()
print("All pins found:", end=' ')
print("All pins found:", end=" ")

# Print pins
for pin in pins:
print(pin, end=' ')
print('\n')
print(pin, end=" ")
print("\n")

# Run test
result = run_test(pins)
print()
print(result[0])
print("Pins tested: " + str(result[1]))


# Execute only if run as main.py or code.py
if __name__ == "__main__":
_main()
Loading