Page 1 of 1

TimePlot not taking string variables

Posted: Fri Jul 19, 2019 1:42 am
by ceremona
Hi

I am trying to use the TimePlot constructor to create different variable streams without putting the string directly in the Timeplot argument, sort of like so:

String tmp="blah";
TimePlot TempPlot1(tmp);

As opposed to just saying Timeplot TempPlot1("blah");

But I get a compile error. (Sorry can't easily copy the error right now). But is there anything obviously wrong with doing this? I don't see it. Do I need to do some kind of clever TempPlot1((char *) tmp) type cast to turn the string into a pointer? Because I tried that and it doesn't work.

Thanks

Re: TimePlot not taking string variables

Posted: Mon Jul 22, 2019 5:48 am
by philr
Hi Ceremona, we have typically chosen not to support strings as they are not great memory wise. We instead recommend the pstring library. This lets you pre-allocate memory which you can use to construct a character array. You then use this with our library. This post explores it a bit:
viewtopic.php?f=5&t=1409&hilit=pstring&start=10

You can get the library here:
http://arduiniana.org/libraries/pstring/

Have a go with that and let me know if you have any questions.
Cheers
Phil