Calls a user supplied function (a callback) whenever the
        specified gpio edge is detected.

        user_gpio:= 0-31.
           edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE.
           func:= user supplied callback function.

        The user supplied callback receives three parameters, the gpio,
        the level, and the tick.

        If a user callback is not specified a default tally callback is
        provided which simply counts edges.  The count may be retrieved
        by calling the tally function.

        The callback may be cancelled by calling the cancel function.

        A gpio may have multiple callbacks (although I can't think of
        a reason to do so).

        ...
        def cbf(gpio, level, tick):
         print(gpio, level, tick)

        cb1 = pi.callback(22, pigpio.EITHER_EDGE, cbf)

        cb2 = pi.callback(4, pigpio.EITHER_EDGE)

        cb3 = pi.callback(17)

        print(cb3.tally())

        cb1.cancel() # To cancel callback cb1.
        ...

def add_callback(self, user_gpio, edge=RISING_EDGE, func=None):
        """
        Calls a user supplied function (a callback) whenever the
        specified gpio edge is detected.

        user_gpio:= 0-31.
           edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE.
           func:= user supplied callback function.

        The user supplied callback receives three parameters, the gpio,
        the level, and the tick.

        If a user callback is not specified a default tally callback is
        provided which simply counts edges.  The count may be retrieved
        by calling the tally function.

        The callback may be cancelled by calling the cancel function.

        A gpio may have multiple callbacks (although I can't think of
        a reason to do so).

        ...
        def cbf(gpio, level, tick):
         print(gpio, level, tick)

        cb1 = pi.callback(22, pigpio.EITHER_EDGE, cbf)

        cb2 = pi.callback(4, pigpio.EITHER_EDGE)

        cb3 = pi.callback(17)

        print(cb3.tally())

        cb1.cancel() # To cancel callback cb1.
        ...
        """

        cb = Callback(self._notify, user_gpio, edge, func)
        yield from self._notify.append(cb)

        return cb