コード例 #1
0
    def __init__(self, inputter):
        self.inputter = inputter
        morse_maker = MorseMaker('C', 'c', 200, 500)
        self.morseAlphbeth = KeyPress.mkUnion(
            morse_maker.mkAll(lambda c: print("=== %s" % c)) + [
                KeyPress.compile(".A.a<go_to_normal>",
                                 go_to_normal=lambda: self.go_normal())
            ])

        self.main_menu = KeyPress.mkUnion([
            KeyPress.compile(".A.C.c.a<go_to_morse>",
                             go_to_morse=lambda: self.go_morse()),
            KeyPress.compile(".A.a<A>", A=lambda: print("A")),
            KeyPress.compile(".B.b<B>", B=lambda: print("B")),
        ])
        self.go_normal()
コード例 #2
0
ファイル: radio.py プロジェクト: rolf007/home_server
 def __init__(self, logger, exc_cb, inputter):
     self.logger = logger
     self.comm = Comm(5000, "buttons", {}, self.logger, exc_cb)
     self.inputter = inputter
     self.menu_linger_time = 5.0
     self.main_menu = KeyPress.mkUnion([
         KeyPress.compile(".A.a<match>",
                          match=lambda: self.go_to_playlist_menu()),
         KeyPress.compile(".B.b<match>",
                          match=lambda: self.multicast_play({
                              "artist": ["bryan adams"],
                              "title": ["summer of 69"]
                          })),
         KeyPress.compile(".C.c<match>",
                          match=lambda: self.go_to_radio_menu()),
         KeyPress.compile(".D.d<match>",
                          match=lambda: self.multicast_play({
                              "artist": ["volbeat"],
                              "title": ["for evigt"]
                          })),
         KeyPress.compile(".E.e<match>", match=lambda: self.apple_dock()),
         KeyPress.compile(".F.f<match>",
                          match=lambda: self.go_to_podcast_menu()),
         KeyPress.compile(".H.h<match>",
                          match=lambda: self.go_to_flow_menu()),
     ])
     self.radio_menu = KeyPress.mkUnion([
         KeyPress.compile(".A.a<match>",
                          match=lambda: self.radio_channel("p1")),
         KeyPress.compile(".B.b<match>",
                          match=lambda: self.radio_channel("p2")),
         KeyPress.compile(".C.c<match>",
                          match=lambda: self.radio_channel("p3")),
         KeyPress.compile(".D.d<match>",
                          match=lambda: self.radio_channel("24syv")),
     ])
     self.podcast_menu = KeyPress.mkUnion([
         KeyPress.compile(".A.a<match>",
                          match=lambda: self.start_podcast("baelte")),
         KeyPress.compile(".B.b<match>",
                          match=lambda: self.start_podcast("orientering")),
         KeyPress.compile(".C.c<match>",
                          match=lambda: self.start_podcast("mads")),
         KeyPress.compile(".D.d<match>",
                          match=lambda: self.start_podcast("d6m")),
     ])
     self.flow_menu = KeyPress.mkUnion([
         KeyPress.compile(".A.a<match>",
                          match=lambda: self.flow({"to": ["0"]})),
         KeyPress.compile(".B.b<match>",
                          match=lambda: self.flow({"prev": [1]})),
         KeyPress.compile(".C.c<match>",
                          match=lambda: self.flow({"to": ["random"]})),
         KeyPress.compile(".D.d<match>",
                          match=lambda: self.flow({"next": ["1"]})),
         KeyPress.compile(".E.e<match>",
                          match=lambda: self.flow({"to": ["last"]})),
         KeyPress.compile(".H.h<match>", match=lambda: self.stop()),
     ])
     self.playlist_menu = KeyPress.mkUnion([
         KeyPress.compile(
             ".A.a<match>",
             match=lambda: self.go_to_users_playlist_menu("user_k")),
         KeyPress.compile(
             ".B.b<match>",
             match=lambda: self.go_to_users_playlist_menu("user_r")),
         KeyPress.compile(
             ".C.c<match>",
             match=lambda: self.go_to_users_playlist_menu("user_c")),
         KeyPress.compile(
             ".D.d<match>",
             match=lambda: self.go_to_users_playlist_menu("user_h")),
         KeyPress.compile(
             ".E.e<match>",
             match=lambda: self.go_to_users_playlist_menu("user_a")),
         KeyPress.compile(
             ".F.f<match>",
             match=lambda: self.go_to_users_playlist_menu("user_s")),
     ])
     self.user_playlist_menu = {}
     self.user_playlist_menu["user_k"] = KeyPress.mkUnion([
         KeyPress.compile(".A.a<match>",
                          match=lambda: self.multicast_play({
                              "source": ["list"],
                              "query": ["svensk"]
                          })),
     ])
     self.user_playlist_menu["user_r"] = KeyPress.mkUnion([
         KeyPress.compile(".A.a<match>",
                          match=lambda: self.multicast_play({
                              "source": ["list"],
                              "query": ["metal"]
                          })),
         KeyPress.compile(
             ".B.b<match>",
             match=lambda: self.multicast_play({"artist": ["metallica"]})),
     ])
     self.user_playlist_menu["user_c"] = KeyPress.mkUnion([])
     self.user_playlist_menu["user_h"] = KeyPress.mkUnion([])
     self.user_playlist_menu["user_a"] = KeyPress.mkUnion([])
     self.user_playlist_menu["user_s"] = KeyPress.mkUnion([])
     print("==== press 'A' for playlists")
     print("==== press 'B' for youtube play")
     print("==== press 'C' for radio")
     print("==== press 'D' for Volbeat - For Evigt")
     print("==== press 'E' for Knight Rider")
     print("==== press 'F' for Pod cast")
     print("==== press 'H' for Flow control")
     print("==== press 'q' to quit")
     self.go_to_main_menu()
     self.inputter.click_NAD_button(3)