Esempio n. 1
0
def radio_loop(now, key_value):
    global currently_tuned
    switch_channel(key_value)  # change radio channel
    get_mpd_info(now)
    if app_states["play"] == 1:
        if mpd.stat() != "play" or currently_tuned != app_states["channel"]:
            mpd.play(app_states["channel"])
    else:
        if mpd.stat() == "play":
            mpd.stop()
    if key_value == "KEY_PLAYPAUSE":
        play_pause(now)
Esempio n. 2
0
def radio_loop(now,key_value):
    global currently_tuned
    switch_channel(key_value)    # change radio channel
    get_mpd_info(now)
    if app_states["play"] == 1:
        if mpd.stat() != "play" or currently_tuned != app_states["channel"]:
            mpd.play(app_states["channel"])
    else:
        if mpd.stat() == "play":
            mpd.stop()
    if key_value == "KEY_PLAYPAUSE":
        play_pause(now)
Esempio n. 3
0
def loop():
    now = millis()  # get timestamp
    key_value = controls.read_key()  # read controls
    if (now - last_update.panel_buttons > update_intervall.panel_buttons):
        button = controls.Read_Panel()
        if button != "":
            key_value = button
            time.sleep(0.2)

    tone_adjust(key_value)  # call tone adjust

    if key_value == "KEY_ENTER":  # switch tone mode
        switch_tone(now)

    if (now - last_update.time >
            update_intervall.time):  # update time in diaplay
        display.disp_content.time = time.strftime("%H:%M")
        last_update.time = now

    if (now - last_update.tone > update_intervall.tone):  # update tones
        update_tones(now)
        last_update.tone = now

    if (now - last_update.tone_adjust_idle > update_intervall.tone_adjust_idle
        ):  # switch back to volume after timeout
        mode_changed = True
        last_update.tone_adjust_idle = now
        app_states["tone_mode"] = tone_mode.volume

    if key_value == "KEY_MENU":
        switch_source(now)

    display.disp_content.tonemode = tone_strings[app_states["tone_mode"]]
    display.disp_content.tonevalue = app_states[tone_mode_to_string[
        app_states["tone_mode"]]]

    get_wifi(now)

    if app_states["app_mode"] == app_modes.IRadio:
        radio_loop(now, key_value)
    else:
        if mpd.stat() == "play":
            mpd.stop()

    if (now - last_update.disp_update >
            update_intervall.disp_update):  # update display
        display.update_display(now)
        last_update.disp_update = now
Esempio n. 4
0
def get_mpd_info(timestamp):
    global currently_tuned
    if (timestamp - last_update.radio > update_intervall.radio):    # update radio data
        if mpd.stat() == "play":
            (name, artist, title, pos) = mpd.info()
            currently_tuned = pos
            display.disp_content.mpd_stat = "play"
            display.disp_content.name     = name
            display.disp_content.artist   = artist
            display.disp_content.title    = title
        else:
            display.disp_content.mpd_stat = "stop"
            display.disp_content.name     = ""
            display.disp_content.artist   = ""
            display.disp_content.title    = ""
        last_update.radio                 = timestamp
Esempio n. 5
0
def get_mpd_info(timestamp):
    global currently_tuned
    if (timestamp - last_update.radio >
            update_intervall.radio):  # update radio data
        if mpd.stat() == "play":
            (name, artist, title, pos) = mpd.info()
            currently_tuned = pos
            display.disp_content.mpd_stat = "play"
            display.disp_content.name = name
            display.disp_content.artist = artist
            display.disp_content.title = title
        else:
            display.disp_content.mpd_stat = "stop"
            display.disp_content.name = ""
            display.disp_content.artist = ""
            display.disp_content.title = ""
        last_update.radio = timestamp
Esempio n. 6
0
def loop():
    now = millis()                  # get timestamp
    key_value = controls.read_key() # read controls
    if (now - last_update.panel_buttons > update_intervall.panel_buttons):
        button = controls.Read_Panel()
        if button != "":
            key_value = button
            time.sleep(0.2)

    tone_adjust(key_value)           # call tone adjust

    if key_value == "KEY_ENTER":    # switch tone mode
        switch_tone(now)

    if (now - last_update.time > update_intervall.time):       # update time in diaplay
        display.disp_content.time = time.strftime("%H:%M")
        last_update.time = now

    if (now - last_update.tone > update_intervall.tone ): # update tones
        update_tones(now)
        last_update.tone = now

    if (now - last_update.tone_adjust_idle > update_intervall.tone_adjust_idle ): # switch back to volume after timeout
        mode_changed = True
        last_update.tone_adjust_idle = now
        app_states["tone_mode"] = tone_mode.volume

    if key_value == "KEY_MENU":
        switch_source(now)

    display.disp_content.tonemode  = tone_strings[app_states["tone_mode"]]
    display.disp_content.tonevalue = app_states[tone_mode_to_string[app_states["tone_mode"]]]

    get_wifi(now)

    if app_states["app_mode"] == app_modes.IRadio:
        radio_loop(now,key_value)
    else:
        if mpd.stat() == "play":
            mpd.stop()

    if (now - last_update.disp_update > update_intervall.disp_update):    # update display
        display.update_display(now)
        last_update.disp_update = now
Esempio n. 7
0
def loop():
    now = millis()  # get timestamp
    key_value = ""
    if (now - last_update.get_input > update_intervall.get_input):
        key_value = controls.read_key()  # read controls
        last_update.get_input = now
    #if (now - last_update.panel_buttons > update_intervall.panel_buttons):
    #    button = controls.Read_Panel()
    #    if button != "":
    #        key_value = button
    #        time.sleep(0.2)

    tone_adjust(key_value)  # call tone adjust

    display.disp_content.power_state = controls.Power_State

    if prev_app_states["power"] != controls.Power_State:
        if app_states["app_mode"] == app_modes.IRadio:
            if controls.Power_State == "ON":
                app_states["play"] = 1
                led = open("/sys/class/leds/green_led/brightness", "w")
                led.write(str(1))
                led.close()
                time.sleep(3)
            else:
                app_states["play"] = 0
                led = open("/sys/class/leds/green_led/brightness", "w")
                led.write(str(0))
                led.close()
        prev_app_states["power"] = controls.Power_State

    if key_value == "KEY_ENTER":  # switch tone mode
        switch_tone(now)

    if (now - last_update.time >
            update_intervall.time):  # update time in diaplay
        display.disp_content.time = time.strftime("%H:%M")
        last_update.time = now

    if (now - last_update.tone > update_intervall.tone):  # update tones
        update_tones(now)
        last_update.tone = now

    if (now - last_update.tone_adjust_idle > update_intervall.tone_adjust_idle
        ):  # switch back to volume after timeout
        mode_changed = True
        last_update.tone_adjust_idle = now
        app_states["tone_mode"] = tone_mode.volume

    if key_value == "KEY_MENU":
        switch_source(now)

    display.disp_content.tonemode = tone_strings[app_states["tone_mode"]]
    display.disp_content.tonevalue = app_states[tone_mode_to_string[
        app_states["tone_mode"]]]
    display.disp_content.app_mode = app_mode_strings[app_states["app_mode"]]

    get_wifi(now)

    if app_states["app_mode"] == app_modes.IRadio:
        radio_loop(now, key_value)
    else:
        if mpd.stat() == "play":
            mpd.stop()

    if (now - last_update.disp_update >
            update_intervall.disp_update):  # update display
        display.update_display(now)
        last_update.disp_update = now