def __init__(self, config):
        '''
        Initalization
        '''
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring(config)

        # Create NeoPixel object with appropriate configuration.
        try:
            brightness = 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.')
            brightness = 255
        try:
            self.strip = Adafruit_NeoPixel(self.wcl.LED_COUNT, self.wcl.LED_PIN, self.wcl.LED_FREQ_HZ, self.wcl.LED_DMA, self.wcl.LED_INVERT, brightness)
        except:
            print('WARNING: Your NeoPixel dependency is to old to accept customized brightness values')
            self.strip = Adafruit_NeoPixel(self.wcl.LED_COUNT, self.wcl.LED_PIN, self.wcl.LED_FREQ_HZ, self.wcl.LED_DMA, self.wcl.LED_INVERT)

        # Initialize the NeoPixel object
        self.strip.begin()

        self.default_font = os.path.join('/usr/share/fonts/truetype/freefont/', config.get('wordclock_display', 'default_font') + '.ttf')
        self.default_fg_color=wcc.WWHITE
        self.default_bg_color=wcc.BLACK
        self.base_path=config.get('wordclock', 'base_path')
    def __init__(self, config, wci):
        """
        Initialization
        """
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring(config)
        self.wci = wci
        try:
            default_brightness = config.getint('wordclock_display',
                                               'brightness')
        except:
            default_brightness = 255
            print(
                'WARNING: Default brightness value not set in config-file: '
                'To do so, add a "brightness" between 1..255 to the [wordclock_display]-section.'
            )

        if config.getboolean('wordclock', 'developer_mode'):
            from GTKstrip import GTKstrip
            self.strip = GTKstrip(wci)
            self.default_font = os.path.join(
                '/usr/share/fonts/TTF/',
                config.get('wordclock_display', 'default_font') + '.ttf')
        else:
            try:
                from neopixel import Adafruit_NeoPixel, ws
                self.strip = Adafruit_NeoPixel(
                    self.wcl.LED_COUNT, self.wcl.LED_PIN, self.wcl.LED_FREQ_HZ,
                    self.wcl.LED_DMA, self.wcl.LED_INVERT, default_brightness,
                    0, ws.WS2811_STRIP_GRB)
            except:
                print(
                    'Update deprecated external dependency rpi_ws281x. '
                    'For details see also https://github.com/jgarff/rpi_ws281x/blob/master/python/README.md'
                )

            self.default_font = os.path.join(
                '/usr/share/fonts/truetype/freefont/',
                config.get('wordclock_display', 'default_font') + '.ttf')

        # Initialize the NeoPixel object
        self.strip.begin()

        self.default_fg_color = wcc.WWHITE
        self.default_bg_color = wcc.BLACK
        self.base_path = config.get('wordclock', 'base_path')
    def __init__(self, config):
        '''
        Initalization
        '''
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring(config)

        # Create NeoPixel object with appropriate configuration.
        try:
            brightness = 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.'
            )
            brightness = 255
        try:
            self.strip = Adafruit_NeoPixel(self.wcl.LED_COUNT,
                                           self.wcl.LED_PIN,
                                           self.wcl.LED_FREQ_HZ,
                                           self.wcl.LED_DMA,
                                           self.wcl.LED_INVERT, brightness, 0,
                                           ws.WS2811_STRIP_GRB)
        except:
            print(
                'WARNING: Your NeoPixel dependency is to old to accept customized brightness values and correct RGB-settings.'
            )
            self.strip = Adafruit_NeoPixel(self.wcl.LED_COUNT,
                                           self.wcl.LED_PIN,
                                           self.wcl.LED_FREQ_HZ,
                                           self.wcl.LED_DMA,
                                           self.wcl.LED_INVERT)

        # Initialize the NeoPixel object
        self.strip.begin()

        self.default_font = os.path.join(
            '/usr/share/fonts/truetype/freefont/',
            config.get('wordclock_display', 'default_font') + '.ttf')
        self.default_fg_color = wcc.WWHITE
        self.default_bg_color = wcc.BLACK
        self.base_path = config.get('wordclock', 'base_path')
