Пример #1
0
 def on_echo(self, _, level, tick):
     if level == 2:
         pigpio.gpio_trigger(self.GPIO_TRIGGER)
     if level == 1:
         self.tick_up = tick
     elif level == 0:
         delta = pigpio.tickDiff(self.tick_up, tick)
         self.update_distance(delta * 0.017)
Пример #2
0
   def read(self):
      """
      Triggers a reading.  The returned reading is the number
      of microseconds for the sonar round-trip.

      round trip cms = round trip time / 1000000.0 * 34030
      """
      if self._inited:
         self._ping = False
         pigpio.gpio_trigger(self._trig)
         while not self._ping:
            time.sleep(0.001)
         return self._time
      else:
         return None
Пример #3
0
def t6():
    global t6_count, t6_on

    print("Trigger tests.")

    pigpio.write(GPIO, pigpio.LOW)

    tp = 0

    t6cb = pigpio.callback(GPIO, pigpio.EITHER_EDGE, t6cbf)

    for t in range(5):
        time.sleep(0.1)
        p = 10 + (t * 10)
        tp += p
        pigpio.gpio_trigger(GPIO, p, 1)

    time.sleep(0.5)

    CHECK(6, 1, t6_count, 5, 0, "gpio trigger count")

    CHECK(6, 2, t6_on, tp, 25, "gpio trigger pulse length")
Пример #4
0
def t6():
   global t6_count, t6_on

   print("Trigger tests.")

   pigpio.write(GPIO, pigpio.LOW)

   tp = 0

   t6cb = pigpio.callback(GPIO, pigpio.EITHER_EDGE, t6cbf)

   for t in range(10):
      time.sleep(0.1)
      p = 10 + (t*10)
      tp += p;
      pigpio.gpio_trigger(4, p, 1)

   time.sleep(0.5)

   CHECK(6, 1, t6_count, 10, 0, "gpio trigger count")

   CHECK(6, 2, t6_on, tp, 25, "gpio trigger pulse length")