def set_text(): global deviceViewport text = request.args.get('msg') fontName = parse_font_name(request.args.get('font')) font = proportional(fontName) if request.args.get( 'proportional') else tolerant(fontName) set_contentHotspot(textSnapshot(text=text, font=font), (32, 0)) return 'OK'
def set_text_blink(): global deviceViewport text = request.args.get('msg') fontName = parse_font_name(request.args.get('font')) font = proportional(fontName) if request.args.get( 'proportional') else tolerant(fontName) duration = request.args.get('duration', default=600, type=int) set_contentHotspot( blinkingTextSnapshot(text=text, font=font, duration=duration / 1000), (32, 0)) return 'OK'
def test_default(): font = tolerant(CP437_FONT) assert font[65] == [0x7C, 0x7E, 0x13, 0x13, 0x7E, 0x7C, 0x00, 0x00] assert font[6543] == [0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80]
def test_with_proportional(): font = proportional(tolerant(CP437_FONT, missing="?")) assert font[65] == [0x7C, 0x7E, 0x13, 0x13, 0x7E, 0x7C, 0x00] assert font[6543] == [0x02, 0x03, 0x51, 0x59, 0x0F, 0x06, 0x00]
def test_custom_missing(): font = tolerant(CP437_FONT, missing="?") assert font[65] == [0x7C, 0x7E, 0x13, 0x13, 0x7E, 0x7C, 0x00, 0x00] assert font[6543] == [0x02, 0x03, 0x51, 0x59, 0x0F, 0x06, 0x00, 0x00]
python_wiki_rss_url = "http://www.poznan.pl/mim/feeds/atom.xml?name=sport" serial = spi(port=0, device=0, gpio=noop()) device = max7219(serial, cascaded=4, block_orientation=-90, rotate=0) feed = feedparser.parse(python_wiki_rss_url) for repeats in range(10): print(repeats) for items in feed["items"]: msg = items["title"] # msg = msg[0:msg.find("")] print(msg) show_message(device, msg, fill="white", font=proportional(tolerant(LCD_FONT, missing="?"))) time.sleep(2) msg = time.asctime() msg = time.strftime("%H:%M:%S") print(msg) show_message(device, msg, fill="white", font=proportional(SINCLAIR_FONT)) time.sleep(10) if __name__ == "__main__": parser = argparse.ArgumentParser( description='matrix_demo arguments', formatter_class=argparse.ArgumentDefaultsHelpFormatter)