def absmin_diff(current, prevs):
    """Min of differences between current sample and all previous samples.
    Given more than one min, use the last one detected which is probably a
    newer value. Returns (difference, prev used)
    """
    diffs = [abs(current-prev) for prev in prevs]
    smallest_pos = 0
    smallest = diffs[0]
    for i, diff in enumerate(diffs):
        if diff <= smallest:
            smallest = diff
            smallest_pos = i
    return current-prevs[smallest_pos], prevs[smallest_pos]