10 years, 11 months ago.

pc.printf a method?

If i make an object pc out of the class serial, you can find in the documentation this object has several methods: baud, format, readable, writeable, attach but there is nothing about printf and scanf. what are these then?? where do i find documentation about how i have to use these commands? thnx

1 Answer

10 years, 11 months ago.

Serial inherits the 'stream' interface and that provides the printf method. See the declaration of the Serial class.

Accepted Answer

I did find stream.h but i dont really understand why it is not just included in serial.h??

posted by Adriaan Van Steendam 14 May 2013

Inheritance is one of the great features of object oriented languages like C++. The stream methods are not included in serial to allow you to use them in other classes as well. They are for example also included in the TextLCD class and in my enhanced TextLCD class. All you need to do to make use of the powerful printf features is implement a putc() method in your own new class.

posted by Wim Huiskamp 14 May 2013

thnx!

posted by Adriaan Van Steendam 15 May 2013