完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
亲爱的各位,
现在我想从EEPROM到LCD读取数据,我使用API -LCDA CARAL PrimeNoUnter(),它可以正确地重放三位数小数,如110122。但是,它不能读取两位数小数和小数位数,如11. 9,这可能是由它所说的“左对齐ASCII字符”引起的,不是吗?但是,为什么三位数的十进制可以显示正确?我怎样才能读出所有的数据?谢谢。 QQY20120131219105218.JPG 17.2 K 以上来自于百度翻译 以下为原文 Dear all, Now I want to read datas from EEPROM to LCD,I use the API——LCD_Char_PrintNumber(),it can diplay three-figure decimal correctly,like 110,122.However,it can't read the two-figure decimal and single-figure decimal right,like 11,9.It maybe caused by it said"left-justified ASCII characters",isn't it?But ,why the three-figure decimal can be display right?How can i read all the datas right on display?THX.
|
|
相关推荐
12个回答
|
|
@希尔
是的,上面的代码是整个Meal.C文件的一部分。我只是复制了与这个问题相关的部分。 以上来自于百度翻译 以下为原文 @hil Yeah,the code above is a part of the whole main.c file.I just copy the part related this problem. |
|
|
|
使用SimultFor()将其打印到字符缓冲区中,并使用所需的格式。然后打印出与任何其他字符串一样的缓冲区。
以上来自于百度翻译 以下为原文 Use sprintf() to print into a char buffer, with the formatting you want. Then you print out that buffer like any other string. |
|
|
|
这是完成一个二进制数转换为ASCII码的几种不同的方式。作为sprintf() HLI建议是最方便和最简单的方式,但是会消耗最多的资源。使用ITOA.()是C.中的另一个可使用的函数。
最后一个做自己动手解决不断将整数10到结果是零,将剩余的ASCII字符(增加0)将做的工作以及。 鲍勃 以上来自于百度翻译 以下为原文 There are several different ways to accomplish conversion of a binary number to ascii characters. As hli suggested sprintf() is the most convinient and easiest way, but will consume the most resources. Using itoa() is another ready to use function in C. Lastly a do-it-yourself solution by constantly dividing an integer by 10 until the result is zero and converting the remainder to an ascii char (by adding '0') will do the job as well. Bob |
|
|
|
就这样?但它不像以前那么好。CHAR*DA=(CHAR*)MALOC(1);int TA;(index=0;index & lt;100;index ++){TA=SaveTFF(DA,“%D”,CythGETYEGRIG8(CydeGeE.Base+索引));LCDA CHARYA 1PrimtScript(DA);IF(index=99)索引=0;CyDelay(1000);}
以上来自于百度翻译 以下为原文 Just like this ?But it doesn't work well as before. char* da=(char*)malloc(1); int ta; for(index=0;index<100;index++) { ta=sprintf(da,"%d",CY_GET_REG8(CYDEV_EE_BASE+index)); LCD_Char_1_PrintString(da); if(index==99) index=0; CyDelay(1000); } |
|
|
|
'Maloc(1)'是错误的。您需要分配尽可能多的字符作为打印字符串可以,加上一个(为终止’0’)。 它也更容易分配一个静态缓冲区(char *Da= char(10);)。 以上来自于百度翻译 以下为原文 The 'malloc(1)' is wrong. You need to allocate as many characters as your printed string can be, plus one (for the terminating ' |