📄 drv_lcd.c
字号:
/************************************************************************
* *
* Copyright (C) SEIKO EPSON CORP. 2002 *
* *
* File name: Drv_LCD.c *
* This is L1F10043T00 LCD module driver. *
* *
* *
* Revision history *
* 2002-5-28 Andrew Yin Start. *
* *
************************************************************************/
/*----------------------------------------------------------------------------------------
This program define L1F10043T00:
Text & Graphic mode:
Total pages: 160 ( page 0: up side to page 159: down side)
Columns in each page: 120 ( Column 0: left side to Column 119: right side)
Bits in each column: 16 bits ( R:D15~D12 G: D11~D8 B: D7~D4 )
Dot Matrix mode:
Total resolution:
X: 120 dots; Y: 160 dots
(0,0) left-up corner to (119,159) right-down corner
-----------------------------------------------------------------------------------------*/
#include "common.h"
#include "io.h"
#include "bcu.h"
#include "int.h"
#include "8timer.h"
#include "16timer.h"
#include "ad.h"
#include "osc.h"
#include "presc.h"
#include "math.h"
//LCD Port Address
#define LCD_COMMAND 0x0400000
#define LCD_DATA 0x0400002
extern unsigned short data;
extern const unsigned short ucpImage[];
void vInitLCD( void ); // LCD initial
void vLCDBacklightOn( void ); // LCD backlight on
void vLCDBacklightOff( void ); // LCD backlight off
void vLCDDisplayOn( void ); // Display ON
void vLCDDisplayOff(void); // Display OFF
void vLCDDrawRctngl( unsigned char ucX1, unsigned char ucX2, unsigned char ucY1,
unsigned char ucY2, unsigned short *uspImage ); //display a rectangle
void vLCDDrawHrzntlLine( unsigned char ucY, unsigned char ucStartPoint,
unsigned char ucLength, unsigned short usColor ); //display a horizontal pure color line
void vLCDDrawVrtclLine( unsigned char ucX, unsigned char ucStartPoint,
unsigned char ucLength, unsigned short usColor ); //display a vertical pure color line
void vLCDDrawOneDot( unsigned char ucX, unsigned char ucY,
unsigned short usColor ); //display a dot
void vLCDDrawPureColor( unsigned short color ); //display pure color on LCD
void vLCDClr( void ); //display with white color
void display( unsigned short data, unsigned short n ); // Display data
void vDrawImage( unsigned short* ucpImage); // Display image
void vDisplayDownloadImage( unsigned char ucX1, unsigned char ucX2, unsigned char ucY1,
unsigned char ucY2, unsigned short *uspImage ); // Display Download image
/***********************************************************************************************
* vInitLCD
* Type : void
* Ret val : none
* Argument : void
* Function : LCD initial routine
***********************************************************************************************/
void vInitLCD( void )
{
*(volatile unsigned char *)LCD_COMMAND = 0x0CA; // Display Control
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x0c; // divid ratio: not divid,driving pattern
*(volatile unsigned char *)LCD_DATA = 0x28; // Duty=1/164
*(volatile unsigned char *)LCD_DATA = 0x0b; // 12H-inversion
*(volatile unsigned char *)LCD_COMMAND = 0x0bb; // Common scan direction
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x02;
*(volatile unsigned char *)LCD_COMMAND = 0x0d1; // Oscillation On
*(volatile unsigned char *)LCD_COMMAND = 0x75; // Page Address Set
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x00;
*(volatile unsigned char *)LCD_DATA = 0x9f;
*(volatile unsigned char *)LCD_COMMAND = 0x15; // Column Address Set
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x00; //0x06; for 45T
*(volatile unsigned char *)LCD_DATA = 0x77; //0x77 + 0x06; for 45T
*(volatile unsigned char *)LCD_COMMAND = 0xbc; // Data Control
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x02; //
*(volatile unsigned char *)LCD_DATA = 0x01; //
*(volatile unsigned char *)LCD_DATA = 0x02; //TYPEa-0x02;TYPEb-0x04
*(volatile unsigned char *)LCD_COMMAND = 0x0be; // Datall Cancel
*(volatile unsigned char *)LCD_COMMAND = 0x0A7; // Display Normal a6/ Revers a7
*(volatile unsigned char *)LCD_COMMAND = 0x94; // Sleep In / Out
*(volatile unsigned char *)LCD_COMMAND = 0x20; // Power Control
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x0f;
*(volatile unsigned char *)LCD_COMMAND = 0x81; // Volume Control
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x2a; //2e;
*(volatile unsigned char *)LCD_DATA = 0x03;
*(volatile unsigned char *)LCD_COMMAND = 0xAf; // Display On / Off
vLCDBacklightOn( );
}
/*****************************************************************************************************
* vLCDDrawOneDot
* Type : void
* Ret val : none
* Argument : unsigned char ucX: ucX ( 0 ~ 119 )
* unsigned char ucY: ucY ( 0 ~ 159 )
* unsigned short usColor: ucColor ( 0x0000 ~ 0x0fff0 )
* Function : refresh one dot of the LCD Module
*****************************************************************************************************/
void vLCDDrawOneDot( unsigned char ucX, unsigned char ucY, unsigned short usColor )
{
*(volatile unsigned char *)LCD_COMMAND = 0x75; // Page Address Set
asm("nop");
*(volatile unsigned char *)LCD_DATA = ucY;
*(volatile unsigned char *)LCD_DATA = ucY;
*(volatile unsigned char *)LCD_COMMAND = 0x15; // Column Address Set
asm("nop");
*(volatile unsigned char *)LCD_DATA = ucX;
*(volatile unsigned char *)LCD_DATA = ucX;
*(volatile unsigned char *)LCD_COMMAND = 0x5C;
asm("nop");
*( volatile unsigned short * )LCD_DATA = usColor;
*(volatile unsigned char *)LCD_COMMAND = 0x25; // NOP command
}
/*****************************************************************************************************************
* vLCDDrawHrzntlLine
* Type : void
* Ret val : none
* Argument : unsigned char ucY: The Y axis of the horizontal line, and the range of ucY is 0 ~ 159
* unsigned char ucStartPoint: The start point of the horizontal line, range is 0 ~ 119
* unsigned char ucLength: The length of the horizontal line, range is 0 ~ 119
* unsigned short usColor: ucColor ( 0x0000 ~ 0x0fff0 )
* Function : refresh one horizontal pure color line of the LCD Module
*****************************************************************************************************************/
void vLCDDrawHrzntlLine( unsigned char ucY, unsigned char ucStartPoint, unsigned char ucLength, unsigned short usColor )
{
unsigned char width;
*(volatile unsigned char *)LCD_COMMAND = 0x75; // Page Address Set
asm("nop");
*(volatile unsigned char *)LCD_DATA = ucY;
*(volatile unsigned char *)LCD_DATA = 0x9F;
*(volatile unsigned char *)LCD_COMMAND = 0x15; // Column Address Set
asm("nop");
*(volatile unsigned char *)LCD_DATA = ucStartPoint;
*(volatile unsigned char *)LCD_DATA = 0x77;
*(volatile unsigned char *)LCD_COMMAND = 0x5C;
for ( width = 0; width <= ucLength; width++ )
*( volatile unsigned short * )LCD_DATA = usColor;
*(volatile unsigned char *)LCD_COMMAND = 0x25; //NOP> command
}
/*****************************************************************************************************
* vLCDDrawVrtclLine
* Type : void
* Ret val : none
* Argument : unsigned char ucX: ucX ( 0 ~ 119 )
* unsigned char ucStartPoint: The start point of the vertical line, range is 0 ~ 159
* unsigned char ucLength: The length of the vertical line, range is 0 ~ 159
* unsigned short usColor: ucColor ( 0x0000 ~ 0x0fff0 )
* Function : refresh one vertical pure color line of the LCD Module
*****************************************************************************************************/
void vLCDDrawVrtclLine( unsigned char ucX, unsigned char ucStartPoint, unsigned char ucLength, unsigned short usColor )
{
unsigned char height;
*(volatile unsigned char *)LCD_COMMAND = 0xbc; // Data Control
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x06; //
*(volatile unsigned char *)LCD_DATA = 0x01; //
*(volatile unsigned char *)LCD_DATA = 0x02; //TYPEa-0x02;TYPEb-0x04
*(volatile unsigned char *)LCD_COMMAND = 0x75; // Page Address Set
asm("nop");
*(volatile unsigned char *)LCD_DATA = ucStartPoint;
*(volatile unsigned char *)LCD_DATA = 0x9F;
*(volatile unsigned char *)LCD_COMMAND = 0x15; // Column Address Set
asm("nop");
*(volatile unsigned char *)LCD_DATA = ucX;
*(volatile unsigned char *)LCD_DATA = 0x77;
*(volatile unsigned char *)LCD_COMMAND = 0x5C;
for ( height = ucStartPoint; height <= ucLength + ucStartPoint; height++ )
*( volatile unsigned short * )LCD_DATA = usColor;
*(volatile unsigned char *)LCD_COMMAND = 0x25; //NOP> command
*(volatile unsigned char *)LCD_COMMAND = 0xbc; // Data Control
asm("nop");
*(volatile unsigned char *)LCD_DATA = 0x02; //
*(volatile unsigned char *)LCD_DATA = 0x01; //
*(volatile unsigned char *)LCD_DATA = 0x02; //TYPEa-0x02;TYPEb-0x04
}
/*****************************************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -