Exemplo n.º 1
0
    def __init__(self, config):
        """
        Initializations for the startup of the current wordclock plugin
        """
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.pretty_name = "Matrix with time"
        self.description = "There is no spoon?"

        try:
            self.purist = config.getboolean('plugin_time_default', 'purist')
        except:
            logging.warning(
                'No purist-flag set for default plugin within the config-file. Prefix will be displayed.'
            )
            self.purist = False

        self.bg_color = wcc.BLACK  # default background color
        self.word_color = wcc.WHITE  # default word color
        self.minute_color = wcc.WHITE  # default minute color

        self.threshold = 0.9

        # Colors from black to green (and a bit gray-ish)
        self.colors = []
        for i in range(0, 8):
            self.colors.append(wcc.Color(0, int(255.0 / 10 * i), 0))
        self.colors.append(wcc.Color(50, 204, 30))
        self.colors.append(wcc.Color(50, 230, 30))
        self.colors.append(wcc.Color(80, 255, 60))
Exemplo n.º 2
0
    def run(self, wcd, wci):
        '''
        Startup message wordclock
        Display... it is Lina o'clock
        '''
        indicies = [0, 1, 3, 4, 55, 65, 75, 85, 102, 103, 104, 105, 106, 107]
        self.bg_color = wcc.BLACK
        self.word_color = wcc.WWHITE
        self.rb_pos = 0
        for x in range(0, 400):
            if self.rb_pos < 85:
                self.word_color = self.minute_color = wcc.Color(
                    3 * self.rb_pos, 255 - 3 * self.rb_pos, 0)
            elif self.rb_pos < 170:
                self.word_color = self.minute_color = wcc.Color(
                    255 - 3 * (self.rb_pos - 85), 0, 3 * (self.rb_pos - 85))
            else:
                self.word_color = self.minute_color = wcc.Color(
                    0, 3 * (self.rb_pos - 170), 255 - 3 * (self.rb_pos - 170))
            # END: Rainbow generation as done in rpi_ws281x strandtest example! Thanks to Tony DiCola for providing :)
            wcd.setColorBy1DCoordinates(wcd.strip, indicies, self.word_color)
            wcd.show()
            self.rb_pos += 1
            if self.rb_pos == 256: self.rb_pos = 0
            time.sleep(0.02)

        return
Exemplo n.º 3
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]

        # Choose language
        try:
            language = config.get('plugin_' + self.name, 'language')
        except NoSectionError:
            language = ''
        if language == 'german':
            self.taw = time_german.time_german()
        else:
            print('Could not detect language: ' + language + '.')
            print('Choosing default: german')
            self.taw = time_german.time_german()

        self.bg_color = wcc.BLACK  # default background color
        self.word_color = wcc.WHITE  # default word color
        self.minute_color = wcc.WHITE  # default minute color

        self.threshold = 0.9

        # Colors from black to green (and a bit gray-ish)
        self.colors = []
        for i in range(0, 8):
            self.colors.append(wcc.Color(0, int(255.0 / 10 * i), 0))
        self.colors.append(wcc.Color(50, 204, 30))
        self.colors.append(wcc.Color(50, 230, 30))
        self.colors.append(wcc.Color(80, 255, 60))
Exemplo n.º 4
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]

        # Choose language
        self.taw = time_english.time_english()

        self.bg_color = wcc.BLACK  # default background color
        self.word_color = wcc.WWHITE  # default word color
        self.minute_color = wcc.WWHITE  # default minute color

        # Other color modes...
        self.color_modes = \
               [[wcc.BLACK, wcc.WWHITE, wcc.WWHITE],
                [wcc.BLACK, wcc.WHITE, wcc.WHITE],
                [wcc.BLACK, wcc.PINK, wcc.GREEN],
                [wcc.BLACK, wcc.RED, wcc.YELLOW],
                [wcc.BLACK, wcc.BLUE, wcc.RED],
                [wcc.BLACK, wcc.RED, wcc.BLUE],
                [wcc.YELLOW, wcc.RED, wcc.BLUE],
                [wcc.RED, wcc.BLUE, wcc.BLUE],
                [wcc.RED, wcc.WHITE, wcc.WHITE],
                [wcc.GREEN, wcc.YELLOW, wcc.PINK],
                [wcc.WWHITE, wcc.BLACK, wcc.BLACK],
                [wcc.BLACK, wcc.Color(30,30,30), wcc.Color(30,30,30)]]
        self.color_mode_pos = 0
        self.rb_pos = 0  # index position for "rainbow"-mode
