1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 04:43:21 +00:00

Some refactoring of the edge detection code to clean stuff up, added more tests

This commit is contained in:
Robert Wolterman
2016-07-11 21:14:40 -05:00
parent bff65d346d
commit ea4a21235d
5 changed files with 36 additions and 6 deletions

View File

@ -1,3 +1,9 @@
0.1.1
----
* Some refactoring of the edge detection code, made it function better
* Added Rising and Both edge detection tests to gptest.py
- Small issue with both edge triggering double pumping on first callback hit
0.1.0
----
* Fixed edge detection code, will trigger proper for callbacks now

View File

@ -20,7 +20,7 @@ classifiers = ['Development Status :: 3 - Alpha',
'Topic :: System :: Hardware']
setup(name = 'CHIP_IO',
version = '0.1.0',
version = '0.1.1',
author = 'Robert Wolterman',
author_email = 'robert.wolterman@gmail.com',
description = 'A module to control CHIP IO channels',

View File

@ -76,6 +76,6 @@ void define_constants(PyObject *module)
both_edge = Py_BuildValue("i", BOTH_EDGE);
PyModule_AddObject(module, "BOTH", both_edge);
version = Py_BuildValue("s", "0.1.0");
version = Py_BuildValue("s", "0.1.1");
PyModule_AddObject(module, "VERSION", version);
}

View File

@ -175,7 +175,7 @@ int fd_lookup(int gpio)
int fde_lookup(int gpio)
{
struct callbacks *cb = callbacks;
struct callback *cb = callbacks;
while (cb != NULL)
{
if (cb->gpio == gpio)

View File

@ -16,7 +16,7 @@ loopfunction_exit = False
def loopfunction():
print("LOOP FUNCTION START")
for i in xrange(6):
for i in xrange(4):
if loopfunction_exit:
break
if i % 2:
@ -50,7 +50,7 @@ else:
print(" Able to use alternate names for GPIO")
GPIO.cleanup()
GPIO.setup("U14_15", GPIO.IN) # XIO-P0
GPIO.setup("U14_15", GPIO.IN) # XIO-P2
GPIO.setup("CSID0", GPIO.OUT, initial=GPIO.LOW)
if (GPIO.input("XIO-P2") != GPIO.LOW):
print(" A low output on CSI0 does not lead to a low input on XIO-P2.")
@ -98,6 +98,8 @@ GPIO.remove_event_detect("AP-EINT3")
# ==============================================
# EDGE DETECTION - EXPANDED GPIO
print("\nSETTING UP FALLING EDGE DETECTION ON XIO-P2")
# WRITING CSID0 LOW FIRST AS THERE IS A DOUBLE HIT ON HIGH
GPIO.output("CSID0", GPIO.LOW)
GPIO.add_event_detect("XIO-P2", GPIO.FALLING, myfuncallback)
print("VERIFYING EDGE DETECT")
@ -115,7 +117,29 @@ mystr = " num_callbacks = %d" % num_callbacks
print(mystr)
GPIO.remove_event_detect("XIO-P2")
print("\nWAIT FOR EDGE TESTING")
print("\nSETTING UP RISING EDGE DETECTION ON XIO-P2")
# WRITING CSID0 LOW FIRST AS THERE IS A DOUBLE HIT ON HIGH
GPIO.output("CSID0", GPIO.LOW)
num_callbacks = 0
GPIO.add_event_detect("XIO-P2", GPIO.RISING, myfuncallback)
print("WAITING FOR CALLBACKS ON XIO-P2")
loopfunction()
mystr = " num_callbacks = %d" % num_callbacks
print(mystr)
GPIO.remove_event_detect("XIO-P2")
print("\nSETTING UP BOTH EDGE DETECTION ON XIO-P2")
# WRITING CSID0 LOW FIRST AS THERE IS A DOUBLE HIT ON HIGH
GPIO.output("CSID0", GPIO.LOW)
num_callbacks = 0
GPIO.add_event_detect("XIO-P2", GPIO.BOTH, myfuncallback)
print("WAITING FOR CALLBACKS ON XIO-P2")
loopfunction()
mystr = " num_callbacks = %d" % num_callbacks
print(mystr)
GPIO.remove_event_detect("XIO-P2")
print("\nWAIT FOR EDGE TESTING, SETUP FOR FALLING EDGE")
print("PRESS CONTROL-C TO EXIT IF SCRIPT GETS STUCK")
try:
# WAIT FOR EDGE