久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2040|回復: 2
打印 上一主題 下一主題
收起左側

1.8 TFT st7735s顯示顏色不對,請幫看看

[復制鏈接]
跳轉到指定樓層
樓主
ID:939553 發表于 2023-10-12 08:54 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
調試字體顏色為#define PURPLE         0xF81F                //紫,實際顯示為綠色
調試字體顏色為#define WHITE                0xFFFF                //白,實際顯示為黃色

不知道哪設置不對
//屏幕轉向和RGB格式
        tft_write_reg(0x36);
        tft_write_byte(0xA0);

//設置A8也不行
        tft_write_byte(0xA8);

//***********************************************************************
//TFT常用顏色(RGB565采用兩個字節表示顏色,前5位表示紅色,中間6位表示綠色,后面5位表示藍色)
#define RED                  0xF800                 //紅
#define YELLOW  0xFFE0                //黃
#define GREEN                0x07E0                //綠
#define CYAN                0x07FF                //青
#define BLUE                 0x001F                //藍
#define PURPLE         0xF81F                //紫
#define BLACK                0x0000                //黑
#define WHITE                0xFFFF                //白
#define GRAY                0x7BEF                //灰


//LCD初始化
void tft_init(void)
{
        sys_delay = 20/10;
        LCD_RST = 0;
        while(sys_delay){rst_wdi();}
        LCD_RST = 1;
       
        //等待芯片復位時間200ms
        sys_delay = 200/10;
        while(sys_delay){rst_wdi();}
       
        //端口初始化
        LCD_CS = 1;
        LCD_CLK = 0;
       
        //芯片初始化
        tft_write_reg(0x11);
        sys_delay = 200/10;
        while(sys_delay){rst_wdi();}

        //tft_write_reg(0x21); //顯示反轉

        //幀速率設置
        tft_write_reg(0xB1);
        tft_write_byte(0x01);
        tft_write_byte(0x2c);
        tft_write_byte(0x2d);
       
        tft_write_reg(0xB2);
        tft_write_byte(0x01);
        tft_write_byte(0x2c);
        tft_write_byte(0x2d);
       
        tft_write_reg(0xB3);
        tft_write_byte(0x01);
        tft_write_byte(0x2c);
        tft_write_byte(0x2d);
        tft_write_byte(0x01);
        tft_write_byte(0x2c);
        tft_write_byte(0x2d);
       
        //列反轉模式設置
        tft_write_reg(0xB4);
        tft_write_byte(0x07);
        //POWER CONTROL
        tft_write_reg(0xC0);
        tft_write_byte(0xa2);
        tft_write_byte(0x02);
        tft_write_byte(0x84);
        //電壓設置
        tft_write_reg(0xC1);
        tft_write_byte(0xC5);
       
        tft_write_reg(0xC2);
        tft_write_byte(0x0a);
        tft_write_byte(0x00);
       
        tft_write_reg(0xC3);
        tft_write_byte(0x8a);
        tft_write_byte(0x2A);   
       
        tft_write_reg(0xC4);
        tft_write_byte(0x8a);
        tft_write_byte(0xEE);
       
        tft_write_reg(0xC5);  //VCOM/
        tft_write_byte(0x0e);   
       
        //屏幕轉向和RGB格式
        tft_write_reg(0x36);
        tft_write_byte(0xA0);

        tft_write_reg(0xe0);
        tft_write_byte(0x0f);
        tft_write_byte(0x1a);
        tft_write_byte(0x0f);
        tft_write_byte(0x18);
        tft_write_byte(0x2f);
        tft_write_byte(0x28);
        tft_write_byte(0x20);
        tft_write_byte(0x22);
        tft_write_byte(0x1f);
        tft_write_byte(0x1b);
        tft_write_byte(0x23);
        tft_write_byte(0x37);
        tft_write_byte(0x00);        
        tft_write_byte(0x07);
        tft_write_byte(0x02);
        tft_write_byte(0x10);
         
        tft_write_reg(0xe1);
        tft_write_byte(0x0f);
        tft_write_byte(0x1b);
        tft_write_byte(0x0f);
        tft_write_byte(0x17);
        tft_write_byte(0x33);
        tft_write_byte(0x2c);
        tft_write_byte(0x29);
        tft_write_byte(0x2e);
        tft_write_byte(0x30);
        tft_write_byte(0x30);
        tft_write_byte(0x39);
        tft_write_byte(0x3f);
        tft_write_byte(0x00);
        tft_write_byte(0x07);
        tft_write_byte(0x03);
        tft_write_byte(0x10);

        //interface 16bit / pixle
        tft_write_reg(0x3A);
        tft_write_byte(0x05);
       
        tft_write_reg(0x29);
       
        tft_clear();
}

void tft_write_char (uint8_t sx,uint8_t sy,uint8_t in_data)
{
        uint8_t i = 0, j= 0,temp;
        uint8_t *ptr = ASCII + ((in_data - 0x20) * 16);
       
        tft_window_set(sx,sy,sx+7,sy+15);
        for (i = 0;i < 16; i++)
        {
                temp = *ptr;
                for (j = 0; j < 8; j++)
                {
                        if(temp & 0x01){tft_write_word(PURPLE);}
                        else{tft_write_word(BLACK);}
                        temp >>= 1;
                }
                ptr++;
        }
}

void tft_write_msg(uint8_t sx,uint8_t sy,uint8_t *str)
{
        unsigned char i = 0;
       
        rst_wdi();
       
        while((*str != '\0')&&(i < 20))//最大限制為20字符
        {
                tft_write_char (sx,sy,*str++);
                sx += 8;
                i++;
        }
}


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:939553 發表于 2023-10-12 20:17 | 只看該作者
結題,范了一個初級錯誤,16bit需要移位是0x8000去取位
回復

使用道具 舉報

板凳
ID:939553 發表于 2023-10-12 20:43 | 只看該作者
犯了初級錯誤,在移位16bit,取高位應為 data & 0x8000
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲图片一区二区三区 | 欧美aaa | 日韩一区二区三区在线播放 | 久久99精品久久久久久国产越南 | 国产一区二区在线免费 | 欧美精品二区三区 | 成人免费毛片在线观看 | 亚洲 自拍 另类 欧美 丝袜 | 日韩欧美在线观看 | 卡通动漫第一页 | 久久精品视频网站 | 久久99一区二区 | 狠狠av | 国产视频一区二区在线观看 | 国产精品.xx视频.xxtv | 在线播放国产一区二区三区 | 日日碰狠狠躁久久躁婷婷 | 国产成人高清在线观看 | 成人毛片视频免费 | 91福利电影在线观看 | 久久久久91 | 国产精品成人在线观看 | 国产欧美精品一区二区色综合朱莉 | 亚洲一区二区三区在线 | h视频免费观看 | 国产欧美视频一区二区 | 中文字幕乱码一区二区三区 | 性一交一乱一透一a级 | 亚洲高清久久 | 这里有精品 | 久久精品99 | 日本精a在线观看 | 日本a在线 | 天天拍夜夜爽 | 国产精品久久久久免费 | 久久久.com | 久久久精品一区二区 | 国产在线观看一区二区三区 | 偷拍亚洲色图 | 国产日韩一区二区 | 91av小视频|