12864 LCD In-depth Study Notes_2——Based on msp430g2553

Publisher:心愿实现Latest update time:2015-08-18 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
7. The following code is to control the LCD to display the picture in full screen. The code is as follows:

//Program function: Display two pictures on the 12864 LCD, one is a negative code picture and the other is a positive code picture

//  I have tried this program and it works.  The LCD is controlled   by two lines WR   EN  serially.

//  This is the serial connection control of the LCD, which can greatly save the IO port of the microcontroller, but the data processing is slower than the parallel connection, so if the display content data is large,

//  If the real-time display requirement is high (such as displaying multiple pictures continuously, demonstrating animations, etc.),  parallel connection should be considered. If the MCU does not have enough IO ports, or the capacity of the displayed content is limited,

//  If the quality and real-time requirements are not high, you can consider using a serial connection

 

//It may be because the processing power of msp430g2553 is strong. I am now using serial connection to display the following pictures. The display effect is very good. I can't see any problem of slow data transmission speed.

 

//msp430g2553 has 16K flash and   512B  RAM  , so it can store the data of the next few pictures.

#include   "msp430g2553.h"

#include   "ser_12864.h"

#include  "qq.h"      //To display the data information of the picture

void  main(void)

{

WDTCTL  WDTPW  WDTHOLD;     //Turn off the dog

 

BCSCTL1  CALBC1_12MHZ;   //Set the CPU clock DCO frequency to 12MHz

DCOCTL  CALDCO_12MHZ;

P2DIR  |=BIT5+BIT4;       //Two lines of LCD

 

init_lcd();                  //Initialize LCD

 

 Clear_GDRAM();    //Clear random data in GDRAM

//   Draw_PM(qq1);

 for(;;)

 {

 

 

//   wr_lcd(comm,0x34);             //Open extended function mode, close drawing display

//   //Reverse command

//   wr_lcd(comm,0x04);             //Highlight lines 1 and 3 at the same time

//   wr_lcd(comm,0x05);             //Highlight lines 2 and 4 at the same time

//   wr_lcd(comm,0x36);

//

//   delay_ms(1000);

//

//   wr_lcd(comm,0x34);

//   wr_lcd(comm,0x04);             //Highlight lines 1 and 3 again, which is equivalent to turning off the highlight of lines 1 and 3

//   wr_lcd(comm,0x05);             //Highlight lines 2 and 4 again, which is equivalent to turning off the highlight of lines 2 and 4

//   wr_lcd(comm,0x36);

//   delay_ms(1000);

 Draw_PM(qq1);     //Display the picture   to display the graphics in negative code format

     delay_ms(1000);        //delay to observe the LCD screen display

 

 Draw_PM(qq2);    //Display the graphics in Yang code format

 delay_ms(1000);

 

 Draw_PM(zhu);

 delay_ms(1000);    //Show the cute pig picture

 

 Draw_PM(zifu);    //Display the picture of Chinese characters

 delay_ms(1000);

 

 Draw_PM(monkey1);    //Display the monkey's negative code picture

 delay_ms(1000);

 

 Draw_PM(monkey2);    //Display the positive code picture of the monkey

 delay_ms(1000);

 

 Draw_PM(QQ);    //Show the image of Q brother and Q sister

 delay_ms(1000);

 

 Draw_PM(zhangbin);    //Display the character picture I made myself

 delay_ms(1000);

 

 

 Draw_PM(dianxin0903xiaolian1);  //Display the character picture and negative code picture   I made myself  

 delay_ms(1000);

 

 Draw_PM(dianxin0903xiaolian2);  //Display the character picture and positive code picture   I made myself   

 delay_ms(1000);

 }

 

}

//The function of this program is to display the graphics in negative code format and positive code format alternately and cyclically

// I wanted to achieve this effect by using the inverse method, but it didn't work. I guess it's because the inverse method can't inverse the entire screen at the same time.

 

8. OK, the above code is for msp430g2553 serial control of LCD, which can be used directly. If you understand the above code, you should have mastered the basic functions of LCD. Here are some commonly used display functions, which I often use, and they are very good:

////

{

     uchar  pos=0;//initialization

 

 

 uchar  cnt=0; //What is passed is the pointer  , cnt is the offset, and then it is written character by character.

  switch(y0)

  {

  case  0:  pos=0x80+x;break;

  case  1:  pos=0x90+x;break;

  case  2:  pos=0x88+x;break;

  case  3:  pos=0x98+x;break;

  default:  break;

  }

   wr_lcd(comm,pos);//write address

 

    while(*(p+cnt)!='')

      {

      wr_lcd(dat,*(p+cnt));//write data

      cnt++;

      };

}

 

 

//************************************************ *******************************************

 void  wr_int(uchar  x,uchar  y0,uint  NUM)   //**************************************************Integer data display

{

uchar  a_SHOW[5];

 

a_SHOW[0]=(NUM/1000)+'0';//qian    //Only the last 4 digits of the data can be displayed

a_SHOW[1]=(NUM/100)+'0'  ;//bai

a_SHOW[2]=(NUM/10)+'0';//show

a_SHOW[3]=NUM+'0';//ge

a_SHOW[4]='';    //Add the count mark of the string

wr_string(x,y0,a_SHOW);

 

 

}

 

 

 

