Skip to content

Commit e7db735

Browse files
committed
GPIO able to be controlled by pin sysfs number like RPi.GPIO, close #65
1 parent e3a077b commit e7db735

File tree

9 files changed

+231
-40
lines changed

9 files changed

+231
-40
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.7.0
2+
---
3+
* Added ability to specify GPIO only as a number, this doesn't work for PWM/SPWM/LRADC/SERVO
4+
15
0.6.2
26
---
37
* Implementation for #77 - ability to push up binary pypi

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ package: clean
44
python setup.py sdist bdist_wheel
55
python3 setup.py bdist_wheel
66

7+
# PyPi Packaging
8+
package3: package
9+
@echo " ** PACKAGING FOR PYPI **"
10+
python3 setup.py bdist_wheel
11+
712
# PyPi Publishing
8-
publish: package
13+
publish: package package3
914
@echo " ** UPLOADING TO PYPI **"
1015
twine upload dist/*
1116

debian/changelog

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
chip-io (0.7.0-1) unstable; urgency=low
2+
3+
* Added ability to specify GPIO only as a number, this doesn't work for PWM/SPWM/LRADC/SERVO
4+
5+
-- Robert Wolterman <[email protected]> Wed, 13 Sep 2017 09:51:00 -0600
6+
17
chip-io (0.6.2-1) unstable; urgency=low
28

3-
* Implementation for #77 - ability to push up binary pypi
4-
* Implementation for #75 - wait_for_edge timeout
9+
* Implementation for number 77 ability to push up binary pypi
10+
* Implementation for number 75 wait for edge timeout
511

612
-- Robert Wolterman <[email protected]> Sun, 03 Sep 2017 21:34:00 -0600
713

debian/files

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
python-chip-io_0.6.1-1_armhf.deb python optional
2-
python3-chip-io_0.6.1-1_armhf.deb python optional
1+
python-chip-io_0.7.0-1_armhf.deb python optional
2+
python3-chip-io_0.7.0-1_armhf.deb python optional

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'Topic :: System :: Hardware']
1414

1515
setup(name = 'CHIP_IO',
16-
version = '0.6.2',
16+
version = '0.7.0',
1717
author = 'Robert Wolterman',
1818
author_email = '[email protected]',
1919
description = 'A module to control CHIP IO channels',

source/common.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,28 @@ int gpio_pud_capable(pins_t *pin)
371371
return capable;
372372
}
373373

374+
int lookup_gpio_by_number(const char *num) {
375+
// Convert the char to an int
376+
char *ptr;
377+
long ret;
378+
int gpnum;
379+
ret = strtol(num, &ptr, 10);
380+
if (ret == 0) {
381+
return -1;
382+
}
383+
// If we make it here, lets look for the data
384+
pins_t *p;
385+
for (p = pins_info; p->key != NULL; ++p) {
386+
gpnum = gpio_number(p);
387+
// If the number of the gpio pin matches the input
388+
// we are
389+
if (gpnum == (int)ret) {
390+
return gpnum;
391+
}
392+
}
393+
return -1;
394+
}
395+
374396
int lookup_gpio_by_key(const char *key)
375397
{
376398
pins_t *p;
@@ -541,10 +563,13 @@ int get_gpio_number(const char *key, int *gpio)
541563
if (*gpio <= 0) {
542564
*gpio = lookup_gpio_by_name(key);
543565
if (*gpio <= 0) {
544-
*gpio = lookup_gpio_by_altname(key);
545-
if (*gpio <=0) {
546-
status = -1; /* error */
547-
}
566+
*gpio = lookup_gpio_by_altname(key);
567+
if (*gpio <=0) {
568+
*gpio = lookup_gpio_by_number(key);
569+
if (*gpio <= 0) {
570+
status = -1; /* error */
571+
}
572+
}
548573
}
549574
}
550575
return status;

source/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ int get_xio_base(void);
9494
int is_this_chippro(void);
9595
int gpio_number(pins_t *pin);
9696
int gpio_pud_capable(pins_t *pin);
97+
int lookup_gpio_by_number(const char *num);
9798
int lookup_gpio_by_key(const char *key);
9899
int lookup_gpio_by_name(const char *name);
99100
int lookup_gpio_by_altname(const char *altname);

source/constants.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ void define_constants(PyObject *module)
8585
bcm = Py_BuildValue("i", BCM);
8686
PyModule_AddObject(module, "BCM", bcm);
8787

88-
version = Py_BuildValue("s", "0.6.2");
88+
version = Py_BuildValue("s", "0.7");
8989
PyModule_AddObject(module, "VERSION", version);
9090
}

0 commit comments

Comments
 (0)