This actually talk about micro python built in modules, these are modules that come with the micro
python interpreter and they are accessible from the scripts running from your E three to you don't have
to import or install any additional files to be able to use the built in modules.
So let's have a quick look at the documentation to begin with and then I'll give you a short demonstration.
Let's go to the latest version of the macro python, the competition.
I'm looking at version one point fourteen here and the very top you'll see a section of micro python
libraries in here.
You'll see there's a few different subcategories of subsections.
First of all, you've got the Python standard libraries and micro libraries right here.
You've got libraries such as math or C UI, although we also use an S for the operating system and so
on.
Then after that, you've got micro python specific libraries such as Machine, which we are going to
be using a lot, and the social network and so on.
And then you've got libraries that are specific to the market and using in our case there is three 32.
So you drill into that and you see that there's a couple of modules here that provide functions specific
to the ISP 32.
Now back to the beginning, just to talk a little bit more about what each one of these does.
The Python standard libraries are libraries that you normally find in the regular or C Python programming
language.
And these are also modules in libraries that come with standard python.
The implementation of those libraries into Micra Python is very close to you, but you cannot expect
one to one correspondence between the functions available, for example, in the IO input output library
in Python against that, that is available in micro python.
So, for example, in this case, you see that I o or the Python Library starts with a U in front of
it, which makes it micro IO and that indicates that this is the micro python version of the IO module
that comes with C Python.
So you can see here there is a reference to this Python input output or IO module.
We're going to click on that and take us over to that documentation.
And we are now looking at Python version three point five and this is the IO.
Documentation of the condition for the library and you can see it right here against what you provides
us in a micro python environment.
So the basic functions will be available, but they will be optimized to operate on a limited performance
environment, preserve memory, for example, and lower ship use cycles.
And some functions might not even be available at all.
So we've got the function open, for example, here, and it's a search for open mic that is also available
here.
And you can use it typically in the same way.
So in Python, the function open requires a file to open.
Then you've got the open modifier sort of mode of the operation of the file.
So whether you'd like to read it, for example, or appended or write and so on, we talk more about
this later.
And then there's also the type of encoding that the file contains.
Now, on the other side, on the micro python side, we have the name again, then the mode, as well
as the third parameter here for the encoding.
But just not notice what it says here or ports which provide access to the file system are required
to support the mode parameter, this parameter right here.
But whether the other arguments are supported, these arguments over here depend on the port, which
means depending on which target device you are writing, your micro python program for, whether it
is for the security or the weepie or something else.
So you need to be a bit careful and consider your target as well when you use in those classes and those
functions.
So that's what's happening here with the Python standard libraries.
And we've got micro python specific libraries.
So these are libraries that only exist in the micro python world that don't exist in Python, for example,
the machine module, which contains functions that relate to the hardware.
You can do things such as reseeded in soft, reset it, disable or enable Arcus and so on.
And these don't make sense, of course, for the regular C Python language.
So if you go over to the C documentation and try to search for a machine module, you find it here,
some machine module specifically designed for micro python and for the hardware tankage that it supports.
Then we've got the port specific libraries, so these are libraries that specifically operate on target
hardware devices and target microcontrollers.
So we're talking about things such as PIB or Pay Board or the HP three to show that.
We'll take us down here for us in our case, since we're using the hospital to click on the ASPCA to
a specific library and you'll see that there is one.
Its name is ASPCA two, which gives us functions such as to wake up one touch or an external pen sending
an IQ or that reads the integrated thermometer to give us the real temperature.
I'll give you an example of this in a moment and so on.
So this is a library that only works on the E.S.P 32 and provides specific functions that only make
sense on the age of two.
So let's play a little with this particular library here.
Just going to make a little bit of room here so we can have the two in the side by side.
And I'm using the show.
I'm connected to my ears to to use the ASPCA to board specific library.
I just need to import it.
So, as usual, I just say import E.S.P 32.
I didn't have to install a file with the name E.S.P 32.
Why said this integrated into the firmware that is running on the microcontroller.
And I do something simple, like I get the internal temperature, internal temperature of my HP 32 right
now.
I'm just going to copy this, paste it in here and enter.
And there is its temperature in Fahrenheit.
So you can see very simple.
Can you see the whole sensor with this case?
I'm going to type it in and use code completion, open close parentheses.
And that is the reading from the integrated magnetic code sensor.
Very easy, as I said, the other thing that you can do here is you can be very specific.
As I said, the memory of the two and other microcontrollers running micro python is fairly limited
compared to that of a computer running python.
So by me importing the whole of the ISP through tumultuously means that are imported all of those functions,
even though I am only interested in using, for example, the real temperature function.
So what I wanted, what I can do in order to be a bit more nimble with my use of resources, I can just
import the specific function that I want to use so I can say.
From E.S.P ferry to import real temperature like that, and now I can call real temperature by name
like this without having to prevent the security dot, as I did earlier, because earlier I just imported
a whole lot, just imported the real temperature function, which means that I can just call it by name
and I'm getting back the same result.
So the second instance, I have been a lot more precise about what it is that I want to import from
a large module.
You'll see later in the next lecture.
Actually, some of the modules that you can import for your projects can be very large in size because
they are designed to cover a multitude of situations and multitude of target hardware.
So you can be specific about which parts of those modules you want to import in order to preserve memory.
All right, so that's about it with the building modules.
Let's go over to the next picture now and a look at that particular community, which was.