//************************************************ *******************************************

void  wr_float(uchar  x,uchar  y0,float  NUM) //********************************8Floating point data display

{

uchar  a_SHOW[7];

long  int  t;

t=NUM*1000;      //Multiply by 1000 first, then display as an integer. The format can only be xx.xxx, so the accuracy can only be three decimal places.

a_SHOW[0]=(t/10000)+'0';//show

a_SHOW[1]=(t/1000)+'0'  ;//ge

a_SHOW[2]='.';                //

a_SHOW[3]=(t/100)+'0';//shi  fen

a_SHOW[4]=(t/10)+'0';  //bai  fen

a_SHOW[5]=t+'0';       //qian  fen

 

a_SHOW[6]='';

wr_string(x,y0,a_SHOW);

}

 

 

Well, let's stop here for the introduction of LCD. This is a rough introduction. If you want a more detailed introduction, you can refer to the LCD manual. However, if you understand the above procedures, you should have no problem with the general application of LCD.

 

The following is an introduction to the application of the modeling software used for LCD display images.

 

 

    2. Application of LCD modeling software

To use LCD to display pictures or character pictures, the data information of the picture must be required, and this data is often very large. So how to generate this huge data? It is too unrealistic to rely on us to write it manually. Then we need the help of modeling software. The software I used is PCtoLCD2002, the author is Chen Xinting. Thanks to the author for providing such a useful software.

This software is powerful and easy to use. Below I will introduce some of the functions I often use. For more detailed introduction, you can refer to other materials.

 

The following settings correspond to the ST7920 controller for 12864 LCD.

   1) Use PCtoLCD2002 LCD modeling software to model the image. The precautions and common settings are as follows:

   1. PCtoLCD2002 only supports .bmp format images.

   2. When displaying images with 12864, the pixel size of the image used for modulus should not exceed 128*64. If it exceeds, some problems will occur. It can be smaller than it.

   3. You can also adjust the pixel position, move the position where you want to display the picture up, down, left, and right, and you can also flip it up, down, left, and right, mirror it, etc.

   4. You can also edit each pixel point. Click the left button on a pixel point to display it. Click the right button to cancel the display. If you keep holding the left button, you can draw and perform other operations.

   5. You can also only take the modulus of the image range with pixels, and not take the modulus of the blank areas on other sides. This can reduce the amount of data and save storage capacity.

   6. You can also create a new picture in PCtoLCD2002, set the pixel size, and then draw directly on it. Click the left button to display and the right button to cancel the display. It is just like drawing directly on the LCD screen, and then you can save it.

   7. If you select character mode in the mode, you can directly enter the characters to be displayed in the software and make them into character pictures directly. You can also change the font, size and other character attributes.

  8. The default display mode of 12864 LCD is line by line, so when taking the modulus, it is generally selected to take the modulus line by line.

  9. Because the high bit comes first when the microcontroller transmits data to the LCD, it is set to forward (high bit comes first) when taking the module.

  10, select hexadecimal as the output number system

  11. Select C51 format for custom format, because we are programming in C language. If you are programming in assembly language, select A51 format

  12. Because the generated data will be placed in an array, the row prefix braces should be removed and only a comma should be kept at the row suffix. Otherwise, there will be a pair of braces before and after each row of the generated data.

 

2) If you want to make a picture of text by yourself and then display it on LCD, in addition to making it directly in the character mode of PCtoLCD2002, you can also use the drawing accessories that come with Windows. The setting method is as follows:

1. Set the image resolution in the image properties: width to 128, height to 64, and other default values. Click OK.

2. Then you can add characters to the set drawing (click A on the left toolbar to add characters), write Chinese characters, and adjust the size, font and other properties of the characters. After that, save

3. Because PCtoLCD2002 only supports .bmp format images, you need to save them in .bmp format. (Usually save them in 24-bit  .bmp format)

4. Then you can use the same method to take the model of the image to take the model of the character image you just created and saved.

 

Following the above method, you should be able to create your own picture and character picture data.

 

Well, above, I have given a relatively comprehensive but rather rough introduction to 12864. For more comprehensive and detailed usage, please refer to the data sheet. When using LCD or any other microcontroller or chip, the most detailed and authoritative information is always the corresponding data sheet.

All other information, no matter how detailed and rich it is, is based on the manual, so you must not rely on this information when using it, it can only be used as a reference. When you encounter a problem, read the manual more and think more, so that you can turn the knowledge into your own.

 

Use 12864 to display the curve graph in real time. I haven't made the demonstration animation yet. I will make it up after it is done. In fact, it should not be difficult if you have mastered the previous ones.

Reference address:12864 LCD In-depth Study Notes_2——Based on msp430g2553

Previous article:My 12864 study notes_3---Control 12864 LCD display curve
Next article:12864 LCD in-depth study notes_1

Latest Microcontroller Articles
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号