Exemplo n.º 5
0
    def __init__(self, config):
        """
        Initializations for the startup of the current wordclock plugin
        """
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.pretty_name = "The time"
        self.description = "The minimum, you should expect from a wordclock."

        try:
            self.typewriter = config.getboolean('plugin_' + self.name,
                                                'typewriter')
        except:
            print(
                '  No typewriter-flag set for default plugin within the config-file. Typewriter animation will be used.'
            )
            self.typewriter = True

        try:
            self.typewriter_speed = config.getint('plugin_' + self.name,
                                                  'typewriter_speed')
        except:
            self.typewriter_speed = 5
            print(
                '  No typewriter_speed set for default plugin within the config-file. Defaulting to '
                + str(self.typewriter_speed) + '.')

        self.bg_color = wcc.BLACK  # default background color
        self.word_color = wcc.WWHITE  # default word color
        self.minute_color = wcc.WWHITE  # default minute color

        # Other color modes...
        self.color_modes = \
            [[wcc.BLACK, wcc.WWHITE, wcc.WWHITE],
             [wcc.BLACK, wcc.WHITE, wcc.WHITE],
             [wcc.BLACK, wcc.ORANGE, wcc.ORANGE],
             [wcc.BLACK, wcc.ORANGE, wcc.WWHITE],
             [wcc.BLACK, wcc.PINK, wcc.GREEN],
             [wcc.BLACK, wcc.RED, wcc.YELLOW],
             [wcc.BLACK, wcc.BLUE, wcc.RED],
             [wcc.BLACK, wcc.RED, wcc.BLUE],
             [wcc.YELLOW, wcc.RED, wcc.BLUE],
             [wcc.RED, wcc.BLUE, wcc.BLUE],
             [wcc.RED, wcc.WHITE, wcc.WHITE],
             [wcc.GREEN, wcc.YELLOW, wcc.PINK],
             [wcc.WWHITE, wcc.BLACK, wcc.BLACK],
             [wcc.BLACK, wcc.Color(30, 30, 30), wcc.Color(30, 30, 30)]]
        self.color_mode_pos = 0
        self.rb_pos = 0  # index position for "rainbow"-mode
        try:
            self.brightness_mode_pos = config.getint('wordclock_display',
                                                     'brightness')
        except:
            print(
                "WARNING: Brightness value not set in config-file: To do so, add a \"brightness\" between 1..255 to the [wordclock_display]-section."
            )
            self.brightness_mode_pos = 255
        self.brightness_change = 8
Exemplo n.º 6
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]

        # Choose language
        language = config.get('plugin_' + self.name, 'language')
        if language == 'dutch':
            self.taw = time_dutch.time_dutch()
        elif language == 'english':
            self.taw = time_english.time_english()
        elif language == 'german':
            self.taw = time_german.time_german()
        elif language == 'swabian':
            self.taw = time_swabian.time_swabian()
        elif language == 'bavarian':
            self.taw = time_bavarian.time_bavarian()
        else:
            print('Could not detect language: ' + language + '.')
            print('Choosing default: german')
            self.taw = time_german.time_german()

        self.bg_color = wcc.BLACK  # default background color
        self.word_color = wcc.WWHITE  # default word color
        self.minute_color = wcc.WWHITE  # default minute color

        # Other color modes...
        self.color_modes = \
               [[wcc.BLACK, wcc.WWHITE, wcc.WWHITE],
                [wcc.BLACK, wcc.WHITE, wcc.WHITE],
                [wcc.BLACK, wcc.ORANGE, wcc.ORANGE],
                [wcc.BLACK, wcc.ORANGE, wcc.WWHITE],
                [wcc.BLACK, wcc.PINK, wcc.GREEN],
                [wcc.BLACK, wcc.RED, wcc.YELLOW],
                [wcc.BLACK, wcc.BLUE, wcc.RED],
                [wcc.BLACK, wcc.RED, wcc.BLUE],
                [wcc.YELLOW, wcc.RED, wcc.BLUE],
                [wcc.RED, wcc.BLUE, wcc.BLUE],
                [wcc.RED, wcc.WHITE, wcc.WHITE],
                [wcc.GREEN, wcc.YELLOW, wcc.PINK],
                [wcc.WWHITE, wcc.BLACK, wcc.BLACK],
                [wcc.BLACK, wcc.Color(30,30,30), wcc.Color(30,30,30)]]
        self.color_mode_pos = 0
        self.rb_pos = 0  # index position for "rainbow"-mode
        try:
            self.brightness_mode_pos = config.getint('wordclock_display',
                                                     'brightness')
        except:
            print(
                'WARNING: Brightness value not set in config-file: To do so, add a "brightness" between 1..255 to the [wordclock_display]-section.'
            )
            self.brightness_mode_pos = 255
        self.brightness_change = 8
