📄 sdk7a404_emwin.c
字号:
/***********************************************************************
* $Workfile: sdk7a404_emwin.c $
* $Revision: 1.1 $
* $Author: WellsK $
* $Date: Oct 28 2003 11:50:50 $
*
* Project: Segger emWin LCD controller driver (8- and 16-bit support)
*
* Notes:
* This driver uses the generic Segger driver as it's reference
* and uses some functions from that driver. Some functions in this
* driver have been slightly changed to improve rendering
* performance.
*
* Revision History:
* $Log: //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a404/bsps/sdk7a404/ports/Segger/emwin/sdk7a404_emwin.c-arc $
*
* Rev 1.1 Oct 28 2003 11:50:50 WellsK
* Updated to common LCD driver format.
*
* Rev 1.0 Oct 27 2003 10:32:42 WellsK
* Initial revision.
*
*
***********************************************************************
* SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
* OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
* AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES,
* SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
*
* SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY
* FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A
* SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
* FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
*
* COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
* CAMAS, WA
**********************************************************************/
#include "LCD_Private.h"
#include "GUI_Private.h"
#include "GUIDebug.h"
#include "LCD_0.h"
#undef LCD_XSIZE
#undef LCD_YSIZE
#include "abl_arm922t_cp15_driver.h"
#include "lh7a404_gpio_driver.h"
#include "sdk7a404_cpld_driver.h"
#include "lh7a404_clcdc_driver.h"
/***********************************************************************
* These switches are presently unsupported. Enabling one of these
* switches will generate an error during compilation.
**********************************************************************/
#if LCD_MIRROR_X > 0
#error X mirroring is not supported, disable LCD_MIRROR_X in LCDConf.h
#endif
#if LCD_MIRROR_Y > 0
#error Y mirroring is not supported, disable LCD_MIRROR_Y in LCDConf.h
#endif
#if LCD_SWAP_XY > 0
#error Swapping is not supported, disable LCD_SWAP_XY in LCDConf.h
#endif
#if LCD_REVERSE > 0
#error LCD reverse is not supported, disable LCD_REVERSE in LCDConf.h
#endif
#if LCD_BITSPERPIXEL <= 8
#error Only 16-bit per pixel color mode is presently supported
#endif
/***********************************************************************
* Local driver defines and data
**********************************************************************/
/* Color size based on bits per pixel */
#if LCD_BITSPERPIXEL == 16
typedef UNS_16 CMEM_TYPE;
#else
typedef UNS_8 CMEM_TYPE;
#endif
/* If the following define is enabled, the video frame buffer will be
created as a data object in memory. If the define is not enabled,
the VBUF_ADDR macro defines the location of the frame buffer . */
//#define STATIC_VBUF
/* Virtual address of frame buffer when STATIC_VBUF is not defined */
#define VBUF_ADDR 0xC1C00000
/* Logical address of frame buffer */
static CMEM_TYPE *vlogbuf;
/* Static frame buffer data object */
#ifdef STATIC_VBUF
static CMEM_TYPE fbuffer[LOCAL_LCD_XSIZE][LOCAL_LCD_YSIZE];
#endif
/* LCD device handle */
static INT_32 lcddev;
/***********************************************************************
*
* Function: _DrawBitLine1BPP
*
* Purpose: 1-bit bitmap rendering function
*
* Processing:
* See function.
*
* Parameters:
* x: Left edge of location to place bitmap
* y: Vertical location to place bitmap
* p: Pointer to pixel data
* Diff: Left side pixel skip difference
* xsize: Number of pixels to display
* pTrans: Pointer to transparency
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
static void _DrawBitLine1BPP (int x,
int y,
U8 const *p,
int Diff,
int xsize,
const LCD_PIXELINDEX *pTrans)
{
CMEM_TYPE *vbuf;
/* Precompute frame buffer vertical address to save some time */
vbuf = vlogbuf + (y * LOCAL_LCD_XSIZE);
x += Diff;
switch (GUI_Context.DrawMode &
(LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR))
{
case 0:
do
{
LCD_L0_SetPixelIndex
(x++, y, (*p & (0x80 >> Diff)) ?
*(pTrans + 1) : *pTrans);
Diff++;
if (Diff == 8)
{
Diff = 0;
p++;
}
}
while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do
{
if ((*p & (0x80 >> Diff)) != 0)
{
*(vbuf + x) = (CMEM_TYPE) *(pTrans + 1);
}
x++;
Diff++;
if (Diff == 8)
{
Diff = 0;
p++;
}
}
while (--xsize);
break;
case LCD_DRAWMODE_XOR:
do
{
if ((*p & (0x80 >> Diff)) != 0)
{
*(vbuf + x) = (CMEM_TYPE) (LCD_NUM_COLORS - 1 -
(int) *(vbuf + x));
}
x++;
Diff++;
if (Diff == 8)
{
Diff = 0;
p++;
}
}
while (--xsize);
break;
}
}
#if LCD_MAX_LOG_COLORS > 2
/***********************************************************************
*
* Function: _DrawBitLine2BPP
*
* Purpose: 2-bit bitmap rendering function
*
* Processing:
* See function.
*
* Parameters:
* x: Left edge of location to place bitmap
* y: Vertical location to place bitmap
* p: Pointer to pixel data
* Diff: Left side pixel skip difference
* xsize: Number of pixels to display
* pTrans: Pointer to transparency
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
static void _DrawBitLine2BPP (int x,
int y,
U8 const *p,
int Diff,
int xsize,
const LCD_PIXELINDEX *pTrans)
{
CMEM_TYPE *vbuf;
int Shift, Index;
/* Precompute frame buffer vertical address to save some time */
vbuf = vlogbuf + (y * LOCAL_LCD_XSIZE);
x = x + Diff;
switch (GUI_Context.DrawMode &
(LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR))
{
case 0:
do
{
Shift = (3 - Diff) << 1;
Index = (*p & (0xC0 >> (6 - Shift))) >> Shift;
/* Place pixel on display and increment to next pixel */
*(vbuf + x) = (CMEM_TYPE) *(pTrans + Index);
x++;
Diff++;
if (Diff == 4)
{
Diff = 0;
p++;
}
}
while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do
{
Shift = (3 - Diff) << 1;
Index = (*p & (0xC0 >> (6 - Shift))) >> Shift;
if (Index != 0)
{
/* Place pixel on display and increment to next pixel */
*(vbuf + x) = (CMEM_TYPE) *(pTrans + Index);
}
x++;
Diff++;
if (Diff == 4)
{
Diff = 0;
p++;
}
}
while (--xsize);
break;
}
}
#endif
#if LCD_MAX_LOG_COLORS > 4
/***********************************************************************
*
* Function: _DrawBitLine4BPP
*
* Purpose: 4-bit bitmap rendering function
*
* Processing:
* See function.
*
* Parameters:
* x: Left edge of location to place bitmap
* y: Vertical location to place bitmap
* p: Pointer to pixel data
* Diff: Left side pixel skip difference
* xsize: Number of pixels to display
* pTrans: Pointer to transparency
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
static void _DrawBitLine4BPP (int x,
int y,
U8 const *p,
int Diff,
int xsize,
const LCD_PIXELINDEX *pTrans)
{
CMEM_TYPE *vbuf;
int Shift, Index;
/* Precompute frame buffer vertical address to save some time */
vbuf = vlogbuf + (y * LOCAL_LCD_XSIZE);
switch (GUI_Context.DrawMode &
(LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR))
{
case 0:
do
{
/* Get pixel index */
Shift = (1 - Diff) << 2;
Index = (*p & (0xF0 >> (4 - Shift))) >> Shift;
/* Place pixel on display and increment to next pixel */
*(vbuf + x) = (CMEM_TYPE) *(pTrans + Index);
x++;
Diff++;
if (Diff == 2)
{
Diff = 0;
p++;
}
}
while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do
{
/* Get pixel index */
Shift = (1 - Diff) << 2;
Index = (*p & (0xF0 >> (4 - Shift))) >> Shift;
/* Put pixel on display if it isn't blank */
if (Index != 0)
{
/* Place pixel on display */
*(vbuf + x) = (CMEM_TYPE) *(pTrans + Index);
}
x++;
Diff++;
if (Diff == 2)
{
Diff = 0;
p++;
}
}
while (--xsize);
break;
}
}
#endif
#if LCD_MAX_LOG_COLORS > 16
/***********************************************************************
*
* Function: _DrawBitLine8BPP
*
* Purpose: 8-bit bitmap rendering function
*
* Processing:
* See function.
*
* Parameters:
* x: Left edge of location to place bitmap
* y: Vertical location to place bitmap
* p: Pointer to pixel data
* xsize: Number of pixels to display
* pTrans: Pointer to transparency
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
static void _DrawBitLine8BPP(int x,
int y,
const U8 *p,
int xsize,
const LCD_PIXELINDEX *pTrans)
{
CMEM_TYPE *vbuf;
/* Precompute frame buffer vertical address to save some time */
vbuf = vlogbuf + (y * LOCAL_LCD_XSIZE);
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR))
{
case 0:
if (pTrans != (LCD_PIXELINDEX *) 0)
{
while (xsize > 0)
{
/* Render pixel */
*(vbuf + x) = (CMEM_TYPE) *(pTrans + *p);
xsize--;
x++;
p++;
}
}
else
{
while (xsize > 0)
{
/* Render pixel */
*(vbuf + x) = (CMEM_TYPE) *p;
xsize--;
x++;
p++;
}
}
break;
case LCD_DRAWMODE_TRANS:
if (pTrans != (LCD_PIXELINDEX *) 0)
{
while (xsize > 0)
{
if ((UNS_16) *p != 0)
{
*(vbuf + x) = (CMEM_TYPE) *(pTrans + *p);
}
xsize--;
x++;
p++;
}
}
else
{
while (xsize > 0)
{
if ((UNS_16) *p != 0)
{
*(vbuf + x) = (CMEM_TYPE) *p;
}
xsize--;
x++;
p++;
}
}
break;
}
}
#endif
#if LCD_BITSPERPIXEL > 8
/***********************************************************************
*
* Function: _DrawBitLine16BPP
*
* Purpose: 16-bit bitmap rendering function
*
* Processing:
* See function.
*
* Parameters:
* x: Left edge of location to place bitmap
* y: Vertical location to place bitmap
* p: Pointer to pixel data
* xsize: Number of pixels to display
* pTrans: Pointer to transparency
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
static void _DrawBitLine16BPP(int x,
int y,
const U16 *p,
int xsize,
const LCD_PIXELINDEX *pTrans)
{
CMEM_TYPE *vbuf;
/* Precompute frame buffer vertical address to save some time */
vbuf = vlogbuf + (y * LOCAL_LCD_XSIZE);
if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) == 0)
{
/* With transparency? */
if (pTrans != (LCD_PIXELINDEX *) 0)
{
while (xsize > 0)
{
/* Render pixel */
*(vbuf + x) = (CMEM_TYPE) *(pTrans + *p);
xsize--;
x++;
p++;
}
}
else
{
while (xsize > 0)
{
/* Render pixel */
*(vbuf + x) = (CMEM_TYPE) *p;
xsize--;
x++;
p++;
}
}
}
else
{
/* With transparency? */
if (pTrans != (LCD_PIXELINDEX *) 0)
{
while (xsize > 0)
{
if ((UNS_16) *p != 0)
{
*(vbuf + x) = (CMEM_TYPE) *(pTrans + *p);
}
xsize--;
x++;
p++;
}
}
else
{
while (xsize > 0)
{
if ((UNS_16) *p != 0)
{
*(vbuf + x) = (CMEM_TYPE) *p;
}
xsize--;
x++;
p++;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -