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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

單片機(jī)+lcd12864部分顯示亂碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
芯片:AT89S52
實(shí)驗(yàn)臺:亞龍YL-236型單片機(jī)控制功能實(shí)訓(xùn)考核裝置
(剛開始學(xué).師傅也不會)
部分顯示亂碼.

我是按照書上的程序弄的.然后在之前也是同一個(gè)程序但只能顯示字模里面的前十個(gè)漢字.
超這個(gè)范圍就亂碼

有沒有其他新的更好的12864的編程方法
求求大佬指教..
代碼如下:
  1. #include <REGX52.H>
  2. #define        uint unsigned int
  3. #define        uchar unsigned char
  4. //12864引腳定義
  5. #define lcdDat P0  /* LCD12864 數(shù)據(jù)線 */
  6. sbit rst=P1^0;
  7. sbit cs2=P1^1;
  8. sbit cs1=P1^2;
  9. sbit e=P1^3;
  10. sbit rw=P1^4;
  11. sbit rs=P1^5;

  12. /** LCM忙檢測 **/
  13. void busy12864(){
  14.         lcdDat=0xff;    //口線置1,防止干擾
  15.         rs=0;
  16.         rw=1;           //置“命令、讀”模式
  17.         e=1;
  18.         while(lcdDat&0x80);
  19.         e=0;//忙等待
  20. }
  21. /** 寫命令 參數(shù):comDat為要發(fā)送的命令 **/
  22. void Writecom(uchar com){  
  23.     busy12864();                     //忙,則等待
  24.         rs=0;
  25.         rw=0;                                //置“命令、寫”模式
  26.     lcdDat=com;
  27.         e=1;
  28.         e=0;//送出命令,并使之有效
  29. }
  30. /** 寫數(shù)據(jù) 參數(shù):dat為要發(fā)送的數(shù)據(jù) **/
  31. void Writedat(uchar dat){  
  32.     busy12864();                           //忙,則等待
  33.         rs=1;
  34.         rw=0;                                  //置“數(shù)據(jù)、寫”模式
  35.     lcdDat=dat;
  36.         e=1;
  37.         e=0;        //送出數(shù)據(jù),并使之有效
  38. }
  39. //清屏函數(shù)
  40. void clrLCD(){
  41.         uchar i,j;
  42.         cs1=cs2=1;                           //同時(shí)選中左右屏
  43.         for(i=0;i<8;i++)
  44.           {           //共8頁
  45.                 Writecom(0xB8+i);  //光標(biāo)到i頁
  46.                 Writecom(0x40);           //光標(biāo)到頁首
  47.                 for(j=0;j<64;j++)
  48.                 {
  49.                 Writedat(0); //寫0清屏
  50.            }
  51.         }
  52. }
  53. /** 初始化12864 **/
  54. void Init12864(){
  55.         lcdDat=0xff;   //口線置1,防止干擾
  56.         rs=0;
  57.         rw=1;           //置“命令、讀”模式
  58.         e=1;
  59.         while(lcdDat&0x10);
  60.         e=0;//等待復(fù)位完成
  61.         Writecom(0x3f);          //開顯示
  62.         Writecom(0xc0);          //設(shè)置顯示起始行
  63.         clrLCD();                  //清屏
  64. }
  65. uchar code ywzc[]="ABC"; //索引字串
  66. uchar code ywzm[][16]={         //字串字模
  67. /*--  文字:  A  --*/
  68. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  69. 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,

  70. /*--  文字:  B  --*/
  71. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  72. 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,

  73. /*--  文字:  C  --*/
  74. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  75. 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,

  76. };
  77. uchar code hzzc[]="一二三四五六七八九十當(dāng)前工步";//字串索引
  78. uchar code hzzm[][32]={  //字串字模
  79. /*--  文字:  一  --*/
  80. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  81. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
  82. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  83. /*--  文字:  二  --*/
  84. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  85. 0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
  86. 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,

  87. /*--  文字:  三  --*/
  88. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  89. 0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04,0x00,0x00,
  90. 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,

  91. /*--  文字:  四  --*/
  92. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  93. 0x00,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00,
  94. 0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7F,0x00,0x00,

  95. /*--  文字:  五  --*/
  96. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  97. 0x00,0x02,0x42,0x42,0x42,0xC2,0x7E,0x42,0x42,0x42,0x42,0xC2,0x02,0x02,0x00,0x00,
  98. 0x40,0x40,0x40,0x40,0x78,0x47,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x00,

  99. /*--  文字:  六  --*/
  100. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  101. 0x20,0x20,0x20,0x20,0x20,0x20,0x21,0x22,0x2C,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
  102. 0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x01,0x02,0x04,0x18,0x60,0x00,0x00,

  103. /*--  文字:  七  --*/
  104. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  105. 0x80,0x80,0x80,0x80,0x80,0x40,0xFF,0x40,0x40,0x40,0x20,0x20,0x20,0x20,0x00,0x00,
  106. 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x78,0x00,0x00,

  107. /*--  文字:  八  --*/
  108. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  109. 0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x7E,0x80,0x00,0x00,0x00,0x00,0x00,
  110. 0x00,0x80,0x60,0x18,0x07,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x30,0x40,0x80,0x00,

  111. /*--  文字:  九  --*/
  112. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  113. 0x00,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0xF0,0x00,0x00,0x00,0x00,0x00,
  114. 0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x78,0x00,

  115. /*--  文字:  十  --*/
  116. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  117. 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
  118. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  119. /*--  文字:  當(dāng)  --*/
  120. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  121. 0x00,0x40,0x42,0x44,0x58,0x40,0x40,0x7F,0x40,0x40,0x50,0x48,0xC6,0x00,0x00,0x00,
  122. 0x00,0x40,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0xFF,0x00,0x00,0x00,

  123. /*--  文字:  前  --*/
  124. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  125. 0x08,0x08,0xE8,0x29,0x2E,0x28,0xE8,0x08,0x08,0xC8,0x0C,0x0B,0xE8,0x08,0x08,0x00,
  126. 0x00,0x00,0xFF,0x09,0x49,0x89,0x7F,0x00,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,0x00,

  127. /*--  文字:  工  --*/
  128. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  129. 0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,
  130. 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,

  131. /*--  文字:  步  --*/
  132. /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  133. 0x40,0x40,0x40,0x7C,0x40,0x40,0x40,0xFF,0x44,0x44,0x44,0x44,0x44,0x40,0x40,0x00,
  134. 0x80,0x90,0x88,0x46,0x40,0x40,0x20,0x2F,0x10,0x10,0x08,0x04,0x02,0x00,0x00,0x00,


  135. };


  136. /******** 任意尺寸點(diǎn)陣顯示函數(shù) ***********|
  137. |參數(shù):顯示位置:row頁數(shù),col列號,                  |
  138. |           字符大。簒橫向像素,y縱向頁數(shù)          |
  139. |           顯示內(nèi)容:tab字模表          ******/
  140. void showXY(uchar row,uchar col,uchar x,uchar y,uchar *tab)
  141. {
  142.         uchar i,j;
  143.         bit right;
  144.         if(col<64){right=0;} //置左右屏標(biāo)志
  145.         else {col-=64;right=1;}        
  146.         for(i=0;i<y;i++)
  147.         {
  148.                 if(right)cs1=0,cs2=1;
  149.                 else  cs1=1,cs2=0;
  150.                 Writecom(0xb8+row+i); //行
  151.                 Writecom(0x40+col);   //列
  152.                 for(j=0;j<x;j++)
  153.                 {
  154.                         if(col+j<64)Writedat(tab[i*x+j]);  //未跨屏
  155.                         else if(right==0)
  156.                         {                  //從左屏跨右屏
  157.                                  cs1=0,cs2=1;                  //選中右屏
  158.                                  Writecom(0xb8+row+i);           //設(shè)置行
  159.                                  Writecom(0x40+(col+j-64));
  160.                                  Writedat(tab[i*x+j]);
  161.                         }                                                 //在右屏越界不顯示
  162.                 }
  163.         }
  164. }
  165. /* 返回一個(gè)8*16字符索引位置 */                                       
  166. uchar enN(uchar *s)
  167. {
  168.         uchar i;
  169.         for(i=0;ywzc[i]!=0;i++)
  170.         if(ywzc[i]==s[0])break;
  171.         return i;        
  172. }
  173. /* 返回一個(gè)16*16字符索引位置 */
  174. uchar cnN(uchar *s)
  175. {
  176.         uchar i;
  177.         for(i=0;hzzc[i]!=0;i+=2)
  178.         if(hzzc[i]==*s&&hzzc[i+1]==*(s+1))break ;
  179.         return i/2;
  180. }
  181. /* 顯示字符串 */
  182. void showStr(uchar row,uchar col,uchar *s)
  183. {
  184.          uchar i;
  185.          for(i=0;s[i]!=0;i++)
  186.          {
  187.                  if(s[i]<0x80)
  188.                 {         //英文
  189.                         showXY(row,col,8,2,ywzm[enN(&s[i])]);
  190.                         col+=8;
  191.                 }
  192.                 else{                        
  193.                         showXY(row,col,16,2,hzzm[cnN(&s[i])]);        
  194.                         col+=16;i+=1;               
  195.                 }
  196.                 if(col>120)
  197.                 {         //換行處理
  198.                         col=0;
  199.                         row+=2;
  200.                 }
  201.          }
  202. }
  203. void main()
  204. {
  205.         Init12864();           //初始化
  206.         showStr(0,0,"一二三四五");
  207.         showStr(3,0,"六七八九十");
  208.         showStr(6,0,"當(dāng)前工步");
  209.          while(1);
  210. }
