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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1436|回復: 8
打印 上一主題 下一主題
收起左側

LCD19264點陣屏怎樣顯示字符串?

[復制鏈接]
跳轉到指定樓層
樓主
ID:965189 發表于 2024-6-25 11:28 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
請教各位大俠,無字庫的19264點陣屏,單個字符顯示可以了,但是,顯示字符串的函數不知道怎樣寫。
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:1109793 發表于 2024-6-25 16:39 | 只看該作者
一個一個順序顯示唄
回復

使用道具 舉報

板凳
ID:366877 發表于 2024-6-25 16:41 | 只看該作者
能寫一個字符就能寫一串字符,無非就是for()語句控制而已。
回復

使用道具 舉報

地板
ID:123289 發表于 2024-6-25 19:04 | 只看該作者
將程序寫成F(x),分別用X1,X2,X3,X4... 代入F(x)多次重復運行。
回復

使用道具 舉報

5#
ID:69038 發表于 2024-6-25 22:57 | 只看該作者
給你參考 一下:
  1. //***功能:顯示一個ASCII字符,5*8字體 ;
  2. //*** x: 列坐標,0-191列,0-63,左屏,64-127,中屏,128-191,右屏        ;
  3. //*** y:行坐標,0~7頁,真實地址是 start_page+row;
  4. //***ustr: 待顯示字符;
  5. void lcd_show_char(uchar x,uchar y,uchar ustr)
  6. {
  7.     char i;
  8.         uchar temp;
  9.         uchar cs;
  10. ustr=ustr-' ';
  11.   for (i=0;i<6;i++)
  12.           {
  13.                 if(x<=63) cs=0;
  14.                 if(x>63 && x<=127) cs=1;
  15.                 if(x>127 ) cs=2;
  16.                 if (x>191) return;//列大于191,無效
  17.                 LCD_SendData(start_page+y,com,cs);
  18.                 LCD_SendData(start_column+x % 64,com,cs);
  19.             temp=dot5x8[ustr][i];
  20.                 temp=butterfly(temp);
  21.             LCD_SendData(temp,dat,cs);
  22.                 x++;
  23.           }
  24. }
  25. //***功能:顯示一個ASCII的字符串,5*8字體 ;
  26. //*** x: 列坐標,0-191列,0-63,左屏,64-127,中屏,128-191,右屏        ;
  27. //*** y:行坐標,0~7頁,真實地址是 start_page+row;
  28. //***ustr: 待顯示字符串;
  29. void lcd_show_string(uchar x,uchar y,uchar *ustr)
  30. {

  31. if (y>=8) return; //頁大于7,無效;
  32.           while(*ustr!='\0')
  33.         {      
  34.                 lcd_show_char(x,y,*ustr);
  35.                 x+=6;
  36.                 ustr++;
  37.         }  
  38. }
復制代碼
調用:
  1.         lcd_show_string(50,0,"LCD_19264 DEMO ");
  2.         lcd_show_string(42,1,"Designed By zhuls");
  3.         lcd_show_string(0,2,"Show a string in LCD screen");
  4.         lcd_show_string(0,3,"if(col<=63) is left;");
  5.         lcd_show_string(0,4,"if(col>63 && col<=127) is middle");
  6.         lcd_show_string(0,5,"if(col>127 && col<=191) is right;");
  7.         lcd_show_string(0,6,"if(col>=192) display is invalid!!"); //
復制代碼
最后一個“!”的X超限,不顯示
如果沒有“if (x>191) return;//列大于191,無效”這行,則最后一個“!”會返回所在屏的第一列顯示,結果是亂碼了。


回復

使用道具 舉報

6#
ID:69038 發表于 2024-6-25 23:28 | 只看該作者
回復

使用道具 舉報

7#
ID:965189 發表于 2024-6-26 08:41 | 只看該作者
zhuls 發表于 2024-6-25 22:57
給你參考 一下:
調用:最后一個“!”的X超限,不顯示
如果沒有“if (x>191) return;//列大于191,無效 ...

