is this possible?

hey everyone, back again!

I am trying to develop my code out of an Arduino/Adafruit libraries. but first I need to fully understand it. here is what's going on:

below you can see the .h CONSTRUCTOR, Adafriut_Thermal, which takes two parameters: *s and dtr:

// Constructor
Adafruit_Thermal::Adafruit_Thermal(Stream *s, uint8_t dtr) :
  stream(s), dtrPin(dtr) {
  dtrEnabled = false;
}

and in the .cpp file you can see the definition of privet variables:

private:

  Stream
    *stream;
  uint8_t
    
    dtrPin;        // DTR handshaking pin (experimental)

now here are the questions:

1- is stream() a function? I've searches online about stream() but I got nothing... :frowning:
2- if dtrPin is a variable name, then why use it like dtrPin()? like a function???

what is going on??? :cry:

Hi,
What do you want your code to do that needs a library to be scrutinized?

Tom… :slight_smile:

ALAA72:
1- is stream() a function? I've searches online about stream() but I got nothing... :frowning:

It's a class that is a standardized piece of the Arduino core library:

ALAA72:
2- if dtrPin is a variable name, then why use it like dtrPin()? like a function???

That's called "member initialization". It's just an alternate way of initializing class member in a constructor:
http://www.cplusplus.com/doc/tutorial/classes/#member_initialization

// Constructor
Adafruit_Thermal::Adafruit_Thermal(Stream *s, uint8_t dtr) :
  stream(s), dtrPin(dtr) {
  dtrEnabled = false;
}

does the same as

// Constructor
Adafruit_Thermal::Adafruit_Thermal(Stream *s, uint8_t dtr)  {
  stream = s;
  dtrPin = dtr;
  dtrEnabled = false;
}

the first version would be neccessary for const Stream* stream.

Stream is a base class for hardware Serials, SoftwareSerial, networking Client, UDP etc.

the library doesn't need to be a class. you can ave standalone functions in library. they can be grouped by a name space