#include "Print.h" / Print.cpp support?

In my quest to get as many LCD and OLED displays working with the Spark Core as humanly possible, I’ve run into a bit of a roadblock. Normally, Arduino includes a Print Class. This is what makes stuff like Serial.print and Wire.println function. Essentially, you just add : Print to your class constructor with a function for write and boom, you’ve inherited all the functionality of Print. :smiley:

So, my issue here is that #include “Print.h” is throwing a “Not Found” error, so one would assume it’s automatically included, sadly it’s clear my class is in no way extending anything.

So am I going to have to port that as well?! xD

I’m porting the brewpi arduino-based fermentation controller to spark - in the code there are several classes that extend Print. Although you don’t have to include “Print.h”, the Print class is already included for you as part of “application.h”.

See, that’s what I thought, but it’s not working right for me. Are you extending it the standard way, with a virtual void write function, etc.?

1 Like

The signature is

virtual size_t write(uint8_t data);

E.g.

class A : public Print
{
public:
    virtual size_t write(uint8_t)  { return 1; }
};

A a;

Compiles fine.

1 Like

Ahh, looks like I missed a couple of size_t entries! It seems the search function is boned in Spark Build. CMD-F doesn’t bring up the search bar, but you can still go through the Find > Find… menu, however it only searches the current visible code and nothing in the scroll buffer. :frowning: