This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
用的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);
}
实在找不到直接解决的办法,目前用其他方法显示整数,如下:
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);
}
不过我还是很想知道有没有直接一点的办法。编译器真是不了解啊。能不能解释一下。
建议您参考http://processors.wiki.ti.com/index.php/Tips_for_using_printf
Make sure you are not using --printf_support=nofloat or --printf_support=minimal.