復(fù)制代碼





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

使用道具 舉報(bào)

沙發(fā)
ID:88256 發(fā)表于 2020-10-2 22:37 | 只看該作者
從畫面來看,不是你說的“只能顯示字模里面的前十個(gè)漢字.超這個(gè)范圍就亂碼”,畫面上比較正常顯示的只有“一二三四”,也就是說只有左半屏是正常顯示的,同一個(gè)字符串里的“五”無法正常顯示,說明左右半屏的處理不對,你得看你用的12864具體型號并找到資料,看看里面左右半屏的片選CS1、CS2是怎樣使用的,然后更改第169行if(right)cs1=0,cs2=1;以及第178行cs1=0,cs2=1;里的片選試試。
回復(fù)

使用道具 舉報(bào)

板凳
ID:155507 發(fā)表于 2020-10-3 09:27 | 只看該作者
給你改了一下試試。

  1. #include <REG52.H>
  2. #define        uint unsigned int
  3. #define        uchar unsigned char
  4. //12864引腳定義
  5. #define lcdDat P0  /* LCD12864 數(shù)據(jù)線 */
  6. sbit rst=P1^0;
  7. sbit cs2=P1^1;    //片選1低電平有效,控制右半屏
  8. sbit cs1=P1^2;    //片選1低電平有效,控制左半屏
  9. sbit e=P1^3;      //使能端
  10. sbit rw=P1^4;     //RW為1---寫;0---讀
  11. sbit rs=P1^5;     //RS為0---命令;1----數(shù)據(jù)

  12. /** LCM忙檢測 **/
  13. void busy12864(){
  14.         lcdDat=0xff;    //口線置1,防止干擾
  15.         rs=0;
  16.         rw=1;           //置“命令、讀”模式
  17.         e=1;
  18.         while(lcdDat&0x80);
  19.         e=0;//忙等待
  20. }
  21. /** 寫命令 參數(shù):comDat為要發(fā)送的命令 **/
  22. void Writecom(uchar com){  
  23.         busy12864();                     //忙,則等待
  24.         rs=0;
  25.         rw=0;                            //置“命令、寫”模式
  26.         lcdDat=com;
  27.         e=1;
  28.         e=0;//送出命令,并使之有效
  29. }
  30. /** 寫數(shù)據(jù) 參數(shù):dat為要發(fā)送的數(shù)據(jù) **/
  31. void Writedat(uchar dat){  
  32.         busy12864();                           //忙,則等待
  33.         rs=1;
  34.         rw=0;                                  //置“數(shù)據(jù)、寫”模式
  35.         lcdDat=dat;
  36.         e=1;
  37.         e=0;        //送出數(shù)據(jù),并使之有效
  38. }
  39. //清屏函數(shù)
  40. void clrLCD(){
  41.         uchar i,j;
  42.         cs1=cs2=0;                           //同時(shí)選中左右屏
  43.         for(i=0;i<8;i++)
  44.         {           //共8頁
  45.                 Writecom(0xB8+i);  //光標(biāo)到i頁
  46.                 Writecom(0x40);           //光標(biāo)到頁首
  47.                 for(j=0;j<64;j++)
  48.                 {
  49.                         Writedat(0); //寫0清屏
  50.                 }
  51.         }
  52. }
  53. /** 初始化12864 **/
  54. void Init12864(){
  55.         lcdDat=0xff;   //口線置1,防止干擾
  56.         rs=0;
  57.         rw=1;          //置“命令、讀”模式
  58.         cs1=cs2=0;     //同時(shí)選中左右屏
  59.         e=1;
  60.         while(lcdDat&0x10);
  61.         e=0;//等待復(fù)位完成
  62.         Writecom(0x3f);          //開顯示
  63.         Writecom(0xc0);          //設(shè)置顯示起始行
  64.         clrLCD();                  //清屏
  65. }
  66. uchar code ywzc[]="ABC"; //索引字串
  67. uchar code ywzm[][16]={         //字串字模
  68.         /*--  文字:  A  --*/
  69.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  70.         0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,

  71.         /*--  文字:  B  --*/
  72.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  73.         0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,

  74.         /*--  文字:  C  --*/
  75.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=8x16   --*/
  76.         0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,

  77. };
  78. uchar code hzzc[]="一二三四五六七八九十當(dāng)前工步";//字串索引
  79. uchar code hzzm[][32]={  //字串字模
  80.         /*--  文字:  一  --*/
  81.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  82.         0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
  83.         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  84.         /*--  文字:  二  --*/
  85.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  86.         0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
  87.         0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,

  88.         /*--  文字:  三  --*/
  89.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  90.         0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04,0x00,0x00,
  91.         0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,

  92.         /*--  文字:  四  --*/
  93.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  94.         0x00,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00,
  95.         0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7F,0x00,0x00,

  96.         /*--  文字:  五  --*/
  97.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  98.         0x00,0x02,0x42,0x42,0x42,0xC2,0x7E,0x42,0x42,0x42,0x42,0xC2,0x02,0x02,0x00,0x00,
  99.         0x40,0x40,0x40,0x40,0x78,0x47,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x00,

  100.         /*--  文字:  六  --*/
  101.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  102.         0x20,0x20,0x20,0x20,0x20,0x20,0x21,0x22,0x2C,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
  103.         0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x01,0x02,0x04,0x18,0x60,0x00,0x00,

  104.         /*--  文字:  七  --*/
  105.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  106.         0x80,0x80,0x80,0x80,0x80,0x40,0xFF,0x40,0x40,0x40,0x20,0x20,0x20,0x20,0x00,0x00,
  107.         0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x78,0x00,0x00,

  108.         /*--  文字:  八  --*/
  109.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  110.         0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x7E,0x80,0x00,0x00,0x00,0x00,0x00,
  111.         0x00,0x80,0x60,0x18,0x07,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x30,0x40,0x80,0x00,

  112.         /*--  文字:  九  --*/
  113.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  114.         0x00,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0xF0,0x00,0x00,0x00,0x00,0x00,
  115.         0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x78,0x00,

  116.         /*--  文字:  十  --*/
  117.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  118.         0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
  119.         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  120.         /*--  文字:  當(dāng)  --*/
  121.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  122.         0x00,0x40,0x42,0x44,0x58,0x40,0x40,0x7F,0x40,0x40,0x50,0x48,0xC6,0x00,0x00,0x00,
  123.         0x00,0x40,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0xFF,0x00,0x00,0x00,

  124.         /*--  文字:  前  --*/
  125.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  126.         0x08,0x08,0xE8,0x29,0x2E,0x28,0xE8,0x08,0x08,0xC8,0x0C,0x0B,0xE8,0x08,0x08,0x00,
  127.         0x00,0x00,0xFF,0x09,0x49,0x89,0x7F,0x00,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,0x00,

  128.         /*--  文字:  工  --*/
  129.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  130.         0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,
  131.         0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,

  132.         /*--  文字:  步  --*/
  133.         /*--  宋體12;  此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16   --*/
  134.         0x40,0x40,0x40,0x7C,0x40,0x40,0x40,0xFF,0x44,0x44,0x44,0x44,0x44,0x40,0x40,0x00,
  135.         0x80,0x90,0x88,0x46,0x40,0x40,0x20,0x2F,0x10,0x10,0x08,0x04,0x02,0x00,0x00,0x00,


  136. };


  137. /******** 任意尺寸點(diǎn)陣顯示函數(shù) ***********|
  138. |參數(shù):顯示位置:row頁數(shù),col列號,                  |
  139. |           字符大。簒橫向像素,y縱向頁數(shù)          |
  140. |           顯示內(nèi)容:tab字模表          ******/
  141. void showXY(uchar row,uchar col,uchar x,uchar y,uchar *tab)
  142. {
  143.         uchar i,j;
  144.         bit right;
  145.         if(col<64){right=0;} //置左右屏標(biāo)志
  146.         else {col-=64;right=1;}        
  147.         for(i=0;i<y;i++)
  148.         {
  149.                 if(right)cs1=1,cs2=0;
  150.                 else  cs1=0,cs2=1;
  151.                 Writecom(0xb8+row+i); //行
  152.                 Writecom(0x40+col);   //列
  153.                 for(j=0;j<x;j++)
  154.                 {
  155.                         if(col+j<64)Writedat(tab[i*x+j]);  //未跨屏
  156.                         else if(right==0)
  157.                         {                  //從左屏跨右屏
  158.                                 cs1=0,cs2=1;                  //選中右屏
  159.                                 Writecom(0xb8+row+i);           //設(shè)置行
  160.                                 Writecom(0x40+(col+j-64));
  161.                                 Writedat(tab[i*x+j]);
  162.                         }                                                 //在右屏越界不顯示
  163.                 }
  164.         }
  165. }
  166. /* 返回一個(gè)8*16字符索引位置 */                                       
  167. uchar enN(uchar *s)
  168. {
  169.         uchar i;
  170.         for(i=0;ywzc[i]!=0;i++)
  171.         if(ywzc[i]==s[0])break;
  172.         return i;        
  173. }
  174. /* 返回一個(gè)16*16字符索引位置 */
  175. uchar cnN(uchar *s)
  176. {
  177.         uchar i;
  178.         for(i=0;hzzc[i]!=0;i+=2)
  179.         if(hzzc[i]==*s&&hzzc[i+1]==*(s+1))break ;
  180.         return i/2;
  181. }
  182. /* 顯示字符串 */
  183. void showStr(uchar row,uchar col,uchar *s)
  184. {
  185.         uchar i;
  186.         for(i=0;s[i]!=0;i++)
  187.         {
  188.                 if(s[i]<0x80)
  189.                 {         //英文
  190.                         showXY(row,col,8,2,ywzm[enN(&s[i])]);
  191.                         col+=8;
  192.                 }
  193.                 else{                        
  194.                         showXY(row,col,16,2,hzzm[cnN(&s[i])]);        
  195.                         col+=16;i+=1;               
  196.                 }
  197.                 if(col>120)
  198.                 {         //換行處理
  199.                         col=0;
  200.                         row+=2;
  201.                 }
  202.         }
  203. }
  204. void main()
  205. {
  206.         Init12864();           //初始化
  207.         showStr(0,0,"一二三四五");
  208.         showStr(3,0,"六七八九十");
  209.         showStr(6,0,"當(dāng)前工步");
  210.         while(1);
  211. }


