Beispiel #1
0
def dim_clock_to_sleep():
    currentBrightness = 7
    oc.display_clock_time(wakeTimeTomorrow)
    while currentBrightness >= 0:
        oc.clockDisplay.SetBrightness(currentBrightness)
        time.sleep(0.8)
        currentBrightness -= 1
    oc.clear_clock()
    oc.clockDisplay.SetBrightness(c.CLOCK_BRIGHTNESS)
Beispiel #2
0
def abort_bedtime_protocol():
    global recordedAbortTime, abortBedtimeDate
    global isDisplayingBedtime, isDisplayingBedtimeCountdown, isBedtimeSirenProtocolEnabled
    isDisplayingBedtime = isDisplayingBedtimeCountdown = isBedtimeSirenProtocolEnabled = False
    recordedAbortTime = get_localized_time()

    abortBedtimeDate = bedtimeTonight.date()

    leff.start(leff.ABORT_BEDTIME_PROTOCOL)
    oc.clear_clock()
    oc.set_clock_brightness(c.CLOCK_BRIGHTNESS)
Beispiel #3
0
def flash_bedtime_then_sleep():
    currentBrightness = 7
    dim = 1
    oc.display_clock_time(wakeTimeTomorrow)
    time.sleep(9.0)
    intv = 0.5
    for i in range(0, 3):
        oc.clockDisplay.SetBrightness(dim)
        time.sleep(intv)
        oc.clockDisplay.SetBrightness(currentBrightness)
        time.sleep(intv)
    oc.clear_clock()
    oc.set_clock_brightness(c.CLOCK_BRIGHTNESS)
Beispiel #4
0
def __woke_up_thread(displayFunction, funcInput):
    global isInWakeUpPeriod

    pause = 1.3
    intv = 2
    oc.clear_clock()

    for i in range(2):
        time.sleep(pause)
        displayFunction(funcInput)
        time.sleep(intv)
        oc.clear_clock()

    isInWakeUpPeriod = False
Beispiel #5
0
def __display_stats_thread():
    global isDislayingStats
    isDislayingStats = True
    actualLength = time.time() - startTimes[SPRINT]
    percentFocus = 100.0 * (1 - (interruptionDelay / actualLength))
    reset_delay()

    pause = 1.3
    oc.clear_clock()
    time.sleep(pause)
    oc.display_int(int(round(percentFocus)))
    time.sleep(c.END_STATS_DISPLAY_LENGTH - pause * 2)
    oc.clear_clock()
    time.sleep(pause)
    isDislayingStats = False
Beispiel #6
0
def __end_session_thread():
    global inSession
    leff.start(leff.END_SESSION)
    time.sleep(2.5)
    if not isDislayingStats:
        oc.clear_clock()
    time.sleep(5.5)

    if inSprint or inBreak:
        return  # a new one was started during shutdown lol

    inSession = False

    bp.isDisplayingBedtime = False
    bp.isDisplayingBedtimeCountdown = False
    bp.isBedtimeSirenProtocolEnabled = False
