Bitmap Printing

This printer can print out bitmaps, which can add a touch of class to a receipt with your logo or similar.

The first step is to get the logo prepared. The printer can only do monochrome (1-bit) images, and the maximum width is 384 pixels. We suggest starting with a small bitmap (100 pixels or less on each side) and then experimenting to get the size and look you want.

A few steps are required to prepare an image for printing. For Windows users, there’s a nice graphical user interface for this. For Mac and Linux, different tools are used…not as visually slick, but they do the job well.

These barcode printers shouldn't be confused with a LaserJet - they're not good at printing heavy/dense images with lots of black or they might stick and stall!

Windows

Use an image editing program to save your image as a 1-bit BMP — in Windows, the built-in Paint program will suffice.

Download, install and run LCD Assistant. This program is for Windows only but does a really fantastic job! Load the BMP file you previously generated (in Paint, etc.). The file must be in BMP format — the software won’t read PNG, GIF, etc. Then a couple of settings need to be adjusted…

First, in the “Byte orientation” section of the settings, select “Horizontal” (item A in the image above).

Second (item B above), you may need to change the Width setting. Because this software (and the thermal printer) handle images in horizontal groups of eight pixels, if the image width is not a multiple of 8, it will be truncated (cropped) to the nearest smaller 8-pixel boundary. For example, with the 75 pixel wide image above, the output will be cropped to only 72 pixels wide, losing some data from the right edge. To avoid this, increase this number to the next multiple of 8 (that would be 80 for the example above), and the output will be padded with blank pixels to cover the gap. Remember the number you use here, you’ll need it later.

The image height does not need to be adjusted this way, only width.

Set the table name to something short but descriptive (e.g. “adalogo” above), then select Save Output from the File menu. Give the file a similarly brief but descriptive name, ending in “.h” (e.g. “adalogo.h”).

To get this file into your Arduino sketch, select “Add File…” from the Sketch menu. This will add a new tab to your code. Your original code is still there under the leftmost tab.

A couple of small changes are now needed in both tabs. First, at the top of the file containing the new table data, change “const unsigned char” to “static const uint8_t PROGMEM” as shown below:

Next, in the tab containing the main body of your code, add an “include” statement to reference the new file:
#include "adalogo.h"

Check the A_printertest example sketch if you’re not sure how to include the code properly.

You can now output the image by calling printBitmap(width, height, tablename), where width and height are the dimensions of the image in pixels (if you changed the image width to a multiple of 8 as previously described, use that number, not the original image size), and tablename is the name of the array in the new tab (e.g. “adalogo” above).

Having a graphical user interface is nice, but some of these extra steps can be confusing and error-prone. If you prefer, the technique below for Mac and Linux works in Windows as well.

Mac and Linux

The conversion tool for Mac and Linux doesn’t include a fancy GUI, but it works well and avoids several steps (and potential mis-steps). The source image doesn’t need to be in BMP format — most image formats can be read natively — and the output can be added to a sketch with no further editing. It works for Windows as well, if you’d rather use this method.

First, if you don’t already have the Processing language installed, download it from processing.org. Processing looks almost exactly like the Arduino IDE, but it’s for writing code for your normal computer, not a microcontroller. This can be a little confusing to first-timers, so if something doesn’t seem to compile, make sure you’re running code in the right environment: Arduino for for the Arduino board, Processing for your computer.

This code runs in Processing 2.x, the latest version of Processing available from their website. Don't use the older Processing 1.5.x version!
The Adafruit_Thermal library folder that you previously downloaded contains a sub-folder called processing. Inside that is a sketch called bitmapImageConvert.pde. Load this into Processing and press RUN (the triangle button).

You’ll be prompted to select an image using the system’s standard file selection dialog. The program runs for just a brief instant, and will create a new file alongside the original image file. For example, if you selected an image called “adalogo.png”, there will be a new file called “adalogo.h” in the same location. This file contains code to add to your Arduino sketch. You shouldn’t need to edit this file unless you want to change the variable names within.

To get this file into your Arduino sketch, select “Add File…” from the Sketch menu. This will add a new tab to your code. Your original code is still there under the leftmost tab.

Next, in the tab containing the main body of your code, add an “include” statement to reference the new file:
#include "adalogo.h"

Check the A_printertest example sketch if you’re not sure how to include the code properly.

If the source image was called adalogo.png, then the resulting .h file (adalogo.h) will contain three values called adalogo_width, adalogo_height and adalogo_data, which can be passed directly and in-order to the printBitmap() function, like this:

printBitmap(adalogo_width, adalogo_height, adalogo_data);
Last updated on 2015-08-04 at 03.12.36 PM Published on 2012-09-02 at 03.50.48 PM