How to pass a char[] array to a Function() ?

I have this CLCD display module from COMFILE Technology which uses I2C for communication. The basic idea is for my Arduino Pro Mini to send some Data to the LCD display. Some example codes are already available in the Arduino programming environment but it is not compatible with the module. COMFILE provide little information about the module but I managed to come up with this code and be able to send some data successfully. I now can send characters to the LCD module as well as number. My challenge was to turn numerical values into text. Sending numerical values such as int or float would result in incomprehensible gibberish. Thanks to the function itoa() I now can send those numbers as text and can read a text such as “My Text is” and “567” and it works quite well.
The end goal is to be able to utilize my LCD module to read some variable length numbers such as 1 or 76 or 876538. The problem I have is I can’t figure out how to pass a numerical value to a function().
So far I tried to implement the String() function with no success. C++ is a bit of a learning curve for me. I have more experience with Visual Basic.
The following code is working

itoa ( x , TheNumber , 10 )           ;   // x is a float() number
Wire.beginTransmission(ADrss )        ;   // Start transmit to LCD screen
  Wire.write  ( "Line of Text" )      ;   // send message
  Wire.write  ( TheNumber      )      ;   // send the x number as a text  
  Wire.endTransmission (       )      ;   // stop transmitting

This code is Not working:

void LCDtext( String(TheText) )    { 
  Wire.beginTransmission(ADrss)  ;
  Wire.write        ( TheText )  ;
  Wire.endTransmission      ( )  ; }

I am unable to come up with a working Function() to do the job.
I am trying to implement a “Function( MyText)” that will send the text to the LCD.
Same for numbers. When passing those values to the LCDtext() function or LCDnumber()
the compiler choke: error

