CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

printing pages to an LCD (with variables) using printf

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Bill Anderson
Guest







printing pages to an LCD (with variables) using printf
PostPosted: Mon Dec 16, 2002 11:52 am     Reply with quote

I would like to printf pages to an LCD. The pages may contain both fixed text and variable values. To avoid printf code bloat, I would like to make up an array that has the constant strings (cstring) for the various pages. The pages may also contain variables, so the constant string for each page would also contain the variable type definition in the appropriate spots in the constant strings. Is it possible to construct code something like this to do the job: (assume lcd_putc is a function to output characters to an LCD)

char page;
char variable1;
char variable2;


char const page_table[3][40] = {{"\%d page_1"}, {"\%d \%d page_2"},
{"page_3"}};

page = 1;
variable1 = 5;
variable2 = 6;

printf(lcd_putc, page_table[page][0], variable1, variable2);
___________________________
This message was ported from CCS's old forum
Original Post ID: 10071
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: printing pages to an LCD (with variables) using printf
PostPosted: Mon Dec 16, 2002 12:03 pm     Reply with quote

:=
:=char const page_table[3][40] = {{"\%d page_1"}, {"\%d \%d page_2"},
:= {"page_3"}};
:=
:=printf(lcd_putc, page_table[page][0], variable1, variable2);
---------------------------------------------------------

That won't work. You're hoping that printf is interpreted
at run-time, but it's done at compile time.

Here's an example of how to tightly pack strings into ROM:
<a href="http://www.pic-c.com/forum/general/posts/1640.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/1640.html</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10072
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group