新人求教:LCD12864和LCD1602的区别 本人想用12864做显示但不知道它和1602在编程上的区别,有什么需要注意

新人求教:LCD12864和LCD1602的区别 本人想用12864做显示但不知道它和1602在编程上的区别,有什么需要注意,第1张

1602是指的16字符2行的那种吧。如果是,其点阵是这样的结构。其IC带有字库。想显示字符,只需要输入对应字的地址。

而拿卖12864的点阵是连续的。一般不带有字库。想写一个圆点,都要自己想好要写那些位置。屏上每个点都对应字IC内部RAM中一个BIT. 黑白的程序已经很久没知宽有用了。不知道240*320彩屏的对LZ有帮助没有。区别是彩屏一个像素点需要16BIT数据(或者18,或者24).

//---------------------------------------------------------------------------

#include "reg51.h"

typedef bit uint1

typedef 搭敏亮unsigned char uint8, uchar, UCHAR

typedef unsigned int uint16, uint, UINT

typedef unsigned long uint32, ulong, ULONG

//---------------------------------------------------------------------------

sbit A0=P3^2

sbit _RES=P3^0

sbit _WR=P3^1

sbit _LE=P3^6

sbit _CS=P3^3

//---------------------------------------------------------------------------

void Delay10ms(UINT t)

void W_COM(UCHAR dat)

void W_DATA1(UCHAR dat)

void W_DATA2(UCHAR dat1, UCHAR dat2)

void Init(void)

void ILI9320_HSD24_Initial(void)

void LCD_CtrlWrite_ILI9320(UINT com, UINT dat)

void Edge(void)

void Test(void)

void Clear(void)

void Full(void)

void Red(void)

void Green(void)

void Blue(void)

void RGBMix(void)

void Bar(void)

void Show(UINT sx, UINT ex, UINT sy, UINT ey, UINT dat)

void SetShowArea(UINT sx, UINT ex, UINT sy, UINT ey)

//void ShowPic(UCHAR* ppic, UCHAR size, UCHAR ystart, UCHAR xstart)

//---------------------------------------------------------------------------

void main(void)

{

_LE = 0

_CS = 0

ILI9320_HSD24_Initial()

while(1)

{

Full()

Delay10ms(400)

Clear()

Delay10ms(400)

Red()

Delay10ms(400)

Green()

Delay10ms(400)

Blue()

Delay10ms(400)

/*RGBMix()

Delay10ms(400)

Bar()

Delay10ms(400)*/

}

}

//---------------------------------------------------------------------------

void Delay10ms(UINT t)

{

UCHAR i

while( t > 0 )

{

t--

for ( i = 0 i < 255 i++ )

}

}

//---------------------------------------------------------------------------

void W_COM(UCHAR dat)

{

A0 = 0

_LE = 1

P1 = 0x00

_LE = 0

P1 = dat

_WR = 0

_WR = 1

}

//---------------------------------------------------------------------------

void W_DATA1(UCHAR dat)

{

A0 = 1

P1 = dat

_WR = 0

_WR = 1

}

//---------------------------------------------------------------------------

void W_DATA2(UCHAR dat1, UCHAR dat2)

{

A0 = 1

_LE = 1

P1 = dat1

_LE = 0

P1 = dat2

_WR = 0

_WR = 1

}

//---------------------------------------------------------------------------

void Init(void)

