예제 #1
0
    def draw(self, screen, offset):
        UiComponent.draw(self, screen, offset)

        if self.wake_enabled:
            (hh_wake, mm_wake, ss_wake) = self.wake.get_time()
            p1 = self.get_point(offset, hh_wake + mm_wake / 60, 0, 0)
            p2 = self.get_point(offset, hh_wake + mm_wake / 60, 0, 0.8)
            pygame.draw.line(screen, self.c_hand_wake, p1, p2, 1)

        if self.sleep_enabled:
            (hh_sleep, mm_sleep, ss_sleep) = self.sleep.get_time()
            p1 = self.get_point(offset, hh_sleep + mm_sleep / 60, 0, 0)
            p2 = self.get_point(offset, hh_sleep + mm_sleep / 60, 0, 0.8)
            pygame.draw.line(screen, self.c_hand_stop, p1, p2, 1)

        (hh, mm, ss) = self.time.get_time()

        p1 = self.get_point(offset, hh + mm / 60, 0, 0.45)
        p2 = self.get_point(offset, hh + mm / 60, 0, 0.0)
        pygame.draw.line(screen, self.c_hand, p1, p2, 3)

        p1 = self.get_point(offset, 0, mm, 0.7)
        p2 = self.get_point(offset, 0, mm, 0.0)
        pygame.draw.line(screen, self.c_hand, p1, p2, 2)

        p1 = self.get_point(offset, 0, ss, 0.8)
        p2 = self.get_point(offset, 0, ss, 0.0)
        pygame.draw.line(screen, self.c_hand, p1, p2, 1)
예제 #2
0
    def __init__(self, screen, images, framebuilder, fonts, sizes, colors):
        UiComponent.__init__(self)
        self.screen = screen
        self.images = images
        self.framebuilder = framebuilder
        self.fonts = fonts
        self.sizes = sizes
        self.colors = colors

        self.actual_time = {"hh": 0, "mm": 0, "ss": 0}
        self.alarm_time = None
        self.sleep_time = {"hh": 0, "mm": 0}

        self.key_enter_handler = lambda: print(
            "confirm changes of setup clock view")
        self.key_back_handler = lambda: print("leave setup clock view")

        self.add(
            ImageComponent(self.images.label(Images.LABEL_RADIO_PI)).set_pos(
                40, 0))
        self.add(
            ImageComponent(self.images.label(Images.LABEL_WAVE)).set_pos(
                160, 0))
        self.clock = ClockComponent(self.images)  #.on_push(self.on_push_clock)
        self.clock.set_pos(0, 0).set_size(40, 40)
        self.add(self.clock)

        self.time_field = TimeField(screen, Images.LABEL_CLOCK, images,
                                    framebuilder, fonts, sizes, colors)
        self.time_field.set_pos(160, 40)
        self.time_field.key_enter_handler = lambda: self.on_key_enter()
        self.add(self.time_field)

        self.wake_time_field = TimeField(screen, Images.LABEL_ALARM, images,
                                         framebuilder, fonts, sizes, colors)
        self.wake_time_field.set_pos(0, 40)
        self.wake_time_field.key_enter_handler = lambda: self.on_key_enter()
        self.add(self.wake_time_field)

        self.sleep_time_field = TimeField(screen, Images.LABEL_SLEEP, images,
                                          framebuilder, fonts, sizes, colors)
        self.sleep_time_field.set_pos(0, 140)
        self.sleep_time_field.key_enter_handler = lambda: self.on_key_enter()
        self.add(self.sleep_time_field)

        self.framebuilder.frame(self, 8, 7, 8, 5)
        self.add_key(170, 210, 0x3d, self.on_key_enter)
        self.add_key(290, 210, 0x2d, self.on_key_back)
예제 #3
0
 def __init__(self, images):
     UiComponent.__init__(self)
     self.images = images
     self.caps = 0  # lower / upper / lock
     self.num = 0  # alpha / num
     self.caps_buttons = []
     self.num_buttons = []
     self.favourite_buttons = []
     self.favourite = False
     self.keyboards = []
     for i in range(3):
         keyboard = UiComponent().set_pos(0, 0).set_size(300, 60)
         self.add_keys(keyboard, i * 3)
         self.keyboards.append(keyboard)
         self.add(keyboard)
     self.show_keyboard()
예제 #4
0
 def __init__(self, images):
     UiComponent.__init__(self)
     self.images = images
     self.add(ImageComponent(self.images.label(Images.LABEL_CLOCK)))
     self.c_dial = (48, 48, 48)
     self.c_grid = (160, 160, 160)
     self.c_hand = (255, 255, 255)
     self.c_hand_stop = (255, 0, 255)
     self.c_hand_wake = (48, 180, 255)
     self.time = Time()
     self.wake = Time()
     self.wake_enabled = False
     self.sleep = Time()
     self.sleep_enabled = False
     self.push_clock_handler = lambda: print("clock pushed")
     self.set_event_listener(UiEvent.MOUSE_CLICK_EVENT, self.on_push_clock)
