Example Program - Print Bipmap
I think the above is something I (stewart newfeld) created by converting the Arduino logo. I need to find it on my old laptop? I should make a video of convering a bitmap.
NOTES: the bitmap.h file supplied with the example draw_bitmap.ino is the SINCLAIR ZX81 logo.
The instruction line: printer.drawBitmap(logo, 0, 256, 72);
tells us to expect a 256 bit x 72 line image.
the file has two lines of 8 8-bit hex characters per line, that is to say two rows of code for each 256 bit image row.
Thus 144 rows for 72 lines.
Filename print_bitmap.ino
const unsigned char logo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff,
0xff, 0xff, 0x0f, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3e, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff,
0xff, 0xff, 0x0f, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3e, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff,
0xff, 0xff, 0x0f, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3e, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff,
[many skipped lines]
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Filename bitmap.h
#include <ZXPrinter.h>
#include "bitmap.h"
/*
Prints a bitmap from the bitmap.h file.
The bitmap must be stored in program memory (PROGMEM). See the bitmap.h file for an example.
There is a utility that will convert monochrome bitmaps into the correct format at
http://javl.github.io/image2cpp/
To convert a bitmap file into the correct format:
- create a monochrome bitmap file up to 256 pixels wide
- browse the above address
- in step 1 click "Choose Files" to upload the bitmap file
- in step 2 check "Invert image colors"
- in step 2 note the "Canvas size", this is the width and the height
- in step 4 click the "Generate code" and then "Copy output"
- in step 4 note the bitmap name
- paste the code into the bitmaps.h file
- update below with drawBitmap([bitmap name], 0, [canvas width], [canvas height]);
- the second parameter of drawBitmap is the horizontal position of the bitmap
*/
ZXPrinter printer;
void setup() {
printer.begin();
printer.printBitmap(logo, 0, 256, 72);
}
void loop() {
}