Syntax of DRAWTEXT with variables

Do you have a question on how to do something.
Ask in here.
Post Reply
Smotz
Posts: 412
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Syntax of DRAWTEXT with variables

Post by Smotz »

Hi All,

Can someone give me the DRAWTEXT syntax to include text, then a variable, then text, then another variable?

Example:

VARa=60;
VARb=10;

ReefAngel.LCD.DrawText(0,255,x,y,"RC" VARa "% +/- " VARb "%");

I want it to say

RC 60% +/-10%
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Syntax of DRAWTEXT with variables

Post by lnevo »

I dont think you can do that with DrawText by itself. You can use sprintf to create the string and then use DrawText to display it.

char buf[16];

sprintf(buf,"RC %d% +/-%d%",VarA,VarB);
Smotz
Posts: 412
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Syntax of DRAWTEXT with variables

Post by Smotz »

lnevo wrote:I dont think you can do that with DrawText by itself. You can use sprintf to create the string and then use DrawText to display it.

char buf[16];

sprintf(buf,"RC %d% +/-%d%",VarA,VarB);

eww. not elegant, huh?

Would my code look like this?

char buf[16];
sprintf(buf,"RC %d% +/-%d%",wpWavStr,wpWavOff);
ReefAngel.LCD.DrawText(0,255,x,y,buf);
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Syntax of DRAWTEXT with variables

Post by lnevo »

Yes. Keep in mind i'm writing the code on my phone...i'm doing that in a few places in my INO you can reference.
Smotz
Posts: 412
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Syntax of DRAWTEXT with variables

Post by Smotz »

lnevo wrote:Yes. Keep in mind i'm writing the code on my phone...i'm doing that in a few places in my INO you can reference.

Again, Thank you so much. I'll review your code.
Post Reply