예제 #5
0
 def draw(self, screen, offset):
     t = self.time.add(self.offset)
     (hh, mm, ss) = t.get_time()
     if self.time_enabled:
         shh = "%02d" % hh
         smm = "%02d" % mm
         self.hh0.set_text("*^^^%s*" % shh[0:1])
         self.hh1.set_text("*^^^%s*" % shh[1:2])
         self.mm0.set_text("*^^^%s*" % smm[0:1])
         self.mm1.set_text("*^^^%s*" % smm[1:2])
     else:
         self.hh0.set_text("*^^^-*")
         self.hh1.set_text("*^^^-*")
         self.mm0.set_text("*^^^-*")
         self.mm1.set_text("*^^^-*")
     return UiComponent.draw(self, screen, offset)
예제 #6
0
    def __init__(self, screen, label, images, framebuilder, fonts, sizes,
                 colors):
        UiComponent.__init__(self)
        self.screen = screen
        self.images = images
        self.label = label
        self.framebuilder = framebuilder
        self.fonts = fonts
        self.sizes = sizes
        self.colors = colors

        width = 8
        height = 5
        if label:
            self.add(ImageComponent(self.images.label(label)).set_pos(110, 30))

        self.set_size(width * 20, height * 20)

        self.framebuilder.frame(self, 0, 0, width, height)

        self.hh0 = TextlabelComponent("*^^^0*", fonts, sizes, colors)
        self.hh0.set_pos(12, 35).set_size(20, 40)
        self.add(self.hh0)

        self.hh1 = TextlabelComponent("*^^^0", fonts, sizes, colors)
        self.hh1.set_pos(32, 35).set_size(20, 40)
        self.add(self.hh1)

        self.ddot = TextlabelComponent("*^^^:", fonts, sizes, colors)
        self.ddot.set_pos(55, 33).set_size(20, 40)
        self.add(self.ddot)

        self.mm0 = TextlabelComponent("*^^^0", fonts, sizes, colors)
        self.mm0.set_pos(72, 35).set_size(20, 40)
        self.add(self.mm0)

        self.mm1 = TextlabelComponent("*^^^0", fonts, sizes, colors)
        self.mm1.set_pos(92, 35).set_size(20, 40)
        self.add(self.mm1)

        self.add_key(10, 10, 0x3e, self.on_key_plus_0)
        self.add_key(30, 10, 0x3e, self.on_key_plus_1)
        self.add_key(70, 10, 0x3e, self.on_key_plus_2)
        self.add_key(90, 10, 0x3e, self.on_key_plus_3)

        self.add_key(10, 70, 0x3f, self.on_key_minus_0)
        self.add_key(30, 70, 0x3f, self.on_key_minus_1)
        self.add_key(70, 70, 0x3f, self.on_key_minus_2)
        self.add_key(90, 70, 0x3f, self.on_key_minus_3)

        self.add_key(120, 70, 0x0d, self.on_key_clear)

        self.time = Time()
        self.offset = Time()
        self.hh_plus_10 = Time().with_hh(10)
        self.hh_minus_10 = Time().with_hh(-10)
        self.hh_plus_1 = Time().with_hh(1)
        self.hh_minus_1 = Time().with_hh(-1)
        self.mm_plus_10 = Time().with_mm(10)
        self.mm_minus_10 = Time().with_mm(-10)
        self.mm_plus_1 = Time().with_mm(1)
        self.mm_minus_1 = Time().with_mm(-1)
        self.time_enabled = True