復(fù)制代碼
回復(fù)

使用道具 舉報(bào)

地板
ID:825326 發(fā)表于 2020-10-3 12:12 | 只看該作者
angmall 發(fā)表于 2020-10-3 09:27
給你改了一下試試。

鐵子.不顯示了.沒圖象遼
回復(fù)

使用道具 舉報(bào)

5#
ID:825326 發(fā)表于 2020-10-3 15:25 | 只看該作者
hhdsdy 發(fā)表于 2020-10-2 22:37
從畫面來看,不是你說的“只能顯示字模里面的前十個(gè)漢字.超這個(gè)范圍就亂碼”,畫面上比較正常顯示的只有“ ...

好的我在試試
回復(fù)

使用道具 舉報(bào)

6#
ID:88256 發(fā)表于 2020-10-4 21:37 | 只看該作者

試得怎么樣?有這款12864的資料嗎?
回復(fù)

使用道具 舉報(bào)

7#
ID:825326 發(fā)表于 2020-10-8 20:02 | 只看該作者
hhdsdy 發(fā)表于 2020-10-4 21:37
試得怎么樣?有這款12864的資料嗎?

不行啊..你有qq嘛.我加一下.
回復(fù)

使用道具 舉報(bào)

8#
ID:88256 發(fā)表于 2020-10-8 23:58 | 只看該作者
嗯哼哼? 發(fā)表于 2020-10-8 20:02
不行啊..你有qq嘛.我加一下.

