找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 2976|回復(fù): 6
收起左側(cè)

求大神看一下單片機(jī)+LCD12232顯示的字體為什么是鏡像的

[復(fù)制鏈接]
ID:700110 發(fā)表于 2020-3-3 16:26 | 顯示全部樓層 |閱讀模式
TIM圖片20200303161855.png TIM圖片20200303162236.png
根據(jù)lab8000用proteus仿真的 剛剛接觸這個(gè)LCD,可能連線不對(duì),單片機(jī)代碼如下
  1. #include<reg51.h>
  2. #define PD1 61

  3. unsigned char Column;
  4. unsigned char Page_;
  5. unsigned char Code_;
  6. unsigned char Command;
  7. unsigned char LCDData;

  8. xdata unsigned char CWADD1 _at_ 0x8000;
  9. xdata unsigned char DWADD1 _at_ 0x8001;
  10. xdata unsigned char CRADD1 _at_ 0x8002;
  11. xdata unsigned char DRADD1 _at_ 0x8003;

  12. xdata unsigned char CWADD2 _at_ 0x8004;
  13. xdata unsigned char DWADD2 _at_ 0x8005;
  14. xdata unsigned char CRADD2 _at_ 0x8006;
  15. xdata unsigned char DRADD2 _at_ 0x8007;

  16. code unsigned char EETAB[ ][8]={
  17.     {0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00},
  18.     {0x10,0x30,0x50,0x10,0x10,0x10,0x7c,0x00},
  19.     {0x38,0x44,0x04,0x08,0x10,0x20,0x7c,0x00},
  20.     {0x78,0x84,0x04,0x38,0x04,0x84,0x78,0x00}
  21. };

  22. code unsigned char CCTAB[][32] ={
  23.     {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
  24.     0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
  25.     0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
  26.     0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},

  27.     {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
  28.     0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
  29.     0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
  30.     0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},

  31.     {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
  32.     0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
  33.     0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
  34.     0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},

  35.     {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
  36.     0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
  37.     0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
  38.     0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00}
  39. };

  40. void WriteCommandE1(){
  41.     while(CRADD1 & 0x80);
  42.     CWADD1 = Command;
  43. }

  44. void WriteDataE1(){
  45.     while(CRADD1 & 0x80);
  46.     DWADD1 = LCDData;
  47. }

  48. void ReadDataE1(){
  49.     while(CRADD1 & 0x80);
  50.     LCDData = DRADD1;
  51. }

  52. void WriteCommandE2(){
  53.     while(CRADD2 & 0x80);
  54.     CWADD2 = Command;
  55. }

  56. void WriteDataE2(){
  57.     while(CRADD2 & 0x80);
  58.     DWADD2 = LCDData;
  59. }

  60. void ReadDataE2(){
  61.     while(CRADD2 & 0x80);
  62.     LCDData = DRADD2;
  63. }

  64. void Init(){
  65.     Command = 0xe2;

  66.     WriteCommandE1();
  67.     WriteCommandE2();

  68.     Command = 0xa4;
  69.     WriteCommandE1();
  70.     WriteCommandE2();

  71.     Command = 0xa9;
  72.     WriteCommandE1();
  73.     WriteCommandE2();

  74.     Command = 0xa0;
  75.     WriteCommandE1();
  76.     WriteCommandE2();

  77.     Command = 0xc0;
  78.     WriteCommandE1();
  79.     WriteCommandE2();

  80.     Command = 0xaf;
  81.     WriteCommandE1();
  82.     WriteCommandE2();

  83. }

  84. void Clear(){
  85.     unsigned char i, j;
  86.     i = 0;
  87.     do{
  88.         Command = (i + 0xb8);
  89.         WriteCommandE1();
  90.         WriteCommandE2();

  91.         Command = 0x00;
  92.         WriteCommandE1();
  93.         WriteCommandE2();
  94.         j = 0x50;
  95.         do{
  96.             LCDData = 0x00;
  97.             WriteDataE1();
  98.             WriteDataE2();
  99.         }while(--j!=0);
  100.     }while(++i!=4);
  101. }

  102. void Delay(){
  103.     unsigned char i, j;
  104.     i = 20;
  105.     j = 0;
  106.     do{
  107.         do{
  108.         }while(--j!=0);
  109.     }while(--i!=0);
  110. }

  111. void WriteCHN16x16(){
  112.     unsigned char i, j, k;
  113.     i = 0;
  114.     j = 0;
  115.     while(j<2){
  116.         Command = ((Page_ + j) & 0x03)|0xb8;
  117.         WriteCommandE1();
  118.         WriteCommandE2();
  119.         k = Column;
  120.         while(k < Column + 16){
  121.             if(k < PD1){
  122.                 Command = k;
  123.                 WriteCommandE1();
  124.                 LCDData = CCTAB[Code_][i];
  125.                 WriteDataE1();
  126.             }
  127.             else{
  128.                 Command = k-PD1;
  129.                 WriteCommandE2();
  130.                 LCDData = CCTAB[Code_][/i][i][i];
  131.                 WriteDataE2();
  132.             }
  133.             i++;
  134.             if(++k >= PD1*2) break;
  135.         }
  136.         j++;
  137.     }
  138. }

  139. void main(){
  140.     Init();
  141.     Clear();
  142.     Page_ = 0x02;
  143.     Column = 0x00;
  144.     Code_ = 0x00;
  145.     WriteCHN16x16();

  146.     while(1);
  147. }
復(fù)制代碼


回復(fù)

使用道具 舉報(bào)

ID:617449 發(fā)表于 2020-3-3 17:33 | 顯示全部樓層
那就取模的時(shí)候先鏡像一下,顯示就是正的了
回復(fù)

使用道具 舉報(bào)

ID:105364 發(fā)表于 2020-3-3 18:12 | 顯示全部樓層
程序沒錯(cuò)。很久以前做過,仿真就這樣是鏡像 的,同樣程序放實(shí)物就正確的。
12232.jpg 91529822720e0cf3233037760a46f21fbf09aa7c.jpg

回復(fù)

使用道具 舉報(bào)

ID:700110 發(fā)表于 2020-3-3 21:39 | 顯示全部樓層
47okey 發(fā)表于 2020-3-3 18:12
程序沒錯(cuò)。很久以前做過,仿真就這樣是鏡像 的,同樣程序放實(shí)物就正確的。

大佬,那您能幫我看下我定義的應(yīng)該是在第二行第一位的位置,為什么在中間呢
回復(fù)

使用道具 舉報(bào)

ID:704664 發(fā)表于 2020-3-10 09:10 | 顯示全部樓層
小哥,你是在做漢字滾動(dòng)的設(shè)計(jì)嗎
回復(fù)

使用道具 舉報(bào)

ID:897458 發(fā)表于 2021-12-24 08:25 來自觸屏版 | 顯示全部樓層
不同廠家生產(chǎn)的屏方向不同
回復(fù)

使用道具 舉報(bào)

ID:232791 發(fā)表于 2021-12-28 09:06 | 顯示全部樓層
程序設(shè)置180°翻轉(zhuǎn)
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表