0:09
hello and welcome to controllers Tech
0:12
today we will continue with our project
0:15
where we were interfacing the dot matrix
0:19
32 in the previous video we saw how to
0:22
store the data in the column form and
0:24
how to convert this data to the row form
0:27
so that we can send it to the display we
0:30
did it so that it would be easier for us
0:32
to scroll the character or string on the
0:35
display today we will write the
0:37
functions to scroll characters and
0:39
strings on the display we will also use
0:42
a font Library later in the
0:45
video let's continue with where we left
0:47
the project in the previous
0:50
video here you can see the same project
0:52
with all the functions which we created
0:56
video Let's create a new function to
0:59
shift the display to the left to do that
1:03
we need to copy the continent of the
1:04
current column to the adjacent column to
1:06
the left but this copying needs to start
1:09
from the last column here we are copying
1:12
the content of the current column to one
1:16
sequence if the count value is 31 the
1:19
data from column 31 will be copied into
1:22
column 32 which does not
1:25
exist therefore we will start our loop
1:27
from column 30 so that we can store the
1:32
31 basically this is our column Z and
1:37
31 we want to shift the data from column
1:42
31 but we need to start the process from
1:44
the higher column first therefore the
1:47
data from column 30 will be copied into
1:50
first then the data from column 29 will
1:54
be copied into 30 then 28 will copy into
1:57
29 and so on finally call the function
2:01
flush buffer to flush the entire column
2:05
display when the count value will be
2:07
zero the content of column Z will be
2:10
copied into column 1 but the data in
2:13
column Z will still remain
2:16
unchanged so here we can either set this
2:19
column to zero or you can update this
2:23
column with the data from column 31 this
2:25
will keep the entire display in the
2:30
Let's test if this shifting is working
2:32
fine we already have the data for the
2:35
number three in the column
2:37
buffer let's put it to the extreme right
2:41
display Now call the function shift left
2:44
inside the while loop and give some
2:47
delay this will keep Shifting the
2:52
milliseconds all right let's build and
2:55
Flash the project to the board you can
2:58
see the number three is sh shifting
3:01
display so the shifting is working fine
3:04
without any issue let's see the fonts
3:09
now here I have a font Library which is
3:12
the closest I found for my
3:14
display this is extracted from the
3:18
Library let's copy this font file into
3:22
project this file contains the data for
3:25
every possible character but I can't use
3:27
this file as it is let's see an example
3:31
for the number one we have the data byes
3:34
40 42 7f 7f Etc let's try to generate
3:40
the character for this particular
3:42
sequence the First Column is 40 hex then
3:46
the second column is 42 hex next is 7f
3:50
again 7f then 40 hex and 40 hex this is
3:55
what we will see on the display if the
3:57
data for the number one is passed to it
3:59
you can see the data generated here is
4:02
the same as what we have for the number
4:04
one in the font file the number is
4:07
inverted and this is not how we want to
4:09
see it let's design the same number in
4:12
the proper format you can see the data
4:15
generated and this is not the same of
4:18
course but if I change the endianness we
4:21
will get exactly the same data that we
4:23
have in the font file so this means that
4:26
the fonts are fine and we just need to
4:29
change the endianness of each bite this
4:32
is not as simple as it
4:34
sounds basically in the little endian
4:36
format the data bite is arranged such
4:39
that the least significant bit is on the
4:41
top but in the big endian format the
4:45
most significant bit is on the top so we
4:48
will use these fonts but we need to
4:50
change the bit order before storing the
4:52
data bite to the column buffer let's
4:55
define a new function to shift the
4:57
character on the display the parameters
5:00
of this function will be the character
5:03
itself and the delay between each shift
5:06
here we will print the data to the First
5:09
Column of the display and then shift the
5:11
data to the left we will repeat this
5:14
process for the entire font width this
5:17
is to make sure that the entire font has
5:19
been printed on the display I have
5:22
defined the font width in the font file
5:25
all the fonts defined in this file use
5:27
eight columns therefore the font will is
5:30
defined as eight inside this F Loop we
5:33
need to change the order of the bits for
5:35
each bite first of all we need to get
5:38
the data array for the particular
5:40
character from the font's
5:42
database the database is defined in a
5:44
way that the row number points to the
5:46
data for the particular character we
5:49
will start extracting from the first
5:51
bite we will take the 7th bit of the
5:54
first bite if this bit is a one we will
5:57
write a one to the zeroth bit of the
5:59
data bite if the bit is a zero this
6:03
condition will not run and a zero will
6:05
be stored at the corresponding position
6:08
after the loop runs one more time the J
6:11
value will become six now we will check
6:15
the sixth bit of the first bite if the
6:17
bit is a one we will write a one to the
6:20
first bit of the data bite this Loop
6:23
will run for a total of eight times
6:25
hence all the bits will be
6:27
rearranged after the first data BTE has
6:30
been extracted we will store it in the
6:32
zeroth element of the column buffer Now
6:35
call the function flush buffer to
6:37
display the result on the device then
6:40
the shift left function will shift the
6:42
entire display content to the left and
6:45
hence this data will now move to column
6:47
one the index variable will increment
6:51
and we will now extract the second bite
6:53
from the array and store it again in the
6:55
zeroth element of the column buffer this
6:58
Loop runs for the entire font width so
7:01
we will see the complete character on
7:03
the display the delay function controls
7:06
how fast you want to display the
7:10
character let's test if the function
7:12
works fine let me delete these
7:16
first now call the function shift
7:19
character and we will display the
7:23
device let's build the
7:25
project I forgot to include the fonts
7:30
all right let's build and Flash it to
7:34
now you can see the character C shifted
7:37
to the left and now it's fully printed
7:40
display let's put this in the while loop
7:43
and see if it can be printed
7:46
continuously you can see a continuous
7:48
stream of character C is being printed
7:51
display so this is actually how we
7:54
scroll the string on the
7:56
display let's define a new function to
7:59
scroll the string the parameter of this
8:02
function will be the pointer to the
8:04
string that we want to
8:06
scroll inside this function we will
8:08
simply call the function to scroll the
8:10
character and pass the string pointer to
8:13
it let's also add the delay parameter to
8:19
function Let's test this function Now
8:23
call the function scroll string to
8:27
world note that I am calling outside the
8:30
while loop so it will not scroll
8:44
continuously you can see the string
8:46
hello world is scrolling on the
8:53
display the scrolling stopped once all
8:55
the characters had been loaded on the
9:00
let's modify the delay to 100
9:03
milliseconds and add one more space to
9:09
string you can see the scrolling is
9:13
now also the string stopped a little
9:16
more left compared to before this is
9:18
because we added one more space to
9:22
it if you want the continuous scrolling
9:25
you can add it to the while
9:27
loop let's see the result
9:42
now the string is now scrolling
9:45
continuously and our project works fine
9:47
so far now let's say that instead of
9:51
scrolling the string we simply want to
9:54
display let's define a new function to
9:57
print the string on the display delay we
10:00
will modify the code from the shift
10:03
function here we do not need the delay
10:06
function so remove it remove the
10:11
also this particular code only prints A
10:14
Single Character so let's put it inside
10:17
another loop which will cover all the
10:19
columns let's remove this flush buffer
10:22
from here and put it outside the loop so
10:25
that the flushing will take place after
10:27
all the columns have been populated
10:29
note that we need to copy the data from
10:31
the higher column first this will
10:34
arrange the string from left to right
10:37
the First Column we will extract from
10:38
the font data we will copy it to the
10:41
last element of the column buffer then
10:43
the K value will decrease and the next
10:46
data bite will be stored in the second
10:48
column from the end this code was
10:51
written to print a single character on
10:53
the display but here we have the entire
10:56
string so we need to change this paramet
11:00
let's Define a variable to store the
11:02
string index instead of this character
11:05
variable we will pass the string data
11:09
the string index will point to a single
11:11
character inside the string and this
11:13
entire Loop will extract the character
11:15
from the font data so we will increment
11:18
the string index outside this
11:22
Loop Let's test this function
11:26
now here we will print the string
11:29
hello let me typ cast this string all
11:33
right let's build and Flash the project
11:36
to the board you can see the string
11:38
hello is printed but the display can't
11:41
accumulate the entire string let me try
11:45
34 this number prints very well on the
11:48
display we can also use it to display
11:51
the time again some portion of the data
11:55
is lying outside the display well this
11:58
is because I am using the wider fonts
12:00
here you can change the fonts to use a
12:03
smaller width by modifying the file or
12:06
create a new set of fonts for your
12:08
project which are comparatively smaller
12:11
in width so this is it for the video we
12:15
were able to scroll characters and
12:17
string on the display we also saw how to
12:20
print the string on the display this
12:23
completes the series for the dot matrix
12:26
display you can download the project
12:28
from Link in the description leave
12:31
comments in case of any doubt keep
12:34
watching and have a nice day ahead