Skip to content

Commit

Permalink
GPIO able to be controlled by pin sysfs number like RPi.GPIO, close #65
Browse files Browse the repository at this point in the history
  • Loading branch information
xtacocorex committed Sep 13, 2017
1 parent e3a077b commit e7db735
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.7.0
---
* Added ability to specify GPIO only as a number, this doesn't work for PWM/SPWM/LRADC/SERVO

0.6.2
---
* Implementation for #77 - ability to push up binary pypi
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ package: clean
python setup.py sdist bdist_wheel
python3 setup.py bdist_wheel

# PyPi Packaging
package3: package
@echo " ** PACKAGING FOR PYPI **"
python3 setup.py bdist_wheel

# PyPi Publishing
publish: package
publish: package package3
@echo " ** UPLOADING TO PYPI **"
twine upload dist/*

Expand Down
10 changes: 8 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
chip-io (0.7.0-1) unstable; urgency=low

* Added ability to specify GPIO only as a number, this doesn't work for PWM/SPWM/LRADC/SERVO

-- Robert Wolterman <robert.wolterman@gmail.com> Wed, 13 Sep 2017 09:51:00 -0600

chip-io (0.6.2-1) unstable; urgency=low

* Implementation for #77 - ability to push up binary pypi
* Implementation for #75 - wait_for_edge timeout
* Implementation for number 77 ability to push up binary pypi
* Implementation for number 75 wait for edge timeout

-- Robert Wolterman <robert.wolterman@gmail.com> Sun, 03 Sep 2017 21:34:00 -0600

Expand Down
4 changes: 2 additions & 2 deletions debian/files
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
python-chip-io_0.6.1-1_armhf.deb python optional
python3-chip-io_0.6.1-1_armhf.deb python optional
python-chip-io_0.7.0-1_armhf.deb python optional
python3-chip-io_0.7.0-1_armhf.deb python optional
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'Topic :: System :: Hardware']

setup(name = 'CHIP_IO',
version = '0.6.2',
version = '0.7.0',
author = 'Robert Wolterman',
author_email = 'robert.wolterman@gmail.com',
description = 'A module to control CHIP IO channels',
Expand Down
33 changes: 29 additions & 4 deletions source/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,28 @@ int gpio_pud_capable(pins_t *pin)
return capable;
}

int lookup_gpio_by_number(const char *num) {
// Convert the char to an int
char *ptr;
long ret;
int gpnum;
ret = strtol(num, &ptr, 10);
if (ret == 0) {
return -1;
}
// If we make it here, lets look for the data
pins_t *p;
for (p = pins_info; p->key != NULL; ++p) {
gpnum = gpio_number(p);
// If the number of the gpio pin matches the input
// we are
if (gpnum == (int)ret) {
return gpnum;
}
}
return -1;
}

int lookup_gpio_by_key(const char *key)
{
pins_t *p;
Expand Down Expand Up @@ -541,10 +563,13 @@ int get_gpio_number(const char *key, int *gpio)
if (*gpio <= 0) {
*gpio = lookup_gpio_by_name(key);
if (*gpio <= 0) {
*gpio = lookup_gpio_by_altname(key);
if (*gpio <=0) {
status = -1; /* error */
}
*gpio = lookup_gpio_by_altname(key);
if (*gpio <=0) {
*gpio = lookup_gpio_by_number(key);
if (*gpio <= 0) {
status = -1; /* error */
}
}
}
}
return status;
Expand Down
1 change: 1 addition & 0 deletions source/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ int get_xio_base(void);
int is_this_chippro(void);
int gpio_number(pins_t *pin);
int gpio_pud_capable(pins_t *pin);
int lookup_gpio_by_number(const char *num);
int lookup_gpio_by_key(const char *key);
int lookup_gpio_by_name(const char *name);
int lookup_gpio_by_altname(const char *altname);
Expand Down
2 changes: 1 addition & 1 deletion source/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ void define_constants(PyObject *module)
bcm = Py_BuildValue("i", BCM);
PyModule_AddObject(module, "BCM", bcm);

version = Py_BuildValue("s", "0.6.2");
version = Py_BuildValue("s", "0.7");
PyModule_AddObject(module, "VERSION", version);
}
Loading

0 comments on commit e7db735

Please sign in to comment.