Skip to content
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

add cubieboard support #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

yanzixiang
Copy link

i modify some place to add support for cubieboard

@yanzixiang yanzixiang mentioned this pull request Nov 30, 2016
@@ -74,6 +76,13 @@
EDGES = (RISING, FALLING, BOTH)
ACTIVE_LOW_MODES = (ACTIVE_LOW_ON, ACTIVE_LOW_OFF)

def GetGpioDirFromPin(number):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project is following snake case. Rename the function to _sysfs_gpio_pin_path (see more below).

if len(nd) > 0:
return nd[0]
else:
return "DONOT"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd not return a bogus string. Raising an exception would work much better.

@@ -198,7 +207,7 @@ def _sysfs_gpio_value_path(self):
@rtype: str
@return: the path to sysfs value file
"""
return SYSFS_GPIO_VALUE_PATH % self.number
return SYSFS_BASE_PATH + "/" + GetGpioDirFromPin(self.number) + SYSFS_GPIO_VALUE_PATH
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a function _sysfs_gpio_pin_path that returns the absolute GPIO path, which would avoid repeating SYSFS_BASE_PATH everywhere.

@@ -74,6 +76,13 @@
EDGES = (RISING, FALLING, BOTH)
ACTIVE_LOW_MODES = (ACTIVE_LOW_ON, ACTIVE_LOW_OFF)

def GetGpioDirFromPin(number):
ds = listdir(SYSFS_BASE_PATH)
nd = filter(lambda a: a.startswith("gpio" + str(number)),ds)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does ds and nd mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants