找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3943|回复: 1
收起左侧

一个12864液晶屏的简单小程序

[复制链接]
ID:406093 发表于 2018-10-21 19:52 | 显示全部楼层 |阅读模式
12864液晶屏 (Graphic Lcd 128x64)通常使用三星 KS108/KS107(Samsung KS108/KS107 controller),现在新产品层出不穷,但是他们驱动模块的功能都是大同小异。相互可以兼容。
以下是一个简单的小程序,希望大家能够喜欢。
  1. //Declarations------------------------------------------------------------------
  2. const code char truck_bmp[1024];
  3. //--------------------------------------------------------------end-declarations

  4. // Glcd module connections
  5. char GLCD_DataPort at P0;

  6. sbit GLCD_CS1 at P2_0_bit;
  7. sbit GLCD_CS2 at P2_1_bit;
  8. sbit GLCD_RS  at P2_2_bit;
  9. sbit GLCD_RW  at P2_3_bit;
  10. sbit GLCD_EN  at P2_4_bit;
  11. sbit GLCD_RST at P2_5_bit;
  12. // End Glcd module connections

  13. void delay2S(){                             // 2 seconds delay function
  14.   Delay_ms(2000);
  15. }

  16. void main() {                       
  17.   unsigned short ii;
  18.   char *someText;

  19.   #define COMPLETE_EXAMPLE                  // comment this line to make simpler/smaller example
  20.   Glcd_Init();                              // Initialize GLCD
  21.   Glcd_Fill(0x00);                          // Clear GLCD

  22.   while(1) {
  23.     #ifdef COMPLETE_EXAMPLE
  24.       Glcd_Image(truck_bmp);                // Draw image
  25.       delay2S(); delay2S();
  26.     #endif
  27.    
  28.     Glcd_Fill(0x00);                        // Clear GLCD

  29.     Glcd_Box(62,40,124,56,1);               // Draw box
  30.     Glcd_Rectangle(5,5,84,35,1);            // Draw rectangle
  31.     Glcd_Line(0, 0, 127, 63, 1);            // Draw line
  32.     delay2S();

  33.     for(ii = 5; ii < 60; ii+=5 ) {          // Draw horizontal and vertical lines
  34.       Delay_ms(250);
  35.       Glcd_V_Line(2, 54, ii, 1);
  36.       Glcd_H_Line(2, 120, ii, 1);
  37.     }

  38.     delay2S();

  39.     Glcd_Fill(0x00);                        // Clear GLCD
  40.     #ifdef COMPLETE_EXAMPLE
  41.       Glcd_Set_Font(Character8x7, 8, 7, 32);// Choose font, see __Lib_GLCDFonts.c in Uses folder

  42.       Glcd_Write_Text("mikroE", 1, 7, 2);   // Write string

  43.       for (ii = 1; ii <= 10; ii++)          // Draw circles
  44.         Glcd_Circle(63,32, 3*ii, 1);
  45.       delay2S();

  46.       Glcd_Box(12,20, 70,57, 2);            // Draw box
  47.       delay2S();

  48.       Glcd_Fill(0xFF);                      // Fill GLCD

  49.       Glcd_Set_Font(Character8x7, 8, 7, 32);// Change font
  50.       someText = "8x7 Font";
  51.       Glcd_Write_Text(someText, 5, 0, 2);   // Write string
  52.       delay2S();

  53.       Glcd_Set_Font(System3x5, 3, 5, 32);   // Change font
  54.       someText = "3X5 CAPITALS ONLY";
  55.       Glcd_Write_Text(someText, 60, 2, 2);  // Write string
  56.       delay2S();

  57.       Glcd_Set_Font(font5x7, 5, 7, 32);     // Change font
  58.       someText = "5x7 Font";
  59.       Glcd_Write_Text(someText, 5, 4, 2);   // Write string
  60.       delay2S();

  61.       Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32); // Change font
  62.       someText = "5x7 Font (v2)";
  63.       Glcd_Write_Text(someText, 5, 6, 2);   // Write string
  64.       delay2S();
  65.     #endif
  66.   }
  67. }

复制代码
相关信息:http://www.51hei.com/bbs/dpj-136722-1.html


GLCD12864.jpg


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:484022 发表于 2019-3-4 09:06 | 显示全部楼层
显示不了
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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