Exemplo n.º 7
0
 def run(self, wcd, wci):
     '''
     Displays time until aborted by user interaction on pin button_return
     '''
     while True:
         # Set background color
         wcd.setColorToAll(self.bg_color, includeMinutes=True)
         # Set current time
         now = datetime.datetime.now()
         # Returns indices, which represent the current time, when beeing illuminated
         taw_indices = self.taw.get_time(now)
         #TODO: Improve rendering of time during while-loop: Render array only once per 5 minutes...
         wcd.setColorBy1DCoordinates(wcd.strip, taw_indices,
                                     self.word_color)
         wcd.setMinutes(now, self.minute_color)
         wcd.show()
         event = wci.waitSecondsForEvent(
             [wci.button_left, wci.button_return, wci.button_right], 10)
         # Switch display color, if button_left is pressed
         if (event == wci.button_left):
             self.color_mode_pos += 1
             if self.color_mode_pos == len(self.color_modes):
                 self.color_mode_pos = 0
             self.bg_color = self.color_modes[self.color_mode_pos][0]
             self.word_color = self.color_modes[self.color_mode_pos][1]
             self.minute_color = self.color_modes[self.color_mode_pos][2]
             time.sleep(0.2)
         # Return to main menu, if button_return is pressed
         if (event == wci.button_return):
             return
         if (event == wci.button_right):
             self.bg_color = wcc.BLACK
             wcd.setColorToAll(self.bg_color, includeMinutes=True)
             while wci.getPinState(wci.button_right):
                 # BEGIN: Rainbow generation as done in rpi_ws281x strandtest example! Thanks to Tony DiCola for providing :)
                 if self.rb_pos < 85:
                     self.word_color = self.minute_color = wcc.Color(
                         3 * self.rb_pos, 255 - 3 * self.rb_pos, 0)
                 elif self.rb_pos < 170:
                     self.word_color = self.minute_color = wcc.Color(
                         255 - 3 * (self.rb_pos - 85), 0,
                         3 * (self.rb_pos - 85))
                 else:
                     self.word_color = self.minute_color = wcc.Color(
                         0, 3 * (self.rb_pos - 170),
                         255 - 3 * (self.rb_pos - 170))
                 # END: Rainbow generation as done in rpi_ws281x strandtest example! Thanks to Tony DiCola for providing :)
                 wcd.setColorBy1DCoordinates(wcd.strip, taw_indices,
                                             self.word_color)
                 wcd.setMinutes(now, self.minute_color)
                 wcd.show()
                 self.rb_pos += 1
                 if self.rb_pos == 256: self.rb_pos = 0
                 time.sleep(0.02)
Exemplo n.º 8
0
 def wheel(self, pos):
     """
     Generate rainbow colors across 0-255 positions.
     """
     if pos < 85:
         return wcc.Color(pos * 3, 255 - pos * 3, 0)
     elif pos < 170:
         pos -= 85
         return wcc.Color(255 - pos * 3, 0, pos * 3)
     else:
         pos -= 170
         return wcc.Color(0, pos * 3, 255 - pos * 3)
Exemplo n.º 9
0
 def color_selection(self, wcd, wci):
     while True:
         # BEGIN: Rainbow generation as done in rpi_ws281x strandtest example! Thanks to Tony DiCola for providing :)
         if self.rb_pos < 85:
             self.word_color = self.minute_color = wcc.Color(
                 3 * self.rb_pos, 255 - 3 * self.rb_pos, 0)
         elif self.rb_pos < 170:
             self.word_color = self.minute_color = wcc.Color(
                 255 - 3 * (self.rb_pos - 85), 0, 3 * (self.rb_pos - 85))
         else:
             self.word_color = self.minute_color = wcc.Color(
                 0, 3 * (self.rb_pos - 170), 255 - 3 * (self.rb_pos - 170))
         # END: Rainbow generation as done in rpi_ws281x strandtest example! Thanks to Tony DiCola for providing :)
         # TODO: Evaluate taw_indices only every n-th loop (saving resources)
         now = datetime.datetime.now()  # Set current time
         taw_indices = wcd.taw.get_time(now, self.purist)
         wcd.setColorToAll(self.bg_color, includeMinutes=True)
         wcd.setColorBy1DCoordinates(wcd.strip, taw_indices,
                                     self.word_color)
         wcd.setMinutes(now, self.minute_color)
         wcd.show()
         self.rb_pos += 1
         if self.rb_pos == 256: self.rb_pos = 0
         event = wci.waitForEvent(0.1)
         if event != wci.EVENT_INVALID:
             time.sleep(wci.lock_time)
             break
     if not self.use_brightness_sensor:
         while True:
             self.brightness_mode_pos += self.brightness_change
             # TODO: Evaluate taw_indices only every n-th loop (saving resources)
             now = datetime.datetime.now()  # Set current time
             taw_indices = wcd.taw.get_time(now, self.purist)
             wcd.setColorToAll(self.bg_color, includeMinutes=True)
             wcd.setColorBy1DCoordinates(wcd.strip, taw_indices,
                                         self.word_color)
             wcd.setMinutes(now, self.minute_color)
             wcd.setBrightness(self.brightness_mode_pos)
             wcd.show()
             if self.brightness_mode_pos < abs(
                     self.brightness_change
             ) or self.brightness_mode_pos > 255 - abs(
                     self.brightness_change):
                 self.brightness_change *= -1
             event = wci.waitForEvent(0.1)
             if event != wci.EVENT_INVALID:
                 time.sleep(wci.lock_time)
                 return
