Developing a Class

honestly, than just make a makro, you don't need a class for that.

Thanks for making my point that it's been too long for me.
Rather than trying to develop something that's probably beyond where I'm willing to go in terms of time investment, I'll probably just produce something that works ok for what I'm trying to do.

At 77, I'm just trying to have a little fun before it's time to depart!

I do appreciate the help though -- I'm trying to do too much with so little time left.

Thanks -Ray

I know -- it was because I can't help learning more stuff.

than go for it!

As you brought in "inheritance". I found an older sketch of mine:
now "Debug" is a child of Print, you modify the write method and can switch on / switch off debug messages during runtime.

and if you combine it with a VA_ARGS you can spare some typing - if it is really necessary :wink:

/* 
   Optionale Debug.print Ausgabe zu Serial - Veränderbar zur Laufzeit
   https://forum.arduino.cc/t/developing-a-class/946676/23
   based on
   http://forum.arduino.cc/index.php?topic=575044.0
*/

#define DBG(...)       debug.print(__VA_ARGS__);  
#define DBGLN(...)     debug.println(__VA_ARGS__);

class Debug : public Print {
    uint8_t debugLevel = 1;
    Stream *stream;                // pointer to the used serial interface
  public:
    Debug (Stream &stream) : stream{&stream} {}

    void setDebugLevel(byte newLevel) {
      debugLevel = newLevel;
    }
    
    size_t write (uint8_t value)
    {
      if (debugLevel)
      {
        stream->write(value);
      }
      return 1;
    }
};

//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2, 3); // RX, TX
HardwareSerial &mySerial = Serial;    // HW Serial
Debug debug(mySerial);


void setup() {
  // put your setup code here, to run once:

  mySerial.begin(4800);
  mySerial.println(F("Debug Print Test"));

  debug.println("Debug 1 is on");

  debug.setDebugLevel(0);
  debug.println("Debug 2 is off");

  debug.setDebugLevel(1);
  debug.println("Debug 3 is on again");

  debug.setDebugLevel(0);
  debug.println(F("Debug 4 is off"));

  debug.setDebugLevel(1);
  debug.println(F("Debug 5 is on again"));

  float afloat = 123.45;
  debug.println(afloat);

  char achararray [] = {"bla bla\0"};
  debug.println(achararray);

  String anArduinoStringObject = "bla blub";
  debug.println(anArduinoStringObject);

  DBGLN(F("old boy wants to spare time and writes less characters ;-P"));
  DBG(1234, HEX);
}

void loop() {
  // put your main code here, to run repeatedly:

}

result

Debug Print Test
Debug 1 is on
Debug 3 is on again
Debug 5 is on again
123.45
bla bla
bla blub
old boy wants to spare time and writes less characters ;-P
4D2