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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲国产中文字幕 | 亚洲天天操 | 美日韩丰满少妇在线观看 | 韩日中文字幕 | 欧美日韩国产二区 | 国产精品久久久久久久久久久久午夜片 | 国产人成| 日韩精品国产精品 | 少妇高潮毛片 | 亚洲成人一区二区三区 | 自拍偷拍欧美日韩 | 日韩一区二区av | 羞羞在线视频 | 亚洲精品一区二三区不卡 | 国产精品欧美在线 | 中文字幕免费在线观看 | 奇米影视888| 久久靖品 | 国产精品毛片一区视频播 | 欧美日韩在线精品 | 丁香花在线观看 | 国产午夜精品久久 | 午夜不卡视频 | 日日操av | 日韩成人在线观看视频 | 在线黄色av | 国产精品久久久久久久久久久久午夜片 | 国产精品一区二区三区在线 | 欧美激情精品 | 免费av在线 | 欧美资源在线 | 国产免费一区二区 | 日韩在线观看av | 国产一级免费 | 日韩精品久久久 | 日韩在线不卡视频 | 成人免费观看网站 | 手机在线免费看av | av大全在线观看 | 91激情网| 成人动漫在线观看 |