Exemplo n.º 10
0
    def __init__(self, config):
        """
        Initializations for the startup of the current wordclock plugin
        """
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.pretty_name = "Tetris"
        self.description = "For the players."

        self.bg_color = wcc.BLACK

        self.bricks = [
            brick([[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
                  wcc.Color(255, 0, 0)),
            brick([[1, 0, 0], [1, 1, 1], [0, 0, 0]], wcc.Color(255, 255, 0)),
            brick([[0, 0, 1], [1, 1, 1], [0, 0, 0]], wcc.Color(0, 0, 255)),
            brick([[1, 1], [1, 1]], wcc.Color(255, 0, 255)),
            brick([[0, 1, 1], [
                1,
                1,
                0,
            ], [0, 0, 0]], wcc.Color(0, 255, 255)),
            brick([[0, 1, 0], [1, 1, 1], [0, 0, 0]], wcc.Color(0, 255, 0)),
            brick([[1, 1, 0], [0, 1, 1], [0, 0, 0]], wcc.Color(255, 255, 255))
        ]
Exemplo n.º 11
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]

        self.bg_color = wcc.BLACK

        self.threshold = 0.9

        # Colors from black to green (and a bit gray-ish)
        self.colors = []
        for i in range(0, 8):
            self.colors.append(wcc.Color(0, int(255.0 / 10 * i), 0))
        self.colors.append(wcc.Color(50, 204, 30))
        self.colors.append(wcc.Color(50, 230, 30))
        self.colors.append(wcc.Color(80, 255, 60))
Exemplo n.º 12
0
 def setImage(self, absPathToImage):
     """
     Set image (provided as absolute path) to current display
     """
     img = Image.open(absPathToImage)
     width, height = img.size
     for x in range(0, width):
         for y in range(0, height):
             rgb_img = img.convert('RGB')
             r, g, b = rgb_img.getpixel((x, y))
             self.setColorBy2DCoordinates(x, y, wcc.Color(r, g, b))
     self.show()
Exemplo n.º 13
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]

        # Choose language
        language = config.get('plugin_' + self.name, 'language')
        if language == 'german':
            self.taw = time_german.time_german()
        elif language == 'swabian':
            self.taw = time_swabian.time_swabian()
        elif language == 'dutch':
            self.taw = time_dutch.time_dutch()
        else:
            print('Could not detect language: ' + language + '.')
            print('Choosing default: german')
            self.taw = time_german.time_german()

        self.bg_color = wcc.BLACK  # default background color
        self.word_color = wcc.WWHITE  # default word color
        self.minute_color = wcc.WWHITE  # default minute color

        # Other color modes...
        self.color_modes = \
               [[wcc.BLACK, wcc.WWHITE, wcc.WWHITE],
                [wcc.BLACK, wcc.WHITE, wcc.WHITE],
                [wcc.BLACK, wcc.PINK, wcc.GREEN],
                [wcc.BLACK, wcc.RED, wcc.YELLOW],
                [wcc.BLACK, wcc.BLUE, wcc.RED],
                [wcc.BLACK, wcc.RED, wcc.BLUE],
                [wcc.YELLOW, wcc.RED, wcc.BLUE],
                [wcc.RED, wcc.BLUE, wcc.BLUE],
                [wcc.RED, wcc.WHITE, wcc.WHITE],
                [wcc.GREEN, wcc.YELLOW, wcc.PINK],
                [wcc.WWHITE, wcc.BLACK, wcc.BLACK],
                [wcc.BLACK, wcc.Color(30,30,30), wcc.Color(30,30,30)]]
        self.color_mode_pos = 0
        self.rb_pos = 0  # index position for "rainbow"-mode
Exemplo n.º 14
0
    def drawSnakeCell(self, sn, snakeBoard, row, col, headRow, headCol, wcd):
        wcd.setColorBy2DCoordinates(col, row, wcc.BLACK)

        if ((row == headRow) and (headCol == col)):
            # draw snake body head
            wcd.setColorBy2DCoordinates(col, row, wcc.YELLOW)  #Green
        elif (snakeBoard[row][col] > 0):
            # draw part of the snake body
            wcd.setColorBy2DCoordinates(col, row, wcc.Color(34, 177,
                                                            76))  #Green
        elif (snakeBoard[row][col] < 0):
            # draw food
            wcd.setColorBy2DCoordinates(col, row, wcc.RED)