예제 #7
0
    def __init__(self, screen, images, framebuilder, fonts, sizes, colors):
        UiComponent.__init__(self)
        self.screen = screen
        self.images = images
        self.framebuilder = framebuilder
        self.fonts = fonts
        self.sizes = sizes
        self.colors = colors

        self.handle_select_up = self.default_handler
        self.handle_select_down = self.default_handler
        self.handle_select_wlan = self.default_select_handler
        self.handle_change_password = self.default_handler
        self.handle_return_key = self.default_handler
        self.handle_scan_wlan = self.default_handler

        self.add(
            ImageComponent(self.images.label(Images.LABEL_RADIO_PI)).set_pos(
                40, 0))
        self.add(
            ImageComponent(self.images.label(Images.LABEL_WAVE)).set_pos(
                160, 0))
        self.handle_push_clock = lambda: print("select clock pushed")
        self.clock = ClockComponent(self.images).on_push(self.on_push_clock)
        self.clock.set_pos(0, 0).set_size(40, 40)
        self.add(self.clock)

        self.framebuilder.frame(self, 0, 2, 9, 3)
        self.framebuilder.frame(self, 0, 5, 9, 3)
        self.framebuilder.frame(self, 9, 2, 7, 6)

        self.ssid = ""
        self.pw = ""

        self.edit_pw = True

        self.lan_ip = "unknown"
        self.wlan_ip = "unknown"

        self.wlan_list = []

        self.framebuilder.frame(self, 0, 8, 16, 4)

        self.add(ButtonComponent(self.images.button(Images.BUTTON_SMALL_UP))\
            .set_pos(188, 50)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_select_up())
            )

        self.add(ButtonComponent(self.images.button(Images.BUTTON_SCAN))\
            .set_pos(188, 90)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_scan_wlan())
            )

        self.add(ButtonComponent(self.images.button(Images.BUTTON_SMALL_DOWN))\
            .set_pos(188, 130)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_select_down())
            )

        self.network_status_label = TextlabelComponent("", self.fonts,
                                                       self.sizes, self.colors)
        self.network_status_label.set_pos(10, 55).set_size(170, 50)
        self.add(self.network_status_label)

        self.network_ssid_label = TextlabelComponent("", self.fonts,
                                                     self.sizes, self.colors)
        self.network_ssid_label.set_pos(10, 115).set_size(170, 18)
        self.network_ssid_label.set_event_listener(UiEvent.MOUSE_CLICK_EVENT,
                                                   self.on_edit_ssid_field)
        self.add(self.network_ssid_label)

        self.network_pw_field = TextlabelComponent("", self.fonts, self.sizes,
                                                   self.colors)
        self.network_pw_field.set_pos(10, 130).set_size(140, 18)
        self.network_pw_field.set_event_listener(UiEvent.MOUSE_CLICK_EVENT,
                                                 self.on_edit_pw_field)
        self.add(self.network_pw_field)

        self.add(ButtonComponent(self.images.button(Images.BUTTON_OFS_KEY + 0x3d))\
            .set_pos(150, 130)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_change_password())
            )

        self.wlan_level_icons = [
            ImageComponent(self.images.label(Images.LABEL_WLAN_0)),
            ImageComponent(self.images.label(Images.LABEL_WLAN_1)),
            ImageComponent(self.images.label(Images.LABEL_WLAN_2)),
            ImageComponent(self.images.label(Images.LABEL_WLAN_3)),
        ]

        self.wlan_list_view = ListViewComponent(self.fonts, self.sizes,
                                                self.colors)
        self.wlan_list_view.set_size(100, 100, 17).set_pos(210, 50)
        self.wlan_list_view.set_to_string(
            lambda item: self.wlan_item_to_string(item))
        self.wlan_list_view.set_to_icon(
            lambda item: self.wlan_item_to_icon(item))
        self.wlan_list_view.set_handle_select(
            lambda item: self.handle_select_wlan(item))
        self.wlan_list_view.set_empty_message("_- no signal -")
        self.wlan_list_view.set_items(self.wlan_list)
        self.add(self.wlan_list_view)

        self.keyboard = KeyboardComponent(self.images)
        self.keyboard.set_pos(10, 170).set_size(300, 60)
        self.keyboard.set_keyboard_handler(
            lambda keycode: self.handle_select_key(keycode))
        self.keyboard.disable_favourite_button()
        self.add(self.keyboard)

        self.set_ips("", "")
        self.set_pw("")
        self.set_ssid("")
