📄 hw_hx8347.c
字号:
Mcupanel_RegSet(0x0016,0x00a8);
#endif
Mcupanel_RegSet(0x23,0x0065); // N_DC=1001 0101
Mcupanel_RegSet(0x24,0x0065); // P_DC=1001 0101
Mcupanel_RegSet(0x25,0x0065); // I_DC=1111 1111
Mcupanel_RegSet(0x28,0x0002); // N_BP=0000 0010
Mcupanel_RegSet(0x29,0x0002); // N_FP=0000 0010
Mcupanel_RegSet(0x2a,0x0002); // P_BP=0000 0010
Mcupanel_RegSet(0x2b,0x0002); // P_FP=0000 0010
Mcupanel_RegSet(0x2c,0x0002); // I_BP=0000 0010
Mcupanel_RegSet(0x2d,0x0002); // I_FP=0000 0010
Mcupanel_RegSet(0x3a,0x0001); // N_RTN=0000, N_NW=001
Mcupanel_RegSet(0x3b,0x0001); // P_RTN=0000, P_NW=001
Mcupanel_RegSet(0x3c,0x00f0); // I_RTN=1111, I_NW=000
Mcupanel_RegSet(0x3d,0x0000); // DIV=00
delay_nops(20);
Mcupanel_RegSet(0x0035,0x0038); // EQS=38h
Mcupanel_RegSet(0x0036,0x0078); // EQP=78h
Mcupanel_RegSet(0x003E,0x0038); // SON=38h
Mcupanel_RegSet(0x0040,0x000F); // GDON=0Fh
Mcupanel_RegSet(0x0041,0x00F0); // GDOFF
// Power Supply Setting
Mcupanel_RegSet(0x0019,0x0049); // OSCADJ=10 0000, OSD_EN=1 //60Hz
Mcupanel_RegSet(0x0093,0x000C); // RADJ=1100
delay_nops(10);
Mcupanel_RegSet(0x0020,0x0040); // BT=0100
Mcupanel_RegSet(0x001D,0x0007); // VC1=111
Mcupanel_RegSet(0x001E,0x0000); // VC3=000
Mcupanel_RegSet(0x001F,0x0006); // VRH=0100 //整体亮度
// VCOM Setting for CMO 2.8” Panel
Mcupanel_RegSet(0x0044,0x0024); // VCM=101 0000 //水纹现象
Mcupanel_RegSet(0x0045,0x000f); // VDV=1 0001 //对比度
delay_nops(10);
Mcupanel_RegSet(0x001C,0x0004); // AP=100
delay_nops(20);
Mcupanel_RegSet(0x001B,0x0018); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0
delay_nops(40);
Mcupanel_RegSet(0x001B,0x0014); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0
delay_nops(40);
Mcupanel_RegSet(0x0043,0x0080); //Set VCOMG=1
delay_nops(100);
// Display ON Setting
Mcupanel_RegSet(0x0090,0x007F); // SAP=0111 1111
Mcupanel_RegSet(0x0026,0x0004); //GON=0, DTE=0, D=01
delay_nops(40);
Mcupanel_RegSet(0x0026,0x0024); //GON=1, DTE=0, D=01
Mcupanel_RegSet(0x0026,0x002C); //GON=1, DTE=0, D=11
delay_nops(40);
Mcupanel_RegSet(0x0026,0x003C); //GON=1, DTE=1, D=11
delay_nops(10);
Mcupanel_Command(0x22);
#endif
//******************************************************************************
#if (LCM_HX8346 == 4)
Mcupanel_RegSet(0x0046,0x0095);
Mcupanel_RegSet(0x0047,0x0051);
Mcupanel_RegSet(0x0048,0x0000);
Mcupanel_RegSet(0x0049,0x0036);
Mcupanel_RegSet(0x004A,0x0011);
Mcupanel_RegSet(0x004B,0x0066);
Mcupanel_RegSet(0x004C,0x0014);
Mcupanel_RegSet(0x004D,0x0077);
Mcupanel_RegSet(0x004E,0x0013);
Mcupanel_RegSet(0x004F,0x004C);
Mcupanel_RegSet(0x0050,0x0046);
Mcupanel_RegSet(0x0051,0x0046); //对比度
//240x320 window setting
Mcupanel_RegSet(0x0002,0x0000); // Column address start2
Mcupanel_RegSet(0x0003,0x0000); // Column address start1
Mcupanel_RegSet(0x0004,0x0001); // Column address end2
Mcupanel_RegSet(0x0005,0x003F); // Column address end1
Mcupanel_RegSet(0x0006,0x0000); // Row address start2
Mcupanel_RegSet(0x0007,0x0000); // Row address start1
Mcupanel_RegSet(0x0008,0x0000); // Row address end2
Mcupanel_RegSet(0x0009,0x00EF); // Row address end1
// Display Setting
Mcupanel_RegSet(0x0001,0x0006); // IDMON=0, INVON=1, NORON=1, PTLON=0
#ifdef LCM_ROTAT_180
Mcupanel_RegSet(0x0016,0x0068); // MY=0, MX=0, MV=0, ML=0, BGR=0, TEON=0
#else
Mcupanel_RegSet(0x0016,0x00a8);
#endif
Mcupanel_RegSet(0x0023,0x0095); // N_DC=1001 0101
Mcupanel_RegSet(0x0024,0x0095); // P_DC=1001 0101
Mcupanel_RegSet(0x0025,0x00FF); // I_DC=1111 1111
Mcupanel_RegSet(0x0027,0x0001); // N_BP=0000 0110
Mcupanel_RegSet(0x0028,0x0001); // N_FP=0000 0110
Mcupanel_RegSet(0x0029,0x0001); // P_BP=0000 0110
Mcupanel_RegSet(0x002A,0x0001); // P_FP=0000 0110
Mcupanel_RegSet(0x002B,0x0001); // P_FP=0000 0110
Mcupanel_RegSet(0x002C,0x0001); // I_BP=0000 0110
Mcupanel_RegSet(0x002D,0x0001); // I_FP=0000 0110
Mcupanel_RegSet(0x003A,0x0001); // N_RTN=0000, N_NW=001
Mcupanel_RegSet(0x003B,0x0001); // P_RTN=0000, P_NW=001
Mcupanel_RegSet(0x003C,0x00F0); // I_RTN=1111, I_NW=000
Mcupanel_RegSet(0x003D,0x0000); // DIV=00
delay_nops(20);
Mcupanel_RegSet(0x0035,0x0038); // EQS=38h
Mcupanel_RegSet(0x0036,0x0078); // EQP=78h
Mcupanel_RegSet(0x003E,0x0038); // SON=38h
Mcupanel_RegSet(0x0040,0x000F); // GDON=0Fh
Mcupanel_RegSet(0x0041,0x00F0); // GDOFF
// Power Supply Setting
Mcupanel_RegSet(0x0019,0x0049); // OSCADJ=10 0000, OSD_EN=1 //60Hz
Mcupanel_RegSet(0x0093,0x000C); // RADJ=1100
delay_nops(10);
Mcupanel_RegSet(0x0020,0x0040); // BT=0100
Mcupanel_RegSet(0x001D,0x0007); // VC1=111
Mcupanel_RegSet(0x001E,0x0000); // VC3=000
Mcupanel_RegSet(0x001F,0x0006); // VRH=0100 //整体亮度
// VCOM Setting for CMO 2.8” Panel
Mcupanel_RegSet(0x0044,0x003c); // VCM=101 0000 //水纹现象
Mcupanel_RegSet(0x0045,0x000f); // VDV=1 0001 //对比度
delay_nops(10);
Mcupanel_RegSet(0x001C,0x0004); // AP=100
delay_nops(20);
Mcupanel_RegSet(0x001B,0x0018); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0
delay_nops(40);
Mcupanel_RegSet(0x001B,0x0014); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0
delay_nops(40);
Mcupanel_RegSet(0x0043,0x0080); //Set VCOMG=1
delay_nops(100);
// Display ON Setting
Mcupanel_RegSet(0x0090,0x007F); // SAP=0111 1111
Mcupanel_RegSet(0x0026,0x0004); //GON=0, DTE=0, D=01
delay_nops(40);
Mcupanel_RegSet(0x0026,0x0024); //GON=1, DTE=0, D=01
Mcupanel_RegSet(0x0026,0x002C); //GON=1, DTE=0, D=11
delay_nops(40);
Mcupanel_RegSet(0x0026,0x003C); //GON=1, DTE=1, D=11
delay_nops(10);
Mcupanel_Command(0x22);
#endif
Mcupanel_SetAddr(0x0,0x0);
// ---------- Tested throught displaying black ---------- //
#if 1
for(j=0;j<240;j++)
for(i=0;i<320;i++)
Mcupanel_Data(0x000000);
#endif
}
/*---------------------------------------------------------
Name : Mcupanel_Standby
Desc : Mcupanel的StandBy模式设置
Params: NORMAL -> 恢复正常模式
STANDBY -> 设置为StandBy模式
Return:
Author: nzy
Date :
-----------------------------------------------------------*/
void Mcupanel_Standby(BOOLEAN Enable)
{
if(Enable == STANDBY)//Standby mode
{
}
else//Return normal
{
Mcupanel_SetAddr(0x0,0x0);
}
}
/*---------------------------------------------------------
Name : Mcupanel_Reset_Addr
Desc : Mcupanel起始位置设置
Params:
Return:
Author: nzy
Date :
-----------------------------------------------------------*/
void Mcupanel_Reset_Addr()
{
Lcdctrl_McuBypassMode(TRUE);
Mcupanel_RegSet(0x02,0); // Column address start2
Mcupanel_RegSet(0x03,0); // Column address start1
Mcupanel_RegSet(0x06,0); // Row address start2
Mcupanel_RegSet(0x07,0); // Row address start1
Mcupanel_Command(0x22);
Lcdctrl_McuBypassMode(FALSE);
}
/*---------------------------------------------------------
Name : Mcupanel_SetAddr
Desc : Mcupanel起始位置设置
Params: X -> X方向的坐标
Y -> Y方向的坐标
Return:
Author: nzy
Date :
-----------------------------------------------------------*/
UINT32 cs1,cs2,ce1,ce2,rs1,rs2,re1,re2;
void Mcupanel_SetAddr(UINT32 x, UINT32 y)
{
cs1 = x&0xff;
cs2 = x >> 8;
rs1 = y&0xff;
rs2 = y >> 8;
Lcdctrl_McuBypassMode(TRUE);
Mcupanel_RegSet(0x02,cs2); // Column address start2
Mcupanel_RegSet(0x03,cs1); // Column address start1
Mcupanel_RegSet(0x06,rs2); // Row address start2
Mcupanel_RegSet(0x07,rs1); // Row address start1
Mcupanel_Command(0x22);
Lcdctrl_McuBypassMode(FALSE);
}
/*---------------------------------------------------------
Name : Mcupanel_SetAddr
Desc : Mcupanel矩形区域设置
Params: area -> 矩形区域的左上和右下点坐标
Return:
Author: nzy
Date :
-----------------------------------------------------------*/
void Mcupanel_SetWindow(UHRECT *area)
{
/*
cs1 = area->x&0xff;
cs2 = area->x >> 8;
ce1 = (area->x + area->w - 1)&0xff;
ce2 = (area->x + area->w - 1) >> 8;
rs1 = area->y&0xff;
rs2 = area->y >> 8;
re1 = (area->y + area->h - 1)&0xff;
re2 = (area->y + area->h - 1) >> 8;
Mcupanel_RegSet(0x02,cs2); // Column address start2
Mcupanel_RegSet(0x03,cs1); // Column address start1
Mcupanel_RegSet(0x04,ce2); // Column address end2
Mcupanel_RegSet(0x05,ce1); // Column address end1
Mcupanel_RegSet(0x06,rs2); // Row address start2
Mcupanel_RegSet(0x07,rs1); // Row address start1
Mcupanel_RegSet(0x08,re2); // Row address end2
Mcupanel_RegSet(0x09,re1); // Row address end1 //240*320;
Mcupanel_SetAddr(area->x, area->y);
*/
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -