mirror of https://github.com/joan2937/pigpio
V45
This commit is contained in:
parent
ab3725839f
commit
f99f64f781
2
pigpio.h
2
pigpio.h
|
@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#define PIGPIO_VERSION 44
|
#define PIGPIO_VERSION 45
|
||||||
|
|
||||||
/*TEXT
|
/*TEXT
|
||||||
|
|
||||||
|
|
|
@ -522,12 +522,12 @@ void t7()
|
||||||
/* type of edge shouldn't matter for watchdogs */
|
/* type of edge shouldn't matter for watchdogs */
|
||||||
gpioSetAlertFunc(GPIO, t7cbf);
|
gpioSetAlertFunc(GPIO, t7cbf);
|
||||||
|
|
||||||
gpioSetWatchdog(GPIO, 10); /* 10 ms, 100 per second */
|
gpioSetWatchdog(GPIO, 50); /* 50 ms, 20 per second */
|
||||||
time_sleep(0.5);
|
time_sleep(0.5);
|
||||||
oc = t7_count;
|
oc = t7_count;
|
||||||
time_sleep(2);
|
time_sleep(2);
|
||||||
c = t7_count - oc;
|
c = t7_count - oc;
|
||||||
CHECK(7, 1, c, 200, 1, "set watchdog on count");
|
CHECK(7, 1, c, 39, 5, "set watchdog on count");
|
||||||
|
|
||||||
gpioSetWatchdog(GPIO, 0); /* 0 switches watchdog off */
|
gpioSetWatchdog(GPIO, 0); /* 0 switches watchdog off */
|
||||||
time_sleep(0.5);
|
time_sleep(0.5);
|
||||||
|
|
130
x_pigpio.py
130
x_pigpio.py
|
@ -109,7 +109,6 @@ def t2():
|
||||||
f = t2_count - oc
|
f = t2_count - oc
|
||||||
CHECK(2, 3, f, 0, 0, "set PWM dutycycle, callback")
|
CHECK(2, 3, f, 0, 0, "set PWM dutycycle, callback")
|
||||||
|
|
||||||
|
|
||||||
pi.set_PWM_dutycycle(GPIO, 128)
|
pi.set_PWM_dutycycle(GPIO, 128)
|
||||||
dc = pi.get_PWM_dutycycle(GPIO)
|
dc = pi.get_PWM_dutycycle(GPIO)
|
||||||
CHECK(2, 4, dc, 128, 0, "get PWM dutycycle")
|
CHECK(2, 4, dc, 128, 0, "get PWM dutycycle")
|
||||||
|
@ -155,6 +154,8 @@ def t2():
|
||||||
|
|
||||||
pi.set_PWM_dutycycle(GPIO, 0)
|
pi.set_PWM_dutycycle(GPIO, 0)
|
||||||
|
|
||||||
|
t2cb.cancel()
|
||||||
|
|
||||||
t3_reset=True
|
t3_reset=True
|
||||||
t3_count=0
|
t3_count=0
|
||||||
t3_tick=0
|
t3_tick=0
|
||||||
|
@ -234,6 +235,8 @@ def t3():
|
||||||
|
|
||||||
pi.set_PWM_dutycycle(GPIO, 0)
|
pi.set_PWM_dutycycle(GPIO, 0)
|
||||||
|
|
||||||
|
t3cb.cancel()
|
||||||
|
|
||||||
def t4():
|
def t4():
|
||||||
|
|
||||||
print("Pipe notification tests.")
|
print("Pipe notification tests.")
|
||||||
|
@ -465,6 +468,8 @@ To the lascivious pleasing of a lute.
|
||||||
e = pi.wave_delete(0)
|
e = pi.wave_delete(0)
|
||||||
CHECK(5, 33, e, 0, 0, "wave delete")
|
CHECK(5, 33, e, 0, 0, "wave delete")
|
||||||
|
|
||||||
|
t5cb.cancel()
|
||||||
|
|
||||||
t6_count=0
|
t6_count=0
|
||||||
t6_on=0
|
t6_on=0
|
||||||
t6_on_tick=None
|
t6_on_tick=None
|
||||||
|
@ -501,6 +506,8 @@ def t6():
|
||||||
|
|
||||||
CHECK(6, 2, t6_on, tp, 25, "gpio trigger pulse length")
|
CHECK(6, 2, t6_on, tp, 25, "gpio trigger pulse length")
|
||||||
|
|
||||||
|
t6cb.cancel()
|
||||||
|
|
||||||
t7_count=0
|
t7_count=0
|
||||||
|
|
||||||
def t7cbf(gpio, level, tick):
|
def t7cbf(gpio, level, tick):
|
||||||
|
@ -516,12 +523,12 @@ def t7():
|
||||||
# type of edge shouldn't matter for watchdogs
|
# type of edge shouldn't matter for watchdogs
|
||||||
t7cb = pi.callback(GPIO, pigpio.FALLING_EDGE, t7cbf)
|
t7cb = pi.callback(GPIO, pigpio.FALLING_EDGE, t7cbf)
|
||||||
|
|
||||||
pi.set_watchdog(GPIO, 10) # 10 ms, 100 per second
|
pi.set_watchdog(GPIO, 50) # 50 ms, 20 per second
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
oc = t7_count
|
oc = t7_count
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
c = t7_count - oc
|
c = t7_count - oc
|
||||||
CHECK(7, 1, c, 200, 5, "set watchdog on count")
|
CHECK(7, 1, c, 39, 5, "set watchdog on count")
|
||||||
|
|
||||||
pi.set_watchdog(GPIO, 0) # 0 switches watchdog off
|
pi.set_watchdog(GPIO, 0) # 0 switches watchdog off
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
@ -530,6 +537,8 @@ def t7():
|
||||||
c = t7_count - oc
|
c = t7_count - oc
|
||||||
CHECK(7, 2, c, 0, 1, "set watchdog off count")
|
CHECK(7, 2, c, 0, 1, "set watchdog off count")
|
||||||
|
|
||||||
|
t7cb.cancel()
|
||||||
|
|
||||||
def t8():
|
def t8():
|
||||||
print("Bank read/write tests.")
|
print("Bank read/write tests.")
|
||||||
|
|
||||||
|
@ -661,6 +670,8 @@ def t9():
|
||||||
e = pi.delete_script(s)
|
e = pi.delete_script(s)
|
||||||
CHECK(9, 4, e, 0, 0, "delete script")
|
CHECK(9, 4, e, 0, 0, "delete script")
|
||||||
|
|
||||||
|
t9cb.cancel()
|
||||||
|
|
||||||
pigpio.exceptions = old_exceptions
|
pigpio.exceptions = old_exceptions
|
||||||
|
|
||||||
def ta():
|
def ta():
|
||||||
|
@ -830,6 +841,116 @@ def tc():
|
||||||
e = pi.spi_close(h)
|
e = pi.spi_close(h)
|
||||||
CHECK(12, 99, e, 0, 0, "spi close")
|
CHECK(12, 99, e, 0, 0, "spi close")
|
||||||
|
|
||||||
|
def td():
|
||||||
|
|
||||||
|
print("Wavechains & filter tests.")
|
||||||
|
|
||||||
|
tdcb = pi.callback(GPIO)
|
||||||
|
|
||||||
|
pi.set_mode(GPIO, pigpio.OUTPUT)
|
||||||
|
|
||||||
|
pi.write(GPIO, pigpio.LOW)
|
||||||
|
|
||||||
|
e = pi.wave_clear()
|
||||||
|
CHECK(13, 1, e, 0, 0, "callback, set mode, wave clear")
|
||||||
|
|
||||||
|
wf = []
|
||||||
|
|
||||||
|
wf.append(pigpio.pulse(1<<GPIO, 0, 50))
|
||||||
|
wf.append(pigpio.pulse(0, 1<<GPIO, 70))
|
||||||
|
wf.append(pigpio.pulse(1<<GPIO, 0, 130))
|
||||||
|
wf.append(pigpio.pulse(0, 1<<GPIO, 150))
|
||||||
|
wf.append(pigpio.pulse(1<<GPIO, 0, 90))
|
||||||
|
wf.append(pigpio.pulse(0, 1<<GPIO, 110))
|
||||||
|
|
||||||
|
e = pi.wave_add_generic(wf)
|
||||||
|
CHECK(13, 2, e, 6, 0, "pulse, wave add generic")
|
||||||
|
|
||||||
|
wid = pi.wave_create()
|
||||||
|
|
||||||
|
chain = [
|
||||||
|
255, 0, wid, 255, 1, 128, 0, 255, 2, 0, 8,
|
||||||
|
255, 0, wid, 255, 1, 0, 1, 255, 2, 0, 4,
|
||||||
|
255, 0, wid, 255, 1, 0, 2]
|
||||||
|
|
||||||
|
e = pi.set_glitch_filter(GPIO, 0)
|
||||||
|
CHECK(13, 3, e, 0, 0, "clear glitch filter")
|
||||||
|
|
||||||
|
e = pi.set_noise_filter(GPIO, 0, 0)
|
||||||
|
CHECK(13, 4, e, 0, 0, "clear noise filter")
|
||||||
|
|
||||||
|
tdcb.reset_tally()
|
||||||
|
e = pi.wave_chain(chain)
|
||||||
|
CHECK(13, 5, e, 0, 0, "wave chain")
|
||||||
|
while pi.wave_tx_busy():
|
||||||
|
time.sleep(0.1)
|
||||||
|
time.sleep(0.3)
|
||||||
|
tally = tdcb.tally()
|
||||||
|
CHECK(13, 6, tally, 2688, 2, "wave chain, tally")
|
||||||
|
|
||||||
|
pi.set_glitch_filter(GPIO, 80)
|
||||||
|
tdcb.reset_tally()
|
||||||
|
pi.wave_chain(chain)
|
||||||
|
while pi.wave_tx_busy():
|
||||||
|
time.sleep(0.1)
|
||||||
|
time.sleep(0.3)
|
||||||
|
tally = tdcb.tally()
|
||||||
|
CHECK(13, 7, tally, 1792, 2, "glitch filter, wave chain, tally")
|
||||||
|
|
||||||
|
pi.set_glitch_filter(GPIO, 120)
|
||||||
|
tdcb.reset_tally()
|
||||||
|
pi.wave_chain(chain)
|
||||||
|
while pi.wave_tx_busy():
|
||||||
|
time.sleep(0.1)
|
||||||
|
time.sleep(0.2)
|
||||||
|
tally = tdcb.tally()
|
||||||
|
CHECK(13, 8, tally, 896, 2, "glitch filter, wave chain, tally")
|
||||||
|
|
||||||
|
pi.set_glitch_filter(GPIO, 140)
|
||||||
|
tdcb.reset_tally()
|
||||||
|
pi.wave_chain(chain)
|
||||||
|
while pi.wave_tx_busy():
|
||||||
|
time.sleep(0.1)
|
||||||
|
time.sleep(0.2)
|
||||||
|
tally = tdcb.tally()
|
||||||
|
CHECK(13, 9, tally, 0, 0, "glitch filter, wave chain, tally")
|
||||||
|
|
||||||
|
pi.set_glitch_filter(GPIO, 0)
|
||||||
|
|
||||||
|
pi.wave_chain(chain)
|
||||||
|
pi.set_noise_filter(GPIO, 1000, 150000)
|
||||||
|
tdcb.reset_tally()
|
||||||
|
while pi.wave_tx_busy():
|
||||||
|
time.sleep(0.1)
|
||||||
|
time.sleep(0.2)
|
||||||
|
tally = tdcb.tally()
|
||||||
|
CHECK(13, 10, tally, 1500, 2, "noise filter, wave chain, tally")
|
||||||
|
|
||||||
|
pi.wave_chain(chain)
|
||||||
|
pi.set_noise_filter(GPIO, 2000, 150000)
|
||||||
|
tdcb.reset_tally()
|
||||||
|
while pi.wave_tx_busy():
|
||||||
|
time.sleep(0.1)
|
||||||
|
time.sleep(0.2)
|
||||||
|
tally = tdcb.tally()
|
||||||
|
CHECK(13, 11, tally, 750, 2, "noise filter, wave chain, tally")
|
||||||
|
|
||||||
|
pi.wave_chain(chain)
|
||||||
|
pi.set_noise_filter(GPIO, 3000, 5000)
|
||||||
|
tdcb.reset_tally()
|
||||||
|
while pi.wave_tx_busy():
|
||||||
|
time.sleep(0.1)
|
||||||
|
time.sleep(0.2)
|
||||||
|
tally = tdcb.tally()
|
||||||
|
CHECK(13, 12, tally, 0, 2, "noise filter, wave chain, tally")
|
||||||
|
|
||||||
|
pi.set_noise_filter(GPIO, 0, 0)
|
||||||
|
|
||||||
|
e = pi.wave_delete(wid)
|
||||||
|
CHECK(13, 13, e, 0, 0, "wave delete")
|
||||||
|
|
||||||
|
tdcb.cancel()
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
tests = ""
|
tests = ""
|
||||||
for C in sys.argv[1]:
|
for C in sys.argv[1]:
|
||||||
|
@ -838,7 +959,7 @@ if len(sys.argv) > 1:
|
||||||
tests += c
|
tests += c
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tests = "0123456789"
|
tests = "0123456789d"
|
||||||
|
|
||||||
pi = pigpio.pi()
|
pi = pigpio.pi()
|
||||||
|
|
||||||
|
@ -858,6 +979,7 @@ if pi.connected:
|
||||||
if 'a' in tests: ta()
|
if 'a' in tests: ta()
|
||||||
if 'b' in tests: tb()
|
if 'b' in tests: tb()
|
||||||
if 'c' in tests: tc()
|
if 'c' in tests: tc()
|
||||||
|
if 'd' in tests: td()
|
||||||
|
|
||||||
pi.stop()
|
pi.stop()
|
||||||
|
|
||||||
|
|
|
@ -490,12 +490,12 @@ void t7()
|
||||||
/* type of edge shouldn't matter for watchdogs */
|
/* type of edge shouldn't matter for watchdogs */
|
||||||
callback(GPIO, FALLING_EDGE, t7cbf);
|
callback(GPIO, FALLING_EDGE, t7cbf);
|
||||||
|
|
||||||
set_watchdog(GPIO, 10); /* 10 ms, 100 per second */
|
set_watchdog(GPIO, 50); /* 50 ms, 20 per second */
|
||||||
time_sleep(0.5);
|
time_sleep(0.5);
|
||||||
oc = t7_count;
|
oc = t7_count;
|
||||||
time_sleep(2);
|
time_sleep(2);
|
||||||
c = t7_count - oc;
|
c = t7_count - oc;
|
||||||
CHECK(7, 1, c, 200, 1, "set watchdog on count");
|
CHECK(7, 1, c, 39, 5, "set watchdog on count");
|
||||||
|
|
||||||
set_watchdog(GPIO, 0); /* 0 switches watchdog off */
|
set_watchdog(GPIO, 0); /* 0 switches watchdog off */
|
||||||
time_sleep(0.5);
|
time_sleep(0.5);
|
||||||
|
|
|
@ -498,12 +498,12 @@ void t7(int pi)
|
||||||
/* type of edge shouldn't matter for watchdogs */
|
/* type of edge shouldn't matter for watchdogs */
|
||||||
id = callback(pi, GPIO, FALLING_EDGE, t7cbf);
|
id = callback(pi, GPIO, FALLING_EDGE, t7cbf);
|
||||||
|
|
||||||
set_watchdog(pi, GPIO, 10); /* 10 ms, 100 per second */
|
set_watchdog(pi, GPIO, 50); /* 50 ms, 20 per second */
|
||||||
time_sleep(0.5);
|
time_sleep(0.5);
|
||||||
oc = t7_count;
|
oc = t7_count;
|
||||||
time_sleep(2);
|
time_sleep(2);
|
||||||
c = t7_count - oc;
|
c = t7_count - oc;
|
||||||
CHECK(7, 1, c, 200, 1, "set watchdog on count");
|
CHECK(7, 1, c, 39, 5, "set watchdog on count");
|
||||||
|
|
||||||
set_watchdog(pi, GPIO, 0); /* 0 switches watchdog off */
|
set_watchdog(pi, GPIO, 0); /* 0 switches watchdog off */
|
||||||
time_sleep(0.5);
|
time_sleep(0.5);
|
||||||
|
|
Loading…
Reference in New Issue