先把資料找出來啊
回復(fù)

使用道具 舉報(bào)

9#
ID:808634 發(fā)表于 2020-10-9 07:59 | 只看該作者
根據(jù)12864型號查找相應(yīng)資料,并根據(jù)真值表查找相應(yīng)錯(cuò)誤
回復(fù)

使用道具 舉報(bào)

10#
ID:970554 發(fā)表于 2021-10-8 16:21 | 只看該作者
樓主,12864亂碼的問題解決了嗎
回復(fù)

使用道具 舉報(bào)

11#
ID:970554 發(fā)表于 2021-10-8 16:21 | 只看該作者
樓組,亂碼的問題解決了嗎
回復(fù)

使用道具 舉報(bào)

12#
ID:831736 發(fā)表于 2021-10-11 15:51 | 只看該作者
void wr_lcd(uchar a,b)
{
rs=a;
rw=0;
en=1;
P0=b;
en=0;
}
void disp(uchar x,y,x1,y1,line,rom,uchar *str)
{
uchar a,b,c,d,e;
wr_lcd(0,0x3f);
for(a=0;a<line;a++)
  {
    for(b=0;b<rom;b++)
    {
       for(c=0;c<x1;c++)
           {
                wr_lcd(0,0xb8+x+a*x1+c);
                wr_lcd(0,0xc0);
                wr_lcd(0,0x40+y+b*y1);
                d=a*x1*y1*rom+b*x1*y1+c*y1;
                  for(e=0;e<y1;e++)
                  {
                  wr_lcd(1,str[d+e]);
                  }
           }
    }
  }
}
void qpin()
{
static uchar a,b;
for(a=0;a<8;a++)
  {
  for(b=0;b<64;b++)
    {
        cs1=cs2=1;
        disp(a,b,1,1,1,1,0x00);
        }
  }
}
void tpxsh()
{
  cs1=1;cs2=0;
  disp1(0,0,1,64,1,1,tp1);
  disp1(1,0,1,64,1,1,tp1+64*2);
  disp1(2,0,1,64,1,1,tp1+64*4);
  disp1(3,0,1,64,1,1,tp1+64*6);
  disp1(4,0,1,64,1,1,tp1+64*8);
  disp1(5,0,1,64,1,1,tp1+64*10);
  disp1(6,0,1,64,1,1,tp1+64*12);
  disp1(7,0,1,64,1,1,tp1+64*14);
   cs1=0;cs2=1;
  disp1(0,0,1,64,1,1,tp1+64);
  disp1(1,0,1,64,1,1,tp1+64*3);
  disp1(2,0,1,64,1,1,tp1+64*5);
  disp1(3,0,1,64,1,1,tp1+64*7);
  disp1(4,0,1,64,1,1,tp1+64*9);
  disp1(5,0,1,64,1,1,tp1+64*11);
  disp1(6,0,1,64,1,1,tp1+64*13);
  disp1(7,0,1,64,1,1,tp1+64*15);
}
uchar code tp1[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xF0,0xF8,
0xFC,0xFC,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0xF8,0xF0,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0xE0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0xF8,
0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x03,0x07,0x0F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x0F,0x1F,
0x3F,0x7F,0xFF,0x7F,0x1F,0x07,0x01,0x00,0x00,0x00,0x00,0x60,0x62,0x34,0x1C,0x1C,
0x9C,0xBC,0xF8,0x78,0x70,0x70,0x60,0x20,0x08,0x00,0x30,0x38,0x30,0x30,0x78,0xF8,
0xFC,0x1C,0x1C,0x1C,0x14,0x36,0x76,0x66,0x66,0x64,0x64,0xE8,0x68,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x1F,0xFF,0xFF,0x7F,0x3F,0x1F,
0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,0x83,
0x41,0x21,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x61,0x43,0xC3,0x82,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x59,0x9D,0x0C,0x04,
0x82,0x83,0x82,0x82,0x86,0x86,0x84,0x84,0x84,0x8C,0xBC,0x94,0x86,0x86,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0xC3,0x42,0x6E,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xC0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x1F,0x1F,0x00,
0x00,0x08,0x19,0x31,0x61,0x61,0x61,0x60,0x60,0x60,0x61,0x21,0x10,0x00,0x00,0x0C,
0x0C,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFE,0xFF,0xFF,
0xFE,0xF8,0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xE0,0xF0,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xFC,
0xF8,0xF8,0xF8,0xF8,0xF0,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xFC,0xFC,
0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
自己去定義端口,我寫得有點(diǎn)簡單

評分

參與人數(shù) 1黑幣 +20 收起 理由
admin + 20 回帖助人的獎(jiǎng)勵(lì)!

查看全部評分

回復(fù)

使用道具 舉報(bào)

13#
ID:831736 發(fā)表于 2021-10-11 16:58 | 只看該作者
void disp1(uchar x,y,x1,y1,line,rom,uchar *str)
{
uchar a,b,c,d,e;
wr_lcd(0,0x3f);
for(a=0;a<line;a++)
  {
    for(b=0;b<rom;b++)
    {
       for(c=0;c<x1;c++)
           {
                wr_lcd(0,0xb8+x+a*x1+c);
                wr_lcd(0,0xc0);
                wr_lcd(0,0x40+y+b*y1);
                d=a*x1*y1*rom+b*x1*y1+c*y1;
                  for(e=0;e<y1;e++)
                  {
                  wr_lcd(1,~str[d+e]);
                  }
           }
    }
  }
}
打臉!程序有點(diǎn)小問題,把上面那個(gè)void disp(---)改成這個(gè)
回復(fù)

使用道具 舉報(bào)

14#
ID:822775 發(fā)表于 2021-10-11 18:29 | 只看該作者
LCD12864都不會用,看不懂
回復(fù)

使用道具 舉報(bào)

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

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 欧美综合一区二区三区 | 国产亚洲精品美女久久久久久久久久 | 亚洲免费久久久 | 日韩免费网站 | 九九精品在线 | 8x国产精品视频一区二区 | 国产在视频一区二区三区吞精 | 亚洲免费福利视频 | 中文字幕 国产精品 | 蜜桃视频一区二区三区 | 欧美日韩中文字幕在线播放 | 毛片大全 | 亚洲成人福利视频 | 中文字幕久久久 | 亚洲欧美日韩精品久久亚洲区 | 99久久99热这里只有精品 | 精品国产91亚洲一区二区三区www | 人人射人人 | jlzzxxxx18hd护士 | 91精品国产一区二区三区 | 伊人免费视频二 | 精品国产乱码久久久久久88av | 精品久久国产 | 四虎永久在线精品免费一区二 | 亚洲一av| chengrenzaixian | 久久久久久久一区 | 日日干天天操 | 国产真实精品久久二三区 | 久久毛片 | 日韩免费成人av | 成人免费小视频 | 亚洲精品国产电影 | 国产日韩欧美一区二区 | 精久久久| 成年人在线观看 | 一级大片 | 午夜免费 | 久久成人一区 | 日韩aⅴ视频 | 欧美一级片在线看 |