WEBVTT

00:00.210 --> 00:08.160
This is the number 10 of the final project, and in this step, what we are going to do is to be able

00:08.160 --> 00:11.890
to toggle between different screens on the LCD screen.

00:11.910 --> 00:18.170
OK, so the default one we have is to print the distance and then to bring someone in, for example,

00:18.390 --> 00:20.660
when the application is not locked, of course.

00:21.000 --> 00:23.400
And what we want to do is maybe to bring something out.

00:23.440 --> 00:29.040
So what we are going to print is the instructions to resist to the default settings.

00:29.190 --> 00:35.430
And when we are in that screen, we are going to be able also to reset the default setting using the

00:35.530 --> 00:36.480
remote controller.

00:36.720 --> 00:44.010
So in this that we are going to create some mode for the LCD so we can toggle between different mood

00:44.010 --> 00:47.260
and different displays using the remote control.

00:47.400 --> 00:53.730
And then for the second mode, the reset setting mood, we're going to add the action to reset the settings.

00:54.330 --> 00:57.390
So let's start and let's add some.

00:58.050 --> 00:59.300
So let's do that here.

01:01.070 --> 01:03.050
So kidlets argument.

01:05.000 --> 01:08.310
Distance unit, and here it's a recruitment.

01:09.350 --> 01:15.040
LCD mode, so let's define acidy mode.

01:16.930 --> 01:22.770
Distance, which is the default one, that's zero defined and said.

01:24.270 --> 01:26.400
Moad Sitting's.

01:27.360 --> 01:35.970
One and actually in the next step, we are also going to add another mode, so we have to and let's

01:35.970 --> 01:45.060
create here in LCD mode is equal to the estimated the distance.

01:45.070 --> 01:48.830
So quite similar to what we have done with the distance.

01:49.170 --> 01:51.410
OK, that's the same thing.

01:51.810 --> 01:53.150
Now I'm going to.

01:53.230 --> 01:57.690
So let's find the angle I command.

01:57.940 --> 02:01.830
I'm going to add a new function void toggle.

02:03.040 --> 02:05.110
LCD screen.

02:06.830 --> 02:12.320
And I'm going to use a switch here, because for now we have two modes, and the next step I'm going

02:12.320 --> 02:15.630
to add another mode or switch will be quite appropriate.

02:15.680 --> 02:19.180
You switch with the exiting mode.

02:21.060 --> 02:31.140
And then we're going to take the case LCD mode, this tends to do and then break and in the case LCD

02:31.470 --> 02:32.100
mode.

02:33.440 --> 02:39.290
Settings to do and break and the default.

02:40.970 --> 02:42.010
So what do we want to do?

02:42.020 --> 02:45.650
We want to simply modify the LCD mode.

02:45.660 --> 02:50.300
So if the LCD mode is distance, we do LCD mode.

02:52.200 --> 03:00.210
Become settings, if not, the mode is settings, we do LCD mode becomes.

03:01.890 --> 03:02.580
Defense.

03:03.970 --> 03:10.150
And the default one, basically, if it's none of the two, which should not happen, but if it happens,

03:10.150 --> 03:15.270
which we do, we simply LCG mode is equal to sitting to distance.

03:15.280 --> 03:17.710
We set it back to the default one.

03:18.290 --> 03:23.020
So here we have the default.

03:24.350 --> 03:25.520
OK, that's the same.

03:27.410 --> 03:34.100
So he, as you can see, another simple state metion with a switch and I have used the switch, so when

03:34.100 --> 03:38.880
we add another mode in the next step, that will be super easy to modify.

03:40.030 --> 03:42.100
And I'm going to call this.

03:43.540 --> 03:46.330
So we can toggle between different screens.

03:46.360 --> 03:52.930
We're using the button up and button down to go to the left side, to the next screen, up to the previous

03:52.930 --> 03:55.090
one here, because we only have two screens.

03:55.420 --> 04:02.530
Well, we don't need to worry about that for now because the previews and the next screen is the same

04:02.530 --> 04:03.430
if you have two screens.

04:03.430 --> 04:09.630
So I'm just going to toggle the screen whether we use up or down, OK, but we call the function with

04:09.640 --> 04:10.440
the same behavior.

04:10.750 --> 04:15.800
So now that we have toggled between the stage where we need to actually use that state to do something.

04:16.180 --> 04:20.510
So if we go back to our function, print distance on LCD.

04:20.800 --> 04:24.440
So first we check if it is locked, then we do this.

04:24.460 --> 04:26.450
So that is always going to be the case.

04:26.470 --> 04:31.270
OK, the locked behavior will always overwrite any other behavior.

04:31.690 --> 04:35.800
And then else I'm going to add as if LCD mode.

