def Debounce(threshold=100):
    threshold *= 1000
    max_tick = 0xFFFFFFFF
    class _decorated(object):
        def __init__(self, pigpio_cb):
            self._fn = pigpio_cb
            self.last = 0
            self.is_method = False
        def __call__(self, *args, **kwargs):
            if self.is_method:
                tick = args[3]
            else:
                tick = args[2]
            if self.last > tick:
                delay = max_tick-self.last + tick
            else:
                delay = tick - self.last
            if delay > threshold:
                self._fn(*args, **kwargs)
                print('call passed by debouncer {} {} {}'
                      .format(tick, self.last, threshold))
                self.last = tick
            else:
                print('call filtered out by debouncer {} {} {}'
                      .format(tick, self.last, threshold))
        def __get__(self, instance, type=None):
            self.is_method = True
            return functools.partial(self, instance)
    return _decorated