12864 dots controlled by st7920

Publisher:平和思绪Latest update time:2016-10-07 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
You can mark it at any position. I would like to thank those kind people who explained the places where problems are likely to occur. Be sure to read DATESHEET carefully for the convenience of future generations.
      1. Positioning of dot position
      2. Reading currently displayed data
      3. Or and shift, i.e. rewriting new data
The program is as follows:
void GUI_Point(uchar x,uchar y,uchar flag)
{     
  uchar x_Dyte,x_byte; //Define the byte position of the column address, and which bit in the byte 
  uchar y_Dyte,y_byte; //Define as upper and lower screens (values ​​are 0, 1), row address (values ​​are 0~31)
  Write_command(0x36); //Drawing mode command
  /***X,Y coordinates are interchanged, i.e. ordinary X,Y coordinates***/
  x_Dyte=y/16; //Calculate which one of the 16 bytes
  x_byte=y&0x0f; //Calculate which bit in the byte
  y_Dyte=x/32; //0 is the upper half of the screen, 1 is the lower half of the screen
  y_byte=x&0x1f; //Calculate which row among 0~31
  
  Write_command(0x80+y_byte); //Set the row address (y coordinate)
  Write_command(0x80+x_Dyte+8*y_Dyte); //Set the column address (x coordinate), and select the upper and lower screens through 8*y_DyteRead_data
              
  ();
  GDRAM_hbit=Read_data(); //Read the current display high 8-bit
  dataGDRAM_lbit=Read_data(); //Read the current display low 8-bit datadelay_us
  (5);
  
  if(flag==1)
  { 
  Write_command(0x80+y_byte); //Set the row address (y coordinate)
  Write_command(0x80+x_Dyte+8*y_Dyte); //Set the column address (x coordinate), and select the upper and lower screens through 8*y_Dytedelay_us
  (5);
    if(x_byte<8) //Judge whether it is in the upper 8 bits or the lower 8 bits
  {
    Write_data(GDRAM_hbit|(0X01<<(7-x_byte))); //Display the upper 8-bit data of GDRAM area
    Write_data(GDRAM_lbit); //Display the lower 8-bit data of GDRAM area 
    }
    else
    {
    Write_data(GDRAM_hbit);
    Write_data(GDRAM_lbit|(0x01<<(15-x_byte)));
    } 
  }
  else
  {
  Write_data(0x00)); //Clear the upper 8-bit data of GDRAM area
  Write_data(0x00)); //Clear the lower 8-bit data of GDRAM area
  }    
} /**********Read the LCD


display data of the current address **********/ uchar Read_data() { uchar shuju; LCD_DATA_set_in; // Set port PB to input LCD_DATA_PORT=0xff; SET_DI; // D/I=1, represents data SET_RW; // R/W=1.Read delay_us(10); SET_E; delay_us(100); shuju=PINB; //Read the currently displayed data CLR_E; return(shuju);    }














Reference address:12864 dots controlled by st7920

Previous article:Design of arbitrary menu structure based on single chip microcomputer
Next article:STM8S interrupt priority setting

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号