04:37.400 --> 04:38.480
Is equal to.

04:40.010 --> 04:44.030
And see mode dist..

04:45.780 --> 04:53.640
With two equals, of course, so I'm only printing this if we are in the distance mode, OK?

04:54.480 --> 05:02.580
And if not, so if the application is not locked and not in the distance mode here on the print distance,

05:02.580 --> 05:03.720
we just print nothing.

05:04.200 --> 05:04.590
OK.

05:05.980 --> 05:15.460
And now what I'm going to do here is, well, when we switch to the mode settings here, I'm going simply

05:15.460 --> 05:22.090
to add here, if that's the mode is equal to the mode settings.

05:25.170 --> 05:33.810
Then I'm going to print the instructions to reset the settings, so let's say LCG got set, just saw

05:33.810 --> 05:43.980
with zero zero and then and see that print, that's a price of two and few spaces.

05:44.910 --> 05:55.890
And she said Couso zero one Ellsinore print reset settings.

05:58.270 --> 06:01.460
So I just printed the restriction on two lines.

06:01.480 --> 06:10.390
OK, so basically you see enough when we toggle the LCD screen, if we arrive at the mood settings.

06:11.490 --> 06:16.800
I'm going just to print that and that's it, and now because it's in the mode settings, we are not

06:16.800 --> 06:20.680
going to print anything else in the print distance on Esseily.

06:21.510 --> 06:23.340
And why are you writing this here?

06:23.340 --> 06:26.360
Because, well, simply we just need to write this once.

06:26.370 --> 06:27.990
I could have had it here.

06:27.990 --> 06:35.610
And as if LCG mode settings that would be called also whenever we want to print the distance on Elsley,

06:35.610 --> 06:42.150
but that's another functionality and that will print this many times per segan.

06:42.150 --> 06:43.290
And we don't need to do that.

06:43.290 --> 06:46.980
We just need to print it once when we said the modem.

06:47.010 --> 06:48.920
That's one thing I'm going to do here.

06:48.930 --> 06:55.680
It's also the entity that clear, OK, after I change the mode and is going to clear whatever is on

06:55.680 --> 07:01.660
the LCD screen, though, not if the mode is distance, we bring the distance with the other function.

07:02.040 --> 07:06.950
Now, if we go to settings, we clear, we print press on us to reset the settings.

07:07.000 --> 07:12.530
OK, then we are going to see how to do this section and then we toggle again.

07:12.540 --> 07:16.800
We are going back to the distance mode and in that case we clear the screen.

07:16.830 --> 07:22.630
We don't enter this and then we can continue to print the distance as we did before.

07:23.160 --> 07:29.850
And of course, if we ever lock the application, this will overwrite anything else that you try to

07:29.850 --> 07:30.300
print.

07:31.670 --> 07:39.890
And now that so let's say that we are in this screen, we are in the settings screen, which is seen

07:39.890 --> 07:44.020
press on off to reset settings, so the above is the button here.

07:44.390 --> 07:49.790
So I'm going to create a new function here, void reset settings.

07:51.700 --> 07:52.480
Let's say to.

07:57.170 --> 08:04.930
So here we have only one city that we can modify is the distance unique and the default is sentiment.

08:05.630 --> 08:10.460
But as an improvement for this final project, you could think of adding in many different settings,

08:10.460 --> 08:13.310
for example, doubling bright for the year.

08:13.550 --> 08:19.090
And it is the threshold to detect that an obstacle is on the way.

08:19.400 --> 08:25.100
So you could add many different settings, OK, that you can change, for example, with the remote

08:25.100 --> 08:26.930
controller and save to EPROM.

08:27.110 --> 08:32.510
And then when you call reset settings to default, you just reset all the settings to, well, to default.

08:32.780 --> 08:34.550
So here I'm going to check first if.

08:35.740 --> 08:42.790
So when we call that function from the handle, I recommend mean, to check if the ELSLEY mode is equal

08:42.790 --> 08:44.560
to LCB mode.

08:46.150 --> 08:55.170
Sitting's why I do that, because we are only going to be able to reset the settings when we are on

08:55.180 --> 08:56.410
the settings screen.

08:56.580 --> 09:00.100
OK, so if you want to reset the settings, you have to step first.

09:00.100 --> 09:05.740
You go to the screen and then you press off, OK, to, for example, to avoid that, you just reset

09:05.740 --> 09:07.500
the settings at any time.

09:07.750 --> 09:14.190
So to reset, I'm going to do distance units, set it back to distance.

09:14.950 --> 09:18.820
You need centimetres because I change the distance unit.

09:18.820 --> 09:21.050
I need also to do it from that.

09:21.730 --> 09:22.480
Right.

09:22.900 --> 09:29.260
We've become let's find this is the ultra distance unit.

