marwk@levels.sait.edu.au (04/10/91)
The following program is designed to create a user-defined character inside
the EPSON LQ-400 24-pin printer and then print the character.
It does not work.
The command summary on page 6-7 of the USER's GUIDE uses
ESC & 0 n1 n2 d0 d1 d2 data
as the description of the command, where n1 = code for the first character,
n2 = the code for the last character, d0 = left space of character, d1 = body
width of character, d2 = right space of character and data is 3 bytes for
each column.
Could someone please explain what I am doing wrong here and tell me how
to do it properly.
Ray
----
/* PRNCHAR.C */
#include <stdio.h>
#define ESC 0x1B
void define_a_character(char a[24][18])
{
int i,j;
for (i = 0; i < 24; ++i)
for (j = 0; j < 24; ++j)
a[i][j] = i == j;
}
void select_user_defined_set(void)
{
fprintf(stdprn, "%c%c%c", ESC, '%', 1);
}
void print_character(int c)
{
fprintf(stdprn, "%c", c);
}
void send_character_to_printer(char a[24][18])
{
int i,bit, col;
char byte[3];
fprintf(stdprn, "%c%c%c%c%c%c%c%c",
ESC, '&', 1, 128, 128, 2, 18, 2);
for (col = 0; col < 18; ++col)
{
for (i = 0; i < 3; ++i) /* set up the 3 bytes */
{
byte[i] = 0;
for (bit = 0; bit < 8; ++bit)
byte[i] &= a[bit][col] << (7 - i);
fprintf(stdprn, "%c", byte[i]);
}
}
}
void main(void)
{
char a[24][18];
select_user_defined_set();
define_a_character(a);
send_character_to_printer(a);
print_character(128);
}
--
University of South Australia | Plus ca change, plus c'est la meme chose.
P.O. Box 1 | Ghing thien me how, ming thien gung me how.
Ingle Farm | Knobs, knobs everywhere,
South Australia | just vary a knob to think!