打印
[STM32F1]

关于TFT

[复制链接]
849|7
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
一路向北lm|  楼主 | 2017-10-16 00:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
秉火STM32开发板 怎么在TFT上显示变量 我想显示个温度
沙发
一路向北lm|  楼主 | 2017-10-16 00:17 | 只看该作者
这个是显示一个英文的
/**
* @brief  在 ILI9341 显示器上显示一个英文字符
* @param  usX :在特定扫描方向下字符的起始X坐标
* @param  usY :在特定扫描方向下该点的起始Y坐标
* @param  cChar :要显示的英文字符
* @param  usColor_Background :选择英文字符的背景色
* @param  usColor_Background :选择英文字符的前景色
* @retval 无
*/
void ILI9341_DispChar_EN ( uint16_t usX, uint16_t usY, const char cChar, uint16_t usColor_Background, uint16_t usColor_Foreground )
{
        uint8_t ucTemp, ucRelativePositon, ucPage, ucColumn;

       
        ucRelativePositon = cChar - ' ';
       
        ILI9341_OpenWindow ( usX, usY, macWIDTH_EN_CHAR, macHEIGHT_EN_CHAR );
       
        ILI9341_Write_Cmd ( macCMD_SetPixel );       
       
        for ( ucPage = 0; ucPage < macHEIGHT_EN_CHAR; ucPage ++ )
        {
                ucTemp = ucAscii_1608 [ ucRelativePositon ] [ ucPage ];
               
                for ( ucColumn = 0; ucColumn < macWIDTH_EN_CHAR; ucColumn ++ )
                {
                        if ( ucTemp & 0x01 )
                                ILI9341_Write_Data ( usColor_Foreground );
                       
                        else
                                ILI9341_Write_Data ( usColor_Background );                                                               
                       
                        ucTemp >>= 1;               
                       
                }/* 写完一行 */
               
        }/* 全部写完 */
       
}

使用特权

评论回复
板凳
一路向北lm|  楼主 | 2017-10-16 00:18 | 只看该作者
/**
* @brief  在 ILI9341 显示器上显示英文字符串
* @param  usX :在特定扫描方向下字符串的起始X坐标
* @param  usY :在特定扫描方向下字符串的起始Y坐标
* @param  pStr :要显示的英文字符串的首地址
* @param  usColor_Background :选择英文字符串的背景色
* @param  usColor_Background :选择英文字符串的前景色
* @retval 无
*/
void ILI9341_DispString_EN ( uint16_t usX, uint16_t usY, const char * pStr, uint16_t usColor_Background, uint16_t usColor_Foreground )
{
        while ( * pStr != '\0' )
        {
                if ( ( usX - macILI9341_DispWindow_X_Star + macWIDTH_EN_CHAR ) > macILI9341_DispWindow_COLUMN )
                {
                        usX = macILI9341_DispWindow_X_Star;
                        usY += macHEIGHT_EN_CHAR;
                }
               
                if ( ( usY - macILI9341_DispWindow_Y_Star + macHEIGHT_EN_CHAR ) > macILI9341_DispWindow_PAGE )
                {
                        usX = macILI9341_DispWindow_X_Star;
                        usY = macILI9341_DispWindow_Y_Star;
                }
               
                ILI9341_DispChar_EN ( usX, usY, * pStr, usColor_Background, usColor_Foreground );
               
                pStr ++;
               
                usX += macWIDTH_EN_CHAR;
               
        }
       
}

使用特权

评论回复
地板
一路向北lm|  楼主 | 2017-10-16 00:18 | 只看该作者
/**
* @brief  在 ILI9341 显示器上显示一个中文字符
* @param  usX :在特定扫描方向下字符的起始X坐标
* @param  usY :在特定扫描方向下字符的起始Y坐标
* @param  usChar :要显示的中文字符(国标码)
* @param  usColor_Background :选择中文字符的背景色
* @param  usColor_Background :选择中文字符的前景色
* @retval 无
*/
void ILI9341_DispChar_CH ( uint16_t usX, uint16_t usY, uint16_t usChar, uint16_t usColor_Background, uint16_t usColor_Foreground )
{
        uint8_t ucPage, ucColumn;
        uint8_t ucBuffer [ 32 ];       

  uint16_t usTemp;        

       
        ILI9341_OpenWindow ( usX, usY, macWIDTH_CH_CHAR, macHEIGHT_CH_CHAR );
       
        ILI9341_Write_Cmd ( macCMD_SetPixel );
          
  macGetGBKCode ( ucBuffer, usChar );        //取字模数据
       
        for ( ucPage = 0; ucPage < macHEIGHT_CH_CHAR; ucPage ++ )
        {
    /* 取出两个字节的数据,在lcd上即是一个汉字的一行 */
                usTemp = ucBuffer [ ucPage * 2 ];
                usTemp = ( usTemp << 8 );
                usTemp |= ucBuffer [ ucPage * 2 + 1 ];
               
                for ( ucColumn = 0; ucColumn < macWIDTH_CH_CHAR; ucColumn ++ )
                {                       
                        if ( usTemp & ( 0x01 << 15 ) )  //高位在前
                          ILI9341_Write_Data ( usColor_Foreground );
                               
                        else
                                ILI9341_Write_Data ( usColor_Background );
                       
                        usTemp <<= 1;
                       
                }
               
        }
       
}