Exemple #4
0
    def __init__(self, config):
        '''
        Initalization
        '''
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring(config)

        # Create NeoPixel object with appropriate configuration.
        self.strip = Adafruit_NeoPixel(self.wcl.LED_COUNT, self.wcl.LED_PIN,
                                       self.wcl.LED_FREQ_HZ, self.wcl.LED_DMA,
                                       self.wcl.LED_INVERT)

        # Initialize the NeoPixel object
        self.strip.begin()

        self.default_font = os.path.join(
            '/usr/share/fonts/truetype/freefont/',
            config.get('wordclock_display', 'default_font') + '.ttf')
        self.default_fg_color = wcc.WWHITE
        self.default_bg_color = wcc.BLACK
        self.base_path = config.get('wordclock', 'base_path')
    def __init__(self):
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring()

        brightness = 20

        try:
            self.strip = Adafruit_NeoPixel(self.wcl.LED_COUNT,
                                           self.wcl.LED_PIN,
                                           self.wcl.LED_FREQ_HZ,
                                           self.wcl.LED_DMA,
                                           self.wcl.LED_INVERT, brightness)
        except:
            print(
                'WARNING: Your NeoPixel dependency is too old to accept customized brightness values'
            )
            self.strip = Adafruit_NeoPixel(self.wcl.LED_COUNT,
                                           self.wcl.LED_PIN,
                                           self.wcl.LED_FREQ_HZ,
                                           self.wcl.LED_DMA,
                                           self.wcl.LED_INVERT)

        # Initialize the NeoPixel object
        self.strip.begin()
    def __init__(self, config, wci):
        """
        Initialization
        """
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring(config)
        self.wci = wci
        self.config = config
        self.base_path = config.get('wordclock', 'base_path')
        max_brightness = 255

        try:
            self.setBrightness(config.getint('wordclock_display',
                                             'brightness'))
        except:
            self.brightness = max_brightness
            print(
                'WARNING: Default brightness value not set in config-file: '
                'To do so, add a "brightness" between 1..255 to the [wordclock_display]-section.'
            )

        if config.getboolean('wordclock', 'developer_mode'):
            from GTKstrip import GTKstrip
            self.strip = GTKstrip(wci)
            self.default_font = 'wcfont.ttf'
        else:
            try:
                from neopixel import Adafruit_NeoPixel, ws
                self.strip = Adafruit_NeoPixel(
                    self.wcl.LED_COUNT, self.wcl.LED_PIN, self.wcl.LED_FREQ_HZ,
                    self.wcl.LED_DMA, self.wcl.LED_INVERT, max_brightness, 0,
                    ws.WS2811_STRIP_GRB)
            except:
                print(
                    'Update deprecated external dependency rpi_ws281x. '
                    'For details see also https://github.com/jgarff/rpi_ws281x/blob/master/python/README.md'
                )

            if config.get('wordclock_display', 'default_font') == 'wcfont':
                self.default_font = self.base_path + '/wcfont.ttf'
            else:
                self.default_font = os.path.join(
                    '/usr/share/fonts/truetype/freefont/',
                    config.get('wordclock_display', 'default_font') + '.ttf')

        # Initialize the NeoPixel object
        self.strip.begin()

        self.default_fg_color = wcc.WWHITE
        self.default_bg_color = wcc.BLACK

        # Choose language
        try:
            language = ''.join(config.get('wordclock_display', 'language'))
        except:
            # For backward compatibility
            language = ''.join(config.get('plugin_time_default', 'language'))

        print('  Setting language to ' + language + '.')
        if language == 'dutch':
            self.taw = time_dutch.time_dutch()
        elif language == 'english':
            self.taw = time_english.time_english()
        elif language == 'english_c3jr':
            self.taw = time_english_c3jr.time_english()
        elif language == 'german':
            self.taw = time_german.time_german()
        elif language == 'german2':
            self.taw = time_german2.time_german2()
        elif language == 'swabian':
            self.taw = time_swabian.time_swabian()
        elif language == 'swabian2':
            self.taw = time_swabian2.time_swabian2()
        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()
        else:
            print('Could not detect language: ' + language + '.')
            print('Choosing default: german')
            self.taw = time_german.time_german()
    def __init__(self, config, wci):
        """
        Initialization
        """
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring(config)
        self.wci = wci

        self.transition_cache_next = wordclock_screen.wordclock_screen(self)
        self.transition_cache_curr = wordclock_screen.wordclock_screen(self)

        self.config = config
        self.base_path = config.get('wordclock', 'base_path')
        self.mutex = Lock()

        try:
            self.setBrightness(config.getint('wordclock_display', 'brightness'))
        except:
            self.brightness = 255
            logging.warning(
                'Default brightness value not set in config-file: To do so, add a "brightness" between 1..255 to the [wordclock_display]-section.')

        if config.getboolean('wordclock', 'developer_mode'):
            import wordclock_strip_gtk as wcs_gtk
            self.strip = wcs_gtk.GTKstrip(wci)
        else:
            import wordclock_strip_neopixel as wcs_neo
            self.strip = wcs_neo.wordclock_strip_neopixel(self.wcl)

        if config.get('wordclock_display', 'default_font') == 'wcfont':
            self.default_font =  self.base_path + '/wcfont.ttf'
        else:
            self.default_font = os.path.join('/usr/share/fonts/truetype/freefont/', config.get('wordclock_display', 'default_font') + '.ttf')

        self.strip.begin()

        self.default_fg_color = wcc.WWHITE
        self.default_bg_color = wcc.BLACK

        # Choose language
        try:
            language = ''.join(config.get('wordclock_display', 'language'))
        except:
            # For backward compatibility
            language = ''.join(config.get('plugin_time_default', 'language'))

        logging.info('Setting language to ' + 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 == 'german2':
            self.taw = time_german2.time_german2()
        elif language == 'swabian':
            self.taw = time_swabian.time_swabian()
        elif language == 'swabian2':
            self.taw = time_swabian2.time_swabian2()
        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()
        else:
            logging.error('Could not detect language: ' + language + '.')
            logging.info('Choosing default: german')
            self.taw = time_german.time_german()
    def __init__(self, config, wci):
        """
        Initialization
        """
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring(config)
        self.wci = wci
        try:
            default_brightness = config.getint('wordclock_display', 'brightness')
        except:
            default_brightness = 255
            print(
                'WARNING: Default brightness value not set in config-file: '
                'To do so, add a "brightness" between 1..255 to the [wordclock_display]-section.')

        if config.getboolean('wordclock', 'developer_mode'):
            from GTKstrip import GTKstrip
            self.strip = GTKstrip(wci)
            self.default_font = os.path.join('/usr/share/fonts/TTF/',
                                             config.get('wordclock_display', 'default_font') + '.ttf')
        else:
            try:
                from neopixel import Adafruit_NeoPixel, ws
                self.strip = Adafruit_NeoPixel(self.wcl.LED_COUNT, self.wcl.LED_PIN, self.wcl.LED_FREQ_HZ,
                                               self.wcl.LED_DMA, self.wcl.LED_INVERT, default_brightness , 0,
                                               ws.WS2811_STRIP_GRB)
            except:
                print('Update deprecated external dependency rpi_ws281x. '
                      'For details see also https://github.com/jgarff/rpi_ws281x/blob/master/python/README.md')

            self.default_font = os.path.join('/usr/share/fonts/truetype/freefont/',
                                             config.get('wordclock_display', 'default_font') + '.ttf')

        # Initialize the NeoPixel object
        self.strip.begin()

        self.default_fg_color = wcc.WWHITE
        self.default_bg_color = wcc.BLACK
        self.base_path = config.get('wordclock', 'base_path')

        # Choose language
        try:
            language = ''.join(config.get('wordclock_display', 'language'))
        except:
            # For backward compatibility
            language = ''.join(config.get('plugin_time_default', 'language'))

        print('  Setting language to ' + 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 == 'german2':
            self.taw = time_german2.time_german2()
        elif language == 'swabian':
            self.taw = time_swabian.time_swabian()
        elif language == 'swabian2':
            self.taw = time_swabian2.time_swabian2()
        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()
        else:
            print('Could not detect language: ' + language + '.')
            print('Choosing default: german')
            self.taw = time_german.time_german()
    def __init__(self, config, wci):
        """
        Initialization
        """
        # Get the wordclocks wiring-layout
        self.wcl = wiring.wiring(config)
        self.wci = wci

        self.transition_cache_next = wordclock_screen.wordclock_screen(self)
        self.transition_cache_curr = wordclock_screen.wordclock_screen(self)

        self.config = config
        self.base_path = config.get('wordclock', 'base_path')
        self.mutex = Lock()

        try:
            self.setBrightness(config.getint('wordclock_display', 'brightness'))
        except:
            self.brightness = 255
            logging.warning(
                'Default brightness value not set in config-file: To do so, add a "brightness" between 1..255 to the [wordclock_display]-section.')

        if config.getboolean('wordclock', 'developer_mode'):
            import wordclock_strip_gtk as wcs_gtk
            self.strip = wcs_gtk.GTKstrip(wci)
        else:
            import wordclock_strip_neopixel as wcs_neo
            self.strip = wcs_neo.wordclock_strip_neopixel(self.wcl)

        if config.get('wordclock_display', 'default_font') == 'wcfont':
            self.default_font =  self.base_path + '/wcfont.ttf'
        else:
            self.default_font = os.path.join('/usr/share/fonts/truetype/freefont/', config.get('wordclock_display', 'default_font') + '.ttf')

        self.strip.begin()

        # Choose default minutes_map
        minutes_map_str = ''.join(config.get('plugin_time_default', 'minutes-map'))
        minutes_map_str_list = minutes_map_str.split(',')
        self.minutes_map = list(map(int, minutes_map_str_list))

        # Choose default fgcolor
        fgcolor = ''.join(config.get('plugin_time_default', 'default-fg-color'))

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

        # Choose default bgcolor
        bgcolor = ''.join(config.get('plugin_time_default', 'default-bg-color'))

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

        # Choose language
        try:
            language = ''.join(config.get('wordclock_display', 'language'))
        except:
            # For backward compatibility
            language = ''.join(config.get('plugin_time_default', 'language'))

        logging.info('Setting language to ' + language + '.')
        if language == 'dutch':
            self.taw = time_dutch.time_dutch()
        elif language == 'english':
            self.taw = time_english.time_english()
        elif language == 'french':
            self.taw = time_french.time_french()
        elif language == 'german':
            self.taw = time_german.time_german()
        elif language == 'german2':
            self.taw = time_german2.time_german2()
        elif language == 'swabian':
            self.taw = time_swabian.time_swabian()
        elif language == 'swabian2':
            self.taw = time_swabian2.time_swabian2()
        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()
        else:
            logging.error('Could not detect language: ' + language + '.')
            logging.info('Choosing default: german')
            self.taw = time_german.time_german()