forked from adafruit/Python-Thermal-Printer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
niceties.py
executable file
·37 lines (31 loc) · 1.05 KB
/
niceties.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
# Weather forecast for Raspberry Pi w/Adafruit Mini Thermal Printer.
# Retrieves data from DarkSky.net's API, prints current conditions and
# forecasts for next two days. See timetemp.py for a different
# weather example using nice bitmaps.
# Written by Adafruit Industries. MIT license.
#
# Required software includes Adafruit_Thermal and PySerial libraries.
# Other libraries used are part of stock Python install.
#
# Resources:
# http://www.adafruit.com/products/597 Mini Thermal Receipt Printer
# http://www.adafruit.com/products/600 Printer starter pack
from __future__ import print_function
from random import choice
from Adafruit_Thermal import *
import urllib, json
printer = Adafruit_Thermal("/dev/serial0", 19200, timeout=5)
url = "https://niceties.herokuapp.com"
response = urllib.urlopen(url)
data = json.loads(response.read())
recursors = [
"Bobby (Robert) DeLanghe"
]
# Print nice thing
printer.inverseOn()
printer.print(' ' + choice(recursors) + ' \n')
printer.inverseOff()
printer.print(data)
# Print feed
printer.feed(6)