bench_1.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 #
00004 # WARNING!
00005 #
00006 
00007 ##############################################################################
00008 #                                                                            #
00009 # Unless you know what you are doing don't run this script with anything     #
00010 # connected to the gpios.  You will CAUSE damage.                            #
00011 #                                                                            #
00012 ##############################################################################
00013 
00014 #
00015 # WARNING!
00016 #
00017 
00018 import time
00019 
00020 import pigpio
00021 
00022 delay = 30
00023 
00024 class gpioTest:
00025 
00026    def __init__(self, pi, gpio, edge, freq, duty):
00027       self.pi = pi
00028       self.gpio = gpio
00029       self.edge = edge
00030       self.freq = freq
00031       self.duty = duty
00032       self.calls = 0
00033 
00034    def cb(self, g, t, l):
00035       self.calls = self.calls + 1
00036       # print g,t,l
00037 
00038    def num(self):
00039       return self.calls
00040 
00041    def start(self):
00042       self.pi.set_PWM_frequency(self.gpio, self.freq)
00043       self.pi.set_PWM_range(self.gpio, 25)
00044       self.pi.set_PWM_dutycycle(self.gpio, self.duty)
00045       self.n = self.pi.callback(self.gpio, self.edge, self.cb)
00046 
00047    def stop(self):
00048       self.pi.set_PWM_dutycycle(self.gpio, 0)
00049       self.n.cancel()
00050 
00051 pi = pigpio.pi()
00052 
00053 t1 =  gpioTest(pi, 4, pigpio.EITHER_EDGE,  4000,  1)
00054 t2 =  gpioTest(pi, 7, pigpio.RISING_EDGE,  8000,  2)
00055 t3 =  gpioTest(pi, 8, pigpio.FALLING_EDGE, 8000,  3)
00056 t4 =  gpioTest(pi, 9, pigpio.EITHER_EDGE,  4000,  4)
00057 t5 =  gpioTest(pi,10, pigpio.RISING_EDGE,  8000,  5)
00058 t6 =  gpioTest(pi,11, pigpio.FALLING_EDGE, 8000,  6)
00059 t7 =  gpioTest(pi,14, pigpio.EITHER_EDGE,  4000,  7)
00060 t8 =  gpioTest(pi,15, pigpio.RISING_EDGE,  8000,  8)
00061 t9 =  gpioTest(pi,17, pigpio.FALLING_EDGE, 8000,  9)
00062 t10 = gpioTest(pi,18, pigpio.EITHER_EDGE,  4000, 10)
00063 t11 = gpioTest(pi,22, pigpio.RISING_EDGE,  8000, 11)
00064 t12 = gpioTest(pi,23, pigpio.FALLING_EDGE, 8000, 12)
00065 t13 = gpioTest(pi,24, pigpio.EITHER_EDGE,  4000, 13)
00066 t14 = gpioTest(pi,25, pigpio.RISING_EDGE,  8000, 14)
00067 
00068 # R1: 0 1     4 7 8 9 10 11 14 15 17 18 21 22 23 24 25
00069 # R2:     2 3 4 7 8 9 10 11 14 15 17 18    22 23 24 25 27 28 29 30 31
00070 
00071 tests = [t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14]
00072 
00073 for i in tests: i.start()
00074 
00075 time.sleep(delay)
00076 
00077 for i in tests: i.stop()
00078 
00079 pi.stop()
00080 
00081 tot = 0
00082 msg = ""
00083 
00084 for i in tests:
00085    tot += i.num()
00086    msg += str(i.num()) + " "
00087 
00088 print(msg)
00089 
00090 print("eps={} ({}/{})".format(tot/delay, tot, delay))
00091 


cob_hand_bridge
Author(s): Mathias L├╝dtke
autogenerated on Thu Jun 6 2019 20:43:57