Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix pylint issues
  • Loading branch information
yeyeto2788 committed Dec 1, 2020
commit 60d593e0b01a9aceebea1433aee69dd793645736
1 change: 1 addition & 0 deletions src/adafruit_blinka/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""All constants used on Blinka are defined here :)"""
import os

TRUE_VALUES = [True, "True", "true", "1", 1]
Expand Down
61 changes: 40 additions & 21 deletions src/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,45 @@ def __repr__(self):
def __eq__(self, other):
return self.id == other

def __check_pull_mode(self, pull):
"""Check if pin is setup or not with pull resistors

This is done since there is no current better implementation for this :(

Args:
pull: Mode of pulling the pin

Returns:
None

Raises:
NotImplementedError: When pull equals PULL_UP or PULL_DOWN
RuntimeError: When pull is not PULL_UP or PULL_DOWN
"""
if pull == self.PULL_UP:

if SUPPRESS_WARNINGS:
pass
else:
raise NotImplementedError(
"Internal pullups not supported in libgpiod, "
"use physical resistor instead!"
)
if pull == self.PULL_DOWN:

if SUPPRESS_WARNINGS:
pass
else:
raise NotImplementedError(
"Internal pulldowns not supported in libgpiod,"
" use physical resistor instead!"
)

if SUPPRESS_WARNINGS:
pass
else:
raise RuntimeError("Invalid pull for pin: %s" % self.id)

def init(self, mode=IN, pull=None):
"""Initialize the Pin"""
if not self._line:
Expand All @@ -52,27 +91,7 @@ def init(self, mode=IN, pull=None):
if mode == self.IN:
flags = 0
if pull is not None:
if pull == self.PULL_UP:
if SUPPRESS_WARNINGS:
pass
else:
raise NotImplementedError(
"Internal pullups not supported in libgpiod, "
"use physical resistor instead!"
)
if pull == self.PULL_DOWN:
if SUPPRESS_WARNINGS:
pass
else:
raise NotImplementedError(
"Internal pulldowns not supported in libgpiod,"
" use physical resistor instead!"
)

if SUPPRESS_WARNINGS:
pass
else:
raise RuntimeError("Invalid pull for pin: %s" % self.id)
self.__check_pull_mode(pull)

self._mode = self.IN
self._line.release()
Expand Down