1
00:00:01,000 --> 00:00:01,400
Hello.

2
00:00:01,500 --> 00:00:02,070
Welcome back.

3
00:00:02,610 --> 00:00:08,850
So in this lesson like we said we are keen to take whatever we draw on the screen and scale it down

4
00:00:08,850 --> 00:00:12,930
to fit into the smaller square.

5
00:00:13,230 --> 00:00:15,480
We scale it down to 28 by 28.

6
00:00:15,480 --> 00:00:22,110
And this would show us how this thing that we've drawn or written appears sometimes you draw something

7
00:00:22,500 --> 00:00:23,520
that's not so clear.

8
00:00:23,520 --> 00:00:30,780
And when you shrink it down it looks almost you find it almost unable to recognize.

9
00:00:30,870 --> 00:00:36,460
So by having this way of seeing what it appears in a smaller version we will be able to tell whether

10
00:00:36,630 --> 00:00:39,270
you know on your network is seeing what we are seeing.

11
00:00:39,990 --> 00:00:40,520
Okay.

12
00:00:40,590 --> 00:00:43,040
So I'm going to come over here.

13
00:00:43,050 --> 00:00:50,430
This is our wall one loop over here we get a state of the touch screen and then we check the area in

14
00:00:50,430 --> 00:00:51,810
which the touch occurred.

15
00:00:51,900 --> 00:01:00,840
And based on that we either draw or we clean the entire screen and we do a clean by simply calling our

16
00:01:01,530 --> 00:01:08,340
panel set or reset one would say I think an appropriate name for this should be reset or changes to

17
00:01:08,340 --> 00:01:11,240
reset over here.

18
00:01:11,400 --> 00:01:18,300
I've got to change the name of the function as well as the prototype as well right over here.

19
00:01:18,310 --> 00:01:23,430
Reset should be up here somewhere as well.

20
00:01:23,710 --> 00:01:27,670
Reset over here.

21
00:01:27,670 --> 00:01:28,310
Right.

22
00:01:29,560 --> 00:01:32,760
So um the work for today.

23
00:01:32,800 --> 00:01:43,000
So I'm gonna create two local variables I'll say int x and then X is basically going to take you I state

24
00:01:43,330 --> 00:01:53,140
that you I on this core state DOT y and then we multiply it by this we will perform the scale using

25
00:01:53,170 --> 00:02:01,000
this equation to get it x that we're going to store in the smaller square we take you I state that y

26
00:02:01,120 --> 00:02:10,570
and then we multiply it by and then we multiply it by twenty eight divided by two hundred and forty

27
00:02:10,930 --> 00:02:21,020
because the original image sizes two hundred and forty um we have this over here the LCD input image

28
00:02:21,060 --> 00:02:30,920
into this these are two hundred and forty is um Okay so once that is done we've got a typecast this

29
00:02:30,920 --> 00:02:38,200
to a float and then we going to create the small y as well.

30
00:02:38,210 --> 00:02:44,890
This is X we grab you y y and then we do each x if we use X here we realized that that image is gonna

31
00:02:44,900 --> 00:02:51,790
be rotated and you can try that or we'll try to if we want if we apply X here for the scaling together

32
00:02:51,830 --> 00:02:57,230
small x the image will be rotated so you say you a state

33
00:03:00,350 --> 00:03:04,100
DOT X over here and then this also multiply by

34
00:03:06,800 --> 00:03:09,690
thing as you use the symbolic names we used to here

35
00:03:27,060 --> 00:03:32,860
Yeah or maybe this is too long anyone you want you can need use the symbolic name so just keep it short

36
00:03:33,560 --> 00:03:34,480
No way.

37
00:03:34,590 --> 00:03:38,970
So this is going to be the same since the image is a square shaped image

38
00:03:44,070 --> 00:03:48,130
she missed in brackets.

39
00:03:48,480 --> 00:03:48,780
Right.

40
00:03:48,810 --> 00:03:54,350
So these scaling factors will be used for the um the.

41
00:03:54,390 --> 00:03:57,990
The image we redraw in the smaller square.

42
00:03:57,990 --> 00:04:04,140
And what is going to happen is we need to shift the pixels as well cos the square is on the other side

43
00:04:04,140 --> 00:04:05,060
of the screen.

44
00:04:05,070 --> 00:04:13,260
It s quite particular position and that is why we created this um I think we've created a symbolic name

45
00:04:13,260 --> 00:04:14,870
here.

46
00:04:14,880 --> 00:04:16,740
If we've not created a symbolic name.

