Paintball Gun Printer : Fonts
From Bob's Basement
Turning ASCII into an image
For printing, probably the simplest way to achieve the desired effect is to use a grid of points and generate a message using this.
Canvas
The canvas is the overall grid onto which the message will be printed. For the purposes of simplicity, I suggest a 64x16 grid of "pixels". I believe that the RCX uses an 16-bit processor, so multiples of 8 are a good idea.
In memory, once initialised, the canvas will look like this
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
(aligned for clarity)
The image will be built up from several 8x8 characters which will be placed onto the canvas.
Characters
The character set (a reduced set of ASCII, caps and numerals only) will be made up of 8x8 characters, for example an A will look like this:
00011000 00100100 01000010 01000010 11111111 10000001 10000001 10000001
Replacing the 0's with spaces shows the pattern much clearer
11 1 1 1 1 1 1 11111111 1 1 1 1 1 1
Each other letter will be created in a similar manner. These characters will then be used to build up the lines on the canvas containing text.
Each row (or line) could be referenced in an array format, for example A being the array, and A[0] being the first line, i.e. "00011000", A[1] being "00100100".
The image can be build up in lines. For example, if the string to be printed is "HEY", as each line is processed. The following psudocode (which is strikingly similar to C, but isn't) will build up the canvas using this
int width = 64; // number of bits in the width of the canvas ( 8 characters wide )
int height = 16 ; // number of bits high. ( 2 characters high )
string message = "HEY"; // message we want to print
// note that message[0] will reference the first char in the string.
// Assume that all characters are loaded in the manner described above
// in an array CHARS['X'][n] where X is the letter represented, and
// n is the line number.
// row the line we are currently on
for (int row = 0;row<height;row++) { // for each row (till the end)
int char = 0; // intialise
for(;char < message.length;char++) { // for each char in the message
print CHARS[char][row];
}
while(char<(width/8)) { // while there is still space on the canvas...
print "00000000"; // fill it up
char++;
}
print "\n";
}
while (row < height) { // while there is still space left at the bottom of the canvas
for (int i=0;i<width;i++) { // for the entire row
print "0"; // fill with 0's
}
print "\n";
}
NOTE this is unfinished. This will only work with one line of text, with less than 8 chars. I need to add wrapping etc. Also, print lines are used instead of inserting it into the array.
Using a such a method, a message can be built up on a canvas.
This is the same kind of method a dot matrix LED display would use to display messages! Scope for more fun!

