Hello.
So um we're going to implement printer functionality and then we continue.
I'll start off by saying include
or know that h we might require this and then also say include
says slush.
You NIST D dot H and then O include a string dot h as well over here
then a study I would on h
I'm going to write a simple function here to allow us to be able to send strings come.
Oh put it somewhere here.
This is fine.
The function is a very simple function
this is end on the score.
Call us right and then we'll see in FDR over here and then close down the void.
The pointer to a buffer and simply int
in C is fine open and close over here.
It's closed already.
I'm gonna create a new variable here.
We'll see how studies typedef call this s.t. for starters and I'll simply say SD because I'll use the
whole u out function.
How you got on the score cross MIT and then we pass the U R ton dollar which is h u r t 1 and then the
data is in the buffer plus or we type.
We um we typecast this this first you end 8 on the score t star and then pass buff over here then I'm
gonna pass C overhand and I'm gonna pass the maximum delay by saying ha ha on the score Max delay
and then we're going to return
esta e course return I'll see a return SD equals E course.
Okay.
Then C Ls 0 like this.
Okay so let's build this and see what we have.
And um I'm gonna come over here and write enough
Hello World Center jar a percentage and right click over here to build
it appeared successfully click over here debug
say remember my decision so that I wouldn't have to click this all the time.
It's loaded
I'm going to open my 0 program Tera term
okay.
See this is terror term I'm gonna come over here.
I select as the microelectronics stealing federal comm then I'm going to set it bot rate which we saw
in our Cuba makes us 1 1 5 2 0 as you said is true.
OK
I'll step through the code and see what we have.
Step over
now we get into the print if I see.
Okay.
As you can see over here we have.
Hello world.
Right.
I could assume this in a bit but this a quick test.
So when we use this often no zoom it in.
Now we can use print off basically.
So that's all there is for this lesson if you have any questions at all.
Just let me know.
So let's begin to you I by define into some constants that we are going to be using we are going to
sort of dedicate a large portion of the screen.
Actually we're going to.
Let me say dedicate about 90 percent of the screen for the touch screen.
What do I mean.
Okay.
We're going to dedicate 90 percent of the screen for the portion where you draw your number.
And then the other 10 percent.
We're going to put a button there to allow us to clean and reset the game so let's just create constants
for these.
And also we've got a great Constanta for the frame buffer.
The LCD frame buffer and other things gonna come up here and put a number of defined statements.
I'll start off by
remember the end.
The amnesty data set takes a twenty eight by twenty eight pixel image as inputs.
So I'm going to come over here and see it.
Define an end for neural network input and then image with
a score with a past twenty eight over here and then the height is twenty eight as well.
So this is going to be the input image to our neural network right next the LCD input image.
We're going to have an image that will grow on the LCD.
I'm going to make those I'm gonna make that image 240 by 240.
This big image that we draw on the entire LCD screen is going to be scaled down to 28 by 28.
So I'm gonna have to 40 by 240 Yeah.
And then next I'm going to include the the LCD frame buffer.
The LCD frame buffer.
We're going to have to we're going to have two layers.
We're going to initialize our LCD to use two layers layer zero and the are one.
So um I'm gonna define those and I wouldn't get too much into the LCD to drive by here in the future.
Yeah.
In the future I would make a course on embedded systems graphic user interface.
And in the we would go in-depth about LCD drivers and how to create you know more than you I element
on it and on embedded devices.
So I say LCD frame buffer on this call layer 0
0 simply um.
Yeah.
This information can be um got from the from the data sheet
we'll have LCD iframe portfolio zero and then we'll have LCD frame buffer layer 1 and then we would
have LCD frame buffer
outside the frame buffer right here.
Like it actually LCD frame buffer is declared in our OCD driver.
So we need not declare this.
So I'm simply going to copy LCD frame buffer and set layer 1 2 the same as the default LCD if frame
buffer and then layer 0 is going to be an offset from this.
I'm gonna see LCD frame buffer plus 0 x
0 x 1 3 and then 4 zeros after that
open and then close and then I'm gonna have LCD converted frame buffer here.
And this is also going to be an offset from LCD frame buffer.
This is going to be 0 x
2 6 0 0
right.
So we're going to define another constant known as Umm.
We're going to define positions for um for x and y image as well as buttons.
Or come over here and see the draw.
I m g x.
Call this one.
Mm hmm.
This is going to be like the starting position D.
That s position of the of the screen where we want to grow a Y number.
You to see when this goes into practice.
Oh see.
Define
uh grow.
I m g.
On the score x 1.
We're gonna start at 10 and then define
draw on the score.
I m g on the score X to there's gonna be two hundred
or two thirty let's do it two thirty.
Then I'm gonna do this for y as well
this over here.
Shouldn't have but this should be LCD input image.
This is different from the image that goes into the neural network.
Okay so this is two forty two forty.
This is ten ten.
Okay.
Um yeah.
So once that is done we are going to um we're gonna have a button that we call your raise button to
erase or cleared a screen if you may also define
your res underscore button on a scale X1
0 start this at x1 position 5 and then define
UV rays proton y 1
the position of 4 this is going to be two eighty five
and then
said defined
erase button
underscore x 2 and this is simply you raise the next one plus the um the width of the button we want
to use.
We can give it with up to 30.
This would be plus 230 here and then we can do the same for Y to
change this over here to y one at this time plus 30.
Right.
And then we're going to have a miniature size version of the image.
So what's going to happen is when we draw a number on the LCD screen we're going to scan it down to
what it would appear like to the neural network.
And in order to bring that to life Oh create to some other defined statement here today to hold some
of the constants required.
I'll say define
empty.
Code X shift
and this shift is gonna be two hundred and then we see a define
I m g s killed y shift.
This shift is gonna be two fifty right now.
Yeah but look almost complete.
We're going to s defined a number of labels we have as well or number of classes.
Remember the M S data set.
Labels are 0 1 2 3 4 5 6 7 8 9.
So we've got 10 labels or 10 classes whatever you want to call it.
I'll say define num on the school classes
plus the number 10 here and then I'm going to have another statement another defining statement here.
Define this I'll call Picasso said
and then I'm simply gonna say zero point nine nine over here like this right.
Okay so we've got these defined statements.
Okay.
So I'm gonna come down here and create a function called user interface and it start off by saying void
user interface
underscore a net
plus void over here open and then close.
So we start off by initializing the LCD using the function in our board support package.
So see PSP on the score LCD on the score in it.
Once that is done we are going to end it earlier.
I'm going to start off by going to continue by saying BSP I say BSP and go LCD underscore layer before
it's in it.
All these functions exist in the broad support package that we included plus one here.
That's the face I comment and then I'm going to use frame buffer layer 1 see LCD
on the score frame buffer.
And the score
layer 1.
Here like this.
And then once I start I'm going to select layer 0 2 BSP on a score LCD.
Like I said I'm going to go pretty fast on the LCD.
Oh silly functions because the course is not about developing LCD drivers.
If you have any questions you can certainly send me a message.
But things like this require courses on their own so I just explain as I type where I think explanation
will be useful.
Just bear with me.
Uh yeah.
Don't take shots at me in the review section like some of you like to do nowadays.
Um.
So we've got the PSP LCD select layer and then once that is done we can set the layer color.
We can.
Yeah.
What color should we use.
Well I've got a number of colors I see say BSP.
Let's see what Red would look like.
PSP SB underscore LSC declare war cry it out and see if it doesn't look really good.
We can always change it PSP LV LCD Claire I'm gonna see LCD color I'll pass right over here and then
we green to set the color key in the same PSP
LCD
set.
Color keen
one.
And then we said a color to.
Yeah.
Decided on colors to use.
Well oh just see LCD uh school color.
We can use that sign.
It s exists.
Dark Side.
Oh this
um.
This layer is not going to be much visible so fucked it wouldn't matter much.
Okay.
Once we've done this we going to disable the layer visibility.
I say BSP on the score
LCD underscore
sets layer visible.
Because we're gonna have another layer.
Which.
Yeah.
So that s layer visible pass one over here and then you say well what I do not like you bro.
This cube makes 80 years you do not get help when you are typing I don't know what a particular plugin
is required for that.
But wait to call your vision as you type you just get help and you hit space and it completes for you.
Um yeah.
So.
So let's go to another layer layer 0.
So BSP.
On a score LCD underscore
layer.
Default in it.
And then 0 over here.
And then we're gonna pass LCD on a score frame buffer on a score.
You like this.
Now we're gonna see PSP on a score LCD on a score
select layer no pass here over here and then turn on the display PSP and a score LCD on a score
display on.
And then we can wait for a while.
Oh delay.
Gonna give one fifty four here and then we can play PSP on the score.
Oh city on the score there and then LCD on the score color on this score.
Pass light Sy in here.
And then we can delay a bit as well.
So on this court delay
can delay for 100 here.
So this is going to be in its function for you.
I write I'm going to copy this.
It's a prototype at the top over here.
We're going to have a control panel as well.
Oh just bring the code.
I'll copy and paste the function for that um.
Write it down type it one by one.
So that's why the control panel is going to look like.
Well you don't see it.
No.
But yeah this is the code to generate our control panel.
We're going to have a text a text that will simply read a I guess and this is going to be the label
for the position where we place the result of the prediction of our neural network.
We're going to have a button here known as you raise.
We create this button by having a blue rectangle.
We have a rectangle and then a text.
And then um.
Yeah.
Currently it's not a button this jet is just a rectangle.
You can see we have rectangle fill over here.
We decide a position of the rectangle the x position the Y position the width and the height of the
rectangle.
And then that determines that the um the button that gives us the blue button which we shall see when
we um we test it out.
Okay.
And then we have this over here this text which is going to be um which is um going to be.
Which is going to be placed adjacent to another text that is going to the another takes which is going
to be the prediction of our e I we shall see this in action we are going to have it a small rectangle
which is going to hold the the scaled version of a one of our image.
So if we draw on image on the LCD screen this current version is going to be stored in this small rectangle
and this is going to show how this appears.
Or this will show us how a white large image looks when compressed to twenty eight by twenty eight which
is the um the dimensions that the M next neural network expects.
So I'm going to call these new functions in a while.
You know what main function and let's see what it produces on a microcontroller board.
Start off by in it or copy the init
I'm going gonna clean the print f with test that I already gonna initialize here and then I'm going
to have control panel was set
this over here as well right.
So I'm going to click over here to build.
Let's see if we have any errors.
Mm hmm.
We have a number of errors
right.
So we have these errors because we cannot locate I think a while board support package is no located.
No problem.
This simple situation
I'm simply going to go to our main dot H function main dot h file and include 0 0 head of files for
a PSP.
So you see this is Mendota h I'm going to right click open declaration then I'm going to come down here
right here I'll see it include
S T M thirty two F for two nine I and a score discovery dot H right and then include gonna include this
same thing.
Actually which LCD on the score LCD over here and then glue the same thing on a score T S for touch
screen to SDM 32 F for 2 9 I on the score Discovery got h LCD and then touch screen split again and
see what we have
we still have the same errors Okay
okay.
I report again.
Now we have nine arrows.
And the reason we have this is we've got to include funds right.
We've got to include phones cause some war for war.
Cause some of the folks we've included require phones that H.
So there's a photo that comes with the SDM 32 discovery board.
This one here.
Quote utilities and this one has this forward I would have phones and other things.
So I'm gonna copy that for a day and include it to a project right now.
So this is our project forward.
I'm gonna paste utilities in here
and utilities has phones right and we are certainly using phones in our project.
We so the font size if you check over here we have font size selected.
Click here to build.
It's looking good so far.
26 errors.
Okay let's see
so the cause of this error all these 26 arrows is from the folder arrangement of the generator could.
Over here I can see this is our project forward.
Amnesty is call and drive us forward here yet to get up to get to our project we've got it open this
other photo within our project for what are known as the SDM 32 cube idc.
When we open here we have another photo here called driver's so to solve this problem we've got a copy
our PSP for that and put it in here into this other drivers folder which is in the SDM 32 cube idea.
So I'll come back to our route forward.
Which is our project forward to go to drivers.
This where we have a what PSP currently I'm going to copy this and then go to SDM 32 cube I.D. E and
then go to drivers and then paste this over here.
Okay.
Now minimize this.
And also um I think I have a typo here but let's leave the tie point see if this first action solves
our problem click over here to run okay.
It looks good.
Okay.
We have two arrows.
So I have this typo here.
So this a different era.
I'll just solve this.
I'll fix this and then click here to build it s pull it in.
Okay.
You know we have no errors.
Okay.
Oh.
Download this onto the board or come over here run debug.
Okay to download an S S download in progress.
Okay.
Still working
okay.
Download complete now.
Or simply exit this and reset my microcontroller.
And as you can see this is a war you are currently.
So that's what I was talking about the background color is this color here.
And then we have our blue button.
This is the blue rectangle is currently just the rectangle.
When you touch nothing happens and within the rectangle we have this would erase written there and we're
going to use this blue rectangle area to clean the screen whenever we've sort of written something on
this screen and we have our a guest label to the right of.
This is going to be the predicted value of the neural network and this smaller square box we have on
the side of the screen is going to give a scaled down version of whatever we draw on this screen.
This is this is gonna be scaled down to twenty eight by twenty eight pixels.
So that's it.
And like I said everything that you see on the screen is defined by these lines that we've written over
here in our control panel set function.
So if there's something you don't understand here you can certainly let me know.
But all of it the font size that you raise a word to a I guess the color etc. LCD color blue all of
those text color all of them.
Okay.
So um yeah let's move on.
Let's continue um this in the too.
I'll see you.