{

_RES = 1

Delay10ms(100)

_RES = 0

Delay10ms(100)

_RES = 1

/*W_COM(0xE5)

W_DATA2(0x80, 0x00)*/

W_COM(0x00)

W_DATA2(0x00, 0x01)

Delay10ms(10)

W_COM(0x01)

W_DATA2(0x01, 0x00)

W_COM(0x02)

W_DATA2(0x07, 0x00)

W_COM(0x03)

W_DATA2(0x10, 0x30)

//W_DATA2(0x0030)

W_COM(0x04)

W_DATA2(0x00, 0x00)

W_COM(0x08)

W_DATA2(0x02, 0x02)

W_COM(0x09)

W_DATA2(0x00, 0x00)

W_COM(0x0A)

W_DATA2(0x00, 0x00)

W_COM(0x0C)

W_DATA2(0x00, 0x00)

W_COM(0x0D)

W_DATA2(0x00, 0x00)

W_COM(0x0F)

W_DATA2(0x00, 0x00)

W_COM(0x10)

W_DATA2(0x00, 0x00)

W_COM(0x11)

W_DATA2(0x00, 0x07)

W_COM(0x12)

W_DATA2(0x00, 0x00)

W_COM(0x13)

W_DATA2(0x00, 0x00)

Delay10ms(100)

W_COM(0x10)

W_DATA2(0x17, 0xB0)

W_COM(0x11)

W_DATA2(0x00, 0x37)

Delay10ms(100)

W_COM(0x12)

W_DATA2(0x01, 0x3A)

Delay10ms(100)

W_COM(0x13)

W_DATA2(0x16, 0x00)

W_COM(0x29)

W_DATA2(0x00, 0x0C)

Delay10ms(100)

W_COM(0x20)

W_DATA2(0x00, 0x00)

W_COM(0x21)

W_DATA2(0x00, 0x00)

W_COM(0x30)

W_DATA2(0x05, 0x04)

W_COM(0x31)

W_DATA2(0x07, 0x03)

W_COM(0x32)

W_DATA2(0x07, 0x02)

W_COM(0x35)

W_DATA2(0x01, 0x01)

W_COM(0x36)

W_DATA2(0x0A, 0x1F)

W_COM(0x37)

W_DATA2(0x05, 0x04)

W_COM(0x38)

W_DATA2(0x00, 0x03)

W_COM(0x39)

W_DATA2(0x07, 0x06)

W_COM(0x3C)

W_DATA2(0x07, 0x07)

W_COM(0x3D)

W_DATA2(0x09, 0x1F)

W_COM(0x50)

W_DATA2(0x00, 0x00)

W_COM(0x51)

W_DATA2(0x00, 0xEF)

W_COM(0x52)

W_DATA2(0x00, 0x00)

W_COM(0x53)

W_DATA2(0x01, 0x3F)

W_COM(0x60)

W_DATA2(0x27, 0x00)

W_COM(0x61)

W_DATA2(0x00, 0x01)

W_COM(0x6A)

W_DATA2(0x00, 0x00)

W_COM(0x80)

W_DATA2(0x00, 0x00)

W_COM(0x81)

W_DATA2(0x00, 0x00)

W_COM(0x82)

W_DATA2(0x00, 0x00)

W_COM(0x83)

W_DATA2(0x00, 0x00)

W_COM(0x84)

W_DATA2(0x00, 0x00)

W_COM(0x85)

W_DATA2(0x00, 0x00)

W_COM(0x90)

W_DATA2(0x00, 0x10)

W_COM(0x92)

W_DATA2(0x00, 0x00)

W_COM(0x93)

W_DATA2(0x00, 0x03)

W_COM(0x95)

W_DATA2(0x01, 0x10)

W_COM(0x97)

W_DATA2(0x00, 0x00)

W_COM(0x98)

W_DATA2(0x00, 0x00)

W_COM(0x07)

W_DATA2(0x01, 0x73)

}

//---------------------------------------------------------------------------

void SetShowArea(UINT sx, UINT ex, UINT sy, UINT ey)

{

W_COM(0x50)

W_DATA2(0, sx)

W_COM(0x51)

W_DATA2(0, ex)

W_COM(0x52)

W_DATA2(sy/256, sy%256)

W_COM(0x53)

W_DATA2(ey/256, ey%256)

}

//---------------------------------------------------------------------------

void Clear(void)

{

Show(0x0000, 0x00EF, 0x0000, 0x013F, 0x0000)

}

//---------------------------------------------------------------------------

void Full(void)

{

Show(0x0000, 0x00EF, 0x0000, 0x013F, 0xFFFF)

}

//---------------------------------------------------------------------------

void Red(void)

{

Show(0x0000, 0x00EF, 0x0000, 0x013F, 0xF800)

}

//---------------------------------------------------------------------------

void Green(void)

{

Show(0x0000, 0x00EF, 0x0000, 0x013F, 0x07E0)

}