47
00:04:17,210 --> 00:04:23,880
OK we have this symbolic name that we said I am just killed X shift and then right.

48
00:04:24,090 --> 00:04:27,210
So I'm gonna copy this code X shift

49
00:04:30,720 --> 00:04:32,920
we already use this code X shift

50
00:04:37,150 --> 00:04:39,880
let's see uh.

51
00:04:40,030 --> 00:04:41,440
Yeah we've not used that yet.

52
00:04:41,620 --> 00:04:44,940
So where are we.

53
00:04:44,940 --> 00:04:46,240
It's over here.

54
00:04:46,240 --> 00:04:48,050
So we are going to draw the pixels.

55
00:04:48,070 --> 00:04:49,400
Just bear with me.

56
00:04:49,600 --> 00:05:03,100
So we see BSP we use our PSP LCD pixel draw LCD grow pixel function and then we're gonna say we to draw

57
00:05:03,130 --> 00:05:10,410
pixel we go through a number of sequence you need to follow this we first you take the wife I do not

58
00:05:10,420 --> 00:05:21,760
want to it plus the shift amount which is the X shift amount and then this will give us the exposition

59
00:05:25,420 --> 00:05:38,530
and then take the shift amount for Y we have a symbolic name called I empty scaled y shift as well at

60
00:05:38,530 --> 00:05:39,280
1 2 it

61
00:05:42,180 --> 00:05:52,050
and then 2 5 5 over here and you can take a look at this function it should be able to tell us so BSB

62
00:05:52,050 --> 00:05:58,920
LCD draw pixel The first argument is the exposition the second argument is the y position the last argument

63
00:05:58,920 --> 00:06:05,950
is the pixel color or the Archie B code so I simply passed to forty five here.

64
00:06:05,970 --> 00:06:12,990
So once this is done we can simply copy and paste this and B shift in the y appropriately and I'll explain

65
00:06:12,990 --> 00:06:14,050
what I mean.

66
00:06:14,160 --> 00:06:21,050
So I'm gonna copy this paste this over here and this time I'm gonna see Y minus one to paint the um

67
00:06:21,080 --> 00:06:22,500
the pixel on the other side

68
00:06:25,140 --> 00:06:39,240
over here rather than simply two plus one I'm gonna do LCD skilled why shift plus X plus one that X

69
00:06:39,240 --> 00:06:48,630
over here such that over here are two plus X minus one right and then I'm gonna copy and paste

70
00:06:53,600 --> 00:07:04,840
and this time I'm going to and when I do y plus 1 again I'll bother and then on the X side I'm going

71
00:07:04,840 --> 00:07:07,100
to do simply x plus 1

72
00:07:11,200 --> 00:07:12,560
simply x.

73
00:07:13,030 --> 00:07:19,990
So we have different variations would we first would do y plus one on this side X plus one Y minus one

74
00:07:20,260 --> 00:07:29,890
X minus one Now y plus one simply X and you see how this sort of you know draws the pixels and when

75
00:07:30,050 --> 00:07:36,520
it would take a look at it if the pixel is not clay enough would draw more pixels in the neighborhood

76
00:07:36,880 --> 00:07:48,340
I should say let's see I'm going to add one more or do Y minus one and then and then minus one Yeah

77
00:07:48,370 --> 00:07:57,090
we have Y plus one so we can do Y minus one paste is I'll do Y minus one and simply X over here okay

78
00:07:59,010 --> 00:08:05,520
I think yeah we can check what this looks like a click over here to build it's a bit weird in

79
00:08:10,570 --> 00:08:12,020
and of course you error.

80
00:08:12,700 --> 00:08:15,050
Okay.

81
00:08:15,220 --> 00:08:21,460
Debug click over here debug it s download and onto the port.

82
00:08:21,750 --> 00:08:24,140
I have reset my board now.

83
00:08:24,160 --> 00:08:33,900
I'm gonna write a full as you can see this as its appearance in the um in the smaller square.

84
00:08:34,090 --> 00:08:35,560
This its appearance.

85
00:08:35,710 --> 00:08:37,920
You can see it's not too clear.

86
00:08:38,080 --> 00:08:41,170
It's as if we are mixing uh we are missing certain pixels.

87
00:08:41,560 --> 00:08:45,190
The line is not too clear.

88
00:08:45,220 --> 00:08:46,080
Let's see.

89
00:08:46,710 --> 00:08:47,400
Yeah right.

90
00:08:47,410 --> 00:08:48,430
I'm going to raise

91
00:08:51,190 --> 00:08:56,350
and then write to you right.

