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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 9975|回復: 7
收起左側

ST7571 JLX128*128液晶屏的STM32驅動程序 寄存器版和庫函數版

  [復制鏈接]
ID:241423 發表于 2018-11-24 13:08 | 顯示全部樓層 |閱讀模式
分享下JLX高性價比的液晶的驅動程序,這款是模擬IIC驅動的,操作很方便

單片機源程序如下:
  1. /*         液晶模塊型號:JLX128128G-610-PN-IIC
  2.                 I2C接口
  3.            驅動IC是:ST7571
  4.                 //單片機:STM32F103RBT6
  5. */
  6. #include <stm32f10x_lib.h>
  7. #include <sys.h>
  8. #include <delay.h>
  9. #include <JLX128128G_610_PN_IIC.h>
  10. #include <chinese_code.h>
  11. #include <image.h>

  12. #define uchar unsigned char
  13. #define uint unsigned int
  14. #define ulong unsigned long

  15. //等待按鍵,3個按鍵,有任何一個按鍵按下都可以進入下一步
  16. void waitkey(void)
  17. {
  18.         repeat:
  19.                 if(key2==1&&key3==1&&key4==1)        goto repeat;
  20.                 else                delay_ms(600);
  21. }

  22. void transfer(int data1)
  23. {
  24.         int i;
  25.         for(i=0;i<8;i++)
  26.    {
  27.                 LCD_SCL=0;
  28.                 if(data1&0x80) LCD_SDA=1;
  29.                 else LCD_SDA=0;
  30.                 LCD_SCL=1;
  31.                  LCD_SCL=0;
  32.                  data1=data1<<1;
  33.    }
  34.                 LCD_SDA=0;
  35.                 LCD_SCL=1;
  36.                 LCD_SCL=0;
  37. }

  38. void start_flag()
  39. {
  40.         LCD_SCL=1;                /*START FLAG*/
  41.         LCD_SDA=1;                /*START FLAG*/
  42.         LCD_SDA=0;                /*START FLAG*/
  43. }


  44. void stop_flag()
  45. {
  46.         LCD_SCL=1;                /*STOP FLAG*/
  47.         LCD_SDA=0;                /*STOP FLAG*/               
  48.         LCD_SDA=1;                /*STOP FLAG*/
  49. }

  50. //寫命令到液晶顯示模塊
  51. void transfer_command(uchar com)   
  52. {
  53.         start_flag();
  54.         transfer(0x78);
  55.         transfer(0x80);
  56.         transfer(com);
  57.         stop_flag();
  58. }

  59. //寫數據到液晶顯示模塊
  60. void transfer_data(uchar dat)
  61. {
  62.         start_flag();
  63.         transfer(0x78);
  64.         transfer(0xC0);
  65.         transfer(dat);
  66.         stop_flag();
  67. }

  68. void initial_lcd()
  69. {
  70.   LCD_RST=0;
  71.         delay_ms(1);
  72.         LCD_RST=1;
  73.         delay_ms(10);        
  74.         transfer_command(0x2c);
  75.         delay_ms(200);
  76.         transfer_command(0x2e);
  77.         delay_ms(200);
  78.         transfer_command(0x2f);
  79.         delay_ms(10);
  80.         
  81.         transfer_command(0xae);                //顯示關
  82.         transfer_command(0x38);                //模式設置
  83.         transfer_command(0xb8);                //85HZ
  84.         transfer_command(0xc8);                //行掃描順序        
  85.         transfer_command(0xa0);                //列掃描順序
  86.         
  87.         transfer_command(0x44);                //Set initial COM0 register
  88.         transfer_command(0x00);
  89.         transfer_command(0x40);                //Set initial display line register
  90.         transfer_command(0x00);

  91.         transfer_command(0xab);
  92.         transfer_command(0x67);
  93.         transfer_command(0x27);                //粗調對比度,可設置范圍0x20~0x27
  94.         transfer_command(0x81);                //微調對比度
  95.         transfer_command(0x28);                //微調對比度的值,可設置范圍0x00~0x3f

  96.         transfer_command(0x56);                //0x56 1/11 bias
  97.         transfer_command(0xf3);
  98.         transfer_command(0x04);
  99.         transfer_command(0x93);
  100.         
  101.         transfer_command(0xaf);                //顯示開
  102. }


  103. void lcd_address(uchar page,uchar column)
  104. {
  105.         column=column;
  106.         page=page-1;
  107.         transfer_command(0xb0+page);
  108.         transfer_command(((column>>4)&0x0f)+0x10);
  109.         transfer_command(column&0x0f);
  110. }

  111. void clear_screen()
  112. {        
  113.         uchar i,j;
  114.         for(j=0;j<16;j++)
  115.         {
  116.                 lcd_address(j+1,0);
  117.                 for(i=0;i<128;i++)
  118.                 {
  119.                         transfer_data(0x00);               
  120.                         transfer_data(0x00);
  121.                 }
  122.         }
  123. }


  124. //顯示8x16的點陣的字符串,括號里的參數分別為(頁,列,字符串指針)
  125. void display_string_8x16(u8 page,u8 column,u8*text)
  126. {
  127.         u8 i=0,j,k,n;

  128.         while(text[i]>0x00)
  129.         {
  130.                 if((text[i]>=0x20)&&(text[i]<=0x7e))
  131.                 {
  132.                         j=text[i]-0x20;
  133.                         for(n=0;n<2;n++)
  134.                         {
  135.                                 lcd_address(page+n,column);
  136.                                 for(k=0;k<8;k++)
  137.                                 {
  138.                                         transfer_data(ascii_table_8x16[j][k+8*n]);
  139.                                         transfer_data(ascii_table_8x16[j][k+8*n]);
  140.                                 }
  141.                         }
  142.                         i++;
  143.                         column+=8;
  144.                 }
  145.                 else
  146.                 i++;
  147.                
  148.                 if(column>127)
  149.                 {
  150.                         column=0;
  151.                         page+=2;
  152.                  }        
  153.         }        
  154. }

  155. //寫入一組16x16點陣的漢字字符串(字符串表格中需含有此字)
  156. //括號里的參數:(頁,列,漢字字符串)
  157. void display_string_16x16(u8 page,u8 column,u8 *text)
  158. {
  159.         u8 i,j,k;
  160.         u16 address;
  161.         j = 0;
  162.         while(text[j] != '\0')
  163.         {
  164.                 i=0;
  165.                 address=1;
  166.                 while(Chinese_text_16x16[i]> 0x7e )
  167.                 {
  168.                         if(Chinese_text_16x16[i] == text[j])
  169.                         {
  170.                                 if(Chinese_text_16x16[i+1] == text[j+1])
  171.                                 {
  172.                                         address = i*16;
  173.                                         break;
  174.                                 }
  175.                         }
  176.                         i +=2;
  177.                 }
  178.                 if(column>127)
  179.                 {
  180.                         column =0;
  181.                         page +=2;
  182.                 }
  183.                 if(address !=1)
  184.                 {
  185.                         for(k=0;k<2;k++)
  186.                         {
  187.                                 lcd_address(page+k,column);
  188.                                 for(i=0;i<16;i++)
  189.                                 {
  190.                                         transfer_data(Chinese_code_16x16[address]);
  191.                                         transfer_data(Chinese_code_16x16[address]);
  192.                                         address++;                                
  193.                                 }
  194.                         }
  195.                         j +=2;
  196.                 }
  197.                 else
  198.                 {
  199.                         for(k=0;k<2;k++)
  200.                         {
  201.                                 lcd_address(page+k,column);
  202.                                 for(i=0;i<16;i++)
  203.                                 {
  204.                                         transfer_data(0x00);
  205.                                         transfer_data(0x00);                                
  206.                                 }
  207.                         }
  208.                         j++;
  209.                 }
  210.                 column +=16;
  211.         }
  212. }

  213. //顯示16x16點陣的漢字或者ASCII碼8x16點陣的字符混合字符串
  214. //括號里的參數:(頁,列,字符串)
  215. void display_string_8x16_16x16(u8 page,u8 column,u8 *text)
  216. {
  217.         u8 temp[3];
  218.         u16 i=0;
  219.         while(text[i] !='\0')
  220.         {
  221.                 if(text[i]>0x7e)
  222.                 {
  223.                         temp[0]=text[i];
  224.                         temp[1]=text[i+1];
  225.                         temp[2]='\0';                                                                                                                //漢字為兩個字節
  226.                         display_string_16x16(page,column,temp); //顯示漢字
  227.                         column +=16;
  228.                         i +=2;
  229.                         if(column>127)
  230.                         {
  231.                                 column =0;
  232.                                 page +=2;
  233.                         }
  234.                 }
  235.                 else
  236.                 {
  237.                         temp[0]=text[i];
  238.                         temp[1]='\0';                                                                                                                //字母占一個字節
  239.                         display_string_8x16(page,column,temp);  //顯示字母
  240.                         column +=8;
  241.                         i++;
  242.                         if(column>127)
  243.                         {
  244.                                 column =0;
  245.                                 page +=2;
  246.                         }
  247.                 }
  248.         }
  249. }

  250. void display_32x32(u8 page,u8 column,u8 *dp)
  251. {
  252.         u8 i,j;
  253.         for(j=0;j<4;j++)
  254.         {
  255.                 lcd_address(page+j,column);
  256.                 for(i=0;i<32;i++)
  257.                 {
  258.                         transfer_data(*dp);
  259.                         transfer_data(*dp);
  260.                         dp++;
  261.                 }
  262.         }        
  263. }

  264. void display_graphic(u8 *dp)
  265. {
  266.         u8 i,j;
  267.         for(j=0;j<16;j++)
  268.         {
  269.                 lcd_address(j+1,0);
  270.                 for(i=0;i<128;i++)
  271.                 {
  272.                         transfer_data(*dp);
  273.                         transfer_data(*dp);
  274.                         dp++;        
  275.                 }
  276.         }
  277. }

  278. //==========主程序==========================================
  279. int main(void)
  280. {                                                                                                                                                
  281.         Stm32_Clock_Init(9);         //8MHZ*9倍頻=72MHz
  282.         delay_init(72);                           //72MHz
  283.         MCU_Port_initial();
  284.         initial_lcd();
  285.         while(1)
  286.         {
  287.                 clear_screen();
  288.                 display_graphic(bmp2);
  289.                 waitkey();
  290.                 clear_screen();
  291.                 display_32x32(1,16,jing32);
  292.                 display_32x32(1,48,lian32);
  293.                 display_32x32(1,80,xun32);
  294.                 display_string_16x16(5,1,"深圳市晶聯訊電子有限公司是集研發、生產、銷售于一體的從事液晶顯示屏及液晶顯示模塊的高科技公司。");
  295.                 waitkey();
  296.                 clear_screen();
  297.                 display_string_8x16(1,1,"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&()*+-,-./:;<=>?@[\]^_^{|}~0123456789ABCDFGHIJKLMNOPQRSTUVWXYZ");
  298.                 waitkey();
  299.                 clear_screen();
  300.                 display_string_8x16_16x16(1,1,"深圳市晶聯訊電子 JLX128128G-610   128x128點陣   視區:59.4x59.4mm帶16x16點陣中文 字庫,或8x16或5x7點陣ASCII碼,四灰度級顯示功能。");
  301.                 waitkey();               
  302.         }
  303. }
