请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:MSP430F5529 工具与软件:
多年来、我一直将此代码与标准库"itoa"一起使用、用于将无符号字符值添加到字符串并显示它。
使用"ltoa (char str、int val、int radx)"时无法正常工作。
我知道某些 CCS 版本"ltoa"没有基数、但也不是问题。
请注意、"rawText (int x、int y、unsigned int FG_color、unsigned int bg_color、char const * string)" 函数在程序中的其他地方已经过多次验证。
它打印此文件: 从时钟#XS
应打印: 从时钟#3
void dispClkID() { unsigned char clk_id; char s1[20], s2[3]; /* hardware detection not built yet. * clk_id is hard coded until then. */ clk_id= 3; if (clk_id == 1) { strcpy(s1," MASTER CLOCK #1 "); drawText(TEXT_BG_CENTER,textY(0),BLACK,ORANGE,s1); } else if ((clk_id > 1)&&(clk_id < 5)) { ltoa(clk_id,s2,10); strcpy(s1," SLAVE CLOCK #"); strcat(s1,s2); strcat(s1," "); drawText(TEXT_BG_CENTER,textY(0),BLACK,ORANGE,s1); } else { strcpy(s1,"Clock ID not set"); drawText(TEXT_BG_CENTER,textY(0),RED,BLACK,s1); } }