Skip to main content
deleted 55 characters in body
Source Link
AJP
  • 181
  • 2
  • 9

It works if you move the enum class and cycleToString function declaration aboveto the void setup()top, i.e.:

enum class CYCLE { TypeA, TypeB };

void setup()
{
  // setup code
}

String cycleToString (CYCLE cycle) {
  if (cycle == CYCLE::TypeA) {
    return "TypeA";
  }
  else if (cycle == CYCLE::TypeB) {
    return "TypeB";
  }
  return "Undefined";
}

void setup()
{
  // setup code
}

void loop()
{
  // loop code
}

It works if you move the enum class and cycleToString function declaration above the void setup(), i.e.:

enum class CYCLE { TypeA, TypeB };

String cycleToString (CYCLE cycle) {
  if (cycle == CYCLE::TypeA) {
    return "TypeA";
  }
  else if (cycle == CYCLE::TypeB) {
    return "TypeB";
  }
  return "Undefined";
}

void setup()
{
  // setup code
}

void loop()
{
  // loop code
}

It works if you move the enum class to the top, i.e.:

enum class CYCLE { TypeA, TypeB };

void setup()
{
  // setup code
}

String cycleToString (CYCLE cycle) {
  if (cycle == CYCLE::TypeA) {
    return "TypeA";
  }
  else if (cycle == CYCLE::TypeB) {
    return "TypeB";
  }
  return "Undefined";
}

void loop()
{
  // loop code
}
Source Link
AJP
  • 181
  • 2
  • 9

It works if you move the enum class and cycleToString function declaration above the void setup(), i.e.:

enum class CYCLE { TypeA, TypeB };

String cycleToString (CYCLE cycle) {
  if (cycle == CYCLE::TypeA) {
    return "TypeA";
  }
  else if (cycle == CYCLE::TypeB) {
    return "TypeB";
  }
  return "Undefined";
}

void setup()
{
  // setup code
}

void loop()
{
  // loop code
}