//---------------------------------------------------------------------------

void Blue(void)

{

Show(0x0000, 0x00EF, 0x0000, 0x013F, 0x001F)

}

//---------------------------------------------------------------------------

void RGBMix(void)

{

Show(0x0000, 0x00EF, 0x0000, 0x013F, 0xFFE0)

Delay10ms(400)

Show(0x0000, 0x00EF, 0x0000, 0x013F, 0x07FF)

Delay10ms(400)

Show(0x0000, 0x00EF, 0x0000, 0x013F, 0xF81F)

Delay10ms(400)

Clear()

/*

Show(0x00, 0x3F, 0x00, 0x34, 0xFF, 0xE0)

Show(0x00, 0x3F, 0x35, 0x6A, 0x07, 0xFF)

Show(0x00, 0x3F, 0x6B, 0x9F, 0xF8, 0x1F)

Show(0x40, 0x7F, 0x00, 0x34, 0xF8, 0x00)

Show(0x40, 0x7F, 0x35, 0x6A, 0x07, 0xE0)

Show(0x40, 0x7F, 0x6B, 0x9F, 0x00, 0x1F)*/

}

//---------------------------------------------------------------------------

void Bar(void)

{

Clear()

/*

Show(0x1F, 0x5F, 0x1A, 0x35, 0xF8, 0x00)

Show(0x1F, 0x5F, 0x50, 0x6B, 0x07, 0xE0)

Show(0x1F, 0x5F, 0x86, 0x9F, 0x00, 0x1F) */

}

//---------------------------------------------------------------------------

void Show(UINT sx, UINT ex, UINT sy, UINT ey, UINT dat)

{

UINT x, y, i, j

SetShowArea(sx, ex, sy, ey)

x = ex - sx

y = ey - sy

W_COM(0x22)

for ( i = 0 i <= y i++ )

for ( j = 0 j <= x j++ )

W_DATA2(dat/256, dat%256)

}

//---------------------------------------------------------------------------

void ILI9320_HSD24_Initial(void)

