📄 lcd_phyc_ssd1332.c
字号:
/*
*******************************************************************************
* uc/gui
* This program demostrates how to build an AP
*
* (c) Copyright Actions Co,Ld.
*
*******************************************************************************
*/
//#include "lcmoption.h"
#include "lcd.h"
#include "LCD_PHY_SSD1332.H"
//#define DISMOD_RGB
non_banked void LCM_Enable(void);
non_banked void LCM_Disable(void);
non_banked void LCM_Write_Command(int);
non_banked void LCM_Para_Write_Command(int command,int count,int,int,int,int,int,int,int,int,int,int);
non_banked void LCM_GPIOInit(void);
non_banked void Delay_10us(void);
non_banked void LCM_Write_Pixel(int Pixel);
non_banked void LCM_Fill_Area(int Value,int Size);
non_banked unsigned int LCM_Read_Pixel(int x,int y);
non_banked void LCM_Read_Area(char *Buffer,int Counter);
non_banked void LCM_BuffDataTrans ( char *buff , int datacnt);
int LCM_Set_Column(int xs,int xe);
int LCM_Set_Row(int ys,int ye);
int LCM_Clear_GDDRAM(int xs,int ys,int xe,int ye);
int LCM_Xor_GDRAM(int xs,int ys,int xe,int ye);
int LCM_GAC_FillEnable(int FillOnOff);
int LCM_GAC_ReverseEnable(int ReverseOnOff);
int LCM_GAC_Copy(int xs,int ys,int xe,int ye,int xnew,int ynew);
int LCM_GAC_DimWindow(int xs,int ys,int xe,int ye);
int LCM_GAC_ClearWindow(int xs,int ys,int xe,int ye);
int LCM_GAC_DrawLine(int xs,int ys,int xe,int ye,int Color);
int LCM_GAC_DrawRect(int xs,int ys,int xe,int ye,int ColorLine,int ColorFill);
void LCM_SetSEGAColorContrast(void);
void LCM_SetSEGBColorContrast(void);
void LCM_SetSEGCColorContrast(void);
void LCM_SetMasterCurrent(void);
void LCM_SetRemapANDDataFormat(void);
void LCM_SetDisplayStartLine(void);
void LCM_SetDisplayOffset(void);
void LCM_NormalDisplay(void);
void LCM_SetMultiplexRatio(void);
void LCM_SetMasterConfiguration(void);
void LCM_SetSEGAVoltage(void);
void LCM_SetSEGBVoltage(void);
void LCM_SetSEGCVoltage(void);
/*
*************************************************************************
LCM Physical Code Layer
*************************************************************************
*/
void LCD_P0_DrawRect(int x0, int y0, int x1, int y1,int ColorLine,int ColorFill)
{
LCM_GAC_FillEnable(1);
LCM_GAC_DrawRect(x0,y0,x1,y1,ColorLine,ColorFill);
}
void LCD_P0_InvertRegion(LCD_RECT *reg)
{
LCM_GAC_ReverseEnable(1);
LCM_GAC_Copy(reg->x0,reg->y0,reg->x1,reg->y1,reg->x0,reg->y0);
LCM_GAC_ReverseEnable(0);
}
void LCD_P0_CopyRect(int x0, int y0, int x1, int y1,int newx, int newy)
{
LCM_GAC_Copy(x0,y0,x1,y1,newx,newy);
}
void LCD_P0_ClearRect(int x0, int y0, int x1, int y1)
{
LCM_GAC_ClearWindow(x0,y0,x1,y1);
}
void LCD_P0_BuffDataTrans(U8 *pData, int cnt, char mode)
{
LCM_BuffDataTrans(pData,cnt);
}
void LCD_P0_GetBuffData ( char *buff, int datacnt, char mode)
{
LCM_Read_Area(buff,datacnt);
}
unsigned int LCD_P0_GetPixelIndex(int x, int y)
{
return(LCM_Read_Pixel(x,y));
}
int LCD_P0_DrawLine (int x0, int y0, int x1, int y1,int ColorIndex)
{
int x0save;
#ifdef LCD_GAC
LCM_GAC_DrawLine(x0,y0,x1,y1,ColorIndex);
#else
if((x0>x1)||(y0>y1))
return 1;
if(x0==x1)
{
for(;y0<(y1+1);y0++)
{
LCM_Set_Column(x0,XMAX);
LCM_Set_Row(y0,YMAX);
LCM_Write_Pixel(ColorIndex);
}
}
else if(y0==y1)
{
for(;x0<(x1+1);x0++)
{
LCM_Set_Column(x0,XMAX);
LCM_Set_Row(y0,YMAX);
LCM_Write_Pixel(ColorIndex);
}
}
else
{
x0save = x0;
for(;x0<(x1+1);x0++)
{
LCM_Set_Column(x0,XMAX);
y0 = ((y1-y0)*x0)/(x1-x0save);
LCM_Set_Row(y0,YMAX);
LCM_Write_Pixel(ColorIndex);
}
}
#endif
}
void LCD_P0_XorPixel(int x, int y)
{
LCM_Set_Column(x,XMAX);
LCM_Set_Row(y,YMAX);
LCM_Write_Pixel(0x0000);
}
void LCD_P0_SetPixelIndex(int x, int y, int ColorIndex)
{
LCM_Set_Column(x,XMAX);
LCM_Set_Row(y,YMAX);
LCM_Write_Pixel(ColorIndex);
}
void LCD_P0_SetDrawMode(unsigned char mode)
{
switch(mode)
{
case DrawModeH_def:
LCM_Para_Write_Command(0xa0,0x01,0x70,0,0,0,0,0,0,0,0,0);
break;
case DrawModeV_def:
LCM_Para_Write_Command(0xa0,0x01,0x71,0,0,0,0,0,0,0,0,0);
break;
default: break;
}
}
int LCD_P0_SetWindow(LCD_RECT *win)
{
LCM_Set_Column(win->x0,win->x1);
LCM_Set_Row(win->y0,win->y1);
}
void LCD_P0_SetContrast(char ContrastValue)
{
LCM_Para_Write_Command(0x81,0x01,(int)ContrastValue,0,0,0,0,0,0,0,0,0);
LCM_Para_Write_Command(0x82,0x01,(int)ContrastValue,0,0,0,0,0,0,0,0,0);
LCM_Para_Write_Command(0x83,0x01,(int)ContrastValue,0,0,0,0,0,0,0,0,0);
}
void LCD_P0_Standby(unsigned char bStandby)
{
switch(bStandby)
{
case StandbyStart_def:
LCM_Para_Write_Command(0xb0,0x01,0x12,0,0,0,0,0,0,0,0,0);
break;
case StandbyExit_def:
LCM_Para_Write_Command(0xb0,0x01,0x00,0,0,0,0,0,0,0,0,0);
break;
default: break;
}
}
void LCD_P0_On(void)
{
LCM_Write_Command(0xaf);
}
void LCD_P0_Off(void)
{
LCM_Write_Command(0xae);
}
int LCD_P0_Init(void)
{
LCM_GPIOInit();
LCM_Set_Column(0x00,XMAX);
LCM_Set_Row(0x00,YMAX);
LCM_SetSEGAColorContrast();
LCM_SetSEGBColorContrast();
LCM_SetSEGCColorContrast();
LCM_SetMasterCurrent();
LCM_NormalDisplay ();
LCM_SetMasterConfiguration();
LCM_SetSEGAVoltage();
LCM_SetSEGBVoltage();
LCM_SetSEGCVoltage();
LCM_SetRemapANDDataFormat();
LCM_Write_Command(0xaf);
LCM_Clear_GDDRAM(0x00,0x00,XMAX,YMAX);
}
/*
*************************************************************************
LCM Hardware Code Layer
*************************************************************************
*/
int LCM_Set_Column(int xs,int xe)
{
xs &= 0x7f;
xe &= 0x7f;
LCM_Para_Write_Command(0x15,0x02,xs,xe,0,0,0,0,0,0,0,0);
}
int LCM_Set_Row(int ys,int ye)
{
ys &= 0x3f;
ye &= 0x3f;
LCM_Para_Write_Command(0x75,0x02,ys,ye,0,0,0,0,0,0,0,0);
}
int LCM_Clear_GDDRAM(int xs,int ys,int xe,int ye)
{
int x,y,size;
if((xs>xe)||(ys>ye))
return 1;
x = xe-xs;
y = ye-ys;
size = x*y;
LCM_Set_Column(xs,xe);
LCM_Set_Row(ys,ye);
LCM_Fill_Area(0x0000,96*64);
}
int LCM_Xor_GDRAM(int xs,int ys,int xe,int ye)
{
LCM_Set_Column(xs,xe);
LCM_Set_Row(ys,ye);
LCM_Write_Pixel(0x0000);
}
int LCM_GAC_FillEnable(int FillOnOff)
{
if(FillOnOff)
LCM_Para_Write_Command(0x26,0x01,0x01,0,0,0,0,0,0,0,0,0);
else
LCM_Para_Write_Command(0x26,0x01,0x00,0,0,0,0,0,0,0,0,0);
}
int LCM_GAC_ReverseEnable(int ReverseOnOff)
{
if(ReverseOnOff)
LCM_Para_Write_Command(0x26,0x01,0x11,0,0,0,0,0,0,0,0,0);
else
LCM_Para_Write_Command(0x26,0x01,0x01,0,0,0,0,0,0,0,0,0);
}
int LCM_GAC_Copy(int xs,int ys,int xe,int ye,int xnew,int ynew)
{
xs &= 0x7f;
ys &= 0x3f;
xe &= 0x7f;
ye &= 0x3f;
xnew &= 0x7f;
ynew &= 0x3f;
LCM_Para_Write_Command(0x23,0x06,xs,ys,xe,ye,xnew,ynew,0,0,0,0);
}
int LCM_GAC_DimWindow(int xs,int ys,int xe,int ye)
{
xs &= 0x7f;
ys &= 0x3f;
xe &= 0x7f;
ye &= 0x3f;
LCM_Para_Write_Command(0x24,0x04,xs,ys,xe,ye,0,0,0,0,0,0);
}
int LCM_GAC_ClearWindow(int xs,int ys,int xe,int ye)
{
xs &= 0x7f;
ys &= 0x3f;
xe &= 0x7f;
ye &= 0x3f;
LCM_Para_Write_Command(0x25,0x04,xs,ys,xe,ye,0,0,0,0,0,0);
}
int LCM_GAC_DrawLine(int xs,int ys,int xe,int ye,int Color)
{
int ColorR,ColorG,ColorB;
xs &= 0x7f;
ys &= 0x3f;
xe &= 0x7f;
ye &= 0x3f;
#ifdef DISMOD_RGB
ColorR = (Color>>11)&0x1f;
ColorR <<= 1;
ColorG = (Color>>5)&0x3f;
ColorB = Color&0x1f;
ColorB <<= 1;
#else
ColorB = (Color>>11)&0x1f;
ColorB <<= 1;
ColorG = (Color>>5)&0x3f;
ColorR = Color&0x1f;
ColorR <<= 1;
#endif
LCM_Para_Write_Command(0x21,0x07,xs,ys,xe,ye,ColorB,ColorG,ColorR,0,0,0);
}
int LCM_GAC_DrawRect(int xs,int ys,int xe,int ye,int ColorLine,int ColorFill)
{
int ColorLR,ColorLG,ColorLB;
int ColorFR,ColorFG,ColorFB;
xs &= 0x7f;
ys &= 0x3f;
xe &= 0x7f;
ye &= 0x3f;
#ifdef DISMOD_RGB
ColorLR = (ColorLine>>11)&0x1f;
ColorLR <<= 1;
ColorLG = (ColorLine>>5)&0x3f;
ColorLB = ColorLine&0x1f;
ColorLB <<= 1;
ColorFR = (ColorFill>>11)&0x1f;
ColorFR <<= 1;
ColorFG = (ColorFill>>5)&0x3f;
ColorFB = ColorFill&0x1f;
ColorFB <<= 1;
#else
ColorLB = (ColorLine>>11)&0x1f;
ColorLB <<= 1;
ColorLG = (ColorLine>>5)&0x3f;
ColorLR = ColorLine&0x1f;
ColorLR <<= 1;
ColorFB = (ColorFill>>11)&0x1f;
ColorFB <<= 1;
ColorFG = (ColorFill>>5)&0x3f;
ColorFR = ColorFill&0x1f;
ColorFR <<= 1;
#endif
LCM_Para_Write_Command(0x22,0x0A,xs,ys,xe,ye,ColorLB,ColorLG,ColorLR,ColorFB,ColorFG,ColorFR);
}
/************************************************************/
/* function:Display_OFF */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetSEGAColorContrast(void)
{
LCM_Para_Write_Command(0x81,0x01,0xff,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function: */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetSEGBColorContrast(void)
{
LCM_Para_Write_Command(0x82,0x01,0xff,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function: */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetSEGCColorContrast(void)
{
LCM_Para_Write_Command(0x83,0x01,0xff,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function: */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetMasterCurrent(void)
{
LCM_Para_Write_Command(0x87,0x01,0x0f,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function: */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetRemapANDDataFormat(void)
{
LCM_Para_Write_Command(0xa0,0x01,0x70,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function: */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetDisplayStartLine(void)
{
LCM_Para_Write_Command(0xa1,0x01,0x00,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function: */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetDisplayOffset(void)
{
LCM_Para_Write_Command(0xa2,0x01,0x00,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function: */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_NormalDisplay(void)
{
LCM_Write_Command(0xa4);
}
/************************************************************/
/* function: */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetMultiplexRatio(void)
{
LCM_Para_Write_Command(0xa8,0x01,0x3f,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function:Display_OFF */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetMasterConfiguration(void)
{
LCM_Para_Write_Command(0xad,0x01,0x8f,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function:Display_OFF */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetSEGAVoltage(void)
{
LCM_Para_Write_Command(0xbb,0x01,0x0f,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function:Display_OFF */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetSEGBVoltage(void)
{
LCM_Para_Write_Command(0xbc,0x01,0x00,0,0,0,0,0,0,0,0,0);
}
/************************************************************/
/* function:Display_OFF */
/* Process: send display_OFF command to (8000h) */
/************************************************************/
void LCM_SetSEGCVoltage(void)
{
LCM_Para_Write_Command(0xbd,0x01,0x0f,0,0,0,0,0,0,0,0,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -