|
我用的k600+用单片机串口发送 写入地址 实现字符和地址的显示 目前可以显示字字符但是 数字用却出现了点问题
void DwinWriteAddr(uint16_t addr, char* str, uint8_t strl)
{
uint8_t len,i;
uint8_t lenstr;
uint8_t Packbuf[256 + 6] = {0};
lenstr = strlen(str);
if (lenstr > strl){
lenstr = strl;
}
Packbuf[0] = 0x5a;
Packbuf[1] = 0xa5;
len = 3 + strl;
Packbuf[2] = len;
Packbuf[3] = 0x82;
Packbuf[4] = addr >> 8;
Packbuf[5] = (uint8_t)addr;
for (i=0; i <= lenstr; i++){
Packbuf[6+i] = *(str+i);
}
for (i=0; i < strl - lenstr; i++){
Packbuf[6+strlen(str)] = '\0'; //填补空格
}
len=len+3;
Serial_SendArray(Packbuf, len);
}
uint32_t number=1000;
sprintf((char *)buf,"%d", number );
DwinWriteAddr(0x0202,(char *)buf, 8);
不知道为什么数字显示不正确
|
|