File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/python3
2+ # pylint: disable=E1101,W0614
3+
4+ import time
5+ from Adafruit_Thermal import *
6+
7+ i_feed = 4
8+ f_pause = 1.0
9+
10+ printer = Adafruit_Thermal ("/dev/serial0" , 19200 , timeout = 5 )
11+
12+ datestamp = time .strftime ("%Y-%m-%d" , time .gmtime ())
13+ print ("Date in preferred format:" , datestamp )
14+ timestamp = time .strftime ("%H:%M:%S" , time .gmtime ())
15+ print ("Time in preferred format:" , timestamp )
16+
17+ # Give a little room at the top
18+ printer .feed (i_feed )
19+ # Center justify
20+ printer .justify ('C' )
21+ # Large size
22+ printer .setSize ('L' )
23+ # Print the date
24+ printer .println (datestamp )
25+ # Print the time
26+ printer .println (timestamp )
27+ # Give a little room at the bottom
28+ printer .feed (i_feed )
29+
30+ # Tell printer to sleep
31+ printer .sleep ()
32+ # Call wake() before printing again, even if reset
33+ printer .wake ()
34+ # Restore printer to defaults
35+ printer .setDefault ()
36+
37+ # Sleep for one second in case we're called many times
38+ time .sleep (f_pause )
You can’t perform that action at this time.
0 commit comments