找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5275|回复: 2
收起左侧

关于ST7789V驱动问题 只能背光点亮,屏上没有显示,我采用的是4LINE SPI

[复制链接]
ID:347737 发表于 2018-6-8 17:05 | 显示全部楼层 |阅读模式
大家好!
  现在碰到一个问题,用STM32F205驱动1.54寸触摸显示屏,现在只能背光点亮,屏上没有显示,我采用的是4LINE SPI,有大神能帮忙传一些相关的代码吗?谢谢了!
回复

使用道具 举报

ID:388314 发表于 2018-8-20 21:07 | 显示全部楼层
请问老哥调好了吗?  我现在也在调这款屏
回复

使用道具 举报

ID:903287 发表于 2021-10-10 15:26 | 显示全部楼层
  1. #include "st7789.h"
  2. #include "delay.h"


  3. unsigned int POINT_COLOR = 0X0000;
  4. unsigned int BACK_COLOR = 0XFFFF;


  5. void LCD_WR_DATA(unsigned int val)
  6. {  
  7.         LCD_RS=1;  //RS=1;
  8.         LCD_CS=0;        //CS=0;
  9.         P2=val;                                       
  10.         LCD_WR=0;        //WR=0;
  11.         LCD_WR=1;        //WR=1;
  12.         LCD_CS=1;        //CS=1;        
  13. }


  14. void LCD_WR_REG(unsigned int reg)               
  15. {        
  16.   LCD_RS=0;        //RS=0;
  17.         LCD_CS=0;        //CS=0;        
  18.         P2=reg;        
  19.         LCD_WR=0;        //WR=0;
  20.         LCD_WR=1;        //WR=1;
  21.         LCD_CS=1;        //CS=1;               
  22. }


  23. void LCD_Init()
  24. {
  25.         delay_ms(120);               

  26.         LCD_WR_REG(0x11);   // Sleep Out           
  27.         delay_ms(120);

  28.         LCD_WR_REG(0x36);                        
  29.         LCD_WR_DATA(0x60);

  30.         LCD_WR_REG(0x3A);                        
  31.         LCD_WR_DATA(0x05);



  32.         LCD_WR_REG(0xB2);                        
  33.         LCD_WR_DATA(0x0C);
  34.         LCD_WR_DATA(0x0C);
  35.         LCD_WR_DATA(0x00);
  36.         LCD_WR_DATA(0x33);
  37.         LCD_WR_DATA(0x33);                        

  38.         LCD_WR_REG(0xB7);                        
  39.         LCD_WR_DATA(0x35);

  40.         LCD_WR_REG(0xBB);                        
  41.         LCD_WR_DATA(0x29); //32 Vcom=1.35V
  42.                                                                                                                         
  43.         LCD_WR_REG(0xC2);                        
  44.         LCD_WR_DATA(0x01);

  45.         LCD_WR_REG(0xC3);                        
  46.         LCD_WR_DATA(0x19); //GVDD=4.8V
  47.                                                                                                                         
  48.         LCD_WR_REG(0xC4);                        
  49.         LCD_WR_DATA(0x20); //VDV, 0x20:0v

  50.         LCD_WR_REG(0xC5);                        
  51.         LCD_WR_DATA(0x1A);//VCOM Offset Set

  52.         LCD_WR_REG(0xC6);                        
  53.         LCD_WR_DATA(0x1F); //0x0F:60Hz               

  54.         LCD_WR_REG(0xD0);                        
  55.         LCD_WR_DATA(0xA4);
  56.         LCD_WR_DATA(0xA1);                                                                                                                                                                                                                                                                                                                                                                                             
  57.                                 
  58.                
  59.         LCD_WR_REG( 0xE0);     
  60.         LCD_WR_DATA( 0xD0);   
  61.         LCD_WR_DATA( 0x08);   
  62.         LCD_WR_DATA( 0x0E);   
  63.         LCD_WR_DATA( 0x09);   
  64.         LCD_WR_DATA( 0x09);   
  65.         LCD_WR_DATA( 0x05);   
  66.         LCD_WR_DATA( 0x31);   
  67.         LCD_WR_DATA( 0x33);   
  68.         LCD_WR_DATA( 0x48);   
  69.         LCD_WR_DATA( 0x17);   
  70.         LCD_WR_DATA( 0x14);   
  71.         LCD_WR_DATA( 0x15);   
  72.         LCD_WR_DATA( 0x31);   
  73.         LCD_WR_DATA( 0x34);   

  74.         LCD_WR_REG( 0xE1);     
  75.         LCD_WR_DATA( 0xD0);   
  76.         LCD_WR_DATA( 0x08);   
  77.         LCD_WR_DATA( 0x0E);   
  78.         LCD_WR_DATA( 0x09);   
  79.         LCD_WR_DATA( 0x09);   
  80.         LCD_WR_DATA( 0x15);   
  81.         LCD_WR_DATA( 0x31);   
  82.         LCD_WR_DATA( 0x33);   
  83.         LCD_WR_DATA( 0x48);   
  84.         LCD_WR_DATA( 0x17);   
  85.         LCD_WR_DATA( 0x14);   
  86.         LCD_WR_DATA( 0x15);   
  87.         LCD_WR_DATA( 0x31);   
  88.         LCD_WR_DATA( 0x34);
  89.          

  90.         LCD_WR_REG(0x21);

  91.         LCD_WR_REG(0x29);
  92. }


  93. void LCD_SetArea(unsigned int stx,unsigned int sty,unsigned int endx,unsigned int endy)
  94. {
  95.         LCD_WR_REG(0x2A);  
  96.         LCD_WR_DATA(stx>>8);   
  97.         LCD_WR_DATA(stx&0xff);            
  98.         LCD_WR_DATA(endx>>8);
  99.         LCD_WR_DATA(endx&0xff);        

  100.         LCD_WR_REG(0x2B);  
  101.         LCD_WR_DATA(sty>>8);
  102.         LCD_WR_DATA(sty&0xff);        
  103.         LCD_WR_DATA(endy>>8);
  104.         LCD_WR_DATA(endy&0xff);        
  105. }

  106. /* »-μãoˉêy 2ÎêyêÇÑÕé« */
  107. void LcdWirteColorData(unsigned int color)
  108. {
  109.         LCD_RS=1;  //RS=1;
  110.         LCD_CS=0;        //CS=0;
  111.          P2=color>>8;                                                
  112.         LCD_WR=0;        //WR=0;
  113.         LCD_WR=1;        //WR=1;
  114.         P2=color;                                       
  115.         LCD_WR=0;        //WR=0;
  116.         LCD_WR=1;        //WR=1;
  117.         LCD_CS=1;        //CS=1;        
  118. }


  119. void LCD_Clear(unsigned int color)
  120. {  
  121.         unsigned int i,j;

  122.         LCD_SetArea(0,0,319,239);
  123.   LCD_WR_REG(0x2C);
  124.         for(i=0;i<240;i++)
  125.         {
  126.                 for(j=0;j<320;j++)
  127.                 {
  128.                         LcdWirteColorData(color);
  129.                 }
  130.         }
  131. }


  132. void LCD_Show16(unsigned int x, unsigned int y, unsigned char* zifu)
  133. {
  134.         unsigned int i,j;
  135.         unsigned char temp;
  136.         
  137.         LCD_SetArea(x,y,x+15,y+15);
  138.   LCD_WR_REG(0x2C);
  139.         
  140.         for(i=0;i<32;i++)
  141.         {
  142.                 temp = *(zifu + i);
  143.                 for(j=0;j<8;j++)
  144.                 {
  145.                         if(temp&0x80)
  146.                                 LcdWirteColorData(POINT_COLOR);
  147.                         else
  148.                                 LcdWirteColorData(BACK_COLOR);
  149.                         temp=temp<<1;
  150.                 }
  151.         }
  152. }


  153. void LCD_Show24(unsigned int x, unsigned int y, unsigned char* zifu)
  154. {
  155.         unsigned int i,j;
  156.         unsigned char temp;
  157.         
  158.         LCD_SetArea(x,y,x+23,y+23);
  159.   LCD_WR_REG(0x2C);
  160.         
  161.         for(i=0;i<72;i++)
  162.         {
  163.                 temp = *(zifu + i);
  164.                 for(j=0;j<8;j++)
  165.                 {
  166.                         if(temp&0x80)
  167.                                 LcdWirteColorData(POINT_COLOR);
  168.                         else
  169.                                 LcdWirteColorData(BACK_COLOR);
  170.                         temp=temp<<1;
  171.                 }
  172.         }
  173. }


  174. void LCD_Show32(unsigned int x, unsigned int y, unsigned char* zifu)
  175. {
  176.         unsigned int i,j;
  177.         unsigned char temp;
  178.         
  179.         LCD_SetArea(x,y,x+31,y+31);
  180.   LCD_WR_REG(0x2C);
  181.         
  182.         for(i=0;i<128;i++)
  183.         {
  184.                 temp = *(zifu + i);
  185.                 for(j=0;j<8;j++)
  186.                 {
  187.                         if(temp&0x80)
  188.                                 LcdWirteColorData(POINT_COLOR);
  189.                         else
  190.                                 LcdWirteColorData(BACK_COLOR);
  191.                         temp=temp<<1;
  192.                 }
  193.         }
  194. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表