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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2251|回復: 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 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 91久久看片 | 操皮视频 | 精品久久久久久亚洲精品 | 亚洲国产成人精品久久久国产成人一区 | 一二区成人影院电影网 | 亚洲一区在线日韩在线深爱 | 岛国毛片| 亚洲一区久久 | 很黄很污的网站 | 男女羞羞在线观看 | 欧美一区二区三区在线视频 | 992tv人人草 久久精品超碰 | 久久久片 | 天堂综合 | 91中文在线观看 | 亚洲a视频 | 国产在线拍偷自揄拍视频 | 一级黄色影片在线观看 | av一区二区三区 | 欧美亚洲网站 | 成人黄色网址大全 | 国产精品久久久久久影视 | 午夜免费在线 | 91在线电影 | 九色av | 久久久久久国产精品 | 99九色 | 在线观看的av | 亚洲欧美另类在线观看 | 欧美a级成人淫片免费看 | 国产乡下妇女做爰 | 久久久亚洲一区 | 夜夜摸天天操 | 成人激情视频免费在线观看 | 一区二区三区福利视频 | 888久久久 | 99影视 | 国产精品国产三级国产aⅴ无密码 | 欧美一级高潮片免费的 | 欧美区在线| 女女爱爱视频 |