?? lcd_tft6448.c
字號:
/*********************************************************************
;;;
;;; 模 塊 名:LCD_TFT6448.C
;;; 功 能:LCD控制器驅動,用于支持uC_GUI
;;; 參數說明:
;;; 設 計:XiShouJun 日 期:2006-02-27
;;; 修 改: 日 期:
**********************************************************************/
#include "LCD_Private.h" /* private modul definitions & config */
#include "GUI_Private.h"
#include "GUIDebug.h"
#include "LCDConf.H"
#include "gpio.h"
#include "sleep.h"
#include "lcd_fonts.h"
#ifndef LCDCONF_H
#define LCDCONF_H
#endif
#define TRUE 1
#define FALSE 0
//#if (LCD_CONTROLLER == 0 ) && (!defined(WIN32) | defined(LCD_SIMCONTROLLER))
#define LCD_ADD_WR_CMD(color) *((volatile U16 *)0x64000000) = (color)
#define LCD_ADD_WR_X(xdata) *((volatile U16 *)0x64000002) = (xdata)
#define LCD_ADD_WR_Y(ydata) *((volatile U16 *)0x64000004) = (ydata)
#define LCD_ADD_WR_RX(xdata) *((volatile U16 *)0x64000006) = (xdata)
#define LCD_ADD_RD_CMD(color) (U8)(color=*((volatile U16 *)0x64000000))
#define LCD_ADD_RD_X(xdata) (U8)(xdata=*((volatile U16 *)0x64000002))
//初始化及顯示控制組
int LCD_L0_Init(void);
void LCD_L0_ReInit(void);
void LCD_L0_Off(void);
void LCD_L0_On(void);
//繪制組
void LCD_L0_DrawBitmap(int x0, int y0,
int xsize, int ysize,
int BitsPerPixel,
int BytesPerLine,
const U8* pData, int Diff,
const LCD_PIXELINDEX* pTrans);
void LCD_L0_DrawHLine(int x0,int y,int x1);
void LCD_L0_DrawPixel(int x,int y);
void LCD_L0_DrawVLine (int x, int y0, int y1); //上層調用的畫豎線函數
void LCD_L0_FillRect(int x0, int y0, int x1, int y1); //上層調用的畫矩型函數
void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex); //上層調用的畫點函數
void LCD_L0_XorPixel(int x, int y); //上層調用的異或函數
//get組
unsigned int LCD_L0_GetPixelIndex(int x, int y); //上層調用的取點函數
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color);
/*
*********************************************************
* *
* Compiler specific settings *
* *
*********************************************************
*/
#ifdef WIN32 /* Avoid warnings in MS-compiler */
#pragma warning(disable : 4244) // warning C4244: '=' : conversion from 'long ' to 'unsigned char ', possible loss of data
#pragma warning(disable : 4761) // warning C4761: integral size mismatch in argument; conversion supplied
#endif
//*********************************************************************
//#define TFT640x480
void SetPixel(int x, int y, LCD_COLOR c){
UWORD8 busy= GPIO_ReadBit(1, 15);
if(!busy)
{
if((x < LCD_XSIZE) && (y < LCD_YSIZE))
{
LCD_ADD_WR_Y((y<<8));
ms_sleep(50);
LCD_ADD_WR_Y(y);
ms_sleep(50);
LCD_ADD_WR_X((x<<8));
ms_sleep(50);
LCD_ADD_WR_X(x);
ms_sleep(50);
LCD_ADD_WR_CMD(c);
ms_sleep(50);
}
}
}
unsigned int GetPixelIndex(int x,int y){
volatile UINT16 Colortemp=0;
UWORD8 busy= GPIO_ReadBit(1, 15);
if(!busy){
if((x < LCD_XSIZE) && (y < LCD_YSIZE))
{
LCD_ADD_WR_Y((y<<8));
ms_sleep(50);
LCD_ADD_WR_Y(y);
ms_sleep(50);
LCD_ADD_WR_RX((x<<8));
ms_sleep(50);
LCD_ADD_WR_RX(x);
ms_sleep(50);
LCD_ADD_RD_CMD(Colortemp);
ms_sleep(50);
}
}
return Colortemp;
}
void XorPixel(int x,int y){
volatile UINT16 Colortemp=0;
Colortemp=(UINT16)GetPixelIndex(x,y);
Colortemp=0x00ff-Colortemp-1;
SetPixel(x,y,Colortemp);
}
/*********************************************************************
;;;
;;; 函 數 名:LCD_L0_DrawPixel
;;; 功 能:將屏幕上指定的點設置成指定的顏色
;;; 說 明:
;;; 入口參數:
;;; 出口參數:
;;; 設 計:Zhanghua 日 期:2007-06-22
;;; 修 改: 日 期:
**********************************************************************/
void LCD_L0_DrawPixel(int x,int y){
SetPixel(x,y,LCD_COLORINDEX);
}
/*********************************************************************
;;;
;;; 函 數 名:LCD_L0_XorPixel/LCD_L0_SetPixelIndex
;;; 功 能:由ewin調用
;;; 說 明:
;;; 入口參數:
;;; 出口參數:
;;; 設 計:Zhanghua 日 期:2006-02-27
;;; 修 改: 日 期:
**********************************************************************/
void LCD_L0_XorPixel(int x, int y){
XorPixel(x,y);
}
void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) {
SetPixel(x,y,(LCD_COLOR)ColorIndex);
}
/*********************************************************************
;;;
;;; 函 數 名:LCD_L0_DrawHLine
;;; 功 能:畫水平線
;;; 說 明:
;;; 入口參數:
;;; 出口參數:
;;; 設 計:Zhanghua 日 期:2006-02-27
;;; 修 改: 日 期:
**********************************************************************/
void LCD_L0_DrawHLine(int x0, int y, int x1)
{
if(GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
{
for (; x0 <= x1; x0++) {
XorPixel(x0, y);
}
} else {
for (; x0 <= x1; x0++) {
SetPixel(x0, y, LCD_COLORINDEX);
}
}
}
/*********************************************************************
;;;
;;; 函 數 名: LCD_L0_DrawVLine
;;; 功 能:畫垂直線
;;; 說 明:
;;; 入口參數:
;;; 出口參數:
;;; 設 計:Zhanghua 日 期:2006-02-27
;;; 修 改: 日 期:
**********************************************************************/
void LCD_L0_DrawVLine (int x, int y0, int y1) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
for (; y0 <= y1; y0++) {
XorPixel(x, y0);
}
} else {
for (; y0 <= y1; y0++) {
SetPixel(x, y0, LCD_COLORINDEX);
}
}
}
/*********************************************************************
;;;
;;; 函 數 名:LCD_L0_FillRect
;;; 功 能:填充一個矩形區域
;;; 說 明:
;;; 入口參數:
;;; 出口參數:
;;; 設 計:Zhanghua 日 期:2006-02-27
;;; 修 改: 日 期:
**********************************************************************/
void LCD_L0_FillRect(int x0, int y0, int x1, int y1)
{
#if !LCD_SWAP_XY
for (; y0 <= y1; y0++)
{
LCD_L0_DrawHLine(x0,y0,x1);
}
#else
for (; x0 <= x1; x0++)
{
LCD_L0_DrawVLine(x0,y0,y1);
}
#endif
}
/*********************************************************************
;;;
;;; 函 數 名:DrawBitLine1BPP
;;; 功 能:畫1bit位圖
;;; 說 明:
;;; 入口參數:
;;; 出口參數:
;;; 設 計:Zhanghua 日 期:2006-02-27
;;; 修 改: 日 期:
**********************************************************************/
static void DrawBitLine1BPP(int x, int y, U8 const *p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
LCD_PIXELINDEX Index0 = *(pTrans+0);
LCD_PIXELINDEX Index1 = *(pTrans+1);
x += Diff;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
do {
LCD_L0_SetPixelIndex(x++, y, (*p & (0x80 >> Diff)) ? Index1 : Index0);
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do {
if (*p & (0x80 >> Diff))
LCD_L0_SetPixelIndex(x, y, Index1);
x++;
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
case LCD_DRAWMODE_XOR:;
do {
if (*p & (0x80 >> Diff)) {
int Pixel = LCD_L0_GetPixelIndex(x, y);
LCD_L0_SetPixelIndex(x, y, LCD_NUM_COLORS - 1 - Pixel);
}
x++;
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
}
}
/*********************************************************************
;;;
;;; 函 數 名:DrawBitLine2BPP
;;; 功 能:畫2bit位圖
;;; 說 明:
;;; 入口參數:
;;; 出口參數:
;;; 設 計:Zhanghua 日 期:2006-02-27
;;; 修 改: 日 期:
**********************************************************************/
#if (LCD_MAX_LOG_COLORS > 2)
static void DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
LCD_PIXELINDEX pixels;
/*
// Jump to right entry point
*/
pixels = *p;
if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) switch (Diff&3) {
case 0:
goto WriteTBit0;
case 1:
goto WriteTBit1;
case 2:
goto WriteTBit2;
default:
goto WriteTBit3;
} else switch (Diff&3) {
case 0:
goto WriteBit0;
case 1:
goto WriteBit1;
case 2:
goto WriteBit2;
default:
goto WriteBit3;
}
/*
Write without transparency
*/
WriteBit0:
LCD_L0_SetPixelIndex(x+0, y, *(pTrans+(pixels>>6)));
if (!--xsize)
return;
WriteBit1:
LCD_L0_SetPixelIndex(x+1, y, *(pTrans+(3&(pixels>>4))));
if (!--xsize)
return;
WriteBit2:
LCD_L0_SetPixelIndex(x+2, y, *(pTrans+(3&(pixels>>2))));
if (!--xsize)
return;
WriteBit3:
LCD_L0_SetPixelIndex(x+3, y, *(pTrans+(3&(pixels))));
if (!--xsize)
return;
pixels = *(++p);
x+=4;
goto WriteBit0;
/*
Write with transparency
*/
WriteTBit0:
if (pixels&(3<<6))
LCD_L0_SetPixelIndex(x+0, y, *(pTrans+(pixels>>6)));
if (!--xsize)
return;
WriteTBit1:
if (pixels&(3<<4))
LCD_L0_SetPixelIndex(x+1, y, *(pTrans+(3&(pixels>>4))));
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -