WP 34S: IR plotting (revised) Message #1 Posted by Marcus von Cube, Germany on 8 June 2012, 11:10 a.m.
I've added some commands to allow graphic output to the HP infrared printer. This is work in progress but a first implementation is available in SVN.
Plotting is done in stripes of 8 pixels height and up to 166 pixels wide, exactly what the printer supports natively. The most recent update allows for rectangular graphic objects.
A block of registers is used to store the bit patterns. Building the block and printing it are independent operations which implies that you can build more than one block at a time if you reserve enough registers.
Here are the commands (revised list):
- gDIM n - takes the number of columns for this plot block from X and the number of rows from Y. It clears the register block starting at register n (global or local). X and Y are
left untouched on the stack. The first byte is reserved to store the
configured width, the next byte stores rows=floor((height+7)/8).
The number of registers needed is floor((width*rows+9)/8)
in single precision (floor((width*rows+17)/16) in DP). A value of zero or a
negative value in X sets the width to 166, the paper width. The default height is 8.
The command can be exactly emulated in integer mode by storing rows*256+width in the
first register and clearing the rest.
- gDIM? returns the width to X and the height to Y.
- gSET, gCLR, gFLP n - Set, clear or toggle a bit. The row coordinate
(0..height-1) is in Y, the column coordinate (0..width-1) is in X. n denotes
the register block. X and Y are left untouched. Coordinate (0,0) is top
left.
- gPIX? n - Same syntax as above. Tests if a pixel is on. It's a standard conditional test, skipping the next instruction if the test fails.
- [print]PLOT n - Plots the block in the configured width. If the width is the
paper width (166), a LF is printed, otherwise this is left to the user.
This makes it possible to mix graphic and any other output. Setting
pMODE to 1 (or 2) before printing may increase the printing accuracy
because these modes use the alternate LF character 0x04.
If you want the full width of 166 columns, the block needs 21 registers per row (in single precision). The highest possible value for n is 79 in this case as long as you don't use local registers. After a LocR 021 command you can plot with .00 as the register argument. Of course it makes sense to reserve some more local registers for working storage and relocate the plot block just above these. The global registers can take a block of 79x80 (99 registers) or 166x32 (84 registers).
You can define a custom character in a single register by either
plotting it (after doing pINIT n with the width in X and 8 in Y), or by simply
storing the pattern in a register, with the width in the LSB and 1 in the next byte. This must
be done in integer mode, of course. pPLOT n then prints the custom
character in n. The width needs to be <= 6 in single precision. Wider characters need more registers (or double precision).
Edited: 10 June 2012, 3:58 a.m. after one or more responses were posted
|