欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 1.8 TFT st7735s顯示顏色不對,請幫看看 [打印本頁]

作者: jxcrgt35    時間: 2023-10-12 08:54
標題: 1.8 TFT st7735s顯示顏色不對,請幫看看
調試字體顏色為#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++;
        }
}



作者: jxcrgt35    時間: 2023-10-12 20:17
結題,范了一個初級錯誤,16bit需要移位是0x8000去取位
作者: jxcrgt35    時間: 2023-10-12 20:43
犯了初級錯誤,在移位16bit,取高位應為 data & 0x8000




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1