printf

int fputc(int ch, FILE *f)//重定义fputc函数 
{      

u8 str[2]=0;
        sprintf(str,"%d",ch);
Show_Str(0,0,WHITE,BLUE,str,16,1);

}

此时有问题,打印拥挤在一起的。


Show_Str(0,0,WHITE,BLUE,"str",16,1);

这样是OK但是没啥子意义。显示STR在UI

http://blog.sina.cn/dpool/blog/s/blog_88534dff01010t0s.html

暂时放弃。

根据http://blog.sina.com.cn/s/blog_6e22f4ce010136t9.html

int fputc(int ch, FILE *f)//重定义fputc函数 
{      
#ifdef USEUSART2
while((USART2->SR&0X40)==0);//OSHELP 无线串口   
    USART2->DR = (u8) ch;      
return ch;
#else
// USART1->DR = (u8) ch;  
// while((USART1->SR&0X40)==0){};//循环发送,直到发送完毕     
// return ch;  



static uint16_t x = 0, y = 0;
  uint8_t string[16];


  if(ch == '\n')    //换行
  {
    x = 0;
    y += 16;
    return ch;
  }


  if(x > 240 - 8)  //X_MAX是宏定义, 该值为240
  {
    x = 0;           //x置零
    y += 16;         //y移至下一行
  }
  if(y > 320 - 16)  //Y_MAX是宏定义, 该值是320
  {
    return ch;        //直接退出
  }


sprintf(string,"%d",ch);
Show_Str(x,y,WHITE,BLUE,string,16,1);
  //string = Get_Ascii(ch);   //获取ch的字模
  //LCD_Ascii_One(x, y, string, color); //打印字符ch
  x += 8;                   //跳转到下一个位置, 是否越界有上面函数判断


  return ch;



#endif

}


可以用用

猜你喜欢

转载自blog.csdn.net/weixin_42381351/article/details/80897351