日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當前位置:首頁 > 單片機 > 單片機
[導(dǎo)讀]>_>8;64 n=y;65 Write_Data(m,n);66 67 }68 /*----------------------------------------------------------------69 寫命令70 ----------------------------------------------------------------*/7172 void

>_<:引腳和前面幾個連接一樣,這里做了一個實用的動畫效果,模擬起重機的2維視圖。

9325tp.h

1 #ifndef __ILI9325_H__

2 #define __ILI9325_H__

3

4 void ILI9325_Initial(void);

5 void Write_Cmd_Data(unsigned char x, unsigned int y);

6 void Write_Cmd(unsigned char DH,unsigned char DL);

7 void Write_Data(unsigned char DH,unsigned char DL);

8 void delayms(unsigned int tt);

9 void Write_Data_U16(unsigned int y);

10 static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1);

11 void CLR_Screen(unsigned int bColor);

12 void Put_pixel(unsigned char x,unsigned char y,unsigned int color);

13 void Line(unsigned int X0,

14 unsigned int Y0,

15 unsigned int X1,

16 unsigned int Y1,

17 unsigned int color);

18 void Rectangle(unsigned int left,

19 unsigned int top,

20 unsigned int right,

21 unsigned int bottom,

22 unsigned int color);

23 #endif


9325tp.c

1 /*----------------------------------------------------------------

2 320x240彩屏液晶驅(qū)動程序

3 ----------------------------------------------------------------*/

4 #include"9325tp.h"

5 #include"reg52.h"

6 /*----------------------------------------------------------------

7 全局變量

8 ----------------------------------------------------------------*/

9 #define WINDOW_XADDR_START 0x0050 // Horizontal Start Address Set

10 #define WINDOW_XADDR_END 0x0051 // Horizontal End Address Set

11 #define WINDOW_YADDR_START 0x0052 // Vertical Start Address Set

12 #define WINDOW_YADDR_END 0x0053 // Vertical End Address Set

13 #define GRAM_XADDR 0x0020 // GRAM Horizontal Address Set

14 #define GRAM_YADDR 0x0021 // GRAM Vertical Address Set

15 #define GRAMWR 0x0022 // memory write

16

17 #define DataPort P0 //數(shù)據(jù)口使用DataPort

18

19 /*----------------------------------------------------------------

20 定義硬件端口

21 ----------------------------------------------------------------*/

22 sbit CS=P2^2; //片選

23 sbit RES=P2^1; //復(fù)位

24 sbit RS=P2^4; //數(shù)據(jù)/命令選擇

25 sbit RW=P2^5;

26 /*----------------------------------------------------------------

27 清屏函數(shù)

28 輸入?yún)?shù):bColor 清屏所使用的背景色

29 ----------------------------------------------------------------*/

30 void CLR_Screen(unsigned int bColor)

31 {

32 unsigned int i,j;

33 LCD_SetPos(0,240,0,320);//320x240

34 for (i=0;i<320;i++)

35 {

36

37 for (j=0;j<240;j++)

38 Write_Data_U16(bColor);

39

40 }

41 }

42 /*----------------------------------------------------------------

43 寫命令、寫數(shù)據(jù)

44 輸入?yún)?shù):x 需要輸入的命令 16位

45 y 需要輸入的數(shù)據(jù) 16位

46 ----------------------------------------------------------------*/

47 void Write_Cmd_Data (unsigned char x,unsigned int y)

48 {

49 unsigned char m,n;

50 m=y>>8;

51 n=y;

52 Write_Cmd(0x00,x);

53 Write_Data(m,n);

54

55 }

56

57 /*----------------------------------------------------------------

58 寫16位數(shù)據(jù)

59 ----------------------------------------------------------------*/

60 void Write_Data_U16(unsigned int y)

61 {

62 unsigned char m,n;

63 m=y>>8;

64 n=y;

65 Write_Data(m,n);

66

67 }

68 /*----------------------------------------------------------------

69 寫命令

70 ----------------------------------------------------------------*/

71

72 void Write_Cmd(unsigned char DH,unsigned char DL)

