1
00:00:00,750 --> 00:00:01,480
Hello.

2
00:00:01,590 --> 00:00:02,810
Welcome back.

3
00:00:02,820 --> 00:00:10,020
So in this lesson we agreed to write the function to initialize the touch sensor and then we're gonna

4
00:00:10,050 --> 00:00:11,320
test it out.

5
00:00:11,370 --> 00:00:14,650
So come over here to write a new function.

6
00:00:15,120 --> 00:00:18,290
There's going to be a void.

7
00:00:18,680 --> 00:00:24,360
I call this touch sensor or in it.

8
00:00:24,360 --> 00:00:30,470
And this is simply going to call the on the touch sense or in its function in a while.

9
00:00:30,510 --> 00:00:31,990
Both support package.

10
00:00:32,250 --> 00:00:40,820
So simply say if I access the function in our PSP I'll see if PSP PSP.

11
00:00:41,090 --> 00:00:41,440
Yeah.

12
00:00:41,490 --> 00:00:45,720
On the score T S for such say so or touch screen

13
00:00:48,690 --> 00:00:57,770
and then I'm going to initialize to 40 by 320 which is the size of the LCD screen of course.

14
00:00:57,810 --> 00:00:58,090
Yes.

15
00:00:58,110 --> 00:00:58,380
Area.

16
00:00:58,410 --> 00:01:02,070
I'm gonna see if we are able to initialize it.

17
00:01:04,080 --> 00:01:09,230
So by executing this line we initialize as well as check for error.

18
00:01:09,710 --> 00:01:10,230
Right.

19
00:01:10,230 --> 00:01:17,700
If that's the case we're simply going to print an error message see over here print f

20
00:01:22,890 --> 00:01:24,630
touch sense of failure.

21
00:01:24,690 --> 00:01:25,290
I'll go there.

22
00:01:28,660 --> 00:01:43,150
Like this and we can delay for a bit how delay put 50 over here and I'm going to take this function

23
00:01:43,150 --> 00:01:45,290
prototype to the top.

24
00:01:46,090 --> 00:01:51,440
Copy and paste over here put a semicolon here.

25
00:01:53,200 --> 00:02:00,880
So now we can call this in our main function or come to a main right off to initialize in our control

26
00:02:00,880 --> 00:02:01,330
panel.

27
00:02:01,360 --> 00:02:04,420
I'm going to initialize these types say so over here.

28
00:02:07,540 --> 00:02:16,140
Write Okay so one thing with regards to this.

29
00:02:16,150 --> 00:02:18,400
This function over here our control panel.

30
00:02:18,400 --> 00:02:22,340
I changed a color from dark yellow to black.

31
00:02:22,430 --> 00:02:30,620
This OCD color over here it sets text color used to be dark yellow and when I was taking the video and

32
00:02:30,620 --> 00:02:36,320
a photo of my microcontroller board that color wasn't clear enough for the camera so I changed it to

33
00:02:36,320 --> 00:02:36,790
black.

34
00:02:36,800 --> 00:02:42,080
So in the previous lesson if you saw a dark yellow here and it's black now.

35
00:02:42,260 --> 00:02:43,850
Yeah that's why it is black.

36
00:02:43,870 --> 00:02:45,580
Course I changed it.

37
00:02:45,620 --> 00:02:52,810
Okay so with initialized our touch saying yes or no let's call it you know what.

38
00:02:52,850 --> 00:02:54,960
Infinite Loop we can call it.

39
00:02:54,980 --> 00:02:56,060
I'll come over here.

40
00:02:56,060 --> 00:02:59,990
We have a white infinite loop here I'm going to clean our global variable that we used earlier.

41
00:03:00,020 --> 00:03:02,670
We use this for testing purposes.

42
00:03:02,730 --> 00:03:06,910
I'll come over here and then I'm gonna make use of the function in our board support package.

43
00:03:06,920 --> 00:03:12,740
I'll see BSP touch screen or touch since I'll get state