예제 #8
0
    def __init__(self, screen, images, framebuilder, fonts, sizes, colors):
        UiComponent.__init__(self)
        self.screen = screen
        self.images = images
        self.framebuilder = framebuilder
        self.fonts = fonts
        self.sizes = sizes
        self.colors = colors
        self.keyboard_mode = 0  # 0 = num, 1 = numeric
        self.filter = ""

        self.handle_select_up = self.default_key_handler
        self.handle_select_down = self.default_key_handler
        self.handle_select_music_key = self.default_key_handler
        self.handle_play_station = self.default_play_file_handler
        self.handle_select_station = self.default_key_handler
        self.handle_push_clock = lambda: print("select clock pushed")

        self.favourite_icon = ButtonComponent(
            self.images.button(Images.BUTTON_OFS_KEY + 0x2e))

        self.add(
            ImageComponent(self.images.label(Images.LABEL_RADIO_PI)).set_pos(
                40, 0))
        self.add(
            ImageComponent(self.images.label(Images.LABEL_WAVE)).set_pos(
                160, 0))
        self.clock = ClockComponent(self.images).on_push(self.on_push_clock)
        self.clock.set_pos(0, 0).set_size(40, 40)
        self.add(self.clock)

        self.framebuilder.frame(self, 0, 2, 14, 6)
        self.framebuilder.frame(self, 14, 2, 2, 6)
        self.framebuilder.frame(self, 0, 8, 16, 4)

        self.add(ButtonComponent(self.images.button(Images.BUTTON_SELECT_UP))\
            .set_pos(280, 45)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_select_up())
            )

        self.add(ButtonComponent(self.images.button(Images.BUTTON_SELECT_DOWN))\
            .set_pos(280, 95)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_select_down())
            )

        self.file_list_view = ListViewComponent(self.fonts, self.sizes,
                                                self.colors)
        self.file_list_view.set_size(260, 100, 35).set_pos(10, 50)
        self.file_list_view.set_to_string(
            lambda file: self.get_file_string(file))
        self.file_list_view.set_to_icon(lambda file: self.get_file_icon(file))
        self.file_list_view.set_handle_select(
            lambda file: self.handle_play_file(file))
        self.file_list_view.set_empty_message("-- no data --")
        self.add(self.file_list_view)

        self.keyboard = KeyboardComponent(self.images)
        self.keyboard.set_pos(10, 170).set_size(300, 60)
        self.keyboard.set_keyboard_handler(
            lambda keycode: self.handle_select_music_key(keycode))
        self.add(self.keyboard)
예제 #9
0
    def __init__(self, screen, images, framebuilder, fonts, sizes, colors):
        UiComponent.__init__(self)
        self.screen = screen
        self.images = images
        self.framebuilder = framebuilder

        self.show_start_button = False
        self.station = None
        self.favourite = False

        self.add(
            ImageComponent(self.images.label(Images.LABEL_RADIO_PI)).set_pos(
                40, 0))
        self.add(
            ImageComponent(self.images.label(Images.LABEL_WAVE)).set_pos(
                160, 0))
        self.handle_push_clock = lambda: print("select clock pushed")
        self.clock = ClockComponent(self.images).on_push(self.on_push_clock)
        self.clock.set_pos(0, 0).set_size(40, 40)
        self.add(self.clock)

        self.framebuilder.frame(self, 0, 2, 16, 7)
        self.framebuilder.frame(self, 0, 9, 2, 3)
        self.framebuilder.frame(self, 2, 9, 2, 3)
        self.framebuilder.frame(self, 4, 9, 3, 3)
        self.framebuilder.frame(self, 7, 9, 3, 3)
        self.framebuilder.frame(self, 10, 9, 3, 3)
        self.framebuilder.frame(self, 13, 9, 3, 3)

        self.handle_volume_down = self.default_key_handler
        self.handle_volume_up = self.default_key_handler
        self.handle_start = self.default_key_handler
        self.handle_stop = self.default_key_handler
        self.handle_select_station = self.default_key_handler
        self.handle_select_music = self.default_key_handler
        self.handle_setup = self.default_key_handler
        self.handle_favourite = self.default_favourite_handler

        self.volume_up_button = ButtonComponent(self.images.button(Images.BUTTON_VOLUME_DOWN))\
            .set_pos(0, 180)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_volume_down())
        self.add(self.volume_up_button)

        self.volume_down_button = ButtonComponent(self.images.button(Images.BUTTON_VOLUME_UP))\
            .set_pos(40, 180)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_volume_up())
        self.add(self.volume_down_button)

        self.start_stop_button = ButtonComponent(self.images.button(Images.BUTTON_STOP))\
            .set_pos(80, 180)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_start_stop())
        self.add(self.start_stop_button)

        self.add(ButtonComponent(self.images.button(Images.BUTTON_SELECT_MUSIC))\
            .set_pos(140, 180)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_select_music())
            )

        self.add(ButtonComponent(self.images.button(Images.BUTTON_SELECT_STATION))\
            .set_pos(200, 180)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_select_station())
            )

        self.add(ButtonComponent(self.images.button(Images.BUTTON_SETUP))\
            .set_pos(260, 180)\
            .set_event_listener(UiEvent.MOUSE_CLICK_EVENT, lambda event, source: self.handle_setup())
            )

        self.stationlabel = TextlabelComponent("---", fonts, sizes, colors)
        self.stationlabel.set_pos(10, 50).set_size(300, 120)
        self.add(self.stationlabel)

        # favourite
        self.favourite_button = ButtonComponent(
            self.images.button(Images.BUTTON_OFS_KEY + 0x2f))
        self.favourite_button.set_event_listener(
            UiEvent.MOUSE_CLICK_EVENT,
            lambda event, source: self.switch_favourite()).set_pos(290, 50)
        self.add(self.favourite_button)

        self.set_station(None)