復制代碼

所有資料51hei提供下載:
128128改庫函數版本.rar (304.32 KB, 下載次數: 168)

評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復

使用道具 舉報

ID:148204 發表于 2020-1-12 13:24 | 顯示全部樓層
下載試一下能不能點亮
回復

使用道具 舉報

ID:589512 發表于 2020-2-20 15:56 | 顯示全部樓層
下來看看能不能驅起來
回復

使用道具 舉報

ID:345352 發表于 2020-3-2 18:45 | 顯示全部樓層
你好,我想問一下,顯示內容的灰度是怎么設置的,初始已經設置成Gray-Scale mode了,說明書好像只說了灰度模式需要2個字節每8個像素,黑白模式只需1個字節
回復

使用道具 舉報

ID:844879 發表于 2020-11-17 15:18 | 顯示全部樓層
正需要,下載參考下資源文件
回復

使用道具 舉報

ID:71233 發表于 2024-5-18 08:40 | 顯示全部樓層
顯示屏的對比度一般,灰度實在沒有多大意義。
回復

使用道具 舉報

ID:166310 發表于 2024-7-26 10:51 | 顯示全部樓層
謝謝樓主提供這么好的資料。
回復

使用道具 舉報

ID:45026 發表于 2025-3-19 09:37 | 顯示全部樓層
學習了,正是需要的資料,很不錯,感謝分享,下載了!!!!
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产黄色电影 | 在线观看www | 你懂的免费在线 | 在线免费观看日本 | 户外露出一区二区三区 | 特一级毛片 | 亚洲黄色在线免费观看 | 欧美天堂 | 欧美黑人体内she精在线观看 | 成人一区二区三区 | 97伦理 | 黄色毛片免费 | 成年免费在线观看 | 美女三区 | 一区二区三区欧美在线 | 国产精品18久久久久久白浆动漫 | 中文字幕综合 | 二区久久 | 欧美视频免费在线 | jlzzjlzz国产精品久久 | 蜜桃综合在线 | 91操操操 | 亚洲一区 中文字幕 | 国产操操操 | 亚洲在线免费观看 | 国产精品视频导航 | 99伊人| 亚洲欧美日韩电影 | 在线播放国产一区二区三区 | 男女羞羞视频在线看 | 久久91 | 久久久久免费精品国产 | 欧美日韩久久 | 精品一区电影 | 亚洲综合国产精品 | 国产日韩欧美一区二区在线播放 | 夜夜骚视频 | 精品中文字幕一区 | 午夜一区二区三区在线观看 | 国产精品资源在线 | av资源中文在线天堂 |