Skip to content

moeux/cat-printer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cat-Printer

This is an example program to print with a portable BLE thermal printer using a WeMos D1 mini ESP32.

cat
The thermal printer I used.

Libraries

This example is using the Thermal_Printer library.
The ID on my printer did not match with any of the ones preset in the library, so I had to add it manually to the szPrinterIDs[].

Bitmaps

In order to print any arbitrary image you need to convert it to a bitmap with 1 bit per pixel.

Original:
pikachu

Using GIMP I was able to convert the picture into a bitmap:
Bitmap Creation: Image > Mode > Indexed > Use black and white (1-bit) palette
Bitmap Export: File > Export > <name>.bmp

Tip

Play around with the Color-dithering setting to get the best conversion.

Bitmap:
bitmap

In order to use this bitmap in our program it needs to be converted, once more, into a C byte array.
To get the actual byte information out of a bitmap file a hex editor can be used, in my case I used Okteta.

Using Okteta to open the BMP file and export as C array:
Open BMP: File > Open > <name>.bmp
C Array Export: File > Export > C Array > Data Type: unsigned char

Byte Array:

static uint8_t bitmap[2110] =
{
  0x42, 0x4d, 0x3e, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
  ...
};

Important

  1. Make sure you change the type declaration from unsigned char to uint8_t in order for it to work with the library!
  2. Change the width and height constants to the width and the height of the image you used!

Troubleshooting

No printer found

The library connects successfully only to printers which IDs have been registered in szPrinterIDs[].
Make sure your printer's ID is registered.

If you'd like to find out the ID of your printer, enable the DEBUG_OUTPUT to see all clients (and their IDs) that were found during the Bluetooth scan.

About

An example progam for printing with the cat printer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published