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

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 2389|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

單片機(jī)tft_lcd128*128液晶屏操作相關(guān)函數(shù)頭文件下載

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:335111 發(fā)表于 2018-11-28 12:26 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
頭文件:
  1. #ifndef _oled12864spi_H_
  2. #define _oled12864spi_H_
  3. #define RED          0xf800
  4. #define GREEN        0x07e0
  5. #define BLUE         0x001f
  6. #define WHITE        0xffff
  7. #define BLACK        0x0000
  8. #define YELLOW  0xFFE0
  9. #define GRAY0   0xEF7D   
  10. #define GRAY1   0x8410              
  11. #define GRAY2   0x4208
  12. #define MAGENTA 0xF81F           //×Ï
  13. #define CYAN        0x07FF           //Çà


  14. typedef unsigned char         uchar;
  15. typedef unsigned int          uint;


  16. void lcd_initial();
  17. void LCD_Clear(int color);//ÇåÆá


  18.                                                                      
  19. void LCD_A_Char8X16(uint x, uint y, uint fc, uint bc, uchar *s)reentrant;
  20. void LCD_Char8X16_String(uint x,uint y,uint fc,uint bc,uchar *s,uchar c)reentrant;


  21. void LCD_CHN16X16(uint x, uint y, uint fc, uint bc, uchar *s);
  22. void LCD_CHN16X16_String(uint x,uint y,uint fc,uint bc,uchar *s,uchar c);




  23. //void LCD_CHN32X32(uint x, uint y, uint fc, uint bc, uchar *s); //ÏÔê¾ò»¸ö32*32oo×Ö
  24. //void LCD_CHN32X32_String(uint x,uint y,uint fc,uint bc,uchar *s,uchar c);//ÏÔê¾ò»′®32*32oo×Ö




  25. //void LCD_A_Char24X48(uint x, uint y, uint fc, uint bc, uchar *s);

  26. #endif


  27. C文件
  28. //********************************************************************************
  29. #include <intrins.h>
  30. #define uchar unsigned char
  31. #define uint unsigned int
  32. #include "delay.h"
  33. #include "tft128128spi.h"
  34. #include "STC15.h"
  35. //---------------------------液晶屏接線說(shuō)明-------------------------------------//
  36. //接線前請(qǐng)參考液晶屏說(shuō)明書(shū)第10頁(yè)引腳定義
  37. sbit scl       =P2^7;//接模塊CLK引腳,接裸屏Pin9_SCL
  38. sbit sda       =P2^6;//接模塊DIN/MOSI引腳,接裸屏Pin8_SDA
  39. sbit reset     =P2^5;//接模塊dcT引腳,接裸屏Pin6_RES
  40. sbit dc        =P2^4;//接模塊D/C引腳,接裸屏Pin7_A0
  41. sbit cs        =P2^3;//接模塊CE引腳,接裸屏Pin12_CS
  42. sbit bl        =P2^2;//接模塊BL引腳,背光可以采用IO控制或者PWM控制,也可以直接接到高電平常亮
  43. //---------------------------End of液晶屏接線---------------------------------//
  44. bit USE_LANDSCAPE;//程序橫豎屏切換
  45. //向液晶屏寫(xiě)一個(gè)8位指令
  46. void  LCD_WrCmd(uchar cmd)
  47. {
  48. uchar i;
  49. cs=0;dc=0;
  50. for(i=0;i<8;i++)
  51. {
  52.   scl=0;
  53.   if(cmd&0x80)sda=1;else sda=0;
  54.   scl=1;
  55.   cmd<<=1;
  56. }        
  57. cs=1;
  58. }


  59. //向液晶屏寫(xiě)一個(gè)8位數(shù)據(jù)
  60. void  LCD_WrDat(uchar dat)
  61. {
  62. uchar i;
  63. cs=0;dc=1;
  64. for(i=0;i<8;i++)
  65. {
  66.   scl=0;
  67.   if(dat&0x80)sda=1;else sda=0;
  68.   scl=1;
  69.   dat<<=1;
  70. }        
  71. cs=1;
  72. }
  73. //向液晶屏寫(xiě)一個(gè)16位數(shù)據(jù)
  74. void  LCD_WrDat_16Bit(uint dat)
  75. {
  76. LCD_WrDat(dat>>8);                         //寫(xiě)入高8位數(shù)據(jù)
  77. LCD_WrDat(dat);                         //寫(xiě)入低8位數(shù)據(jù)

  78. }


  79. void Reset()
  80. {
  81.     reset=0;
  82.     delayms(100);
  83.     reset=1;
  84.     delayms(100);
  85. }
  86. //////////////////////////////////////////////////////////////////////////////////////////////
  87. //液晶屏初始化 for S6D02A1
  88. void lcd_initial()
  89. {        Reset();//Reset before LCD Init.
  90.                
  91.         //LCD Init For 1.44Inch LCD Panel with ST7735R.
  92.         LCD_WrCmd(0x11);//Sleep exit
  93.         delayms (120);
  94.                
  95.         //ST7735R Frame Rate
  96.         LCD_WrCmd(0xB1);
  97.         LCD_WrDat(0x01);
  98.         LCD_WrDat(0x2C);
  99.         LCD_WrDat(0x2D);


  100.         LCD_WrCmd(0xB2);
  101.         LCD_WrDat(0x01);
  102.         LCD_WrDat(0x2C);
  103.         LCD_WrDat(0x2D);


  104.         LCD_WrCmd(0xB3);
  105.         LCD_WrDat(0x01);
  106.         LCD_WrDat(0x2C);
  107.         LCD_WrDat(0x2D);
  108.         LCD_WrDat(0x01);
  109.         LCD_WrDat(0x2C);
  110.         LCD_WrDat(0x2D);
  111.         
  112.         LCD_WrCmd(0xB4); //Column invedcion
  113.         LCD_WrDat(0x07);
  114.         
  115.         //ST7735R Power Sequence
  116.         LCD_WrCmd(0xC0);
  117.         LCD_WrDat(0xA2);
  118.         LCD_WrDat(0x02);
  119.         LCD_WrDat(0x84);
  120.         LCD_WrCmd(0xC1);
  121.         LCD_WrDat(0xC5);


  122.         LCD_WrCmd(0xC2);
  123.         LCD_WrDat(0x0A);
  124.         LCD_WrDat(0x00);


  125.         LCD_WrCmd(0xC3);
  126.         LCD_WrDat(0x8A);
  127.         LCD_WrDat(0x2A);
  128.         LCD_WrCmd(0xC4);
  129.         LCD_WrDat(0x8A);
  130.         LCD_WrDat(0xEE);
  131.         
  132.         LCD_WrCmd(0xC5); //VCOM
  133.         LCD_WrDat(0x0E);
  134.         
  135.         LCD_WrCmd(0x36); //MX, MY, RGB mode
  136. if(USE_LANDSCAPE)
  137.         LCD_WrDat(0xA8); //豎屏C8 橫屏08 A8
  138. else
  139.         LCD_WrDat(0xC8); //豎屏C8 橫屏08 A8
  140.         
  141.         //ST7735R Gamma Sequence
  142.         LCD_WrCmd(0xe0);
  143.         LCD_WrDat(0x0f);
  144.         LCD_WrDat(0x1a);
  145.         LCD_WrDat(0x0f);
  146.         LCD_WrDat(0x18);
  147.         LCD_WrDat(0x2f);
  148.         LCD_WrDat(0x28);
  149.         LCD_WrDat(0x20);
  150.         LCD_WrDat(0x22);
  151.         LCD_WrDat(0x1f);
  152.         LCD_WrDat(0x1b);
  153.         LCD_WrDat(0x23);
  154.         LCD_WrDat(0x37);
  155.         LCD_WrDat(0x00);         
  156.         LCD_WrDat(0x07);
  157.         LCD_WrDat(0x02);
  158.         LCD_WrDat(0x10);


  159.         LCD_WrCmd(0xe1);
  160.         LCD_WrDat(0x0f);
  161.         LCD_WrDat(0x1b);
  162.         LCD_WrDat(0x0f);
  163.         LCD_WrDat(0x17);
  164.         LCD_WrDat(0x33);
  165.         LCD_WrDat(0x2c);
  166.         LCD_WrDat(0x29);
  167.         LCD_WrDat(0x2e);
  168.         LCD_WrDat(0x30);
  169.         LCD_WrDat(0x30);
  170.         LCD_WrDat(0x39);
  171.         LCD_WrDat(0x3f);
  172.         LCD_WrDat(0x00);
  173.         LCD_WrDat(0x07);
  174.         LCD_WrDat(0x03);
  175.         LCD_WrDat(0x10);  
  176.         
  177.         LCD_WrCmd(0x2a);
  178.         LCD_WrDat(0x00);
  179.         LCD_WrDat(0x00+2);
  180.         LCD_WrDat(0x00);
  181.         LCD_WrDat(0x80+2);


  182.         LCD_WrCmd(0x2b);
  183.         LCD_WrDat(0x00);
  184.         LCD_WrDat(0x00+3);
  185.         LCD_WrDat(0x00);
  186.         LCD_WrDat(0x80+3);
  187.         
  188.         LCD_WrCmd(0xF0); //Enable test command  
  189.         LCD_WrDat(0x01);
  190.         LCD_WrCmd(0xF6); //Disable ram power save mode
  191.         LCD_WrDat(0x00);
  192.         
  193.         LCD_WrCmd(0x3A); //65k mode
  194.         LCD_WrDat(0x05);
  195.         
  196.         
  197.         LCD_WrCmd(0x29);//Display on




  198.         bl=1;                         //背光


  199. }






  200. /*************************************************
  201. 函數(shù)名:LCD_Set_Region
  202. 功能:設(shè)置lcd顯示區(qū)域,在此區(qū)域?qū)扅c(diǎn)數(shù)據(jù)自動(dòng)換行
  203. 入口參數(shù):xy起點(diǎn)和終點(diǎn)
  204. 返回值:無(wú)
  205. *************************************************/
  206. void Lcd_SetRegion(uint x_start,uint y_start,uint x_end,uint y_end)reentrant
  207. {        
  208. if(USE_LANDSCAPE)//使用橫屏模式
  209.    {
  210.     LCD_WrCmd(0x2a);
  211.         LCD_WrDat(0x00);
  212.         LCD_WrDat(x_start+3);
  213.         LCD_WrDat(0x00);
  214.         LCD_WrDat(x_end+3);


  215.         LCD_WrCmd(0x2b);
  216.         LCD_WrDat(0x00);
  217.         LCD_WrDat(y_start+2);
  218.         LCD_WrDat(0x00);
  219.         LCD_WrDat(y_end+2);
  220.    }
  221. else//豎屏模式        
  222.   {
  223.         LCD_WrCmd(0x2a);
  224.         LCD_WrDat(0x00);
  225.         LCD_WrDat(x_start+2);
  226.         LCD_WrDat(0x00);
  227.         LCD_WrDat(x_end+2);


  228.         LCD_WrCmd(0x2b);
  229.         LCD_WrDat(0x00);
  230.         LCD_WrDat(y_start+3);
  231.         LCD_WrDat(0x00);
  232.         LCD_WrDat(y_end+3);        
  233.   }
  234.         LCD_WrCmd(0x2c);
  235. }








  236. void LCD_Clear(int color)
  237. {
  238.          uchar i,j;
  239.         Lcd_SetRegion(0,0,128-1,128-1);
  240.          for (i=0;i<128;i++)
  241.             for (j=0;j<128;j++)
  242.                 LCD_WrDat_16Bit(color);
  243. }






  244. void LCD_A_Char8X16(uint x, uint y, uint fc, uint bc, uchar *s)reentrant
  245. {
  246. uchar i,j,temp;
  247. Lcd_SetRegion(x,y,x+8-1,y+16-1);
  248. for(i=0;i<16;i++)
  249.         {
  250.          temp=s[ i];[ i]
  251.          for(j=0;j<8;j++)
  252.            {
  253.             if(temp&0x80)LCD_WrDat_16Bit(fc);
  254.                 else if        (fc!=bc) LCD_WrDat_16Bit(bc);
  255.             temp<<=1;
  256.            }  
  257.         }


  258. }


  259. void LCD_Char8X16_String(uint x,uint y,uint fc,uint bc,uchar *s,uchar c)reentrant
  260. {
  261. uchar i;
  262. for(i=0;i<c;i++) LCD_A_Char8X16(x+i*8,y,fc,bc,s+i*16);
  263. }






  264. void LCD_CHN16X16(uint x, uint y, uint fc, uint bc, uchar *s) //顯示一個(gè)漢字
  265. {
  266. uchar i,j,temp;
  267. Lcd_SetRegion(x,y,x+16-1,y+16-1);
  268. for(i=0;i<32;i++)
  269.         {
  270.          temp=s[ i];[ i]
  271.          for(j=0;j<8;j++)
  272.            {
  273.             if(temp&0x80)LCD_WrDat_16Bit(fc);
  274.                 else if        (fc!=bc) LCD_WrDat_16Bit(bc);
  275.             temp<<=1;
  276.            }  
  277.         }
  278. }


  279. void LCD_CHN16X16_String(uint x,uint y,uint fc,uint bc,uchar *s,uchar c)
  280. {
  281. uchar i;
  282. for(i=0;i<c;i++)LCD_CHN16X16(x+i*16,y,fc,bc,s+i*32);
  283. }

  284. //void LCD_A_Char16X32(uint x, uint y, uint fc, uint bc, uchar *s)
  285. //{
  286. // uchar i,j,temp;
  287. // Lcd_SetRegion(x,y,x+16-1,y+32-1);
  288. // for(i=0;i<64;i++)                                                  //16*32西文字符點(diǎn)陣64個(gè)8位字節(jié)
  289. //        {
  290. //         temp=s[ i];[ i]
  291. //         for(j=0;j<8;j++)
  292. //           {
  293. //            if(temp&0x80)LCD_WrDat_16Bit(fc);
  294. //                else if        (fc!=bc) LCD_WrDat_16Bit(bc);
  295. //            temp<<=1;
  296. //           }  
  297. //        }
  298. //
  299. //}




  300. /*
  301. void LCD_A_Char24X48(uint x, uint y, uint fc, uint bc, uchar *s)
  302. {
  303. uchar i,j,temp;
  304. Lcd_SetRegion(x,y,x+24-1,y+48-1);
  305. for(i=0;i<144;i++)                                                  //24*48西文字符點(diǎn)陣144個(gè)8位字節(jié)
  306.         {
  307.          temp=s[ i];[ i]
  308.          for(j=0;j<8;j++)
  309.            {
  310.             if(temp&0x80)LCD_WrDat_16Bit(fc);
  311.                 else if        (fc!=bc) LCD_WrDat_16Bit(bc);
  312.             temp<<=1;
  313.            }  
  314.         }


  315. }










  316. void LCD_CHN32X32(uint x, uint y, uint fc, uint bc, uchar *s) //顯示一個(gè)32*32漢字
  317. {
  318. uchar i,j,temp;
  319. Lcd_SetRegion(x,y,x+32-1,y+32-1);
  320. for(i=0;i<128;i++)                                                                                         //32*32漢字128字節(jié)
  321.         {
  322.          temp=s[ i];[ i]
  323.          for(j=0;j<8;j++)
  324.            {
  325.             if(temp&0x80)LCD_WrDat_16Bit(fc);
  326.                 else if        (fc!=bc) LCD_WrDat_16Bit(bc);
  327.             temp<<=1;
  328.            }  
  329.         }
  330. }


  331. void LCD_CHN32X32_String(uint x,uint y,uint fc,uint bc,uchar *s,uchar c)//顯示一串32*32漢字
  332. {
  333. uchar i;
  334. for(i=0;i<c;i++)LCD_CHN32X32(x+i*32,y,fc,bc,s+i*128);
  335. }


  336. */