73 {

74 CS=0;

75 RS=0;

76

77 DataPort=DH;

78 RW=0;

79 RW=1;

80

81 DataPort=DL;

82

83 RW=0;

84 RW=1;

85 CS=1;

86 }

87

88 /*----------------------------------------------------------------

89 寫數(shù)據(jù) 雙8位

90 ----------------------------------------------------------------*/

91 void Write_Data(unsigned char DH,unsigned char DL)

92 {

93

94 CS=0;

95

96 RS=1;

97 DataPort=DH;

98 RW=0;

99 RW=1;

100

101 DataPort=DL;

102 RW=0;

103 RW=1;

104 CS=1;

105 }

106 /*----------------------------------------------------------------

107 延時函數(shù)

108 ----------------------------------------------------------------*/

109 void delayms(unsigned int count)

110 {

111 int i,j;

112 for(i=0;i

113 {

114 for(j=0;j<260;j++);

115 }

116 }

117 /*----------------------------------------------------------------

118 液晶初始化

119 ----------------------------------------------------------------*/

120 void ILI9325_Initial(void)

121 {

122 CS=1;

123 delayms(5);

124 RES=0;

125 delayms(5);

126 RES=1;

127 delayms(50);

128 Write_Cmd_Data(0x0001,0x0100);

129 Write_Cmd_Data(0x0002,0x0700);

130 Write_Cmd_Data(0x0003,0x1030);

131 Write_Cmd_Data(0x0004,0x0000);

132 Write_Cmd_Data(0x0008,0x0207);

133 Write_Cmd_Data(0x0009,0x0000);

134 Write_Cmd_Data(0x000A,0x0000);

135 Write_Cmd_Data(0x000C,0x0000);

136 Write_Cmd_Data(0x000D,0x0000);

137 Write_Cmd_Data(0x000F,0x0000);

138 //power on sequence VGHVGL

139 Write_Cmd_Data(0x0010,0x0000);

140 Write_Cmd_Data(0x0011,0x0007);

141 Write_Cmd_Data(0x0012,0x0000);

142 Write_Cmd_Data(0x0013,0x0000);

143 //vgh

144 Write_Cmd_Data(0x0010,0x1290);

145 Write_Cmd_Data(0x0011,0x0227);

146 //delayms(100);

147 //vregiout

148 Write_Cmd_Data(0x0012,0x001d); //0x001b

149 //delayms(100);

150 //vom amplitude

151 Write_Cmd_Data(0x0013,0x1500);

152 //delayms(100);

153 //vom H

154 Write_Cmd_Data(0x0029,0x0018);

155 Write_Cmd_Data(0x002B,0x000D);

156

157 //gamma

158 Write_Cmd_Data(0x0030,0x0004);

159 Write_Cmd_Data(0x0031,0x0307);

160 Write_Cmd_Data(0x0032,0x0002);// 0006

161 Write_Cmd_Data(0x0035,0x0206);

162 Write_Cmd_Data(0x0036,0x0408);

163 Write_Cmd_Data(0x0037,0x0507);

164 Write_Cmd_Data(0x0038,0x0204);//0200

165 Write_Cmd_Data(0x0039,0x0707);

166 Write_Cmd_Data(0x003C,0x0405);// 0504

167 Write_Cmd_Data(0x003D,0x0F02);

168 //ram

169 Write_Cmd_Data(0x0050,0x0000);

170 Write_Cmd_Data(0x0051,0x00EF);

171 Write_Cmd_Data(0x0052,0x0000);

172 Write_Cmd_Data(0x0053,0x013F);

173 Write_Cmd_Data(0x0060,0xA700);

174 Write_Cmd_Data(0x0061,0x0001);

175 Write_Cmd_Data(0x006A,0x0000);

176 //

177 Write_Cmd_Data(0x0080,0x0000);

178 Write_Cmd_Data(0x0081,0x0000);

179 Write_Cmd_Data(0x0082,0x0000);

180 Write_Cmd_Data(0x0083,0x0000);

181 Write_Cmd_Data(0x00

本站聲明: 本文章由作者或相關(guān)機構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