📄 lcddummy.c
字号:
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* 礐/GUI is protected by international copyright laws. Knowledge of the
* source code may not be used to write a similar product. This file may
* only be used in accordance with a license and should not be redistributed
* in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File : LCDDummy.C
Purpose : Empty driver for emWin GSC
This driver does no perform any function, but it can be
used for 2 purposes:
a) Satisfy all externals so an application can be
compiled and linked in target hardware even if the
driver is not already available
b) Template for a starting point for a new driver.
----------------------------------------------------------------------
Adapting to a new system (creating a new driver):
In this case, the first step is to fill the routines
LCD_L0_GetPixelIndex, LCD_L0_SetPixelIndex and LCD_L0_Init with
functionality, which is sufficient to make the hardware work.
A second (optional) step would be to optimize higher level routines.
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
1.00.00 020417 JE a) Changed to have only to adapt _GetPixelIndex
and _SetPixelIndex
0.90.00 020214 JE a) First release
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Private.h" /* private modul definitions & config */
#include "GUI_Private.h"
#include "GUIDebug.h"
#include "LCD_0.h" /* Defines for first display */
#define GBA_REG_DISPCNT (*(volatile unsigned int *)0x04000000) //显示控制寄存器地址
#define GBA_VRAM (*(volatile unsigned int *)0x06000000) //图像缓冲区地址
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
void GBA_LCD_Initialize(void)
{
GBA_REG_DISPCNT = 0x0403;
}
#ifndef LCD_INIT_CONTROLLER
#define LCD_INIT_CONTROLLER() GBA_LCD_Initialize()
#endif
/*********************************************
*
* Draw Bitmap 16 BPP
*
**********************************************
*/
static void DrawBitLine16BPP(int x, int y, U16 const * p, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX pixel;
if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) == 0) {
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
LCD_L0_SetPixelIndex(x, y, *(pTrans + pixel));
}
} else {
for (;xsize > 0; xsize--, x++, p++) {
LCD_L0_SetPixelIndex(x, y, *p);
}
}
} else {
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
if (pixel) {
LCD_L0_SetPixelIndex(x, y, *(pTrans + pixel));
}
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
if (pixel) {
LCD_L0_SetPixelIndex(x, y, pixel);
}
}
}
}
}
/*********************************************
*
* LCD_L0_SetPixelIndex
*
**********************************************
Purpose:
Sets the index of the given pixel. The upper layers of emWin
calling this routine make sure that the coordinates are in range, so
that no check on the parameters needs to be performed.
*/
unsigned int * video_buffer = &GBA_VRAM;
void LCD_L0_SetPixelIndex(int x, int y,int PixelIndex) {
// 设置相应的点
video_buffer[y*240 + x] = PixelIndex;
}
/*********************************************
*
* LCD_L0_GetPixelIndex
*
**********************************************
Purpose:
Returns the index of the given pixel. The upper layers of emWin
calling this routine make sure that the coordinates are in range, so
that no check on the parameters needs to be performed.
*/
unsigned int LCD_L0_GetPixelIndex(int x, int y) {
return video_buffer[y*240 + x];
}
/*********************************************
*
* LCD_L0_XorPixel
*
**********************************************
*/
void LCD_L0_XorPixel(int x, int y) {
LCD_PIXELINDEX PixelIndex = LCD_L0_GetPixelIndex(x, y);
LCD_L0_SetPixelIndex(x, y, LCD_NUM_COLORS - PixelIndex - 1);
}
/*********************************************
*
* LCD_L0_DrawHLine
*
**********************************************
*/
void LCD_L0_DrawHLine (int x0, int y, int x1) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
for (; x0 <= x1; x0++) {
LCD_L0_XorPixel(x0, y);
}
} else {
for (; x0 <= x1; x0++) {
LCD_L0_SetPixelIndex(x0, y, LCD_COLORINDEX);
}
}
}
/*********************************************
*
* LCD_L0_DrawVLine
*
**********************************************
*/
void LCD_L0_DrawVLine (int x, int y0, int y1) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
for (; y0 <= y1; y0++) {
LCD_L0_XorPixel(x, y0);
}
} else {
for (; y0 <= y1; y0++) {
LCD_L0_SetPixelIndex(x, y0, LCD_COLORINDEX);
}
}
}
/*********************************************
*
* LCD_L0_FillRect
*
**********************************************
*/
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
}
/*********************************************
*
* LCD_L0_DrawBitmap
*
**********************************************
*/
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)
{
int i;
/* Use _DrawBitLineXBPP */
for (i=0; i<ysize; i++) {
DrawBitLine16BPP(x0, i + y0, (const U16 *)pData, xsize, pTrans);
pData += BytesPerLine;
}
}
/*********************************************
*
* LCD_L0_SetOrg
*
**********************************************
*/
/*
void LCD_L0_SetOrg(int x, int y) {
GUI_USE_PARA(x);
GUI_USE_PARA(y);
}*/
int OrgX, OrgY;
void LCD_L0_SetOrg(int x, int y) {
OrgX = x;
OrgY = y;
}
/*********************************************
*
* LCD_On / LCD_Off
*
**********************************************
*/
void LCD_On (void) {
#ifdef LCD_ON
LCD_ON();
#endif
}
void LCD_Off (void) {
#ifdef LCD_OFF
LCD_OFF();
#endif
}
/*********************************************
*
* LCD_L0_Init
*
**********************************************
Purpose:
Initialises the LCD-controller.
*/
int LCD_L0_Init(void) {
LCD_INIT_CONTROLLER();
return 0;
}
/*********************************************
*
* LCD_L0_SetLUTEntry
*
**********************************************
*/
/*
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR Color) {
GUI_USE_PARA(Pos);
GUI_USE_PARA(Color);
}*/
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR Color) {
Pos = Pos;
Color = Color;
}
/* (LCD_CONTROLLER undefined) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -