Converting to a string

I have some output to the LCD like this:

lcdSerial << "AZ ";
lcdSerial << _FLOAT(azFloat, 1) << azRotorMovement ;		// Then print the line including the wish rotor angle

How can i convert this to a single string so i can add som speces to fit on the LCD saving two commands to clear that line first.

How can i convert this to a single string

sprintf() comes to mind, except for the float. For that, you need dtostrf() first.

Solved the problem like this:

void displayAz(long az)	{
  double azFloat = az / 100.0;					//adjust value for display
  String _azString = "AZ ";
  static char _azBuffer[7];
  
  if (azFloat < 10.0) {						// pad with spaces if needed
    _azString += " ";
  }
  if (azFloat < 100.0){
    _azString += " ";
  }
#ifdef LCD_I2C
 dtostrf(azFloat,4, 2, _azBuffer);
  _azString = "  " + _azString + _azBuffer;
  _azString += azRotorMovement;
  lcdSerial.setCursor(0,1);
  lcdSerial << _azString;  
//  Serial << _azString << endl;
#else
  lcdSerial << _BYTE(_line1) << _azString;
  lcdSerial << _FLOAT(azFloat, 1) << azRotorMovement ;		// Then print the line including the wish rotor angle
#endif
}

Now i only need to figure out how to mak each string 20 characters long

please note that String can cause trouble in pre 1.04 versions as the underlying free() was buggy.

{
  double azFloat = az / 100.0;					//adjust value for display
  String _azString = "AZ ";
  static char _azBuffer[7];
  
  if (azFloat < 10.0) {						// pad with spaces if needed
    _azString += " ";
  }
  if (azFloat < 100.0){
    _azString += " ";
  }

Did you really go to all this bother to save 2 commands to clear the LCD line ?

Yes, any idea how to this different? Remember i am not a C++ programmer.

It was you that said that you wanted to save the 2 lines required to clear the line on the LCD so I presume that you know what they are.

You where quoting some code, so i am asuming that it was about those lines.
In my code i used this to clear a line of text later on:

#ifdef LCD_SER_4X20
#ifndef LCD_I2C
const byte _line2 = 0xA8;	// lcd line 2 - 3th line
const byte _line3 = 0xBC;	// lcd line 3 - bottom line
#endif
String _clearString = "                    ";
#else
String _clearString = "                ";
#endif

And it either took 17 or 21 bytes in program memory.
Adding spaces to the actual line took less.