///////////////////////////////////////////////////////////////////////////////////
//
// Functions mainly used for development and debugging
//
///////////////////////////////////////////////////////////////////////////////////

void ScopeReport(int zGPnn ) {
  ///////////////////////////////////////////////////////////////////////
  // a choice of print statements to inspect variables dynamically
  ///////////////////////////////////////////////////////////////////////
  // Note at 4ms cycle and 115200 baud string length is limited to 46 chars
  // max in a 4ms period, otherwise blocking will occur. If used over WiFi then
  // link corruption may occur; so to prevent rogue values we send data twice and
  // checked on receive as a valid pair of duplicate values, otherwise disgard it.
  // Adjust the following three values to match the switch() list below, so that
  // title reports the extent of the GPnn list to the Monitor+ app, whenever a
  // new GPnn us called for.
  GPmin = 0; GPmax = 11; String zGM = "GM11\n";

  switch (zGPnn) {
    case 0:
      if (GP_Title) {PrintTx += "#AcY,AcZ\n" + zGM; GP_Title = false;}
      PrintTx += String(AcY) + ",";
      PrintTx += String(AcZ) + "\n";
      break;

    case 1:
      if (GP_Title) {PrintTx += "#GyX,GyY,GyZ\n" + zGM; GP_Title = false;}
      PrintTx += String(GyX) + ",";
      PrintTx += String(GyY) + ",";
      PrintTx += String(GyZ) + "\n";
      break;

    case 2:
      if (GP_Title) {PrintTx += "#PtchAccAng,PtchGyrAng,RollAccAng,RollGyrAng\n" + zGM; GP_Title = false;}
      PrintTx += String(PtchAccAng) + ",";
      PrintTx += String(PtchGyrAng) + ",";
      PrintTx += String(RollAccAng) + ",";
      PrintTx += String(RollGyrAng) + "\n";
      break;

    case 3:
      if (GP_Title) {PrintTx += "#Ptch_P,Ptch_i_mem,Ptch_D,Ptch_Opx10\n" + zGM; GP_Title = false;}
      PrintTx += String(Ptch_P) + ",";
      PrintTx += String(Ptch_i_mem) + ",";
      PrintTx += String(Ptch_D) + ",";
      PrintTx += String(Ptch_Op * 10.0) + "\n";
      break;

    case 4:
      if (GP_Title) {PrintTx += "#Roll_P,Roll_i_mem,Roll_D,motoA_Vel\n" + zGM; GP_Title = false;}
      PrintTx += String(Roll_P) + ",";
      PrintTx += String(Roll_i_mem) + ",";
      PrintTx += String(Roll_D) + ",";
      PrintTx += String(motorA_Vel) + "\n";
      break;

    case 5:
      if (GP_Title) {PrintTx += "#PtchErr,SbPtchSp,RollErr,SbRollSp\n" + zGM; GP_Title = false;}
      PrintTx += String(PtchErr) + ",";
      PrintTx += String(SbPtchSp) + ",";
      PrintTx += String(RollErr) + ",";
      PrintTx += String(SbRollSp) + "\n";
      break;

    case 6:
      if (GP_Title) {PrintTx += "#motorA_Vel,motorB_Vel,motorC_Vel\n" + zGM; GP_Title = false;}
      PrintTx += String(motorA_Vel) + ",";
      PrintTx += String(motorB_Vel) + ",";
      PrintTx += String(motorC_Vel) + "\n";
      break;

    case 7:
      if (GP_Title) {PrintTx += "#motorA_Vel,motorA_Vd,motorAVol,SbRollSp\n" + zGM; GP_Title = false;}
      PrintTx += String(motorA_Vel) + ",";
      PrintTx += String(motorA_Vd) + ",";
      PrintTx += String(motorAVol) + ",";
      PrintTx += String(SbRollSp) + "\n";
      break;

    case 8:
      if (GP_Title) {PrintTx += "#motorB_Vel,motorB_Vd,motorBVol\n" + zGM; GP_Title = false;}
      PrintTx += String(motorB_Vel) + ",";
      PrintTx += String(motorB_Vd) + ",";
      PrintTx += String(motorBVol) + "\n";
      break;

    case 9:
      if (GP_Title) {PrintTx += "#motorC_Vel,motorC_Vd,motorCVol,SbPtchSp\n" + zGM; GP_Title = false;}
      PrintTx += String(motorC_Vel) + ",";
      PrintTx += String(motorC_Vd) + ",";
      PrintTx += String(motorCVol) + ",";
      PrintTx += String(SbPtchSp) + "\n";
      break;

    case 10:
      if (GP_Title) {PrintTx += "#motorC_Vel,JoyY/10,Brake\n" + zGM; GP_Title = false;}
      PrintTx += String(motorC_Vel) + ",";
      PrintTx += String(JoyY/10) + ",";
      PrintTx += String(Brake) + "\n";
      break;

    case 11:
      if (GP_Title) {PrintTx += "#motorC_Vel/10,PtchSp,SbPtchSp,PtchErr\n" + zGM; GP_Title = false;}
      PrintTx += String(motorC_Vel/10.0) + ",";
      PrintTx += String(PtchSp) + ",";
      PrintTx += String(SbPtchSp) + ",";
      PrintTx += String(PtchErr) + "\n";
      break;

    default:
      // zRPnn was out of range so reset the reporting pointer and send commands
      // to set RP = 0 and RMax to the highest number in your case list. ie. 7
      GPnn = GPmin; PrintTx += "GP" + String(GPmin) + "\n";
      PrintTx += "GM" + String(GPmax) + "\n"; break;
  }
}

// --------------------------------------------------------------------------------
