def marquee_display_words(words, index = 0, min_x = 0, max_x = 84, min_y = 0, max_y = 6, alarm = 0): if words == None: return if index < 0 or index >= len(words): index = 0 txt = words[index] if len(txt) <= 14: lcd.display_words(words, min_x, max_x, min_y, max_y) else: for t in xrange(max(2, 30//(len(txt)-13))): for i in xrange(len(txt)-13): copy_words = words[:] copy_words[index] = txt[i:i+14] lcd.display_words(copy_words, min_x, max_x, min_y, max_y) time.sleep(.2) time.sleep(2)
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)
def shake_display_words(words, index = 0, times = 3, min_x = 0, max_x = 84, min_y = 0, max_y = 6): if words == None: return if index < 0 or index >= len(words): index = 0 cnt_space_char = 0 txt = words[index] chrs = (max_x - min_x) // 6 max_space = chrs - len(txt) for i in xrange((max_space + 1) * times): if cnt_space_char > max_space: cnt_space_char = 0 copy_words = words[:] copy_words[index] = (' ' * cnt_space_char + txt).ljust(chrs) lcd.display_words(copy_words, min_x, max_x, min_y, max_y) cnt_space_char += 1 time.sleep(.3)
def show_earthquake(): e = __get_recent_earthquake__() if e == None: return # if this earthquake is expired, older than two hours # not show if (time.time() - time.mktime(e['time'])) > RECENT_TIME: return lcd.display_words([chr(213) + chr(205) * 12 + chr(184), chr(179) + " " * 12 + chr(179), chr(179) + " EARTHQUAKE " + chr(179), chr(179) + " in WORLD " + chr(179), chr(179) + " " * 12 + chr(179), chr(212) + chr(205) * 12 + chr(190)]) time.sleep(4) lcd.alarm(3) lcd_ext.marquee_display_words([time.strftime("%m/%d %H:%M:%S", e['time']), e['place'], e['mag'], e['lat'], e['lon'], e['dep']], 1) lcd.alarm(3) 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 alarm_display_words(words, min_x = 0, max_x = 84, min_y = 0, max_y = 6): if words == None: return lcd.alarm(1) lcd.display_words(words, min_x, max_x, min_y, max_y)