Hi all,
I have a sketch which uses a Real Time Clock to count down the time remaining until a certain date and display it on a 16*2 LCD. At the same time I made the info scroll from right to left on the display.
Everything works as expected, even the scrolling which was fun to do as it scrolls just one row leaving the other static.
However as I like to keep my code organized, after I finished the sketch on a sigle .ino file, I want to create separate libraries to handle LCD and RTC codes.
Firstly I created the RTC library and apparently works as intended. I created a public method that returns a char array. It looks like this:
char RtcSetup::timeChar(){
//some calculations
String preCharLib;
preCharLib=preCharLib + weeks + " Woche(n) " + days + " Tag(e) " + hours + " Stunde(n) " + minutes + " Minute(n)";
char secondLine[preCharLib.length()+1]; // create the char array
preCharLib.toCharArray(secondLine, preCharLib.length()+1); // populate the array
return secondLine;
}
The code compiles ok so far. The problem arises when I try to call this created char array from the .ino file
If I try to call it like this:
char secondLine[]=rtClock.timeChar();
I got the following error:
initializer fails to determine size of 'secondLine'
If I try to call it like this:
char secondLine=rtClock.timeChar();
and I try to do somethig like this
temporal[i]=secondLine[i+foo];
I got the error:
invalid types 'char[int]' for array subscript
Getting an integer of the length of the char array and using in when initializing on the .ino file, also does not work.
I know I could be much better off working with Strings instead, I guess. But for a future expansion, I really need to work with char array, which I never found easy to begin with.
I really tried google the issues, but I haven't found anything really helpful.
Any help in moving on, will be much appreciated.