You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
# This is a program that takes keyboard input and prints it out ont a card shaped piece of paper using a pen plotter
|
|
|
|
# Global stuff
|
|
import os
|
|
import csv
|
|
import getch
|
|
|
|
userText = ["growing","write seven","words onto","a card"]
|
|
currentCard = 0
|
|
cardHeight = 95
|
|
cardWidth = 70
|
|
pageHeight = 249
|
|
pageWidth = 378
|
|
cardX = 0
|
|
cardY = pageHeight
|
|
lineHeight = 10
|
|
locX = 0
|
|
locY = 0
|
|
newLines = [" "]
|
|
|
|
|
|
#--------------------------------------------------------
|
|
# Getting the input from the keyboard one character at a time
|
|
# If you want to do stuff one character at a time maybe use getch
|
|
|
|
print("Enter the body line by line. Press ^C then enter to cancel")
|
|
os.system('echo "IN;" > /dev/ttyUSB0')
|
|
os.system('echo "SC0,379,0,250,2;" > /dev/ttyUSB0')
|
|
# os.system('echo "DT#,1;" > /dev/ttyUSB0')
|
|
|
|
#--------------------------------------------------------
|
|
# Sneakily saving it maybe to a txt file for alternative documentation
|
|
def fileWrite(char):
|
|
with open('the-record.txt', 'a') as file:
|
|
file.write(char)
|
|
file.close()
|
|
|
|
while 1:
|
|
char = getch.getch()
|
|
if char == 13:
|
|
os.system('echo "LB' + chr(3) + ';" > /dev/ttyUSB0')
|
|
fileWrite(char)
|
|
else:
|
|
os.system('echo "LB' + char + chr(3) + ';" > /dev/ttyUSB0')
|
|
fileWrite(char)
|
|
|
|
# os.system('echo "#;" > /dev/ttyUSB0') |