Exemplo n.º 15
0
    def __init__(self, config):
        """
        Initializations for the startup of the current wordclock plugin
        """
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.pretty_name = "Matrix with time"
        self.description = "There is no spoon?"

        self.bg_color = wcc.BLACK  # default background color
        self.word_color = wcc.WHITE  # default word color
        self.minute_color = wcc.WHITE  # default minute color

        self.threshold = 0.9

        # Colors from black to green (and a bit gray-ish)
        self.colors = []
        for i in range(0, 8):
            self.colors.append(wcc.Color(0, int(255.0 / 10 * i), 0))
        self.colors.append(wcc.Color(50, 204, 30))
        self.colors.append(wcc.Color(50, 230, 30))
        self.colors.append(wcc.Color(80, 255, 60))
Exemplo n.º 16
0
    def show_time(self, wcd, wci, currentSecond):
        # Set background color
        wcd.setColorToAll(self.bg_color, includeMinutes=True)
        #show seconds based on numbers defined in time_seconds
	for i in range(110, -1, -110/11):
		#previous seconds, dimming down
		taw_indices = self.taw.get_time(currentSecond-1 if currentSecond != 0 else 59)
		wcd.setColorBy1DCoordinates(wcd.strip, taw_indices, wcc.Color(i, i, i))
		#current seconds
		taw_indices = self.taw.get_time(currentSecond)
		wcd.setColorBy1DCoordinates(wcd.strip, taw_indices, self.word_color)
		wcd.show()
		time.sleep(0.05)
Exemplo n.º 17
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.bg_color = wcc.BLACK
        self.word_color = wcc.ORANGE
        self.color = wcc.Color(212, 165, 25)

        self.threshold = 0.9

        self.pretty_name = "Lichtzeitpegel"
        self.description = "Wie Rheinturm nur nebeneinander"
Exemplo n.º 18
0
    def post(self):
        supplied_color = wcc.Color(web_interface.api.payload.get('red'),
                                   web_interface.api.payload.get('green'),
                                   web_interface.api.payload.get('blue'))

        supplied_type = web_interface.api.payload.get('type')
        supplied_type = 'all' if supplied_type is None else supplied_type

        default_plugin_idx = web_interface.app.wclk.default_plugin
        web_interface.app.wclk.runNext(default_plugin_idx)
        default_plugin = web_interface.app.wclk.plugins[default_plugin_idx]
        if supplied_type == 'all':
            default_plugin.bg_color = wcc.BLACK
            default_plugin.word_color = supplied_color
            default_plugin.minute_color = supplied_color
        elif supplied_type == 'words':
            default_plugin.word_color = supplied_color
        elif supplied_type == 'minutes':
            default_plugin.minute_color = supplied_color
        elif supplied_type == 'background':
            default_plugin.bg_color = supplied_color
        default_plugin.show_time(web_interface.app.wclk.wcd, web_interface.app.wclk.wci, animation=None)
        return "Wordclock color set to " + supplied_type
