Close

Thermal Printer on Spark Core

A project log for Hackaday monitor and Lighting Box

Hackaday monitor, artistic light decoration, clock, game and more!

atherosAtheros 08/20/2014 at 15:550 Comments

Printing on a thermal printer from Spark Core

As I wrote previously, in order to continue with my project, I had to port Adafruit's Thermal Printer Arduino library to Spark Core. It didn't turn out to be very difficult. As promised, I'm publishing Adafruit Thermal Printer library ported to Spark Core. Here you can see it in action:

I had to modify the API a bit, as well as the example. You'll find more details bellow. 

No SoftSerial

There is no software serial on Spark Core. It is not a problem, Spark has already two serials (and a third on the way). That means the Adafruit_Thermal::Adafruit_Thermal() constructor doesn't accept any arguments and Adafruit_Thermal::begin() requires a pointer to a stream object - a serial port. Example:

Adafruit_Thermal printer;
Serial1.begin(19200);
printer.begin(&Serial1);

An other thing you'll notice is I initialize the speed of Serial1 manually. I am not sure it is a good idea to put it inside printer.begin(). I may of course reconsider that if anyone has a good reason for it.

No program memory

Since I don't know if or how Spark Core handles data stored in program memory, the fromProgMem argument in Adafruit_Printer::printBitmap() is ignored. That means I only know bitmaps held in RAM can be properly drawn. If anyone knows anything about that issue, please tell me. On the good side, Spark Core has 10x more RAM than Arduino UNO, so hopefully this won't be an issue.

Example code

The example code is mostly the same. The initialization of the serial port is different (see above) and bitmap data that was previously in external header files were moved to the source code. The reason for this is when you try to run the example ("Use This Example" button) from Spark IDE, it doesn't include the header files (it does not know they are part of the example).

This library is published on Spark IDE, so you can use it right away.

If you find any issues with this port, please report a bug on GitHub.

Discussions