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
   based on

#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
    Debug (Stream &stream) : stream{&stream} {}

    void setDebugLevel(byte newLevel) {
      debugLevel = newLevel;
    size_t write (uint8_t value)
      if (debugLevel)
      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.println(F("Debug Print Test"));

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

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

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

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

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

  float afloat = 123.45;

  char achararray [] = {"bla bla\0"};

  String anArduinoStringObject = "bla blub";

  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:



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