非常感謝你。我慢慢消化一下。有不明白的地方再向你請教。
回復

使用道具 舉報

8#
ID:1129954 發表于 2024-7-31 16:01 | 只看該作者
zhuls 發表于 2024-6-25 22:57
給你參考 一下:
調用:最后一個“!”的X超限,不顯示
如果沒有“if (x>191) return;//列大于191,無效 ...

大佬,源碼能分享一下嗎。感謝
回復

使用道具 舉報

9#
ID:69038 發表于 2024-8-2 07:01 | 只看該作者
柒月了吧 發表于 2024-7-31 16:01
大佬,源碼能分享一下嗎。感謝

可以,只是基本的顯示:

  1. #include <STC8H.H>
  2. #include "5x8_dot.h"
  3. #include "HZFONT.h"
  4. #define uchar unsigned char
  5. #define uint  unsigned int

  6. #define DATABus P1
  7. #define CSBus P3
  8. sbit RS = P3^7;         //指令數據選擇 =>pin4
  9. sbit RW = P3^6;         //讀寫控制          =>pin5
  10. sbit ENABLE  = P3^5;    //指令數據控制 =>pin6
  11. sbit Reset = P5^4;      //復位                  =>pin16

  12. sbit CS1 = P3^4;   //左屏幕選擇,低電平有效        =>pin15
  13. sbit CS2 = P3^3;   //中屏幕選擇                            =>pin17
  14. sbit CS3 = P3^2;   //右屏幕選擇                                =>pin18


  15. #define start_line      0xC0    //起始行,可以用于圖形上下滾動
  16. #define start_page      0xb8    //起始頁
  17. #define start_column    0x40    //起始列
  18. #define display_on      0x3f    //顯示開
  19. #define display_off     0x3e    //顯示關

  20. #define screen_left     0    //左屏
  21. #define screen_mid      1    //左屏
  22. #define screen_right    2    //右屏

  23. #define com    0    //命令標志
  24. #define dat    1    //數據標志
  25. void LCD_Show_Chinese(uchar x,uchar y,uchar index);
  26. void lcd_show_string(uchar x,uchar y,uchar *ustr);
  27. void lcd_show_char(uchar x,uchar y,uchar ustr);
  28. void LCD_SendData(char data_byte,char data_type,char Screen);
  29. void LCD_Init();
  30. void LCD_Fill(uchar fill);
  31. void Delay1ms(unsigned int T);
  32. uchar butterfly(uchar byte) ;
  33. void test();
  34. void Delay1ms(unsigned int T)                        //延時1ms
  35. {
  36.     uchar j;
  37.         while (T)  
  38.     {
  39.         for (j=12;j>0;j--);
  40.     T--;
  41.         }
  42. }

  43. void main (void) //主程序
  44. {

  45.         P3M0 = 0x00; P3M1 = 0x00;
  46.     P1M0 = 0x00; P1M1 = 0x00;
  47.         P5M0 = 0x00; P5M1 = 0x00;
  48.         LCD_Init();   //LCD初始化
  49.         LCD_Fill(0);  //清屏
  50.         LCD_Show_Chinese(0,0,0);
  51.         LCD_Show_Chinese(16,0,1);
  52.         LCD_Show_Chinese(160,0,2);
  53.         LCD_Show_Chinese(176,0,3);
  54.         LCD_Show_Chinese(168,2,4);


  55.         lcd_show_string(50,0,"LCD_19264 DEMO ");
  56.         lcd_show_string(42,1,"Designed By zhuls");
  57.         lcd_show_string(0,2,"Show a string in LCD screen");
  58.         lcd_show_string(0,3,"if(col<=63) is left;");
  59.         lcd_show_string(0,4,"if(col>63 && col<=127) is middle");
  60.         lcd_show_string(0,5,"if(col>127 && col<=191) is right");
  61.         lcd_show_string(0,6,"if(col>=192) display is invalid!!");

  62. while(1)//主循環
  63. {
  64.     test();
  65. }
  66. }
  67. //***********************************************
  68. //一次送一個字節數據,存于data_byte//
  69. //數據類型由data_type決定,為1是數據,為0是命令
  70. //左中右屏選擇由screen決定,為0是左屏,為1是中屏,為2是右屏
  71. //
  72. //*******************************************

  73. void LCD_SendData(char data_byte,char data_type,char Screen)//
  74. {
  75. switch (Screen)//screen為0是左屏,為1是中屏,為2是右屏
  76. {
  77. case 0: CS1=0;CS2=1;CS3=1;break;
  78. case 1: CS1=1;CS2=0;CS3=1;break;
  79. case 2: CS1=1;CS2=1;CS3=0;break;
  80. }
  81.         RW=0;
  82.     RS=data_type;
  83.         DATABus=data_byte;
  84.     Delay1ms(1);
  85.            ENABLE=1;
  86.     Delay1ms(1);
  87.         ENABLE=0;
  88.     Delay1ms(1);
  89. }

  90. //*******************************************
  91. //初始化LCD
  92. //******************************************
  93. void LCD_Init()       
  94. {
  95.         char Screen;
  96.          Delay1ms(10);
  97.         for (Screen=0;Screen<3;Screen++)
  98.         {
  99.     LCD_SendData(display_on,com,Screen);//開顯示
  100.            }
  101. }
  102. //*******************************************
  103. //填充數據FILL,
  104. //fill是要填充的數據
  105. //******************************************
  106. void LCD_Fill(uchar fill)
  107. {
  108.         char column,page;
  109.         char Screen;
  110.         for (Screen=0;Screen<3;Screen++)//0是左屏,1是中屏,2是右屏
  111.         {
  112.           for (page=0;page<8;page++)                        //清屏
  113.           {
  114.             LCD_SendData(start_page+page,com,Screen);//清屏
  115.                 LCD_SendData(start_column,com,Screen);//定位到0列
  116.                 for (column=0;column<64;column++)
  117.                 {
  118.                         LCD_SendData(fill,dat,Screen);
  119.                 }
  120.           }  
  121.     }
  122. }
  123. //*******************************************************
  124. // 一個字節中的8bit高低互換,
  125. //bit0=bit7,bit1=bit6...bit6=bit1,bit7=bit0
  126. //蝶形算法
  127. uchar butterfly(uchar byte)
  128. {
  129.   uchar half_h,half_l;
  130.   half_h= (byte & 0x55)<<1;
  131.   half_l= (byte & 0xAA)>>1;
  132.   byte=half_h | half_l;
  133.   half_h= (byte & 0x33)<<2;
  134.   half_l= (byte & 0xcc)>>2;
  135.   byte=half_h | half_l;
  136.   half_h= (byte & 0x0f)<<4;
  137.   half_l= (byte & 0xf0)>>4;
  138.   byte=half_h | half_l;
  139.   return byte;
  140. }
  141. //測試顯示
  142. void test()
  143. {
  144.   uchar i,j;

  145.   for (j=0;j<3;j++)
  146.   {
  147.          LCD_SendData(start_page+7,com,j);
  148.          LCD_SendData(start_column,com,j);
  149.   for (i=0;i<32;i++)
  150.     {
  151.      LCD_SendData(0x55,dat,j);
  152.      LCD_SendData(0xaa,dat,j);
  153.           Delay1ms(10000);
  154.         }
  155. }       
  156.     Delay1ms(50000);
  157. for(j=0;j<3;j++)
  158.         {
  159.          LCD_SendData(start_page+7,com,j);
  160.          LCD_SendData(start_column,com,j);
  161. for (i=0;i<64;i++)
  162.     {
  163.      LCD_SendData(0xff,dat,j);
  164.          Delay1ms(5000);
  165.         }
  166.         }
  167. }
  168. //***功能:顯示一個ASCII,5*8字體 ;
  169. //*** x: 列坐標,0-191列,0-63,左屏,64-127,中屏,128-191,右屏        ;
  170. //*** y:行坐標,0~7頁,真實地址是 start_page+row;
  171. //***ustr: 待顯示字符;

  172. void lcd_show_char(uchar x,uchar y,uchar ustr)
  173. {
  174.     char i;
  175.         uchar temp;
  176.         uchar cs;
  177. if (y>=8) return; //頁大于7,無效;
  178.    ustr=ustr-' ';
  179.   for (i=0;i<6;i++)
  180.           {
  181.                 if(x<=63) cs=0;
  182.                 if(x>63 && x<=127) cs=1;
  183.                 if(x>127 ) cs=2;
  184.                 if (x>191) return;//列大于191,無效
  185.                 LCD_SendData(start_page+y,com,cs);
  186.                 LCD_SendData(start_column+x % 64,com,cs);
  187.             temp=dot5x8[ustr][i];
  188.                 temp=butterfly(temp);
  189.             LCD_SendData(temp,dat,cs);
  190.                 x++;
  191.           }
  192. }
  193. //***功能:顯示一個ASCII的字符串,5*8字體 ;
  194. //*** x: 列坐標,0-191列,0-63,左屏,64-127,中屏,128-191,右屏        ;
  195. //*** y:行坐標,0~7頁,真實地址是 start_page+row;
  196. //***ustr: 待顯示字符串;
  197. void lcd_show_string(uchar x,uchar y,uchar *ustr)
  198. {

  199.           while(*ustr!='\0')
  200.         {      
  201.                 lcd_show_char(x,y,*ustr);
  202.                 x+=6;
  203.                 ustr++;
  204.         }  
  205. }
  206. /******************************************************************************
  207.       函數說明:顯示單個16x16漢字
  208.       入口數據:x,y顯示坐標
  209.                 index 要顯示的漢字索引
  210.       返回值:  無
  211. ******************************************************************************/
  212. void LCD_Show_Chinese(uchar x,uchar y,uchar index)
  213. {
  214.   uchar i,temp,cs;
  215.   
  216.    for (i=0;i<16;i++)
  217.           {
  218.                 if(x<=63) cs=0;
  219.                 if(x>63 && x<=127) cs=1;
  220.                 if(x>127 ) cs=2;
  221.                 if (x>191) return;//列大于191,無效
  222.                 LCD_SendData(start_page+y,com,cs);
  223.                 LCD_SendData(start_column+x % 64,com,cs);
  224.             temp=font16[index][i*2];
  225.             LCD_SendData(temp,dat,cs);
  226.                 LCD_SendData(start_page+y+1,com,cs);
  227.                 LCD_SendData(start_column+x % 64,com,cs);
  228.             temp=font16[index][i*2+1];
  229.             LCD_SendData(temp,dat,cs);
  230.                 x++;
  231.          }                                         
  232. }

