/*------External crystal oscillator is 12MHz-------*/
/*--------Last modified 2011.02.26-------*/
#include "STC12C5620AD.h"
#include "RT12864M.h"
#include "delay.h"
/**************************Custom character encoding****************************/
unsigned char code CGROM_Code[]={0x00,0x00,0x00,0x00,0x7F,0xFE,0x60,0x06,0x33,0xCC,0x19,0x98,0x0C,0x30,0x06,0x60, 0x03,0xC0,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80
, //Antenna graphics
0x00,0x00,0xE0,0x00,0xA0,0x00,0xEE,0x00,0x1B,0x00,0x31,0x00,0x30,0x00,0x30,0x00,
0x30,0x00,0x30,0x00,0x31,0x00,0x1B,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //Celsius graphics
/**********************LCD test is busy****************************/
bit LCD_Test_Busy(void)
{
bit Temp;
LCD_DATAPORT=0xff; //Data port all set first
LCD_RS=0;
LCD_RW=1;
LCD_E=1;
Temp=(bit)(LCD_DATAPORT & 0x80); //Take the highest bit, 1 is busy
LCD_E=0;
return Temp;
}
/*************************LCD write command******************************/
void LCD_Write_CMD(uchar cmd)
{
while(LCD_Test_Busy()); //First check if LCD is busy
LCD_RS=0;
LCD_RW=0;
LCD_E=1;
LCD_DATAPORT=cmd; //Write command
LCD_E=0;
}
/*************************LCD write data**************************/
void LCD_Write_DATA(uchar Inputdata)
{
while(LCD_Test_Busy()); //First check if LCD is busy
LCD_RS=1;
LCD_RW=0;
LCD_E=1;
LCD_DATAPORT=Inputdata; //Write data
LCD_E=0;
}
/************ Write custom characters or graphics to CGRAM *****************/
void LCD_Write_CGRAM(uchar *Char_Code)
{
uchar i;
LCD_Write_CMD(0x34); //Open extended instructions
LCD_Write_CMD(0x02); //SR=0, allow input of CGRAM address
LCD_Write_CMD(0x30); //Restore basic instructions
LCD_Write_CMD(0x40); //CGRAM address
for(i=0;i<32;i++)
{
LCD_Write_DATA(Char_Code[i*2]);
LCD_Write_DATA(Char_Code[i*2+1]);
}
}
/**********************Set operation address**************************/
void LCD_Set_XY(uchar x,uchar y)
{
uchar Address;
switch(x)
{
case 0:
Address = 0x80 + y;
break;
case 1:
Address = 0x90 + y;
break;
case 2:
Address = 0x88 + y;
break;
case 3:
Address = 0x98 + y;
break;
default:
Address = 0x80 + y;
}
LCD_Write_CMD(Address);
}
/*************************Display a CGRAM******************************/
/**************Parameters: row number, column number, CGRAM to be displayed********************/
void LCD_Display_CGRAM(uchar x,uchar y,uchar add1,uchar add2)
{
LCD_Set_XY(x,y); //First determine the display row and column
LCD_Write_DATA(add1);
LCD_Write_DATA(add2);
}
/**************Display a string at X (row) Y (column)********************/
void LCD_Display_String( uchar x,uchar y,uchar *str )
{
LCD_Set_XY(x,y); //First determine the starting row and columnwhile
(*str!='')
{
LCD_Write_DATA(*str);
str++;
}
}
/**************Display value at X (row) Y (column)************************/
void LCD_Display_Value( uchar x,uchar y,uchar val )
{
LCD_Set_XY(x,y); //Determine the starting row and column first
LCD_Write_DATA(val);
}
/**************Display array at X (row) Y (column)************************/
void LCD_Display_Array( uchar x,uchar y,uchar *Array,uchar Lenth )
{
LCD_Set_XY(x,y); //Determine the starting row and column firstwhile
(Lenth--)
{
LCD_Write_DATA(*Array);
Array++;
}
}
/*****************************LCD initialization**************************/
void LCD_Init(void)
{
LCD_RST=0;
Delay_us(10);
LCD_RST=1; //LCD reset
LCD_Write_CMD(0x30); //Function setting (parallel, basic instructions)
LCD_Write_CMD(0x0c); //Overall display, cursor
LCD_Write_CMD(0x01); //Clear screen
LCD_Write_CMD(0x06); //Move cursor right, not overall
LCD_Write_CGRAM(CGROM_Code); //Write custom characters
}
This is a subroutine header file and schematic diagram extracted from a complete project. Please go to http://www.51hei.com/bbs/dpj-19294-1.html to download it.
Previous article:Electronic tag identification system using ZigBee and RFID technology
Next article:State machine mode key scanning microcontroller program
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Who are the talented people who are leading the industry research in various fields of electrical engineering?
- Internals of the BME280 sensor
- Amplifier Circuit
- Static Timing Analysis and Logic
- I would like to ask if there is a PDF of the fourth edition of "The Definitive Guide to Operational Amplifiers"
- I need help from you guys, I need a chip that can boost 5V to 36V, thank you
- [Flower carving DIY] Interesting and fun music visualization series of small projects (15) - horizontal LED square tube lights
- TI - Improving the design of smart speakers
- Electromagnetic Compatibility Design and Testing (4th Edition)
- Software requirements for legally controlling microcontrollers remotely via Android phones