44
00:03:16,390 --> 00:03:25,690
and I'm going to I'm going to create I'm going to create an instance of the t s state typedef and pass

45
00:03:25,690 --> 00:03:27,200
it over here.

46
00:03:27,200 --> 00:03:40,110
So I'll come over here and say t s on this call state typedef you know simply call this you a state

47
00:03:43,420 --> 00:03:52,940
I'm gonna pass the address of this to our call down here put an ambush on here to grab the address put

48
00:03:52,940 --> 00:03:55,250
a semicolon here right.

49
00:03:55,760 --> 00:04:07,820
So we going to get state and then we can simply grow a circle or we can simply draw us we detect.

50
00:04:07,820 --> 00:04:15,560
So what I'm going to do is I'm going to still come in here or should I write a new function for this.

51
00:04:15,580 --> 00:04:15,890
Okay.

52
00:04:15,890 --> 00:04:17,360
We can keep it here.

53
00:04:17,360 --> 00:04:24,700
I'm gonna say if you I state you I state got touched detected.

54
00:04:25,460 --> 00:04:27,760
If touch is detected.

55
00:04:32,240 --> 00:04:36,890
I'm simply going to draw a circle or border.

56
00:04:37,140 --> 00:04:43,550
I'll say BSP PSP underscore LCD underscore

57
00:04:46,690 --> 00:04:48,020
full circle.

58
00:04:49,910 --> 00:04:59,020
And then I'm going to draw the circle at the position so I'll see you I states dot X and then you isolate

59
00:04:59,060 --> 00:05:04,490
the Y and then I'm gonna pass size 5 over here like this.

60
00:05:04,490 --> 00:05:07,770
Okay let's build and see what we have.

61
00:05:07,820 --> 00:05:09,020
Click over here to build

62
00:05:13,510 --> 00:05:22,050
it's built successfully or connect my port and download a quick run and then debug over here.

63
00:05:29,020 --> 00:05:29,590
Okay.

64
00:05:33,170 --> 00:05:34,080
It's setting up

65
00:05:37,300 --> 00:05:39,140
okay download complete.

66
00:05:39,190 --> 00:05:41,040
I'm simply going to turn it off.

67
00:05:41,050 --> 00:05:47,920
I'll terminate and then press reset on my microcontroller board the block button

68
00:05:51,790 --> 00:05:54,280
and then I'm gonna test the touchscreen

69
00:05:57,780 --> 00:06:01,250
I'm simply going to attempt to write something here.

70
00:06:02,690 --> 00:06:03,600
Um yeah.

71
00:06:03,630 --> 00:06:13,380
It's work in but it s a bit like in it s not flowing smoothly so we may have to debug somethin.

72
00:06:13,730 --> 00:06:18,720
You see I'm trying to write to 6 but it s not perfect.

73
00:06:18,800 --> 00:06:23,570
So the c word the error lies.

74
00:06:23,710 --> 00:06:29,770
Okay um I suspect the cause of the sluggishness is from this function over here.

75
00:06:29,780 --> 00:06:36,680
We can comment this out for now we're going to deal with it later and I'm going to add a bit of delay

76
00:06:36,680 --> 00:06:38,690
down here.

77
00:06:39,950 --> 00:06:43,850
Once we you know grow the um the picture.

78
00:06:43,940 --> 00:06:45,320
Where you going to just delete

79
00:06:49,520 --> 00:06:53,680
delay 1 over here okay.

80
00:06:53,780 --> 00:06:59,590
No no C from the top or we have to have this the addresses of the LCD.

81
00:07:00,320 --> 00:07:02,530
Oh this one here is missing a zero as well.

82
00:07:03,680 --> 00:07:06,540
Okay let's build it see what we have now.

83
00:07:08,420 --> 00:07:09,680
Click over here to build

84
00:07:19,710 --> 00:07:24,470
and then click here debug to download onto the port

