jdg@hpqtdla.HP.COM (James Gentles) (03/28/90)
Anyone out there still plodding along with the HP28??? Still using Mark Adler's HPREAD to get stuff into your PC? Well this one could be for you. Another little addition to Marks program that will print HP28 screen dumps on your PC printer. The C source follows. I've made it as simple as possible, so that any compiler will compile it for you. It uses stdin and stdout so all you do is stick it between HPREAD and the printer. It will print out screen dumps contiguously ONLY if they are presented to HPLCD as one input file. It may print them contigiously anyway depending on the inteligence of your printer. It should work for most dot matrix printers with graphics mode, but before you compile it check that the escape codes for your printer are the same as the ones I am using with HP printers. Change the strings for your own printer's codes and away you go. Any comments or suggestions, please email, It's nice to know there's people listening! Regards James Gentles --------------------------------------------------------------------- I have no professional connection with Hewlett-Packard's calculator operations other than as a user of their products. --------------------------------------------------------------------- Opinions expressed are my own, and are not intended to be an official statement by Hewlett-Packard Company --------------------------------------------------------------------- Name: James Gentles GM4WZP Organization: Hewlett-Packard Queensferry Telecomunications Division Email: jdg@hpqtdla.hpsqf.hp.com hp-sdd Address: Station Road, South Queensferry, West Lothian, Scotland --------------------------------------------------------------------- /* HPLCD Revision 1.0 James Gentles 27th Mar 1990 jdg@hpqtdla.hp.com This program accepts from stdip a file created by the HPREAD program from the HP28's IR link. This file is a HP28 screen dump which is a raster bit pattern. The pattern is massaged into the correct form for a standard HP/ EPSON raster printer dump and placed in standard ouput complete with all the correct escape sequences. The exact escape sequences for your printer need to be included at compile time, the program as received uses: Start ESC*rA Send row ESC*bxW where x is a decimal number of bytes Stop ESC*rB This has been tested on a HP Thinkjet and HP Paintjet. Different codes could easily be used for different printers, as long as the format of the printers raster graphics is row-wise. The size of the output can be varied from 1 to 9 by using the /s option: HPLCD /s4, gives 4 output pixels per HP28 pixel etc. The default is 2. There is also a short help page accessed by HPLCD /h The / options cannot be combined Note: When using HPREAD to generate the input to this program always use /n option to prevent data corruption. Example: HPREAD /n >LCD.28 HPLCD /s4 >LCD.OUT TYPE LCD.OUT >PRN */ #include <stdio.h> main(argc,argv) int argc; char *argv[]; { int size,i,row,rowrpt,byte,bit,c,op; int pwr2[]={1,2,4,8,16,32,64,128}; int ipdata[144]; char help1[]=" HPLCD 1.0 27th Mar 1990 James Gentles jdg@hpqtdla.hp.com\n\ HPLCD takes a screen dump from a HP28's Infra-red transmitter (received\n\ with HPREAD) and encodes it for printing on a standard printer with raster\n\ graphics capability.\n"; char help2[]=" Typical usage: HPREAD /n | HPLCD /s4 >PRN\n\ Options allowed:\n\ /sx Set size of output (x in range 1 to 9). Defaults to /s2\n\ /h Prints help\n"; if (argc>=2 && argv[1][0]=='/') { if ((argv[1][1]=='s' || argv[1][1]=='S') && argv[1][3]==0) { size=argv[1][2]-48; if (size<1 || size>9) size=-1; /* IF outside range print opts */ } else { size=-1; } if ((argv[1][1]=='h' || argv[1][1]=='H') && argv[1][2]==0) size=0; /* Print full HELP info */ } else size=-1; if (argc==1) size=2; /* default if no passing params */ if (size>0) /* IF size<=0 then help only */ { for (i=0;i<=144;++i) ipdata[i]=0; i=0; printf("%c*rA",27); /* BEGIN GRAPHICS ESC SEQUENCE */ while ((c = getchar()) != EOF) { ++i; if (i<140) /* Collect one row of 28 data */ { if (i>=4) ipdata[i-3]=c; } if (i==140) { i=0; for(row=0;row<=7;++row) for(rowrpt=1;rowrpt<=size;++rowrpt) { printf("%c*b%dW",27,(18*size)); /* SEND ROW OF GRAPHICS ESC SEQ*/ for(byte=0;byte<=((18*size)-1);++byte) { op=0; for (bit=0;bit<=7;++bit) { if(ipdata[(((byte*8)+bit)/size)+1] & pwr2[row]) op|=pwr2[7-bit]; } putchar(op); } } } } printf("%c*rB" , 27); /* End graphics escape sequence */ } else { if (size==0) printf("%s%s",help1,help2); /* PRINT HELP INFO */ if (size==-1) printf("HPLCD Pass parameter error...\n%s",help2); /* PRINT Pass Pars */ } }