“ (Send_I2C:39:31: error: no matching function for call to 'TwoWire::write(String&)' Wire.write ( TheText ) ”

My suspicion is that the I2C Arduino routine does not accept a String() as input.
I need to pass a char() type text but the length has to be dynamic.
Not sure how to implement that.

The complete code is here:

#include <Wire.h>

#include <string.h>


void setup() {
  pinMode(LED_BUILTIN, OUTPUT) ; 
 
  Wire.begin()                 ; } //   join i2c bus


bool  BrdLED = 0      ;

float x = 0           ;

int   ADrss = 0x00    ;

char  TheNumber[9]    ;

String MyText = String("0123456789ABCDEF");



void loop()   { 
  x++;

  itoa ( x , TheNumber , 10 )         ;


    if (x/2 == int(x/2) )   {
      LCDrow1234(1)     ;   }

    else                    {
      LCDrow1234(2)     ;   }


  String MyText = String( "Text: ")   ;

LCDtext(MyText); // this function call not working
LCDnumber(x);    // this function call not working
  Wire.beginTransmission(ADrss )      ;   // Start transmit to LCD screen

  Wire.write  ( "Line of Text" )      ;   // send message

  Wire.write  ( TheNumber      )      ;   // send one byte 
 
  Wire.endTransmission (       )      ;   // stop transmitting


  delay(200)  ;

  FlashLED()  ;
  } 
  

void LCDtext( String(TheText) )      { 
  Wire.write        ( TheText )  ;

  Wire.endTransmission      ( )  ; }   // stop transmitting 

   
void LCDnumber( char n[9]        )      { 
  char             TheString [ 9 ]   ;

  itoa      ( n , TheString , 10 )   ;

  Wire.beginTransmission ( ADrss )   ;

  Wire.write         ( TheString )   ;

  Wire.endTransmission         ( )   ;  }


void LCDclear() {
  delay(100);

  Wire.beginTransmission(ADrss);

  Wire.write(" ClearLCD ");   
  Wire.write(0x1B);

  Wire.write(0x43); 

  Wire.endTransmission(  );   
  delay(20);
  }


void LCDcursor  ( bool ONOFF    )     {   
  Wire.beginTransmission( ADrss ) ;

  Wire.write    ( 0x1B          ) ;

    if          ( ONOFF == true  )   {
      Wire.write( 0x53          ) ; }     

    else                            {
      Wire.write( 0x73          ) ; }     
      
  Wire.endTransmission  (       ) ; 
 
  delay(20);
  }


void LCDbacklight ( bool ONOFF  )     {
  Wire.beginTransmission( ADrss ) ;

  Wire.write    ( 0x1B          ) ;

    if          ( ONOFF == true  )   {
      Wire.write( 0x42          ) ; }     
    else                            {
      Wire.write( 0x62          ) ; }     
      
  Wire.endTransmission  (       ) ; 
 
  delay(20);
  }

void LCDhome    ( void          )     {   
  Wire.beginTransmission( ADrss ) ;

  Wire.write    ( 0x1B          ) ;       
      Wire.write( 0x48          ) ;       //  Bring Cursor Home

  Wire.endTransmission  (       ) ; 
 
  delay(20);
  }


void LCDlocate  ( byte XX , byte YY ) {   
  Wire.beginTransmission( ADrss ) ;

  Wire.write    ( 0x1B          ) ;

  Wire.write    ( 0x4C          ) ;

  Wire.write    ( XX            ) ;   // X coordinate

  Wire.write    ( YY            ) ;   // Y coordinate

  Wire.endTransmission  (       ) ; 
 
  delay(120);
  }


void LCDuser    ( char B8[7]    )     {   
  Wire.beginTransmission( ADrss ) ;

  Wire.write    ( 0x1B          ) ;

  Wire.write    ( 0x44          ) ;

  Wire.write    ( B8            ) ;   // This is 8bytes string containing the custom character

  Wire.endTransmission  (       ) ; 
 
  delay(20);
  }


void LCDrow1234 ( byte row      ) {     // row 0x01 to go to Row 1

  Wire.beginTransmission( ADrss ) ;  // row 0x02 to go to Row 2

  Wire.write    ( row           ) ;               // row 0x03 to go to Row 3

  Wire.endTransmission  (       ) ;         // row 0x04 to go to Row 4

  delay(20); }                       // NO row 5 available


 
void LCDzero() {
  delay(100); 
 
  Wire.beginTransmission(ADrss);

  Wire.write(" LCDzero ");

  Wire.write(0x1B);

  Wire.write(0x48); 

  Wire.endTransmission();    // stop transmitting

  delay(20); 
  }



  
void FlashLED( ) { 
  BrdLED = !BrdLED;                 //  This funciton will flash the OnBoard LED

  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on

  delay(200);  
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off

  delay(1000); }

Don't use String class.

About six months ago, I swore off using the String class and coding exclusively with char strings. But, if you follow my advice, you will get more compile errors. But fixing them will make you a better programmer.

Here is an explanation of why Strings are evil.

Never use

String = "This is some text";

Instead, use:

char *text = "This is some text";
or
char text[] = "This is some text";

Both assignments are identical. (I think).

Here is some notes from my notebook that may help:

//Here is an example of passing a string pointer to a function:
//  sendWav() 
// This function sends an audio filename to the slave device.
// In this case an Arduino Uno with the Adafruit Audio shield.
//

void sendWav(const char *f) {
  Wire.beginTransmission(slaveAddress);     // begin with device address 8
  Wire.write(f);                             // send the filename
  Wire.endTransmission();                   // stop transmitting
  delayMicroseconds(500);                   // Why is this needed?
}

The function LCDtext() is missing a Wire.beginTransmission().

You are allowed to have your very own style for the text of the code.
However, no one does this:

bool  BrdLED = 0      ;
float x = 0           ;
int   ADrss = 0x00    ;
char  TheNumber[9]    ;

That is confusing. Can you please put the ';' directly after the statement.

The global variables are always above the setup() function. You have them below the setup() function, and that is okay for the 'C++' language, but no one does that.

The auto-increment is used for integers. It is weird to use that for float numbers.
The normal way to use auto-increment is:

int i;
float f;

i++;   // auto-increment
f += 1.0;  // add 1.0 to a float

Comparing a float number to a integer is not possible. A float number is almost never a precise integer.
This is not possible:

float x;
if (x / 2 == int(x / 2) )

The itoa() function uses a integer for its first parameter: itoa - C++ Reference.
It is not allowed to use a character array instead of the integer:

void LCDnumber( char n[9])
{
  char TheString[9];
  itoa(n,TheString,10);

Can you press Ctrl+T in the Arduino IDE, and then fix every indent, every space, every newline.
When the layout of the text is good and consistant, then the structure of the code can be seen at the first glance at the code.
On the other hand, I have never seen a good working sketch with the text of the source code being a big mess.

You can start with a good working example. Adafruit has many tutorials. For example tutorials with ledstrips.
https://learn.adafruit.com/ (click "Explore and Learn" for the categories).

SteveMann:
Instead, use:

char *text1 = "This is some text";

or
char text2 = "This is some text";



Both assignments are identical. (I think).

They are not identical from an ISO C++ perspective.

Technically with the first one (text1) you have a pointer to character(s) that are supposed to be constant. The spec states that you can’t (or shouldn’t) try to modify the content.
If you do a text1[0] = 't';or *text1 = 't';to change the first letter, the compiler will complain with a warning but on an arduino it will still let you do it and it will work as the text will have been stored in SRAM so can technically be modified by a write operation. But another compiler could have chosen to store the data in Flash and then the write would have failed, that’s why you get the warning.

So the right way to declare would be const char * text1 = "This is some text"; or const char * const  text1 = "This is some text"; and then if you try to modify the first letter then you have a compilation error instead of just a warning this time as you break the promise you made to the compiler.

The second expression is different, you are declaring an array with an initial default value (used also to infer the size of the array if you did not provide a size). Such an array is modifiable and thus you will have no warning if you try to modify the first char (or any char).

Regarding the String class, it’s only evil if you do (willingly or unwillingly) some nasty operations involving lots of allocations and deallocations which could lead to poking holes in heap memory (and it has some small bugs/quirks). If you need something that will never grow or never be released and avoid dynamic allocation then you are fine. One key recommendation is to use the reserve() method to allocate a large enough buffer to meet your needs and never expand.
The main challenge and why it’s not so recommended is because beginners (and some more advanced developers) don’t get what is risky versus not risky.
Using char buffers and proper safeguards when you read or (especially) write to the buffer to stay within bounds puts you in control of your code.