📄 lcd_m128128.c
字号:
* y 指定点所在行的位置
* color 对于黑白色或蓝白色LCM12864,为0时灭,为1时显示
* 出口参数:返回值为1时表示操作成功,为0时表示操作失败。
***********************************************************************/
void LCD_L0_SetPixelIndex(int x, int y, int PixelIndex)
{
int bak;
bak = LCM128128_ReadByte( x, y );
if( 0 == PixelIndex )
{
bak &= (~DEC_HEX_TAB[y&0x07]);
}
else
{
bak |= DEC_HEX_TAB[y&0x07];
}
y=y>>3;
lcd_buffer[y][x] = bak;
}
/***********************************************************************
* 函数名称:LCD_L0_GetPixelIndex()
* 功 能:读取指定点的颜色。
* 入口参数:x 指定点所在列的位置
* y 指定点所在行的位置
* ret 保存颜色值的指针
* 出口参数:返回0表示指定地址超出缓冲区范围。
* 说 明:对于单色,设置ret的d0位为1或0
***********************************************************************/
unsigned int LCD_L0_GetPixelIndex( int x, int y )
{
int bak;
bak = LCM128128_ReadByte(x,y);
if( (bak & ( DEC_HEX_TAB[ y & 0x07 ] ) ) == 0 )
return 0;
else
return 1;
}
/***********************************************************************
* 函数名称:RefreshFrameBuffer()
* 功 能:刷新屏幕。
* 入口参数:无
* 出口参数:无
***********************************************************************/
void RefreshFrameBuffer(INT8U disp_mode )
{
int x = 0;
int y = 0;
INT8U page;
for( y = 0; y <= 15; y++ )
{
set128128Addr( SET_X_Y, 0, y );
for( x = 0; x <= 127; x++ )
{
if( x == 0 )
set128128Addr( SET_X_Y, 0, y );
if(x<64)
{
if( y > 7 )
page = PAGE_3;
else
page = PAGE_1;
LCD_WriteData( disp_mode, page, lcd_buffer[y][x] );
}
if(x==64)
set128128Addr(SET_X_Y,x,y);
if(x>63)
{
if( y > 7 )
page = PAGE_4;
else
page = PAGE_2;
LCD_WriteData( disp_mode, page, lcd_buffer[y][x] );
}
}
}
}
/***********************************************************************
* 名称:LCD_L0_DrawPixel()
* 功能:清除屏幕。
* 入口参数:无
* 出口参数:无
***********************************************************************/
void LCD_L0_DrawPixel(int x, int y)
{
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
{
LCD_L0_XorPixel(x, y);
}
else
{
LCD_L0_SetPixelIndex(x, y, LCD_COLORINDEX);
}
}
/***********************************************************************
* 名称: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)
{
for (; y0 <= y1; y0++)
{
LCD_L0_DrawHLine(x0, y0, x1);
}
}
/***********************************************************************
* 名称:DrawBitLine1BPP()
* 功能:清除屏幕。
* 入口参数:无
* 出口参数:无
***********************************************************************/
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: /* Write mode */
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;
}
}
/***********************************************************************
* 名称: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++) {
switch (BitsPerPixel) {
case 1:
DrawBitLine1BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#if (LCD_MAX_LOG_COLORS > 2)
case 2:
DrawBitLine2BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#endif
#if (LCD_MAX_LOG_COLORS > 4)
case 4:
DrawBitLine4BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#endif
#if (LCD_MAX_LOG_COLORS > 16)
case 8:
DrawBitLine8BPP(x0, i+y0, pData, xsize, pTrans);
break;
#endif
#if (LCD_BITSPERPIXEL > 8)
case 16:
DrawBitLine16BPP(x0, i+y0, (const U16 *)pData, xsize, pTrans);
break;
#endif
}
pData += BytesPerLine;
}
}
/***********************************************************************
* 名称:LCD_L0_SetOrg()
* 功能:清除屏幕。
* 入口参数:无
* 出口参数:无
***********************************************************************/
int OrgX, OrgY;
void LCD_L0_SetOrg(int x, int y)
{
OrgX = x;
OrgY = y;
}
/***********************************************************************
* 名称:LCD_On()/LCD_Off()
* 功能:清除屏幕。
* 入口参数:无
* 出口参数:无
***********************************************************************/
void LCD_On (void) { LCD_WriteCommand( PAGE_ALL_S,LCD_DISP_ON); }
void LCD_Off (void) { LCD_WriteCommand(PAGE_ALL_S,LCD_DISP_OFF); }
/***********************************************************************
* 名称:LCD_L0_SetLUTEntry()
* 功能:清除屏幕。
* 入口参数:无
* 出口参数:无
***********************************************************************/
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR Color)
{
GUI_USE_PARA(Pos);
GUI_USE_PARA(Color);
}
/***********************************************************************
* 名称:LCD_L0_CheckInit()
* 功能:清除屏幕。
* 入口参数:无
* 出口参数:无
***********************************************************************/
int LCD_L0_CheckInit(void)
{
return 0;
}
/***********************************************************************
* 名称: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);
}
/***********************************************************************
* END
***********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -