def determine_perc(time, period, width):
    """
    Models a rise time of width/2 followed immediately by a fall time of width/2
    Each instance is separated by (period - width) milliseconds
    """
    cur_time = time%period
    if cur_time < width//2:
        return float(cur_time)/(width/2)
    elif cur_time < width:
        return 1. - float(cur_time - width//2)/(width/2)
    else:
        return 0.