![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Chevy64
Joined: 05 Apr 2013 Posts: 7
|
printf(lcd_putc, |
Posted: Tue Feb 09, 2016 2:28 am |
|
|
Hi Guys;
This is my first time to write in the forum if I have written in wrong spot please accept my apology.
Here is my simplest code:
Code: |
printf(lcd_putc,"\f%C%C%C%C%C%C%C%C%C%C%C%C%C%C%C%C%C%C%C%C
%C%C%C%C%C%C%C%C",243,243,243,143,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,
243,243,243,243,243,243,243,243,);
|
if I print 26 characters compiler runs OK, however if I try to add one more %C, compiler throws an error: Too many parameters... Namely can not put 27 characters. Why is that ?
1) I am using Flex_LCD420.c as a LCD driver. Although checked by replacing it LCD420.c still same error message.
2) My compiler version PCH 5.025 and have not tried other versions.
Thank you guys in advance...Please help. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19360
|
|
Posted: Tue Feb 09, 2016 2:48 am |
|
|
There are limits on most things. There are length limits on the format string, limits on the maximum number of variables allowed etc. etc..
I think you will find your whole bracket contents are exceeding 255 characters, and this is the actual 'limit'.
Remember there is nothing to stop you splitting this onto multiple lines. Do 16 per line. Also, if this is just to send a graphic character to the LCD, then:
Code: |
int8 ctr;
lcd_putc('\f');;
for (ctr=0;ctr<80;ctr++)
lcd_putc(243);
|
sends the 243 character 80 times, and is much smaller and easier for the compiler.... |
|
![](templates/subSilver/images/spacer.gif) |
Chevy64
Joined: 05 Apr 2013 Posts: 7
|
|
Posted: Tue Feb 09, 2016 3:50 am |
|
|
Thank you Ttelmah;
I got you, but still have a hard time to understand.
I am printing only 26 Characters not 255,and what if I try to print different characters instead of repeating characters. How come I could exceed my quota?
Ok I made a calculations totally assumptive.. Say every character in LCD composed of 5x8 pixels and I can put 26 thus 40X26=1040 which is 1K. So I have to have 4x255 pixels. Than question is How come I can put an ordinary numbers filling up the LCD. Tried I can not.. So problem is LCD's memory becomes full. Sorry for out loudly thinking. So how to clear? Should I print one line at a time? Tnx Tnx. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19360
|
|
Posted: Tue Feb 09, 2016 4:26 am |
|
|
The point is that the compiler has to parse the whole statement. It is the length limit on the _statement_ that you are hitting. Think about it, you have all the individual %C's, then all the ,xxx values. All have to be handled.
Remember a line in the printf, is not a line in the display. You can do something like:
Code: |
printf("something");
printf(" something else");
|
and the output will receive "something something else", without break.
Hopefully you would never be sending separate characters for anything involving this many outputs. If you have (for instance) a load of data, then have an array containing this, and use a loop to send the array.
The thing about 'printf', is that it involves a parser. So the %C command says 'go and pull the next variable, format it in this form, and send it'. A complete separate routine. Though you are using the simplest output from the parser, it is still a terribly complex way of just outputting a value...
Look at how font data is sent from the fgx_graphics routines. |
|
![](templates/subSilver/images/spacer.gif) |
Chevy64
Joined: 05 Apr 2013 Posts: 7
|
|
Posted: Tue Feb 09, 2016 5:28 am |
|
|
Thank you all for your prompt answer. As Ttelmah explained; despite printf is an adorable function and does arduous job it is a parser with limits. If one splits also works with 4X20 LCD by putting r\n or \n at the end. Again many thanks for your answers. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|