Using Char Value from Library

I Hope Everyone had a Happy Holiday.

I have created a library that collects values from switches and a Joystick:

Here is a sample:

char Nav_Buff[25];             // Navigation cmd Buffer
int xAxis_val;

void Controller::Collect_Commands(){ 
// Collects all Buttons State and Joystick Values and store in Nav_Buff
  if(digitalRead(button_A)==0)      // CHECK BRAKE
  { strcat(Nav_Buff, "1,");}      // BRAKE
  else strcat(Nav_Buff, "0,");      // NO BRAKE

  if(digitalRead(button_B)==0)      // CHECK THROTTLE
  { strcat(Nav_Buff, "1,");}      // THROTTLE
  else strcat(Nav_Buff, "0,");      // NO THROTTLE 

  if(digitalRead(button_C)==0)      // Check Button C
  { strcat(Nav_Buff, "1,"); }
  else strcat(Nav_Buff, "0,");      //  

  xAxis_val=analogRead(xAxis_pin);                   //Read Analog input 
         if(xAxis_val==511){strcat(Nav_Buff, "0");}       //home
  else if(xAxis_val>=515){strcat(Nav_Buff, "1");}      // Left
  else if(xAxis_val<=500){strcat(Nav_Buff, "2");}      // Right


What do I need to do to pass this value to the sketch?
I want to be able to assign based on each value using "if .. else"

Thanks in Advance


The simple crude way would be to put...

extern char Nav_Buff[25]; // Navigation cmd Buffer the top of your Sketch. After calling Controller::Collect_Commands you can then access Nav_Buff directly.

You may want to include some details describing what you're trying to accomplish. That may elicit better responses.

You could also use pass-by-reference, to make the caller allocate the space. Your function then just fills the buffer provided by the caller.

void someFunc(char *&whereToPutTheResults)
   whereToPutTheResults[0] = '\0'; // Initialize
   // Fill more of whereToPutTheResults[]

The call it like so:

char myBuffer[16];
Serial.print("myBuffer: ");