0:17
hello every body welcome to controllers
0:21
tech few months ago I made a video about
0:24
how to interface SSD 1306 128 by 64 o
0:31
LED display with stm32 that video only
0:36
covered the interfacing part and some
0:38
basic text display today in this video
0:41
we will use some advanced display
0:44
functions in SSD 1306 I have modified
0:49
the previous library and now we can
0:53
display lines shapes bitmaps and also
0:56
animations you can also scroll text and
1:00
bitmaps on the screen in different
1:02
directions I am starting my setup with
1:06
cube MX I am using my you who left 103
1:10
controller make sure you use the fast
1:13
mode at 400 kilo Hertz
1:41
let's copy some library related files in
2:07
now we need to include all those header
2:22
let's just quickly build it once okay
2:33
let's see the list of functions
2:34
available for the programming we will
2:38
start by initializing the display let me
2:49
just print some string on the display
2:51
and it is the usual one hello world
2:55
you have to write update screen function
2:58
every time you want something to display
3:01
on the screen I want to keep this text
3:04
for two seconds and that explains the
3:06
delay in the end let's check the list of
3:09
functions again we have scroll functions
3:18
to right and left along with diagonal
3:21
scrolling and then there is stopped
3:23
scroll we can also invert the display or
3:27
display bitmap let's start with
3:30
scrolling the screen I am going to
3:32
scroll the text above as you can see
3:35
this function takes two parameters the
3:38
first one is the row where you want the
3:40
scroll to start the second one is the
3:43
end row well basically these are not the
3:47
rows these are the pages this display
3:50
have seven pages you can scroll however
3:53
you want as I want to scroll the entire
3:56
screen start page will be 0 and the end
4:00
page will be 7 providing delay will keep
4:03
the scrolling for that amount of time
4:06
you should stop the scroll or else the
4:09
screen will keep scrolling let's draw
4:16
I have this image right here which I
4:21
want to display on the screen I am using
4:24
to modify the image it's free and
4:27
open source and it's good
4:35
first thing we need to do is resize the
4:38
image to 128 by 64 next we need to
4:48
change the color index to one bit black
4:58
and now we can export this image as a
5:04
bitmap image with BMP extension
5:19
next I am using LCD assistance to
5:22
convert it to the hex format you can
5:26
it's easily available for download
5:35
make sure that the bite orientation is
5:38
horizontal and the size endian this is
5:41
big after this just save the file and
5:44
you will get you hex code
6:01
I am creating another file in the
6:03
project where I can store my bitmaps and
6:06
I will name it bitmap itself
6:24
just include it in the project and we
6:33
drawbitmap takes six parameters the
6:37
first two other x and y coordinates
6:39
where you want to start the draw from
6:42
next is the pointer to the array than
6:45
the size of the image and at last the
6:48
color it will remain one in our case we
6:51
still need to update the display to
6:53
print the image on the screen I am going
6:56
to keep the image for some time and then
6:59
scroll the image in different directions
7:01
note that there is some delay after
7:04
every scroll like I mentioned before we
7:08
need to give some delay or else we won't
7:10
be able to see it scrolling and at last
7:13
I am going to invert the display and
7:16
then normalize it again let's compile
7:19
the code and download it to the
7:21
controller to see the results
7:48
as you can see the text scrolling the
7:53
bitmap scrolling and the invert display
7:55
functions are working properly now let's
7:59
see how to display any animation on the
8:02
screen I have this horse running gif
8:05
here you can just google them they are
8:07
available to download for free open it
8:19
look at the right side we have ten
8:22
different frames for this animation
8:24
first thing we need to do is scale our
8:47
and then we need to change the color
8:50
index to one bit black and white
9:08
look at the picture if I show each frame
9:11
one by one you can actually see the
9:14
animation next we need to hide all other
9:17
frames and keep the first one then
9:24
export it to the BMP extension just like
9:27
we did in the bitmap then open the LCD
9:34
assistance and convert it to the hex
9:36
code I will create another file where I
9:47
can keep this animation and I am naming
9:50
it as whoreson m dot H go back to
10:00
now and delete the first frame unhide
10:03
the second frame and repeat the same
10:25
you have to do this for all ten frames
10:41
now it's time to display this animation
10:44
on our screen first we need to include
10:47
the file we created in our project next
10:51
in the while loop clear the screen draw
10:54
the bitmap of the first frame and update
10:57
the screen repeat these steps for all
11:36
let's compile download and run
11:52
yeah so the horse is running good
11:55
I am only displaying the animation part
11:58
here rest as usual I also ported some
12:03
tests for the screen if you open the
12:06
test dot C file you will see the list of
12:09
tests we can perform these includes
12:12
lines rectangles circles and triangles
12:16
let's write them all
12:36
they all take color as the only
12:40
parameter except circles it takes two
12:43
parameters one is radius and other is
12:46
color let's test them now
13:46
everything works great hope you liked
13:50
the video leave comments if you have any
13:53
doubt you can download the code from the
13:56
link in the description have a nice day