⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glcd.h

📁 PIC KS0108 圖型液晶驅動C源碼
💻 H
字号:
//==============================================================================
// DEVICE       = PICC-18
// VERSION      = 1.0
// DATE         = 11.08.2007
// LAST CHANGE  = -
// Developer    = Keith Yuen
// =============================================================================
// Description:  KS0108 GLCD Driver
// =============================================================================

/***NOTE: Please init all ports before use*/

#ifndef __GLCD_H
#define __GLCD_H

#include "font5x6.h"
#include "font6x8.h"


/****************************************************************
* SETTINGS
****************************************************************/

//FREQUENCY:
#define DELAY_48MHZ
//#define DELAY_24MHZ
//#define DELAY_20MHZ
//#define DELAY_12MHZ
//#define DELAY_8MHZ
//#define DELAY_4MHZ


//COLOR INVERT:
//#define GLCD_INVERT


/****************************************************************
* LCD MODULE - DEFINE PINS
****************************************************************/
#define GLCD_PIN_DATA PORTD
#define GLCD_PIN_DATA_TRIS TRISD
#define GLCD_PIN_CS	  PORTB
#define GLCD_CS_A_MASK	0x01
#define GLCD_CS_B_MASK	0x02
#define GLCD_CS_BOTH_MASK	0x03
#define GLCD_PIN_RS   RC1
#define GLCD_PIN_RW   RC2
#define GLCD_PIN_EN   RC7
#define GLCD_PIN_RST  RC6

/****************************************************************
* LCD MODULE - DEFINE INSTRUCTION
****************************************************************/
#define GLCD_DATA 1
#define GLCD_CMD  0
#define GLCD_READ 1
#define GLCD_WRITE 0
#define GLCD_ENABLE 1
#define GLCD_DISABLE 0
#define GLCD_RST	0
#define GLCD_NOT_RST 1


/****************************************************************
* DEFINE CONST 
****************************************************************/
#define GLCD_DISPLAY_ON 1
#define GLCD_DISPLAY_OFF 0

#define GLCD_BUSY 		1
#define GLCD_NOT_BUSY 	0

//ALIGNMENT
#define GLCD_ALIGN_LEFT		0
#define GLCD_ALIGN_RIGHT	1
#define GLCD_ALIGN_CENTER	2

//FONT SIZE

//#define GLCD_FONT_5x6
#define GLCD_FONT_6x8

#ifdef GLCD_FONT_5x6
	#define GLCD_FONT_WIDTH FONT5x6_WIDTH
	#define GLCD_GetCharPos(index) 	FONT5x6_charPos[index]
	#define GLCD_GetCharData(ch) 	FONT5x6_GetCharData(ch);
#elif defined(GLCD_FONT_6x8)
	#define GLCD_FONT_WIDTH FONT6x8_WIDTH
	#define GLCD_GetCharPos(index) 	FONT6x8_charPos[index]
	#define GLCD_GetCharData(ch) 	FONT6x8_GetCharData(ch);
#endif


/****************************************************************
* DEFINE LCD DISPLAY MODULE SPEC
****************************************************************/
#define GLCD_FULL_WIDTH		128
#define GLCD_HALF_WIDTH		64
#define GLCD_HALF_HEIGHT	64

#define GLCD_NO_OF_CHARS	GLCD_FULL_WIDTH / GLCD_FONT_WIDTH




/****************************************************************
* PUBLIC FUNCTIONS
****************************************************************/

///////////////////////////////////////////////////
//Low Level Functions

//Init the LCD
void GLCD_Init(void);
//Set font size
void GLCD_SetFontSize(unsigned char sizeIndex);
//Clear the LCD
void GLCD_Clear(void);
//Turn on/off the LCD
void GLCD_SetDisplayOn(unsigned char onOff);
//Set LCD startline
void GLCD_SetStartLine(unsigned char startLine);
//Set cursor position
void GLCD_SetPos(unsigned char line, unsigned char pos);
//Write data to LCD
void GLCD_WriteData(unsigned char cData);


///////////////////////////////////////////////////
//High Level Basic functions

//Combine data with the data in LCD (OR data)
void GLCD_WriteCombineData(unsigned char cData);
//Write a character on the current position
void GLCD_WriteChar(unsigned char ch);
//Write a character without space on the current position
void GLCD_WritePackedChar(unsigned char ch);
//Write a string to the specified line and position
void GLCD_WriteString(const unsigned char *strPtr, unsigned char line, unsigned char startPos);
//Write a string with alignment
//align: GLCD_FULL_WIDTH, GLCD_HALF_WIDTH, GLCD_HALF_HEIGHT
void GLCD_WriteAlignString(const unsigned char *strPtr, unsigned char line, unsigned char align);

///////////////////////////////////////////////////
//Special functions

//Write a unsigned char in 2 digit decimal representation,  on the current position
void GLCD_WriteDec2(unsigned char num);
//Write a unsigned int in 3 digit decimal representation,  on the current position
void GLCD_WriteDec3(unsigned int num);
//Write a 4-bits unsigned char in 1 digit hex representation,  on the current position
void GLCD_Write4Bits(unsigned char num);
//Write a 8-bits unsigned char in 1 digit hex representation,  on the current position
void GLCD_WriteHex(unsigned char num);
//Write a dot on the x,y position
void GLCD_WriteDot(unsigned char x, unsigned char y);
//Write a dot on the x,y position (combine)
void GLCD_WriteDotCombine(unsigned char x, unsigned char y);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -