system
December 23, 2009, 1:27am
1
Hello. I'm a noob trying to convert http://mikeyancey.com/files/arduino-fm/ARRduino_FM_v1/ARRduino_FM.pde so that it will work with Arduino-17. If I use TextString, it refuses to compile, so I figured I'd try to convert it to use WString. If I just change the #include then I get an error about using getArray. Instead, I tried to change all of the setCharAt/getArray/setArray as follows:
TextString lcdOutput = TextString( 9 );
lcdOutput.setArray("108.0MHZ" );
lcdOutput.setCharAt( 4, chrDigits[ aDigit ] );
to
char lcdOutput[][9] = {"108.0mhz"};
lcdOutput[4] = chrDigits[ aDigit ];
This doesn't work and gives the following error:
error: incompatible types in assignment of 'const char [2]' to 'char [9]
I've tried searching around the forum and google for solutions but nothing seems to work. Any ideas?
Thanks!
system
December 23, 2009, 10:14am
2
char lcdOutput[][9]
This defines a two dimensional array of a size that the compiler is supposed to figure out based on the initialization data provided.
= {"108.0mhz"};
This is one dimensional initialization data.
The sizes (2D and 1D) don't match, so you can't do that.
Change it to:
char lcdOutput[9] = {"108.0mhz"};
lcdOutput[4] = chrDigits[ aDigit ];
system
December 23, 2009, 6:32pm
3
I could have sworn that I'd tried that but now that you tell me to do it, it works
Now I'm getting a different problem. Originally, the code read the array using:
lcd.printIn( lcdOutput.getArray() );
How would I do the same with WString? I tried several variations of:
lcd.printIn( lcdOutput[] );
but nothing worked.
Thanks again!
system
December 23, 2009, 10:09pm
4
I have no idea where TextString::getArray() is getting data from, so I don't know what to suggest as a replacement. Maybe someone else does.
Is one of these what you need...
lcd.printIn( lcdOutput.cstr() );
lcd.printIn( (char*)lcdOutput );