Exemplo n.º 19
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]

        self.bg_color = wcc.BLACK

        self.bricks = [
            brick([[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
                  wcc.Color(255, 0, 0)),
            brick([[1, 0, 0], [1, 1, 1], [0, 0, 0]], wcc.Color(255, 255, 0)),
            brick([[0, 0, 1], [1, 1, 1], [0, 0, 0]], wcc.Color(0, 0, 255)),
            brick([[1, 1], [1, 1]], wcc.Color(255, 0, 255)),
            brick([[0, 1, 1], [
                1,
                1,
                0,
            ], [0, 0, 0]], wcc.Color(0, 255, 255)),
            brick([[0, 1, 0], [1, 1, 1], [0, 0, 0]], wcc.Color(0, 255, 0)),
            brick([[1, 1, 0], [0, 1, 1], [0, 0, 0]], wcc.Color(255, 255, 255))
        ]
Exemplo n.º 20
0
    def __init__(self, config):
        """
        Initializations for the startup of the current wordclock plugin
        """
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.pretty_name = "The time"
        self.description = "The minimum, you should expect from a wordclock."

        # For backward compatibility
        try:
            typewriter = config.getboolean('plugin_' + self.name, 'typewriter')
        except:
            typewriter = False

        # animation
        if typewriter:
            self.animation = "typewriter"
        else:
            try:
                self.animation = ''.join(
                    config.get('plugin_' + self.name, 'animation'))
            except:
                self.animation = "fadeOutIn"

        animations = ["fadeOutIn", "typewriter", "none"]

        if self.animation not in animations:
            logging.warning(
                'No animation set for default plugin within the config-file. '
                + animations[0] + ' animation will be used.')
            self.animation = animations[0]

        try:
            self.animation_speed = config.getint('plugin_' + self.name,
                                                 'animation_speed')
        except:
            self.animation_speed = 5
            logging.warning(
                'No animation_speed set for default plugin within the config-file. Defaulting to '
                + str(self.animation_speed) + '.')

        try:
            self.purist = config.getboolean('plugin_time_default', 'purist')
        except:
            logging.warning(
                'No purist-flag set for default plugin within the config-file. Prefix will be displayed.'
            )
            self.purist = False

        # sleep mode
        try:
            self.sleep_begin = datetime.time(
                config.getint('plugin_' + self.name, 'sleep_begin_hour'),
                config.getint('plugin_' + self.name, 'sleep_begin_minute'), 0)
        except:
            self.sleep_begin = datetime.time(0, 0, 0)
            self.sleep_end = datetime.time(0, 0, 0)
            logging.warning(
                '  No sleeping time set, display will stay bright 24/7.')

        try:
            self.sleep_end = datetime.time(
                config.getint('plugin_' + self.name, 'sleep_end_hour'),
                config.getint('plugin_' + self.name, 'sleep_end_minute'), 0)
        except:
            self.sleep_begin = datetime.time(0, 0, 0)
            self.sleep_end = datetime.time(0, 0, 0)
            logging.warning(
                '  No sleeping time set, display will stay bright 24/7.')

        try:
            self.sleep_brightness = config.getint('plugin_' + self.name,
                                                  'sleep_brightness')
        except:
            self.sleep_brightness = 5
            logging.warning(
                '  No sleep brightness set within the config-file. Defaulting to '
                + str(self.sleep_brightness) + '.')

        # if left/right button is pressed during sleep cycle, the current sleep cycle is skipped for the rest of the night
        # to allow manual override
        self.skip_sleep = False
        self.is_sleep = False

        # monitor sleep mode changes to apply brightness
        self.sleep_switch = False

        # Choose default fgcolor
        try:
            fgcolor = ''.join(config.get('wordclock', 'default-fg-color'))
        except:
            # For backward compatibility
            fgcolor = ''.join(
                config.get('plugin_time_default', 'default-fg-color'))

        if fgcolor == 'BLACK':
            self.word_color = wcc.BLACK
            self.minute_color = wcc.BLACK
        elif fgcolor == 'WHITE':
            self.word_color = wcc.WHITE
            self.minute_color = wcc.WHITE
        elif fgcolor == 'WWHITE':
            self.word_color = wcc.WWHITE
            self.minute_color = wcc.WWHITE
        elif fgcolor == 'RED':
            self.word_color = wcc.RED
            self.minute_color = wcc.RED
        elif fgcolor == 'YELLOW':
            self.word_color = wcc.YELLOW
            self.minute_color = wcc.YELLOW
        elif fgcolor == 'LIME':
            self.word_color = wcc.LIME
            self.minute_color = wcc.LIME
        elif fgcolor == 'GREEN':
            self.word_color = wcc.GREEN
            self.minute_color = wcc.GREEN
        elif fgcolor == 'BLUE':
            self.word_color = wcc.BLUE
            self.minute_color = wcc.BLUE
        else:
            print('Could not detect default-fg-color: ' + fgcolor + '.')
            print('Choosing default: warm white')
            self.word_color = wcc.WWHITE
            self.minute_color = wcc.WWHITE

        # Choose default bgcolor
        try:
            bgcolor = ''.join(config.get('wordclock', 'default-bg-color'))
        except:
            # For backward compatibility
            bgcolor = ''.join(
                config.get('plugin_time_default', 'default-bg-color'))

        if bgcolor == 'BLACK':
            self.bg_color = wcc.BLACK
        elif bgcolor == 'WHITE':
            self.bg_color = wcc.WHITE
        elif bgcolor == 'WWHITE':
            self.bg_color = wcc.WWHITE
        elif bgcolor == 'RED':
            self.bg_color = wcc.RED
        elif bgcolor == 'YELLOW':
            self.bg_color = wcc.YELLOW
        elif bgcolor == 'LIME':
            self.bg_color = wcc.LIME
        elif bgcolor == 'GREEN':
            self.bg_color = wcc.GREEN
        elif bgcolor == 'BLUE':
            self.bg_color = wcc.BLUE
        else:
            print('Could not detect default-bg-color: ' + bgcolor + '.')
            print('Choosing default: black')
            self.bg_color = wcc.BLACK

        # Other color modes...
        self.color_modes = \
            [[wcc.BLACK, wcc.WWHITE, wcc.WWHITE],
             [wcc.BLACK, wcc.WHITE, wcc.WHITE],
             [wcc.BLACK, wcc.ORANGE, wcc.ORANGE],
             [wcc.BLACK, wcc.ORANGE, wcc.WWHITE],
             [wcc.BLACK, wcc.PINK, wcc.GREEN],
             [wcc.BLACK, wcc.RED, wcc.YELLOW],
             [wcc.BLACK, wcc.BLUE, wcc.RED],
             [wcc.BLACK, wcc.RED, wcc.BLUE],
             [wcc.YELLOW, wcc.RED, wcc.BLUE],
             [wcc.RED, wcc.BLUE, wcc.BLUE],
             [wcc.RED, wcc.WHITE, wcc.WHITE],
             [wcc.GREEN, wcc.YELLOW, wcc.PINK],
             [wcc.WWHITE, wcc.BLACK, wcc.BLACK],
             [wcc.BLACK, wcc.Color(30, 30, 30), wcc.Color(30, 30, 30)]]
        self.color_mode_pos = 0
        self.rb_pos = 0  # index position for "rainbow"-mode
        try:
            self.brightness_mode_pos = config.getint('wordclock_display',
                                                     'brightness')
        except:
            logging.warning(
                "Brightness value not set in config-file: To do so, add a \"brightness\" between 1..255 to the [wordclock_display]-section."
            )
            self.brightness_mode_pos = 255
        self.brightness_change = 8

        # save current brightness for switching back from sleep mode
        self.wake_brightness = self.brightness_mode_pos
Exemplo n.º 21
0
 def apply_brightness(self, color):
     [h, s, v] = colorsys.rgb_to_hsv(color.r/255.0, color.g/255.0, color.b/255.0)
     [r, g, b] = colorsys.hsv_to_rgb(h, s, v * self.brightness/255.0)
     return wcc.Color(int(r*255.0), int(g*255.0), int(b*255.0))
Exemplo n.º 22
0
    def __init__(self, config):
        '''
        Initializations for the startup of the current wordclock plugin
        '''
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.pretty_name = "The time"
        self.description = "The minimum, you should expect from a wordclock."

        # Choose language
        language = config.get('plugin_' + self.name, 'language')
        if language == 'dutch':
            self.taw = time_dutch.time_dutch()
        elif language == 'english':
            self.taw = time_english.time_english()
        elif language == 'german':
            self.taw = time_german.time_german()
        elif language == 'swabian':
            self.taw = time_swabian.time_swabian()
        elif language == 'bavarian':
            self.taw = time_bavarian.time_bavarian()
        elif language == 'swiss_german':
            self.taw = time_swiss_german.time_swiss_german()
        elif language == 'swiss_german2':
            self.taw = time_swiss_german2.time_swiss_german2()
        elif language == 'french':
            self.taw = time_french.time_french()
        else:
            print('Could not detect language: ' + language + '.')
            print('Choosing default: german')
            self.taw = time_english.time_english()

        try:
            self.typewriter = config.getboolean('plugin_' + self.name, 'typewriter')
        except:
            print('  No typewriter-flag set for default plugin within the config-file. Typewriter animation will be used.')
            self.typewriter = True

        try:
            self.typewriter_speed = config.getint('plugin_' + self.name, 'typewriter_speed')
        except:
            self.typewriter_speed = 5
            print('  No typewriter_speed set for default plugin within the config-file. Defaulting to ' + str(self.typewriter_speed) + '.')

        self.bg_color     = wcc.BLACK  # default background color
        self.word_color   = wcc.WWHITE # default word color
        self.minute_color = wcc.WWHITE # default minute color

        # Other color modes...
        self.color_modes = \
               [[wcc.BLACK, wcc.WWHITE, wcc.WWHITE],
                [wcc.BLACK, wcc.WHITE, wcc.WHITE],
                [wcc.BLACK, wcc.ORANGE, wcc.ORANGE],
                [wcc.BLACK, wcc.ORANGE, wcc.WWHITE],
                [wcc.BLACK, wcc.PINK, wcc.GREEN],
                [wcc.BLACK, wcc.RED, wcc.YELLOW],
                [wcc.BLACK, wcc.BLUE, wcc.RED],
                [wcc.BLACK, wcc.RED, wcc.BLUE],
                [wcc.YELLOW, wcc.RED, wcc.BLUE],
                [wcc.RED, wcc.BLUE, wcc.BLUE],
                [wcc.RED, wcc.WHITE, wcc.WHITE],
                [wcc.GREEN, wcc.YELLOW, wcc.PINK],
                [wcc.WWHITE, wcc.BLACK, wcc.BLACK],
                [wcc.BLACK, wcc.Color(30,30,30), wcc.Color(30,30,30)]]
        self.color_mode_pos = 0
        self.rb_pos = 0 # index position for "rainbow"-mode
        try:
            self.brightness_mode_pos = config.getint('wordclock_display', 'brightness')
        except:
            print('WARNING: Brightness value not set in config-file: To do so, add a "brightness" between 1..255 to the [wordclock_display]-section.')
            self.brightness_mode_pos = 255
        self.brightness_change = 8
Exemplo n.º 23
0
    def __init__(self, config):
        """
        Initializations for the startup of the current wordclock plugin
        """
        # Get plugin name (according to the folder, it is contained in)
        self.name = os.path.dirname(__file__).split('/')[-1]
        self.pretty_name = "The time"
        self.description = "The minimum, you should expect from a wordclock."

        # typewriter effect
        try:
            self.typewriter = config.getboolean('plugin_' + self.name,
                                                'typewriter')
        except:
            print(
                '  No typewriter-flag set for default plugin within the config-file. Typewriter animation will be used.'
            )
            self.typewriter = True

        try:
            self.typewriter_speed = config.getint('plugin_' + self.name,
                                                  'typewriter_speed')
        except:
            self.typewriter_speed = 5
            print(
                '  No typewriter_speed set for default plugin within the config-file. Defaulting to '
                + str(self.typewriter_speed) + '.')
        try:
            self.purist = config.getboolean('plugin_time_default', 'purist')
        except:
            print(
                '  No purist-flag set for default plugin within the config-file. Prefix will be displayed.'
            )
            self.purist = False

        # sleep mode
        try:
            self.sleep_begin = datetime.time(
                config.getint('plugin_' + self.name, 'sleep_begin_hour'),
                config.getint('plugin_' + self.name, 'sleep_begin_minute'), 0)
        except:
            self.sleep_begin = datetime.time(0, 0, 0)
            self.sleep_end = datetime.time(0, 0, 0)
            print('  No sleeping time set, display will stay bright 24/7.')

        try:
            self.sleep_end = datetime.time(
                config.getint('plugin_' + self.name, 'sleep_end_hour'),
                config.getint('plugin_' + self.name, 'sleep_end_minute'), 0)
        except:
            self.sleep_begin = datetime.time(0, 0, 0)
            self.sleep_end = datetime.time(0, 0, 0)
            print('  No sleeping time set, display will stay bright 24/7.')

        try:
            self.sleep_brightness = config.getint('plugin_' + self.name,
                                                  'sleep_brightness')
        except:
            self.sleep_brightness = 5
            print(
                '  No sleep brightness set within the config-file. Defaulting to '
                + str(self.sleep_brightness) + '.')

        # if left/right button is pressed during sleep cycle, the current sleep cycle is skipped for the rest of the night
        # to allow manual override
        self.skip_sleep = False
        self.is_sleep = False

        self.bg_color = wcc.BLACK  # default background color
        self.word_color = wcc.WWHITE  # default word color
        self.minute_color = wcc.WWHITE  # default minute color

        # Other color modes...
        self.color_modes = \
            [[wcc.BLACK, wcc.WWHITE, wcc.WWHITE],
             [wcc.BLACK, wcc.WHITE, wcc.WHITE],
             [wcc.BLACK, wcc.ORANGE, wcc.ORANGE],
             [wcc.BLACK, wcc.ORANGE, wcc.WWHITE],
             [wcc.BLACK, wcc.PINK, wcc.GREEN],
             [wcc.BLACK, wcc.RED, wcc.YELLOW],
             [wcc.BLACK, wcc.BLUE, wcc.RED],
             [wcc.BLACK, wcc.RED, wcc.BLUE],
             [wcc.YELLOW, wcc.RED, wcc.BLUE],
             [wcc.RED, wcc.BLUE, wcc.BLUE],
             [wcc.RED, wcc.WHITE, wcc.WHITE],
             [wcc.GREEN, wcc.YELLOW, wcc.PINK],
             [wcc.WWHITE, wcc.BLACK, wcc.BLACK],
             [wcc.BLACK, wcc.Color(30, 30, 30), wcc.Color(30, 30, 30)]]
        self.color_mode_pos = 0
        self.rb_pos = 0  # index position for "rainbow"-mode
        try:
            self.brightness_mode_pos = config.getint('wordclock_display',
                                                     'brightness')
        except:
            print(
                "WARNING: Brightness value not set in config-file: To do so, add a \"brightness\" between 1..255 to the [wordclock_display]-section."
            )
            self.brightness_mode_pos = 255
        self.brightness_change = 8

        try:
            self.use_brightness_sensor = config.getboolean(
                'wordclock_display', 'use_brightness_sensor')
        except:
            print('Not found brigtness sensor value ')
            self.use_brightness_sensor = False

        print('Using brigtness sensor : ' + str(self.use_brightness_sensor))
        if self.use_brightness_sensor:
            print('Importing sensor Library ')
            import Adafruit_GPIO.I2C as I2C
            address = 0x39  ## Device address
            self.i2c = I2C.Device(address, 1)
        # save current brightness for switching back from sleep mode
        self.wake_brightness = self.brightness_mode_pos