09:30.640 --> 09:32.360
And these tensions.

09:34.780 --> 09:40.450
So if you have any other parameters of any other settings, you or is it then here and then what I'm

09:40.450 --> 09:44.470
going to do, I'm going to print a confirmation message on the AC.

09:44.560 --> 09:50.500
So let's do LTT clear and then SCD that sits.

09:52.420 --> 10:00.610
Tiso zero zero And she that print with let's say sitting's have.

10:02.020 --> 10:07.300
And in a city that sits just zero one.

10:08.940 --> 10:09.960
Nancy DePrince.

10:11.080 --> 10:13.540
Settings have been or is it?

10:14.690 --> 10:21.560
I don't add extra species here because I just cleared the screen before, so no need to add them and

10:21.560 --> 10:25.880
actually here because they clearly screen these, I could add them on.

10:25.880 --> 10:27.790
That's not the problem here.

10:28.940 --> 10:35.360
And I'm going to call that function from the IT when we press on the button.

10:37.380 --> 10:40.710
All right, it seems to me that the good is good.

10:40.740 --> 10:45.100
Now I'm going to verify and see it as a final project.

10:45.120 --> 10:46.500
Step number 10.

10:49.660 --> 10:59.320
And a quick recap here, so when we press the button up button down on the remote controller, we call

10:59.330 --> 11:02.420
the toggle and discreet, which is here.

11:02.770 --> 11:07.570
So now we have set an LCD mode, which is distance all settings.

11:08.560 --> 11:11.380
So when we talk on the screen, we are going to change the mode.

11:12.010 --> 11:16.600
And then depending on the movie, we are going to print different things on the LCD.

11:16.600 --> 11:20.920
So if the mode is distance, we print the distance as before.

11:21.250 --> 11:27.350
If the mode is settings, we print the message and instructions so we can present the settings, OK.

11:27.810 --> 11:31.270
And of course, if the application is locked, this will of the right.

11:31.270 --> 11:32.620
Any other behavioral.

11:33.640 --> 11:41.380
Now, when we are on the LCD mode settings, if we price on the off button, we call the reset settings

11:41.380 --> 11:47.070
to default, and so we see that we are actually in the correct mode to do that.

11:47.590 --> 11:53.280
And in that case, we just reset the settings and we print a confirmation message.

11:53.770 --> 12:00.430
And also one thing and going to the one small additional thing I'm going to do is when I unlock the

12:00.430 --> 12:07.290
application, I'm also going to the LCD that clear because now we have different modes.

12:07.300 --> 12:11.680
So if we have the distance mode, it's going to continue to print the distance.

12:11.680 --> 12:19.210
But if we are in the settings mode, because we just print the setting text once, we need to clear

12:19.600 --> 12:25.720
to make sure that we don't get the error message if we were in the settings mode.

12:26.110 --> 12:28.060
So now let's upload code.

12:30.900 --> 12:37.560
So the application is running as expected, normally with the default behavior, which is to print the

12:38.070 --> 12:40.890
distance and you can see here we print in inches.

12:40.920 --> 12:46.310
OK, that was the previous settings, the regular distance unit that I have set.

12:46.590 --> 12:52.170
And when I started to program, it was retrieved from the from memory.

12:52.560 --> 12:59.580
So what I'm going to do, I'm going to press on the button here the button Ildong to go to the different

13:00.660 --> 13:01.930
modes of the LCD.

13:01.950 --> 13:08.700
So this is the other mode where you can see press on off to reset settings so I can toggle between the

13:08.700 --> 13:11.970
distance and this sitting mode.

13:12.300 --> 13:18.730
Now, in this mode, I can just press on the off button and you can see settings have been there.

13:18.750 --> 13:20.310
Is it if I go back.

13:20.320 --> 13:28.010
So using the Ildong or you can see now I have the distance in centimeters, not in inches.

13:28.320 --> 13:31.050
So you can see that all the default settings.

13:31.050 --> 13:34.200
So we just have the distance you need.

13:34.380 --> 13:36.900
All the default settings have been reset.

13:37.380 --> 13:38.160
And of course.

13:38.610 --> 13:44.700
Well the thing is that if you have an obstacle, it still overrides everything and you can't well,

13:44.700 --> 13:46.020
you can't change the screen, OK?

13:46.200 --> 13:53.670
The only way is to press on the play button to unlock and then you can continue to do whatever you want

13:53.670 --> 13:54.270
with the screen.

13:55.190 --> 13:59.660
All right, and that will be the end of this step, and as you can see, that can be quite convenient

13:59.660 --> 14:06.200
to switch between different screens for the LCD to bring a different kind of informations, all different

14:06.200 --> 14:07.340
kind of actions.