Beispiel #7
0
def run_light_thread():
    from output_controller import set_light_rgba, set_light_calib_rgba
    from random import random
    global isLightEffectRunning
    effect = currentEffect

    if effect == END_SESSION:
        fade_linear((255, 0, 120, 1), 2)
        fade_off(4)

    elif effect == START_SPRINT:
        set_light_calib_rgba(c.SPRINT_L_B)

    elif effect == START_BREAK:
        fade_on(c.BREAK_L_B, 4)
        #set_light_rgba(c.BREAK_L_B)

    elif effect == START_INTERRUPTION:
        intv = 0.2  # s
        flash = 0.07
        flashPause = 0.05
        for i in range(0, 3):
            fade_off(flash)
            sleep(intv)
            fade_on(c.INTERRUPTION_L_B, flash)
            sleep(flashPause)

        intv = 1.5  # s
        while effect == START_INTERRUPTION:
            set_light_calib_rgba(c.INTERRUPTION_L_B)
            sleep(intv)
            turnOff()
            sleep(intv)

    elif effect == PAST_BREAK:
        intv = 0.55  # s
        pause = 1.2
        r, g, b, a = c.BREAK_L_B  # pylint: disable=unused-variable
        while effect == PAST_BREAK:
            fade_on((r, g, b, 1), intv)
            sleep(pause)
            fade_off(intv)
            sleep(pause)

    elif effect == ENTERING_OVERTIME:
        intv = 0.17  # s
        flash = 0.15
        flashPause = 0.13
        turnOff()
        sleep(0.22)
        for i in range(0, 2):
            set_light_rgba((0, 255, 0, 1))
            sleep(flashPause)
            fade_off(flash)
            sleep(intv)
        fade_on(c.SPRINT_L_B, 1.4)

    elif effect == PAST_BEDTIME:
        intv = 0.2  # s
        pauseMax = 1.4
        flashPause = intv
        level1End = bp.bedtimeTonight + bp.timedelta(
            seconds=c.BEDTIME_ALARM_LEVEL_1_LENGTH)
        level2End = level1End + bp.timedelta(
            seconds=c.BEDTIME_ALARM_LEVEL_2_LENGTH)

        while effect == PAST_BEDTIME:
            for i in range(3):
                if i == 1 and bp.get_localized_time() > level1End:
                    if bp.get_localized_time < level2End:
                        set_light_rgba((50, 0, 255, 0.4))
                    else:
                        set_light_rgba((0, 0, 255, 1))
                else:
                    set_light_calib_rgba(c.INTERRUPTION_L_B)
                sleep(intv)
                turnOff()
                sleep(flashPause)
            sleep(random() * pauseMax)

    elif effect == BEDTIME:
        r, g, b, a = c.BREAK_L_B  # pylint: disable=unused-variable
        set_light_calib_rgba((0, 255, 70, 0.2))
        linfadelen = 5
        fade_linear(oc.calculate_calib_rgba((r, g, b, 1)), linfadelen)
        set_light_calib_rgba((r, g, b, 1))
        #fade_off(8.3)
        fade_off(7.3)

    elif effect == MORNING:
        intv = 5  # s
        #drop = 0.3 # s
        pause = 5
        startTime = time.time()
        endTime = startTime + c.MORNING_WAKE_EFFECT_LENGTH
        while time.time() < endTime:
            fade_on(c.MORNING_L_B, intv)
            sleep(pause)
            fade_off(intv)
            sleep(pause)

    elif effect == ABORT_BEDTIME_PROTOCOL:
        intv = 0.3  # s
        for i in range(0, 5):
            turnOff()
            sleep(intv)
            set_light_calib_rgba(c.INTERRUPTION_L_B)
            sleep(intv)
        fade_off(2.3)

    elif effect == BEDTIME_COUNTDOWN:
        intv = 0.5  # s
        longBoot = 3.  # s
        fade_on((255, 9, 0, 0.2), intv)
        fade_off(intv)
        fade_on((255, 9, 0, 0.2), intv)
        fade_off(intv)

        fade_on((255, 40, 0, 0.2), longBoot)

    elif effect == DEMO_MODE:
        intv = 0.08  # s
        oc.display_int(9999)
        for i in range(0, 10):
            set_light_rgba((255, 255, 255, 1))
            sleep(intv)
            turnOff()
            sleep(intv)
        intv = 0.3  # s
        for i in range(0, 12):
            set_light_rgba((255, 0, 0, 1))
            sleep(0.05)
            fade_linear((255, 200, 0, 1), intv)
            fade_linear((0, 255, 0, 1), intv)
            fade_linear((0, 0, 255, 1), intv)
        fade_linear((255, 0, 120, 1), 2)
        oc.clear_clock()
        fade_off(7)

    else:
        logging.error(
            f'Oops! No such available effect with the value: {effect}')
        raise Exception(
            f'Oops! No such available effect with the value: {effect}')

    isLightEffectRunning = False