User:Ssstephen/write-here-write-now
This is an attempt to write directly from a keyboard to a plotter pen, onto precut pages (cards) on an A3 sheet.
Can it be broken down into steps hopefully yes.
Getting the input from the keyboard
newLines = [" "] #-------------------------------------------------------- # Getting the input from the keyboard newTitle = input("Enter a title: ") print("Enter the body line by line. Press x then enter to cancel") while newLines[-1] != "x": newLines.append(input("Type: ")) newLines = newLines[:-1] print(newTitle) for line in newLines: print(line)
mmhmm all good. Maybe it would make more sense to take the body of the description all at once. Although maybe also it would be more appropriate to take it one character at a time, so they can be sent directly to the plotter.
Sneakily saving it maybe to a txt file for alternative documentation
with open('definitions.csv', 'a', newline='') as file: writer = csv.writer(file) writer.writerow([newTitle, newLines]) file.close()
yah cool
Converting it to HPGL with some nice formatting
HPGL things to run before printing any cards:
IN SP1 SC0,379,0,250,2 DT.,1;
IN: initialise the plotter
SP1: Select pen 1
SC0,40,0,40,2: Scale the plotter units to mm (roughly? or maybe this is exact, need to measure) EditL this was wrong, "SC0,379,0,250,2" worked but I'm not sure why.
DT.,1; : Set the terminator character to period. This should be a non-printing character but not really working at the moment.
Positioning it on the page and sending it to the printer
A very rough way to do this would be to wrap each hpgl command in bash. Chiplotle is probably better but I cant get it working yet. First some hpgl setup. (This needs to know which cards have been used in future, and position the pen based on what card were curently on in a matrix or list, currently it is just printing from the absolute location 0,23 (mm apparently but I dont think so).
for line in userText: # first line is the title if userText.index(line) == 0: os.system(('echo "PA0,' + str(23-userText.index(line)) + '" > /dev/ttyUSB0')) os.system(('echo "LB' + line + '." > /dev/ttyUSB0')) # all the other lines else: os.system(('echo "PA0,' + str(21-userText.index(line)) + '" > /dev/ttyUSB0')) os.system(('echo "LB' + line + '." > /dev/ttyUSB0'))
PA: position absolute LB: label (text, needs a terminator character)
Connecting a plotter directly to a keyboard with no computer
The easiest way to do this is to use a small device to convert from keyboard language into plotter language. I'm going to use a Raspberry Pi with a python script running as my converter.
- Set up the raspberry pi with debian and all its bits and bobs.
- make sure it can send characters to the plotter
- set up function keys (next page, backspace, dont use letters)
- set up page size functions
- decide actual page sizes