def __draw_value__(value, x = 24, y = 0): for c in value: if c == ".": lcd.draw_bitmap(icons.POINT, x = x, y = y, w = 7, h = 24) else: lcd.draw_bitmap(icons.NUMBERS[ord(c) - ord("0")], x = x, y = y, w = 7, h = 24) x += 7
def show_stock(stocks = '/home/pi/stocks.ls'): lcd.draw_bitmap(STOCK_ICON) time.sleep(5) lines = [l.strip() for l in open(stocks, 'r')] for s in __get_stock_data__(lines): lcd_ext.marquee_display_words(s, 5) time.sleep(2)
def show_time(): lcd.draw_bitmap(BACKGROUND) d = time.strftime("%A", time.localtime()) cnt_space_char = 0 max_space = 12 - len(d) for i in xrange((max_space + 1) * 6): if cnt_space_char > max_space: cnt_space_char = 0 lcd.display_words([time.strftime(" %Y/%m/%d ", time.localtime()), (' ' * cnt_space_char + d).ljust(12), ' ' * 12, time.strftime(" %H:%M:%S", time.localtime()).ljust(12)], TEXT_AREA_REGION[0] * 6, TEXT_AREA_REGION[2] * 6, TEXT_AREA_REGION[1], TEXT_AREA_REGION[3]) cnt_space_char += 1 time.sleep(.3)
def show_weather(city, days = 5): w = __get_weather__(city, days) # show graphic weather hur = time.localtime().tm_hour if w == None: return lcd.draw_bitmap(icon.WEATHER_ICONS[(w['weather_code'] + "N") if hur >= 18 or hur < 6 else w['weather_code']], w = 42, h = 48) if w['temp'] < 0: lcd.draw_bitmap(icon.MINUS, x = 42, w = 14, h = 24) else: lcd.draw_bitmap(icon.BLANK, x = 42, w = 14, h = 24) lcd.draw_bitmap(icon.NUMBERS[w['temp'] // 10], x = 56, w = 14, h = 24) lcd.draw_bitmap(icon.NUMBERS[w['temp'] % 10], x = 70, w = 14, h = 24) lcd.draw_bitmap(icon.C_DEGREE, x = 42, y = 3, w = 42, h = 24) time.sleep(10) # show current weather lcd_ext.shake_display_words(w['current'], 1) time.sleep(5) # show forecast weather for fw in w['forecast']: lcd_ext.shake_display_words(fw, 2) time.sleep(5)
def show_logo(): lcd.draw_bitmap(LOGO) time.sleep(5) lcd.draw_bitmap(NAME) time.sleep(5)
def show_sys_info(): lcd.draw_bitmap(icons.SPLASH) time.sleep(5) for i in xrange(4): lcd.cls() # draw CPU and GPU icon and temp, usage lcd.draw_bitmap(icons.CPU, x = 3, w = 21, h = 24) __draw_value__("{:2.2f}".format(__get_cpu_temp__()), 27) lcd.draw_bitmap(icons.C_DEGREE, x = 66, w = 18, h = 24) lcd.draw_bitmap(icons.GPU, x = 3, y = 3, w = 21, h = 24) __draw_value__("{:2.2f}".format(__get_gpu_temp__()), 27, y = 3) lcd.draw_bitmap(icons.C_DEGREE, x = 66, y = 3, w = 18, h = 24) time.sleep(2) lcd.cls() # CPU usage lcd.draw_bitmap(icons.CPU, x = 3, w = 21, h = 24) p = "{:d}".format(__get_cpu_idle__()) __draw_value__(p, 55 - len(p) * 7) lcd.draw_bitmap(icons.PERCENTAGE, x = 67, w = 17, h = 24) # Memory usage lcd.draw_bitmap(icons.RAM, x = 3, y = 3, w = 21, h = 24) m = "{:.0f}".format(__get_mem_free__()) __draw_value__(m, 55 - len(m) * 7, y = 3) lcd.draw_bitmap(icons.MB, x = 57, y = 3, w = 27, h = 24) time.sleep(2) lcd.display_words([__get_time__(), "----Net IO----", "eth0:", __get_network_rx__(), __get_network_tx__(), " " * 14]) time.sleep(5) disk_stats = __get_disk_space__() lcd.display_words([__get_time__(), "-----Disk-----", "Used:" + disk_stats[1], "Avail:" + disk_stats[2], "Used%:" + disk_stats[3], " " * 14]) time.sleep(5)