Hello.
Welcome back.
So in this lesson like we said we are keen to take whatever we draw on the screen and scale it down
to fit into the smaller square.
We scale it down to 28 by 28.
And this would show us how this thing that we've drawn or written appears sometimes you draw something
that's not so clear.
And when you shrink it down it looks almost you find it almost unable to recognize.
So by having this way of seeing what it appears in a smaller version we will be able to tell whether
you know on your network is seeing what we are seeing.
Okay.
So I'm going to come over here.
This is our wall one loop over here we get a state of the touch screen and then we check the area in
which the touch occurred.
And based on that we either draw or we clean the entire screen and we do a clean by simply calling our
panel set or reset one would say I think an appropriate name for this should be reset or changes to
reset over here.
I've got to change the name of the function as well as the prototype as well right over here.
Reset should be up here somewhere as well.
Reset over here.
Right.
So um the work for today.
So I'm gonna create two local variables I'll say int x and then X is basically going to take you I state
that you I on this core state DOT y and then we multiply it by this we will perform the scale using
this equation to get it x that we're going to store in the smaller square we take you I state that y
and then we multiply it by and then we multiply it by twenty eight divided by two hundred and forty
because the original image sizes two hundred and forty um we have this over here the LCD input image
into this these are two hundred and forty is um Okay so once that is done we've got a typecast this
to a float and then we going to create the small y as well.
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
be rotated and you can try that or we'll try to if we want if we apply X here for the scaling together
small x the image will be rotated so you say you a state
DOT X over here and then this also multiply by
thing as you use the symbolic names we used to here
Yeah or maybe this is too long anyone you want you can need use the symbolic name so just keep it short
No way.
So this is going to be the same since the image is a square shaped image
she missed in brackets.
Right.
So these scaling factors will be used for the um the.
The image we redraw in the smaller square.
And what is going to happen is we need to shift the pixels as well cos the square is on the other side
of the screen.
It s quite particular position and that is why we created this um I think we've created a symbolic name
here.
If we've not created a symbolic name.
OK we have this symbolic name that we said I am just killed X shift and then right.
So I'm gonna copy this code X shift
we already use this code X shift
let's see uh.
Yeah we've not used that yet.
So where are we.
It's over here.
So we are going to draw the pixels.
Just bear with me.
So we see BSP we use our PSP LCD pixel draw LCD grow pixel function and then we're gonna say we to draw
pixel we go through a number of sequence you need to follow this we first you take the wife I do not
want to it plus the shift amount which is the X shift amount and then this will give us the exposition
and then take the shift amount for Y we have a symbolic name called I empty scaled y shift as well at
1 2 it
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
LCD draw pixel The first argument is the exposition the second argument is the y position the last argument
is the pixel color or the Archie B code so I simply passed to forty five here.
So once this is done we can simply copy and paste this and B shift in the y appropriately and I'll explain
what I mean.
So I'm gonna copy this paste this over here and this time I'm gonna see Y minus one to paint the um
the pixel on the other side
over here rather than simply two plus one I'm gonna do LCD skilled why shift plus X plus one that X
over here such that over here are two plus X minus one right and then I'm gonna copy and paste
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
to do simply x plus 1
simply x.
So we have different variations would we first would do y plus one on this side X plus one Y minus one
X minus one Now y plus one simply X and you see how this sort of you know draws the pixels and when
it would take a look at it if the pixel is not clay enough would draw more pixels in the neighborhood
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
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
I think yeah we can check what this looks like a click over here to build it's a bit weird in
and of course you error.
Okay.
Debug click over here debug it s download and onto the port.
I have reset my board now.
I'm gonna write a full as you can see this as its appearance in the um in the smaller square.
This its appearance.
You can see it's not too clear.
It's as if we are mixing uh we are missing certain pixels.
The line is not too clear.
Let's see.
Yeah right.
I'm going to raise
and then write to you right.
So I'm going to add more pixels to be drawn.
Okay so let's draw more pixels.
I'm gonna come over here.
Um I'll paste.
Course I still have my clipboard.
Paste it.
And um this time I'm going to start with.
I'll see y plus inmates killed X and then on the y side I'll do x plus one over here
or simply do X or Y.
And then I'm going to do Y plus X plus one next.
I could've just kept it.
But let's follow this sequence so y plus image scale would X shift and then comma Y shift plus X plus
one I would say over here and we can do X minus one.
Next page this over here and then we have y plus y plus.
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
one right.
We can add two more.
I'm going to do Y plus one over here.
Y.
Plus 1
and then I'll leave the X minus 1 the same.
And then lastly we can do X plus 1 y minus 1.
Yeah then this should clear up the image Y minus one over here Y minus one plus I M G right.
And over here we can do X plus 1
Okay.
Let's see what EMH looks like now when I click over here to build
okay.
Click here to download click debug
all right.
It's downloaded and I have reset my board.
Let's see what it looks like.
So I write to 4.
Okay.
It's coming out of this choir so there's a problem somewhere.
Okay.
It's giving me a mirrored version of the image.
Okay let's see where the arrow is in our code right.
The issue is with the x position it is.
I think these two lines here ought to be image scaled.
Y plus X minus one.
So I'm simply going to do plus X minus one over here and then plus X minus one click it to build it
s appeal successfully.
Click here download to download in F reset my board.
Let's see what we have.
Okay.
Now when I write the four you can see it's very clear in the smaller square.
Okay let me try five.
This is very clever as well.
It's just an image a smaller version of exactly what I wrote.
You don't find any white lines between the black lines.
Okay so looking good so far.
Right.