92
00:08:56,440 --> 00:08:58,910
So I'm going to add more pixels to be drawn.

93
00:08:58,970 --> 00:09:01,900
Okay so let's draw more pixels.

94
00:09:02,050 --> 00:09:03,820
I'm gonna come over here.

95
00:09:05,080 --> 00:09:06,830
Um I'll paste.

96
00:09:06,850 --> 00:09:08,470
Course I still have my clipboard.

97
00:09:08,530 --> 00:09:09,860
Paste it.

98
00:09:10,150 --> 00:09:12,810
And um this time I'm going to start with.

99
00:09:12,820 --> 00:09:20,560
I'll see y plus inmates killed X and then on the y side I'll do x plus one over here

100
00:09:26,090 --> 00:09:28,310
or simply do X or Y.

101
00:09:29,610 --> 00:09:33,820
And then I'm going to do Y plus X plus one next.

102
00:09:34,230 --> 00:09:35,240
I could've just kept it.

103
00:09:35,270 --> 00:09:46,560
But let's follow this sequence so y plus image scale would X shift and then comma Y shift plus X plus

104
00:09:46,560 --> 00:09:50,950
one I would say over here and we can do X minus one.

105
00:09:50,960 --> 00:10:01,200
Next page this over here and then we have y plus y plus.

106
00:10:01,260 --> 00:10:08,550
The third one so we can still do y plus image skilled X shift and then on the y side we can do X minus

107
00:10:08,550 --> 00:10:12,330
one right.

108
00:10:12,450 --> 00:10:14,970
We can add two more.

109
00:10:15,510 --> 00:10:20,770
I'm going to do Y plus one over here.

110
00:10:21,000 --> 00:10:21,570
Y.

111
00:10:21,600 --> 00:10:22,470
Plus 1

112
00:10:25,550 --> 00:10:29,210
and then I'll leave the X minus 1 the same.

113
00:10:29,240 --> 00:10:32,210
And then lastly we can do X plus 1 y minus 1.

114
00:10:33,830 --> 00:10:48,230
Yeah then this should clear up the image Y minus one over here Y minus one plus I M G right.

115
00:10:48,410 --> 00:10:51,820
And over here we can do X plus 1

116
00:10:59,640 --> 00:11:00,080
Okay.

117
00:11:00,270 --> 00:11:04,200
Let's see what EMH looks like now when I click over here to build

118
00:11:12,810 --> 00:11:13,540
okay.

119
00:11:13,560 --> 00:11:15,720
Click here to download click debug

120
00:11:20,680 --> 00:11:21,560
all right.

121
00:11:21,580 --> 00:11:25,600
It's downloaded and I have reset my board.

122
00:11:25,630 --> 00:11:28,080
Let's see what it looks like.

123
00:11:28,390 --> 00:11:29,770
So I write to 4.

124
00:11:30,040 --> 00:11:30,670
Okay.

125
00:11:30,760 --> 00:11:35,050
It's coming out of this choir so there's a problem somewhere.

126
00:11:35,950 --> 00:11:36,620
Okay.

127
00:11:36,640 --> 00:11:39,580
It's giving me a mirrored version of the image.

128
00:11:39,610 --> 00:11:44,390
Okay let's see where the arrow is in our code right.

129
00:11:44,410 --> 00:11:47,610
The issue is with the x position it is.

130
00:11:47,620 --> 00:11:54,110
I think these two lines here ought to be image scaled.

131
00:11:54,100 --> 00:11:56,530
Y plus X minus one.

132
00:11:57,160 --> 00:12:10,470
So I'm simply going to do plus X minus one over here and then plus X minus one click it to build it

133
00:12:10,470 --> 00:12:11,830
s appeal successfully.

134
00:12:11,830 --> 00:12:18,650
Click here download to download in F reset my board.

135
00:12:18,970 --> 00:12:22,510
Let's see what we have.

136
00:12:23,080 --> 00:12:23,750
Okay.

137
00:12:23,800 --> 00:12:28,810
Now when I write the four you can see it's very clear in the smaller square.

138
00:12:30,100 --> 00:12:33,140
Okay let me try five.

139
00:12:33,250 --> 00:12:34,870
This is very clever as well.

140
00:12:34,870 --> 00:12:39,370
It's just an image a smaller version of exactly what I wrote.

141
00:12:39,400 --> 00:12:43,020
You don't find any white lines between the black lines.

142
00:12:43,330 --> 00:12:45,780
Okay so looking good so far.

143
00:12:46,980 --> 00:12:47,630
Right.
