用的CCSv5
调试的时候遇到一个问题——sprintf要么不支持float,要么不支持int,情况如下:
void Dogs102x6_FloatDraw(uint8_t row, uint8_t col, float temp, uint8_t style)
{
char buffer[50];
sprintf(buffer,"%-10.3f",temp);//在level of printf support 中选择Full时可用
Dogs102x6_stringDraw(row, col, buffer, style);
}
void Dogs102x6_IntDraw(uint8_t row, uint8_t col, uint16_t temp, uint8_t style)
{
char buffer[50];
sprintf(buffer, "%d", temp);//在level of printf support 中选择minimal时可用
Dogs102x6_stringDraw(row, col, buffer, style);
}
灰小子:
好奇怪,按理说,选择full:,应该Supports all format specifiers.
yixin wang:
实在找不到直接解决的办法,目前用其他方法显示整数,如下:
void Dogs102x6_IntDraw(uint8_t row, uint8_t col, uint16_t temp, uint8_t style){ char buffer[50]; sprintf(buffer, "%.0f", (float)temp); Dogs102x6_stringDraw(row, col, buffer, style);}
不过我还是很想知道有没有直接一点的办法。编译器真是不了解啊。能不能解释一下。
Susan Yang:
回复 yixin wang:
建议您参考http://processors.wiki.ti.com/index.php/Tips_for_using_printf
Make sure you are not using –printf_support=nofloat or –printf_support=minimal.
yixin wang:
回复 Susan Yang:
用的确实是Full