85
00:07:29,050 --> 00:07:29,910
it's downloaded

86
00:07:44,770 --> 00:07:45,900
it's still downloading

87
00:07:57,050 --> 00:07:58,570
the download should be complete.

88
00:07:58,580 --> 00:07:58,910
No.

89
00:08:00,980 --> 00:08:04,790
Okay I'm gonna click here to run

90
00:08:09,520 --> 00:08:11,050
she can see the LCD screen.

91
00:08:11,050 --> 00:08:12,330
This is it.

92
00:08:12,400 --> 00:08:14,520
I'm gonna attempt to draw something.

93
00:08:14,770 --> 00:08:15,870
No it's smooth.

94
00:08:15,940 --> 00:08:20,800
I just drew a 6 when I reset to my port right.

95
00:08:20,800 --> 00:08:26,390
1 reset to my board and then 2.

96
00:08:26,740 --> 00:08:33,470
In fact I'm gonna use a pointer to do this 6 3

97
00:08:36,200 --> 00:08:39,040
2 Okay.

98
00:08:39,610 --> 00:08:42,730
So now it s smooth and working perfectly.

99
00:08:42,760 --> 00:08:43,720
Um yeah.

100
00:08:43,750 --> 00:08:45,330
So the button doesn't work.

101
00:08:45,340 --> 00:08:46,050
Now.

102
00:08:46,420 --> 00:08:47,710
That's what we're going to do next.

103
00:08:47,710 --> 00:08:55,720
We're going to isolate the bottom half of the screen from the top where we write so that we can we can

104
00:08:55,720 --> 00:09:00,650
sort of press the reset button and have the screen you know erased.

105
00:09:00,670 --> 00:09:02,930
So that's what we'll do next.

106
00:09:03,130 --> 00:09:05,620
I'm going to exit that burger from over here

107
00:09:10,780 --> 00:09:11,630
right.

108
00:09:11,650 --> 00:09:20,500
So like I said we are going to separate the Boston area of the of this crane from the part where we

109
00:09:20,500 --> 00:09:21,130
draw.

110
00:09:21,260 --> 00:09:28,960
I'm gonna use a simple if statement over here I'm going to see if and I'll see you.

111
00:09:28,960 --> 00:09:31,450
I do it okay.

112
00:09:31,450 --> 00:09:31,950
It's called.

113
00:09:31,970 --> 00:09:39,310
You state you I state that if you I state DOT x is greater than

114
00:09:42,370 --> 00:09:42,920
the draw.

115
00:09:42,920 --> 00:09:47,360
I m g we have we have a symbolic name that we call draw.

116
00:09:47,360 --> 00:09:49,610
I m g X1 to draw.

117
00:09:49,610 --> 00:09:56,050
I m g X1 if it s greater than this.

118
00:09:56,050 --> 00:10:07,840
And you I state that X is less than X to just complete this

119
00:10:19,410 --> 00:10:20,930
if it is less than x 2.

120
00:10:22,590 --> 00:10:26,600
And we've got a check for y as well.

121
00:10:26,590 --> 00:10:27,120
And

122
00:10:34,380 --> 00:10:40,530
and I'll simply say you I Stage 1 Stage Two y

123
00:10:43,400 --> 00:10:44,980
s greater than y one

124
00:10:56,120 --> 00:10:58,170
and less than y.

125
00:11:18,100 --> 00:11:19,620
Why you like this.

126
00:11:20,680 --> 00:11:23,060
Why not put brackets here.

127
00:11:25,190 --> 00:11:25,930
Yes you are.

128
00:11:25,940 --> 00:11:38,190
We have you I state X if you have state X is greater than X one and less than X 2 and it's greater than

129
00:11:39,210 --> 00:11:39,930
any other state.

130
00:11:39,930 --> 00:11:43,170
Y is in the way I see it.

131
00:11:43,170 --> 00:11:47,080
Why is greater than why one does sprockets should come up here

