- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have loaded the PWM PRS example and added an LCD to display the CompareValue as a percentage as well as show the CompareValue as a bar graph. The 0 bargraph appears to be all partially on without the hexbyte displayed.
Archive attached
Any suggestions?
Chris
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@ bob. Is csprinf for wide characters?
also I was wondering why it's need to have type cast, I think it should not need to. as the formating string "%3d" is actually on flash.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Greetings from Harvard.
Since in the PSoC1 code the access to data residing in flash differs from ram accesses functiond need to know where parameters are stored. So sometimes two different functions exist like LCD_PrString() and LCD_PrCString();
Same is for sprintf() which expects the formatstring residing in ram and csprintf() expecting it in flash. This is specific for the PSoC1 implementation, PSoC3,4 and 5's C-compiler work differently.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
csprintf (s,%3d,BG) prints 3d on the LCD. Nothing else.
sprintf(s,%3d,ip) should print the value pointed to by ip into s with the format of up to 3 characters right justified leading zero's replaced with a space.
Nothing like what actually happens.
Regards
Chris D.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sorry that should read csprintf(s,"%3d",BG)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dinesh's thread predates Imagecraft Pro release, makes one
wonder if the gyrations still needed as pointed out by thread.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dinesh's post only used stdio.h. What different library did he call?
When I used that format of csprintf as suggested by Bob the result was to print the "3d" characters on the LCD. Not what I wanted.
Has anyone actually done this on the 3210 eval kit?
Regards
Chris D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an application that has done both integer, longs,
and floats, but used HiTech compiler.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Same for me, but uses ImageCraft compiler.
Did you already post your actual project here?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sprintf(s,%3d,ip) should print the value pointed to by ip into s with the format of up to 3 characters right justified leading zero's replaced with a space.
sprintf will take a numeric in ram and fill an array with the ascii string representation, using formatting parameter,
terminated with a NULL character. After you execute sprintf then you execute the LCD_PrString() on the buffer that
sprintf() filled.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I loaded Bob's project. I also had to manually include PSoCAPI.h manually to Bob's library file because it was not included.
I have had to also add PRS.h?? and PWM.h?? before it would start the compiler.
Then the compiler produced the following error string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I compiled Bob's project under PSOC Designer 5.4 with no mods, and it completed error free.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is the version info -
Imagecraft Compiler Standard V7.0.5
PSoC Designer Code Examples 5.4 - Build 2946 - 19-May-2013.10:14:46
PSoC Designer Content 5.4 CP1 - Build 3013 - 14-July-2014.07:37:02
PSoC Designer Core 5.4 - Build 2946 - 19-May-2013.10:14:46
PSoC Designer Documentation 5.4 CP1 - Build 3013 - 14-July-2014.07:37:02
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My version is identical.
What now?
Chris D.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem Solved!!!
I have added LCD_PrCString(" ") at the same position on the LCD as the LCD_Prstring command thus,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is this correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, Thats correct as well as fill leading zero's with a blank character-- BUT-- it does NOT right justify. The number 5 is printed as 500 and the number 50 is also printed as 500 once the display has displayed 100. When the program is reinitilised the display reads 50 (127 is 50% of 255) if the bargraph is reduced to 3% the display reads30. If I increase the display to 100% then back to 50% the display teads 500 and maintains the 3 character format.
Using LCD_PrCstringF(" "); at the position of the character print on the LCD fixes the problem. The single digit numbers print as a single digit ie 5% displays 5 even if I run up to 100% and back to 5%.
As for your other suggestions re the debounce, it is not required as the inputs come from a digital source.
The other suggestions re if-then-else loops, in my humble opinion, makes the program harder to follow.
Regards
Chris D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Should the 2nd argument be the formatting, and the third one be the number to print?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BTW can someone tell me where I can find documentation about that csprintf()? Tks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the presented code-snippets are some ambiguities as coding, parameter order, variable declarations, It would clear many questions and shoten the discussiond when we can get an actual project archive.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And of course it should read
char s[17];
int ip;
csprintf(s,"%3d",ip);
LCD_PrString(s);
Mark the parameter order: csprintf(char*Buffer,"FormatString",Var1,Var2,...)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Dana, thanks for the link. But there is mainly fo5 the cprintf rsther than csprintf. Any way, I read the header files in the designer project, and kown a bit more about these special library funtions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Bodb. I think the same too.