找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2869|回复: 1
打印 上一主题 下一主题
收起左侧

一个T6963C 240x128液晶显示屏测试小程序

[复制链接]
跳转到指定楼层
楼主
T6963C 240x128 液晶显示屏是由东芝公司生产的产品,也是目前比较流行的显示屏之一。以下是一个简单的测试小程序,希望大家能够喜欢。
  1. #include        "__T6963C.h"
  2.                            
  3. // T6963C module connections
  4. char T6963C_dataPort at P3;                       // DATA port

  5. sbit T6963C_ctrlwr  at P2_2_bit;                  // WR write signal
  6. sbit T6963C_ctrlrd  at P2_1_bit;                  // RD read signal
  7. sbit T6963C_ctrlcd  at P2_0_bit;                  // CD command/data signal
  8. sbit T6963C_ctrlrst at P2_4_bit;                  // RST reset signal

  9. // Signals not used by library, they are set in main function
  10. sbit T6963C_ctrlce at P2_3_bit;                   // CE signal
  11. sbit T6963C_ctrlfs at P2_6_bit;                   // FS signal
  12. sbit T6963C_ctrlmd at P2_5_bit;                   // MD signal
  13. // End T6963C module connections

  14. /*
  15. * bitmap pictures stored in ROM
  16. */
  17. const code char mikroE_240x128_bmp[];
  18. const code char einstein[];


  19. void main() {
  20.   char idata txt1[] = " EINSTEIN WOULD HAVE LIKED mE";
  21.   char idata txt[] =  " GLCD LIBRARY DEMO, WELCOME !";

  22.   unsigned char  panel;         // Current panel
  23.   unsigned int   i;             // General purpose register
  24.   unsigned char  curs;          // Cursor visibility
  25.   unsigned int   cposx, cposy;  // Cursor x-y position
  26.   
  27.   #define COMPLETE_EXAMPLE      // comment this line to make simpler/smaller example
  28.   
  29.   T6963C_ctrlce = 0;            // Enable T6963C
  30.   T6963C_ctrlfs = 0;            // Font Select 8x8
  31.   T6963C_ctrlmd = 0;            // Column number select


  32.   // Initialize T6963C
  33.   T6963C_init(240, 128, 8);

  34.   /*
  35.    * Enable both graphics and text display at the same time
  36.    */
  37.   T6963C_graphics(1);
  38.   T6963C_text(1);

  39.   panel = 0;
  40.   i = 0;
  41.   curs = 0;
  42.   cposx = cposy = 0;
  43.   /*
  44.    * Text messages
  45.    */
  46.   T6963C_write_text(txt, 0, 0, T6963C_ROM_MODE_XOR);
  47.   T6963C_write_text(txt1, 0, 15, T6963C_ROM_MODE_XOR);

  48.   /*
  49.    * Cursor
  50.    */
  51.   T6963C_cursor_height(8);       // 8 pixel height
  52.   T6963C_set_cursor(0, 0);       // Move cursor to top left
  53.   T6963C_cursor(0);              // Cursor off
  54.   
  55.   /*
  56.    * Draw rectangles
  57.    */
  58.   T6963C_rectangle(0, 0, 239, 127, T6963C_WHITE);
  59.   T6963C_rectangle(20, 20, 219, 107, T6963C_WHITE);
  60.   T6963C_rectangle(40, 40, 199, 87, T6963C_WHITE);
  61.   T6963C_rectangle(60, 60, 179, 67, T6963C_WHITE);

  62.   /*
  63.    * Draw a cross
  64.    */
  65.   T6963C_line(0, 0, 239, 127, T6963C_WHITE);
  66.   T6963C_line(0, 127, 239, 0, T6963C_WHITE);

  67.   /*
  68.    * Draw solid boxes
  69.    */
  70.   T6963C_box(0, 0, 239, 8, T6963C_WHITE);
  71.   T6963C_box(0, 119, 239, 127, T6963C_WHITE);

  72.   #ifdef COMPLETE_EXAMPLE
  73.     /*
  74.      * Draw circles
  75.      */
  76.     T6963C_circle(120, 64, 10, T6963C_WHITE);
  77.     T6963C_circle(120, 64, 30, T6963C_WHITE);
  78.     T6963C_circle(120, 64, 50, T6963C_WHITE);
  79.     T6963C_circle(120, 64, 70, T6963C_WHITE);
  80.     T6963C_circle(120, 64, 90, T6963C_WHITE);
  81.     T6963C_circle(120, 64, 110, T6963C_WHITE);
  82.     T6963C_circle(120, 64, 130, T6963C_WHITE);

  83.     T6963C_sprite(76, 4, einstein, 88, 119);         // Draw a sprite

  84.     T6963C_setGrPanel(1);                            // Select other graphic panel

  85.     T6963C_image(mikroE_240x128_bmp);                // Draw an image

  86.   #endif

  87.   for(;;) {                                          // Endless loop
  88.     /*
  89.      * If P1.0 is pressed, display only graphic panel
  90.      */
  91.     if(!P1_0_bit) {
  92.       T6963C_graphics(1);
  93.       T6963C_text(0);
  94.       Delay_ms(300);
  95.       }
  96.     #ifdef COMPLETE_EXAMPLE
  97.       /*
  98.        * If P1.1 is pressed, toggle the display between graphic panel 0 and graphic panel 1
  99.        */
  100.       else if(!P1_1_bit) {
  101.         panel++;
  102.         panel &= 1;
  103.         T6963C_displayGrPanel(panel);
  104.         Delay_ms(300);
  105.         }
  106.     #endif
  107.     /*
  108.      * If P1.2 is pressed, display only text panel
  109.      */
  110.     else if(!P1_2_bit) {
  111.       T6963C_graphics(0);
  112.       T6963C_text(1);
  113.       Delay_ms(300);
  114.       }

  115.     /*
  116.      * If P1.3 is pressed, display text and graphic panels
  117.      */
  118.     else if(!P1_3_bit) {
  119.       T6963C_graphics(1);
  120.       T6963C_text(1);
  121.       Delay_ms(300);
  122.       }

  123.     /*
  124.      * If P1.4 is pressed, change cursor
  125.      */
  126.     else if(!P1_4_bit) {
  127.       curs++;
  128.       if(curs == 3) curs = 0;
  129.       switch(curs) {
  130.         case 0:
  131.           // no cursor
  132.           T6963C_cursor(0);
  133.           break;
  134.         case 1:
  135.           // blinking cursor
  136.           T6963C_cursor(1);
  137.           T6963C_cursor_blink(1);
  138.           break;
  139.         case 2:
  140.           // non blinking cursor
  141.           T6963C_cursor(1);
  142.           T6963C_cursor_blink(0);
  143.           break;
  144.         }
  145.       Delay_ms(300);
  146.       }

  147.     /*
  148.      * Move cursor, even if not visible
  149.      */
  150.     cposx++;
  151.     if(cposx == T6963C_txtCols) {
  152.       cposx = 0;
  153.       cposy++;
  154.       if(cposy == T6963C_grHeight / T6963C_CHARACTER_HEIGHT) {
  155.         cposy = 0;
  156.         }
  157.       }
  158.     T6963C_set_cursor(cposx, cposy);

  159.     Delay_ms(100);
  160.     }
  161. }
复制代码
相关信息:http://www.51hei.com/bbs/dpj-136722-1.html




评分

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

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:600695 发表于 2021-3-18 14:42 | 只看该作者
t6963c.h头文件没有
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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