復(fù)制代碼




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

使用道具 舉報(bào)

本版積分規(guī)則

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

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 91av在线视频观看 | 99这里只有精品 | 98成人网 | 91精品国产综合久久久久久漫画 | 国产色片在线 | 精品久久国产 | 色综合久久天天综合网 | 国产精品九九九 | 亚洲精品一二三区 | 日韩av美女电影 | 亚洲 欧美 另类 综合 偷拍 | 久久看看 | 亚洲成人自拍网 | 日韩av第一页 | 欧美一级做a爰片免费视频 国产美女特级嫩嫩嫩bbb片 | 亚洲一区二区三区免费视频 | 蜜月aⅴ免费一区二区三区 99re在线视频 | 日本一区二区不卡视频 | 国产精品亚洲一区二区三区在线 | 国产精品一区二区在线 | 精品亚洲一区二区三区四区五区 | 国产精品久久久 | 狠狠做六月爱婷婷综合aⅴ 国产精品视频网 | 国产9 9在线 | 中文 | 亚洲精品乱码 | 91欧美精品成人综合在线观看 | 在线午夜 | 欧美在线播放一区 | www.欧美.com| 亚洲一区二区电影在线观看 | 亚洲女人天堂网 | 欧美区在线观看 | 精品国产99 | 婷婷在线免费 | 蜜桃视频一区二区三区 | 99国产精品久久久久久久 | 亚洲成av人片在线观看无码 | 日本不卡一区二区三区在线观看 | 久久99精品久久久久久国产越南 | 亚洲成人黄色 | av在线电影网站 |