132
00:11:50,340 --> 00:11:51,220
and your state.

133
00:11:51,220 --> 00:11:56,670
Why is greater than why one and I state why is less than Why two.

134
00:11:57,010 --> 00:11:59,130
If that's the case then we uh.

135
00:11:59,140 --> 00:12:06,700
In the um we're in the growing area.

136
00:12:06,740 --> 00:12:14,450
So in the groin area we simply perform our groin which we have over here feel.

137
00:12:14,540 --> 00:12:15,220
Circle

138
00:12:18,650 --> 00:12:25,330
ls we've got up put on else for the Portland area so I'll come over here and see who else

139
00:12:28,930 --> 00:12:34,840
if you I state got x

140
00:12:37,800 --> 00:12:46,890
is greater than you raise button cos we have a symbolic name known as erase button X as well say erase

141
00:12:46,890 --> 00:12:48,810
button on the score x 1

142
00:12:51,550 --> 00:12:55,540
and you y.

143
00:12:55,870 --> 00:12:57,610
State X

144
00:13:01,850 --> 00:13:06,350
is less than a race button x 2

145
00:13:12,120 --> 00:13:13,210
Just fudge this

146
00:13:18,040 --> 00:13:26,950
and then we do the same for y and you y state Y

147
00:13:29,730 --> 00:13:32,230
is created than erase button y 1

148
00:13:41,470 --> 00:13:52,010
and you I state that y s s done erase button y 2

149
00:13:58,870 --> 00:14:04,060
if that's the case then we kinda erase zone see why do we have

150
00:14:06,950 --> 00:14:09,370
a problem.

151
00:14:09,740 --> 00:14:19,060
I'm simply going to open and close over here so let's check it you I state X is created on x 1 and US

152
00:14:19,090 --> 00:14:23,180
states X is less than X 2 Over here it should be.

153
00:14:24,340 --> 00:14:32,440
And then you y states Y is created and Y 1 and you y states Y is less than y 2.

154
00:14:32,530 --> 00:14:46,260
If this is the case we are going to reset the game or cloud a UI and now we cleared a UI by taking it

155
00:14:46,260 --> 00:14:50,760
to its default state which is control panel set over here.

156
00:14:50,820 --> 00:14:53,190
Already have this we've created this function already

157
00:14:55,750 --> 00:14:58,500
so I'll just paste this over here.

158
00:14:58,930 --> 00:15:00,880
Now let's build and see what we have.

159
00:15:00,900 --> 00:15:02,070
Click over here to build

160
00:15:14,000 --> 00:15:24,200
okay and then I'm going to click over here to run by clicking on debug it s finished the book and I'm

161
00:15:24,200 --> 00:15:29,610
going to click here to run and um.

162
00:15:29,920 --> 00:15:30,840
Let's see.

163
00:15:30,840 --> 00:15:34,510
Ron my board is frozen.

164
00:15:34,520 --> 00:15:39,400
So I've got a text my board and put it back into the computer.

165
00:15:39,440 --> 00:15:41,580
Sometimes I get this for the touch screen.

166
00:15:43,070 --> 00:15:44,580
So here we go.

167
00:15:44,580 --> 00:15:49,930
I've reset my port as you can see it looks the same.

168
00:15:49,940 --> 00:15:55,920
Now I'm gonna write six and then I'm gonna press erase it s clean.

169
00:15:56,480 --> 00:16:04,900
I'm gonna use a pointer to write a right to then I'll click you one raise three.

170
00:16:05,000 --> 00:16:08,190
You rage just like that.

171
00:16:08,410 --> 00:16:11,060
So the race button works.

172
00:16:11,300 --> 00:16:14,860
Okay then right.

173
00:16:14,940 --> 00:16:21,810
So in the next lesson what are we going to do is we going to take whatever we write over here in a large

174
00:16:21,810 --> 00:16:25,440
area and shrink it to a twenty eight by twenty eight size.
