def __init__(self, config): ''' Initializations for the startup of the weather forecast ''' # Get plugin name (according to the folder, it is contained in) self.name = os.path.dirname(__file__).split('/')[-1] self.astral_at_location = Astral()[config.get('plugin_' + self.name, 'location')] # Choose language to display sunrise language = config.get('plugin_time_default', 'language') if language == 'german': self.taw = wcp_time_german.time_german() elif language == 'dutch': self.taw = wcp_time_dutch.time_dutch() elif language == 'swiss_german': self.taw = wcp_swiss_german.time_swiss_german() else: print('Could not detect language: ' + language + '.') print('Choosing default: german') self.taw = wcp_time_german.time_german() self.bg_color_index = 0 # default background color: black self.word_color_index = 2 # default word color: warm white self.minute_color_index = 2 # default minute color: warm white
def __init__(self, config): ''' Initializations for the startup of the weather forecast ''' # Get plugin name (according to the folder, it is contained in) self.name = os.path.dirname(__file__).split('/')[-1] self.pretty_name = "Sunrise" self.description = "Displays the current times of sunrise and sunset." self.astral_at_location = Astral()[config.get('plugin_' + self.name, 'location')] # Choose language to display sunrise language = config.get('plugin_time_default', 'language') if language == 'german': self.taw = wcp_time_german.time_german() elif language == 'dutch': self.taw = wcp_time_dutch.time_dutch() elif language == 'swiss_german': self.taw = wcp_swiss_german.time_swiss_german() else: print('Could not detect language: ' + language + '.') print('Choosing default: german') self.taw = wcp_time_german.time_german() self.bg_color_index = 0 # default background color: black self.word_color_index = 2 # default word color: warm white self.minute_color_index = 2 # default minute color: warm white
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() 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.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))
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()