User:Ssstephen/write-here-write-now: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 4: Line 4:


=Getting the input from the keyboard=
=Getting the input from the keyboard=
<pre>
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)
</pre>
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=
=Sneakily saving it maybe to a txt file for alternative documentation=

Revision as of 18:58, 18 November 2022

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

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)