????????将上位机采集到的数据通过串口发给单片机,数码管显示收到的信息。数码管显示程序见上篇文章,串口带协议收发在我的文章中也可以找到。
//mian函数
BYTE CODE[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //0~9显示代码
BYTE CODE1[10] = {0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xEF}; //带点显示
while(1)
{
if(flag == 1)
{
flag = 0;
for(j=3;j<count;j++)
{
check += rbuff[j];
}
check_1 = check % 6;
if(check_1 == check_2)
{
check = 0;
TM1650_Set(0x6C,CODE[rbuff[5]]);
TM1650_Set(0x6A,CODE1[rbuff[4]]);
TM1650_Set(0x68,CODE[rbuff[3]]);
TM1650_Set1(0x6C,CODE[rbuff[6]]);
TM1650_Set1(0x6A,CODE1[rbuff[7]]);
TM1650_Set1(0x68,CODE[rbuff[8]]);
TM1650_Set2(0x6C,CODE[rbuff[9]]);
TM1650_Set2(0x6A,CODE1[rbuff[10]]);
TM1650_Set2(0x68,CODE[rbuff[11]]);
}
else
{
SendData(0xbb);
// flag = 1;
state = 0;
}
count = 0;
}
}
|