使用特权

评论回复
5
一路向北lm|  楼主 | 2017-10-16 00:19 | 只看该作者
/**
* @brief  在 ILI9341 显示器上显示中文字符串
* @param  usX :在特定扫描方向下字符串的起始X坐标
* @param  usY :在特定扫描方向下字符串的起始Y坐标
* @param  pStr :要显示的英文字符串的首地址
* @param  usColor_Background :选择字符串的背景色
* @param  usColor_Background :选择字符串的前景色
* @retval 无
*/
void ILI9341_DispString_CH ( uint16_t usX, uint16_t usY, const uint8_t * pStr, uint16_t usColor_Background, uint16_t usColor_Foreground )
{       
        uint16_t usCh;
       
       
        while( * pStr != '\0' )
        {               
                if ( ( usX - macILI9341_DispWindow_X_Star + macWIDTH_CH_CHAR ) > macILI9341_DispWindow_COLUMN )
                {
                        usX = macILI9341_DispWindow_X_Star;
                        usY += macHEIGHT_CH_CHAR;
                }
               
                if ( ( usY - macILI9341_DispWindow_Y_Star + macHEIGHT_CH_CHAR ) > macILI9341_DispWindow_PAGE )
                {
                        usX = macILI9341_DispWindow_X_Star;
                        usY = macILI9341_DispWindow_Y_Star;
                }       
               
                usCh = * ( uint16_t * ) pStr;       
          usCh = ( usCh << 8 ) + ( usCh >> 8 );

                ILI9341_DispChar_CH ( usX, usY, usCh, usColor_Background, usColor_Foreground );
               
                usX += macWIDTH_CH_CHAR;
               
                pStr += 2;           //一个汉字两个字节

        }          
       
}

使用特权

评论回复
6
一路向北lm|  楼主 | 2017-10-16 00:20 | 只看该作者

/**
* @brief  在 ILI9341 显示器上显示中英文字符串
* @param  usX :在特定扫描方向下字符串的起始X坐标
* @param  usY :在特定扫描方向下字符串的起始Y坐标
* @param  pStr :要显示的字符串的首地址
* @param  usColor_Background :选择字符串的背景色
* @param  usColor_Background :选择字符串的前景色
* @retval 无
*/
void ILI9341_DispString_EN_CH ( uint16_t usX, uint16_t usY, const uint8_t * pStr, uint16_t usColor_Background, uint16_t usColor_Foreground )
{
        uint16_t usCh;
       
       
        while( * pStr != '\0' )
        {
                if ( * pStr <= 126 )                           //英文字符
                {
                        if ( ( usX - macILI9341_DispWindow_X_Star + macWIDTH_EN_CHAR ) > macILI9341_DispWindow_COLUMN )
                        {
                                usX = macILI9341_DispWindow_X_Star;
                                usY += macHEIGHT_EN_CHAR;
                        }
                       
                        if ( ( usY - macILI9341_DispWindow_Y_Star + macHEIGHT_EN_CHAR ) > macILI9341_DispWindow_PAGE )
                        {
                                usX = macILI9341_DispWindow_X_Star;
                                usY = macILI9341_DispWindow_Y_Star;
                        }                       
               
                  ILI9341_DispChar_EN ( usX, usY, * pStr, usColor_Background, usColor_Foreground );
                       
                        usX += macWIDTH_EN_CHAR;
               
                  pStr ++;

                }
               
                else                                    //汉字字符
                {
                        if ( ( usX - macILI9341_DispWindow_X_Star + macWIDTH_CH_CHAR ) > macILI9341_DispWindow_COLUMN )
                        {
                                usX = macILI9341_DispWindow_X_Star;
                                usY += macHEIGHT_CH_CHAR;
                        }
                       
                        if ( ( usY - macILI9341_DispWindow_Y_Star + macHEIGHT_CH_CHAR ) > macILI9341_DispWindow_PAGE )
                        {
                                usX = macILI9341_DispWindow_X_Star;
                                usY = macILI9341_DispWindow_Y_Star;
                        }       
                       
                        usCh = * ( uint16_t * ) pStr;       
                       
                        usCh = ( usCh << 8 ) + ( usCh >> 8 );               

                        ILI9341_DispChar_CH ( usX, usY, usCh, usColor_Background, usColor_Foreground );
                       
                        usX += macWIDTH_CH_CHAR;
                       
                        pStr += 2;           //一个汉字两个字节
               
    }
               
  }
       
       
}

使用特权

评论回复
7
一路向北lm|  楼主 | 2017-10-16 00:21 | 只看该作者
怎么修改以上任意函数来显示一个变量呢?

使用特权

评论回复
8
mmuuss586| | 2017-10-16 09:39 | 只看该作者
没用过他们的开发板;
你可以问他们技术支持看看;

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

257

主题

3643

帖子

73

粉丝