Function with 2 "Stream" types

Hi',

I have a function which prints data to Serial

void printData(Stream &myserial) {
    myserial.print("test");
}

printData(Serial5);

I would like to use this same function now with my oled screen.
The oled library (SSD1306Ascii) use "print" and "println" but is not a "Stream" type so I get error when compiling.

Is there a way to use my function with 2 different types (Stream and SSD1306Ascii type) ?

It's probably deriving from Print instead. Look at the class definition in the .h file of the library. If you're still not sure post it.

Hmmm, I get this in the first lines of the SSD1306Ascii.h :

/**
 * @class SSD1306Ascii
 * @brief SSD1306 base class
 */
class SSD1306Ascii : public Print {
 public:

So yes you're right, it seems to work fine :slight_smile:
Thanks a lot for your help ! I don't even think about using something else than "Stream" :slight_smile: