CH552/projects/LCD/usr/LCD.h

113 lines
3.4 KiB
C
Raw Normal View History

2018-10-17 05:37:36 +02:00
#ifndef __LCD_H
#define __LCD_H
#include "CH554.h"
#include "common.h"
//#include "sys.h"
#define u8 unsigned char
#define u16 unsigned int
#define u32 unsigned long
/******************************************************
GND=GND
VCC=3.3V
P00=CLK
P01=MOSI
P02=RES
P03=DC
P04=CS1
BLKΪLCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹܽţ<EFBFBD><EFBFBD>͵<EFBFBD>ƽ<EFBFBD>رձ<EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ƽ<EFBFBD>򿪣<EFBFBD>Ĭ<EFBFBD>Ͽ<EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD>Ӵ򿪱<EFBFBD><EFBFBD><EFBFBD>
////////////////////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD<43><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>/////////////////////////////////////
P05=FSO
P06=CS2
******************************************************/
//<2F><><EFBFBD><EFBFBD>LCD<43>ijߴ<C4B3>
#define LCD_W 128
#define LCD_H 160
sbit LCD_CS1 =P1^4; //Ƭѡ
sbit LCD_DC =P1^3; //<2F><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>
sbit LCD_SDI =P1^1; //<2F><><EFBFBD><EFBFBD>
sbit LCD_SCK =P1^0; //ʱ<><CAB1>
//sbit LCD_REST =P0^2; //<2F><>λ
sbit LCD_REST =P1^5; //<2F><>λ
sbit ZK_MISO =P1^7; //ʱ<><CAB1>
sbit ZK_CS2 =P1^6; //<2F><>λ
extern u16 BACK_COLOR, POINT_COLOR; //<2F><><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
void Lcd_Init(void);
void LCD_Clear(u16 Color);
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);
void LCD_WR_DATA8(char da); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-8λ<38><CEBB><EFBFBD><EFBFBD>
void LCD_WR_DATA(int da);
void LCD_WR_REG(char da);
void LCD_DrawPoint(u16 x,u16 y);//<2F><><EFBFBD><EFBFBD>
void LCD_DrawPoint_big(u16 x,u16 y);//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
u16 LCD_ReadPoint(u16 x,u16 y); //<2F><><EFBFBD><EFBFBD>
void Draw_Circle(u16 x0,u16 y0,u8 r);
void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2);
void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2);
void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
void LCD_ShowChar(u16 x,u16 y,u8 num,u8 mode);//<2F><>ʾһ<CABE><D2BB><EFBFBD>ַ<EFBFBD>
void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len);//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void LCD_Show2Num(u16 x,u16 y,u16 num,u8 len);//<2F><>ʾ2<CABE><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void LCD_ShowString(u16 x,u16 y,const u8 *p); //<2F><>ʾһ<CABE><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>,16<31><36><EFBFBD><EFBFBD>
void showhanzi(unsigned int x,unsigned int y,unsigned char index);
void CL_Mem(void);
void GBZK_ROMOUTSET(void); //<2F>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void GBZK_ROMOUTRESET(void); //<2F>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void GBZK_GPIO_Config(void); //<2F>ֿ<EFBFBD>оƬ<D0BE><C6AC>ʼ<EFBFBD><CABC>
void ZK_command( unsigned char dat );
unsigned char get_data_from_ROM(void);
void get_n_bytes_data_from_ROM(unsigned char AddrHigh,unsigned char AddrMid,unsigned char AddrLow,unsigned char *pBuff,unsigned char DataLen );
void Display_Asc_String(unsigned char zk_num,unsigned int x, unsigned int y, unsigned char text[]);
void Display_Asc( unsigned char zk_num,unsigned int x, unsigned int y );
void zk_map( unsigned char *getdate, unsigned char *putdata, unsigned char high, unsigned char width);
void Display_GB2312_String(unsigned char zk_num,unsigned int x,unsigned int y, unsigned char text[]);
void Display_GB2312( unsigned char zk_num,unsigned int x, unsigned int y );
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40 //<2F><>ɫ
#define BRRED 0XFC07 //<2F>غ<EFBFBD>ɫ
#define GRAY 0X8430 //<2F><>ɫ
//GUI<55><49>ɫ
#define DARKBLUE 0X01CF //<2F><><EFBFBD><EFBFBD>ɫ
#define LIGHTBLUE 0X7D7C //dz<><C7B3>ɫ
#define GRAYBLUE 0X5458 //<2F><><EFBFBD><EFBFBD>ɫ
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫΪPANEL<45><4C><EFBFBD><EFBFBD>ɫ
#define LIGHTGREEN 0X841F //dz<><C7B3>ɫ
#define LGRAY 0XC618 //dz<><C7B3>ɫ(PANNEL),<2C><><EFBFBD><EFBFBD><E5B1B3>ɫ
#define LGRAYBLUE 0XA651 //dz<><C7B3><EFBFBD><EFBFBD>ɫ(<28>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD>ɫ)
#define LBBLUE 0X2B12 //dz<><C7B3><EFBFBD><EFBFBD>ɫ(ѡ<><D1A1><EFBFBD><EFBFBD>Ŀ<EFBFBD>ķ<EFBFBD>ɫ)
#endif