|
|
View previous topic :: View next topic |
Author |
Message |
Bill Anderson Guest
|
printing pages to an LCD (with variables) using printf |
Posted: Mon Dec 16, 2002 11:52 am |
|
|
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
|
Re: printing pages to an LCD (with variables) using printf |
Posted: Mon Dec 16, 2002 12:03 pm |
|
|
:=
:=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 |
|
|
|
|
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
|