{

// VCI=2.8V

//************* Reset LCD Driver ****************//

_RES = 1

Delay10ms(1) // Delay 1ms

_RES = 0

Delay10ms(10) // Delay 10ms // This delay time is necessary

_RES = 1

Delay10ms(50) // Delay 50 ms

//************* Start Initial Sequence **********//

LCD_CtrlWrite_ILI9320(0x00E5, 0x8000) // Set the internal vcore voltage

LCD_CtrlWrite_ILI9320(0x0000, 0x0001) // Start internal OSC.

LCD_CtrlWrite_ILI9320(0x0001, 0x0100) // set SS and SM bit

LCD_CtrlWrite_ILI9320(0x0002, 0x0700) // set 1 line inversion

LCD_CtrlWrite_ILI9320(0x0003, 0x1030) // set GRAM write direction and BGR=1.

LCD_CtrlWrite_ILI9320(0x0004, 0x0000) // Resize register

LCD_CtrlWrite_ILI9320(0x0008, 0x0202) // set the back porch and front porch

LCD_CtrlWrite_ILI9320(0x0009, 0x0000) // set non-display area refresh cycle ISC[3:0]

LCD_CtrlWrite_ILI9320(0x000A, 0x0000) // FMARK function

LCD_CtrlWrite_ILI9320(0x000C, 0x0000) // RGB interface setting

LCD_CtrlWrite_ILI9320(0x000D, 0x0000) // Frame marker Position

LCD_CtrlWrite_ILI9320(0x000F, 0x0000) // RGB interface polarity

//*************Power On sequence ****************//

LCD_CtrlWrite_ILI9320(0x0010, 0x0000) // SAP, BT[3:0], AP, DSTB, SLP, STB

LCD_CtrlWrite_ILI9320(0x0011, 0x0000) // DC1[2:0], DC0[2:0], VC[2:0]

LCD_CtrlWrite_ILI9320(0x0012, 0x0000) // VREG1OUT voltage

LCD_CtrlWrite_ILI9320(0x0013, 0x0000) // VDV[4:0] for VCOM amplitude

Delay10ms(200) // Dis-charge capacitor power voltage

LCD_CtrlWrite_ILI9320(0x0010, 0x17B0) // SAP, BT[3:0], AP, DSTB, SLP, STB

LCD_CtrlWrite_ILI9320(0x0011, 0x0037) // DC1[2:0], DC0[2:0], VC[2:0]

Delay10ms(50) // Delay 50ms

LCD_CtrlWrite_ILI9320(0x0012, 0x013A) // VREG1OUT voltage

Delay10ms(50) // Delay 50ms

LCD_CtrlWrite_ILI9320(0x0013, 0x1C00) // VDV[4:0] for VCOM amplitude

LCD_CtrlWrite_ILI9320(0x0029, 0x000A) // VCM[4:0] for VCOMH

Delay10ms(50)

LCD_CtrlWrite_ILI9320(0x0020, 0x0000) // GRAM horizontal Address

LCD_CtrlWrite_ILI9320(0x0021, 0x0000) // GRAM Vertical Address

// ----------- Adjust the Gamma Curve ----------//

LCD_CtrlWrite_ILI9320(0x0030, 0x0007)

LCD_CtrlWrite_ILI9320(0x0031, 0x0203)

LCD_CtrlWrite_ILI9320(0x0032, 0x0001)

LCD_CtrlWrite_ILI9320(0x0035, 0x0007)

LCD_CtrlWrite_ILI9320(0x0036, 0x0407)

LCD_CtrlWrite_ILI9320(0x0037, 0x0607)

LCD_CtrlWrite_ILI9320(0x0038, 0x0106)

LCD_CtrlWrite_ILI9320(0x0039, 0x0007)

LCD_CtrlWrite_ILI9320(0x003C, 0x0007)

LCD_CtrlWrite_ILI9320(0x003D, 0x001E)

//------------------ Set GRAM area ---------------//

LCD_CtrlWrite_ILI9320(0x0050, 0x0000) // Horizontal GRAM Start Address

LCD_CtrlWrite_ILI9320(0x0051, 0x00EF) // Horizontal GRAM End Address

LCD_CtrlWrite_ILI9320(0x0052, 0x0000) // Vertical GRAM Start Address

LCD_CtrlWrite_ILI9320(0x0053, 0x013F) // Vertical GRAM Start Address

LCD_CtrlWrite_ILI9320(0x0060, 0x2700) // Gate Scan Line

LCD_CtrlWrite_ILI9320(0x0061, 0x0001) // NDL,VLE, REV

LCD_CtrlWrite_ILI9320(0x006A, 0x0000) // set scrolling line

//-------------- Partial Display Control ---------//

LCD_CtrlWrite_ILI9320(0x0080, 0x0000)

LCD_CtrlWrite_ILI9320(0x0081, 0x0000)

LCD_CtrlWrite_ILI9320(0x0082, 0x0000)

LCD_CtrlWrite_ILI9320(0x0083, 0x0000)

LCD_CtrlWrite_ILI9320(0x0084, 0x0000)

LCD_CtrlWrite_ILI9320(0x0085, 0x0000)

//-------------- Panel Control -------------------//

LCD_CtrlWrite_ILI9320(0x0090, 0x0010)

LCD_CtrlWrite_ILI9320(0x0092, 0x0000)

LCD_CtrlWrite_ILI9320(0x0093, 0x0003)

LCD_CtrlWrite_ILI9320(0x0095, 0x0110)

LCD_CtrlWrite_ILI9320(0x0097, 0x0000)

LCD_CtrlWrite_ILI9320(0x0098, 0x0000)

LCD_CtrlWrite_ILI9320(0x0007, 0x0173) // 262K color and display ON

}

//---------------------------------------------------------------------------

void LCD_CtrlWrite_ILI9320(UINT com, UINT dat)

{

W_COM( com&0xFF )

W_DATA2( dat>>8, dat&0xFF )

}

区别昌运是:

第一种可以分解成这种状况:

/*中间为注释内容*/

这就代表*号之间的就是注释内容

第二凯信种可耐孙梁以理解为:

//注释内容只能写在一行


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/yw/12504183.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存