修改STC_SEG7_ShowString的逻辑后,能正确处理带.的字符串,且能处理多个.的情况了
- //功能1: 在数码管上显示字符串
- void STC_SEG7_ShowString(const char *str)
- {
- uchar len,pos;
- stc_buff[0] = 0x37;
- stc_buff[1] = 0x53;
- stc_buff[2] = 0x45;
- stc_buff[3] = 0x47;
- stc_buff[4] = 0x53;
- stc_buff[5] = 0x00;
- stc_buff[6] = 0x00;
- stc_buff[7] = 0x00;
-
- pos=8,len=0;
-
- while(*str)
- {
- if(*str == '.')
- {
- if(stc_buff[pos-1] == '.')//如果上一位是点,则跳过
- {
- str++;
- continue;
- }
- stc_buff[pos++] = *str++; //否则添加点,但是不算位数
- }
- else
- {
- stc_buff[pos++] = *str++;
- len++;
- if(len >=8)
- {
- if(*str == '.')
- stc_buff[pos++] = *str;
- break;
- }
- }
- }
- stc_buff[pos] = 0;
- UartSendData(stc_buff,pos+1);
- }
复制代码
|