復制代碼
回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 五月婷婷 六月丁香 | 波多野结衣二区 | 精品国产乱码 | 久久久久久久久国产 | 欧美在线视频二区 | 一区二区三区免费 | 成人h免费观看视频 | 国产视频一区二区三区四区五区 | 美日韩免费视频 | 中国一级特黄真人毛片 | 国产精品久久久久婷婷二区次 | 插插插干干干 | 国产一区二区久久久 | 日韩欧美在线免费观看 | www视频在线观看 | 日韩久久久久久 | 天天成人综合网 | 一区二区三区欧美 | 精品亚洲二区 | 欧美一区二区三区高清视频 | 91视频一区二区 | 亚洲一区精品在线 | 亚洲精视频 | 国产精品一区二区三区四区五区 | av大片在线观看 | 欧美亚州综合 | 国产一区二区三区在线免费观看 | 国产一区二区电影网 | 一区二区在线 | 国产成人99久久亚洲综合精品 | 欧美极品在线观看 | 国产在线精品一区二区 | 国产成人一区二区三区精 | 久久久久久久久久久丰满 | h视频在线播放 | 日本中文在线视频 | 精品不卡| 亚洲欧美激情视频 | 国产高清视频一区 | 久久精品在线播放 | 日韩在线观看中文字幕 |