WEBVTT

00:00:00.000 --> 00:00:01.820
<v Chris Gammell>This is The Amp Hour Podcast.

00:00:02.960 --> 00:00:05.780
<v Chris Gammell>Recorded November 16th, 2016.

00:00:07.800 --> 00:00:09.400
<v Chris Gammell>Episode 323.

00:00:11.120 --> 00:00:13.020
<v Chris Gammell>An interview with Tony DeCola.

00:00:30.000 --> 00:00:31.900
<v Dave Jones>Welcome to the Amp Hour.

00:00:32.020 --> 00:00:33.840
<v Dave Jones>I'm Dave Jones from the AEV blog.

00:00:34.140 --> 00:00:36.040
<v Chris Gammell>And I'm Chris Gammell of Contextual Electronics.

00:00:36.440 --> 00:00:38.340
<v Chris Gammell>And I'm Tony DeCola of Adafruit.

00:00:38.960 --> 00:00:40.380
<v Dave Jones>Hey, Tony, thanks for joining us.

00:00:40.560 --> 00:00:40.980
<v MicroPython>Welcome, Tony.

00:00:41.020 --> 00:00:41.860
<v MicroPython>Oh, yeah, thanks for having me.

00:00:42.240 --> 00:00:43.580
<v Dave Jones>Is this our first Adafruit?

00:00:43.920 --> 00:00:44.480
<v Dave Jones>It is.

00:00:44.660 --> 00:00:46.400
<v Dave Jones>Do Adafruit people have a name?

00:00:47.700 --> 00:00:48.640
<v Dave Jones>That's a good question.

00:00:48.820 --> 00:00:49.100
<v Dave Jones>Adafruiters.

00:00:49.820 --> 00:00:50.220
<v Dave Jones>Adafruitians?

00:00:50.600 --> 00:00:52.640
<v Dave Jones>Adafruiters, yeah, that could be it.

00:00:52.680 --> 00:00:54.000
<v MicroPython>We'll pick that and we'll see that's the name.

00:00:54.400 --> 00:00:55.340
<v Dave Jones>Right, okay.

00:00:57.020 --> 00:00:57.420
<v Chris Gammell>Cool.

00:00:57.420 --> 00:01:03.300
<v Chris Gammell>And Tony's here because, well, last week we were talking about, I brought up MicroPython

00:01:03.300 --> 00:01:05.120
<v Chris Gammell>and I mentioned Tony's tutorials.

00:01:05.120 --> 00:01:08.320
<v Chris Gammell>And then I quickly sent him an email and said, hey, Tony, can you come on the show this week

00:01:08.320 --> 00:01:09.040
<v Chris Gammell>and talk about it?

00:01:09.180 --> 00:01:11.720
<v Chris Gammell>So, yeah, thanks for being here.

00:01:11.820 --> 00:01:16.220
<v Chris Gammell>And we're excited to talk about this stuff, mostly based on my interest and now Dave's

00:01:16.220 --> 00:01:18.180
<v Chris Gammell>disinterest, which will be turning into interest, I'm sure.

00:01:18.480 --> 00:01:19.160
<v MicroPython>Yeah, and this is good.

00:01:19.220 --> 00:01:21.040
<v MicroPython>It's good to have kind of both sides of the coin, I think.

00:01:21.120 --> 00:01:24.740
<v MicroPython>So, you know, we can talk about what's good and, you know, where you might want to use MicroPython.

00:01:24.740 --> 00:01:29.560
<v MicroPython>And then maybe cases where, yeah, you might not want to use it in some instances to give

00:01:29.560 --> 00:01:31.820
<v MicroPython>you kind of both sides of how you'd want to use it.

00:01:31.860 --> 00:01:36.620
<v MicroPython>But yeah, I've been working a lot with MicroPython in the last couple months or so, just using

00:01:36.620 --> 00:01:40.600
<v MicroPython>it at Adafruit with some of our boards and things and doing lots of guides and videos.

00:01:40.720 --> 00:01:45.000
<v MicroPython>So if you've seen like our YouTube channel and our learning system, you'll probably see

00:01:45.000 --> 00:01:46.000
<v MicroPython>all kinds of stuff from me there.

00:01:46.000 --> 00:01:49.720
<v MicroPython>And so, yeah, we're trying to kind of get the word out that it's a really cool platform.

00:01:50.120 --> 00:01:54.900
<v MicroPython>If you've used things like Arduino or Raspberry Pi and you're familiar with those kind of systems

00:01:54.900 --> 00:01:59.280
<v MicroPython>for like learning electronics, MicroPython could be a really cool platform to explore

00:01:59.280 --> 00:02:03.720
<v MicroPython>to do things like high-level programming on small little microcontrollers, you know,

00:02:03.760 --> 00:02:07.220
<v MicroPython>things that are like the size of an Arduino or even smaller than that, for example.

00:02:07.360 --> 00:02:09.000
<v MicroPython>So, yeah, I'm really kind of passionate about it.

00:02:09.020 --> 00:02:11.660
<v MicroPython>And that's, I think, a good discussion that we can have about it here.

00:02:12.280 --> 00:02:12.920
<v Dave Jones>All right.

00:02:12.940 --> 00:02:15.300
<v Dave Jones>For the dummies out there like me, what is Python?

00:02:16.060 --> 00:02:16.440
<v Dave Jones>Oh, yeah.

00:02:16.480 --> 00:02:16.940
<v MicroPython>Great question.

00:02:16.960 --> 00:02:18.220
<v Dave Jones>Let alone MicroPython.

00:02:18.420 --> 00:02:18.620
<v Dave Jones>Right.

00:02:18.900 --> 00:02:19.400
<v Dave Jones>Yeah, exactly.

00:02:19.400 --> 00:02:19.720
<v Dave Jones>Python.

00:02:20.740 --> 00:02:21.140
<v MicroPython>Exactly.

00:02:21.280 --> 00:02:21.680
<v MicroPython>Start there.

00:02:21.980 --> 00:02:24.260
<v MicroPython>So Python, it's a programming language.

00:02:24.560 --> 00:02:27.640
<v MicroPython>And I don't know exactly how old it is, but I think it was created in kind of the early

00:02:27.640 --> 00:02:28.200
<v MicroPython>90s.

00:02:28.700 --> 00:02:31.420
<v MicroPython>And it's basically a high-level programming language.

00:02:31.700 --> 00:02:33.180
<v MicroPython>So it's interpreted.

00:02:33.560 --> 00:02:38.400
<v MicroPython>You write code that's, you know, not necessarily compiled straight down into assembly language

00:02:38.400 --> 00:02:41.600
<v MicroPython>that runs on the processor, but it gives you a simpler interface.

00:02:41.600 --> 00:02:46.380
<v MicroPython>And so it was built kind of like a lot of languages like Perl, you know, some of those higher level

00:02:46.380 --> 00:02:50.000
<v MicroPython>languages that are meant to do things like administration of your system.

00:02:50.180 --> 00:02:54.360
<v MicroPython>You know, you want to process a lot of files, read a lot of data, maybe parse out interesting

00:02:54.360 --> 00:02:56.440
<v MicroPython>things and go from there with it.

00:02:56.440 --> 00:03:00.560
<v MicroPython>And it was kind of created as a similar language like that, but with different principles.

00:03:01.000 --> 00:03:06.720
<v MicroPython>So in Python, things are meant to be obvious and easy and like only one way to do it in

00:03:06.720 --> 00:03:10.120
<v MicroPython>contrast to like Perl, where there may be like 10 different ways to open a file.

00:03:10.700 --> 00:03:10.900
<v MicroPython>Right.

00:03:10.900 --> 00:03:12.160
<v MicroPython>Exactly.

00:03:12.260 --> 00:03:16.260
<v MicroPython>So it was meant to be kind of a simpler little language, maybe not simpler, but a little more

00:03:16.260 --> 00:03:17.740
<v MicroPython>obvious, easier to learn language.

00:03:18.120 --> 00:03:19.780
<v MicroPython>And it kind of took off from there.

00:03:19.920 --> 00:03:25.560
<v MicroPython>And I'm not like a total Python expert, but it's really kind of become a beginner's language,

00:03:25.680 --> 00:03:30.000
<v MicroPython>like a great place to learn programming, but also a language for advanced things.

00:03:30.000 --> 00:03:35.900
<v MicroPython>So they're like full web apps, like Dropbox is actually all written in Python, apparently,

00:03:36.400 --> 00:03:38.940
<v MicroPython>like the client apps and the web servers and things like that.

00:03:38.980 --> 00:03:43.480
<v MicroPython>So it is a pretty capable language, but also used as a great way to learn because it's got

00:03:43.480 --> 00:03:47.000
<v MicroPython>a simpler syntax, you know, you don't have like the memory management and things that

00:03:47.000 --> 00:03:47.580
<v MicroPython>you have to deal with.

00:03:47.620 --> 00:03:51.060
<v MicroPython>It's got garbage collection and reference counting and things like that internally.

00:03:51.240 --> 00:03:54.980
<v MicroPython>So it's, you know, really good kind of platform to begin with, but then also to go

00:03:54.980 --> 00:03:56.580
<v MicroPython>further and do real things with it.

00:03:56.580 --> 00:04:03.360
<v Dave Jones>So if apps like that, like Dropbox are written in Python, does that mean that my web browser,

00:04:03.460 --> 00:04:06.500
<v Dave Jones>my computer has a Python interpreter built in?

00:04:07.100 --> 00:04:09.840
<v Dave Jones>Your web browser, not necessarily, but...

00:04:09.840 --> 00:04:14.800
<v Dave Jones>Like how, yeah, how does it, if I run Dropbox on their website, how does it run?

00:04:15.060 --> 00:04:15.240
<v MicroPython>Right.

00:04:15.300 --> 00:04:19.360
<v MicroPython>They do a thing where they embed the Python interpreter into their executable.

00:04:20.000 --> 00:04:20.880
<v MicroPython>And that's one...

00:04:20.880 --> 00:04:20.960
<v MicroPython>Aha.

00:04:21.100 --> 00:04:24.720
<v Dave Jones>So it's an interpreter running an executable.

00:04:25.100 --> 00:04:25.340
<v MicroPython>Got it.

00:04:25.420 --> 00:04:26.080
<v MicroPython>Exactly right.

00:04:26.080 --> 00:04:27.200
<v Dave Jones>As like an executable.

00:04:27.340 --> 00:04:27.580
<v Dave Jones>Right.

00:04:27.720 --> 00:04:27.960
<v Dave Jones>Okay.

00:04:28.260 --> 00:04:34.960
<v Dave Jones>So in that respect, you can maybe think of it as a compiled language because it generates

00:04:34.960 --> 00:04:39.960
<v Dave Jones>an executable, but there's a kernel, there's a Python kernel in there, which is running

00:04:39.960 --> 00:04:42.720
<v Dave Jones>and then taking the code and then executing it.

00:04:43.100 --> 00:04:43.360
<v MicroPython>Right.

00:04:43.420 --> 00:04:43.820
<v MicroPython>Exactly.

00:04:44.000 --> 00:04:49.480
<v MicroPython>It's, you, you can take Python and, you know, attach its interpreter to it and run that

00:04:49.480 --> 00:04:50.720
<v MicroPython>code, you know, run your code.

00:04:50.720 --> 00:04:52.100
<v MicroPython>And even though it's still interpreted, you're right.

00:04:52.100 --> 00:04:55.020
<v MicroPython>You've got like an executable that runs on their tools.

00:04:55.020 --> 00:04:59.480
<v MicroPython>I think Dropbox actually makes one that lets you take a Python app and like turn it into

00:04:59.480 --> 00:05:01.920
<v MicroPython>an executable that runs your code like that.

00:05:02.160 --> 00:05:02.880
<v MicroPython>So exactly.

00:05:03.040 --> 00:05:05.580
<v MicroPython>Does it really make that more portable or how does that end up?

00:05:05.660 --> 00:05:07.040
<v Chris Gammell>What's, what is the net result of that?

00:05:07.040 --> 00:05:11.300
<v MicroPython>Uh, you just have one executable, so you don't have to have Python installed.

00:05:11.500 --> 00:05:14.660
<v MicroPython>So like Dave was saying, you know, you don't necessarily have it installed on your machine.

00:05:14.660 --> 00:05:19.860
<v MicroPython>Like if you downloaded a .py file and you wanted to run it, unless you had Python installed,

00:05:20.180 --> 00:05:20.880
<v MicroPython>you're just going to get an error.

00:05:20.960 --> 00:05:23.380
<v MicroPython>Like a computer says, I have no idea what to do with this thing.

00:05:23.380 --> 00:05:27.840
<v MicroPython>Whereas you can use certain tools to say, okay, I want to make an executable like, you know,

00:05:27.840 --> 00:05:31.340
<v MicroPython>a Mac OS 10.app file or a windows.exe.

00:05:31.500 --> 00:05:35.340
<v MicroPython>And then inside of there, it will add the Python interpreter and your code.

00:05:35.660 --> 00:05:39.180
<v MicroPython>So when you double click that executable, it'll run the interpreter and then feed your code

00:05:39.180 --> 00:05:39.660
<v MicroPython>into it.

00:05:39.820 --> 00:05:44.480
<v MicroPython>So to the user, it feels like they're running a normal app, but in reality, it's a Python

00:05:44.480 --> 00:05:46.220
<v MicroPython>program that's running behind the scenes there.

00:05:46.760 --> 00:05:47.820
<v Dave Jones>That's interesting.

00:05:47.820 --> 00:05:52.700
<v Dave Jones>Why not at that point that you're generating an executable, why not actually just turn it

00:05:52.700 --> 00:05:54.960
<v Dave Jones>into compiled assembly language?

00:05:55.060 --> 00:05:59.440
<v Dave Jones>This is similar to like, uh, the versions of basic back in the old days, right?

00:05:59.520 --> 00:06:05.260
<v Dave Jones>Basic was mostly an interpreted language, but then the basic compilers came along, which

00:06:05.260 --> 00:06:09.140
<v Dave Jones>then took your existing basic code and would actually generate proper executables.

00:06:09.140 --> 00:06:11.920
<v Dave Jones>And it would not run as an interpreter in the exit.

00:06:12.300 --> 00:06:12.620
<v MicroPython>Oh, right.

00:06:12.660 --> 00:06:12.800
<v MicroPython>Yeah.

00:06:12.800 --> 00:06:15.760
<v MicroPython>Like do a conversion into like C or assembly, something like that.

00:06:15.760 --> 00:06:18.180
<v MicroPython>Uh, I, I would bet there are tools to do that.

00:06:18.240 --> 00:06:19.160
<v MicroPython>I haven't looked into it myself.

00:06:19.460 --> 00:06:22.840
<v MicroPython>Um, but one thing is that Python is a pretty dynamic language.

00:06:22.840 --> 00:06:27.460
<v MicroPython>So kind of like JavaScript where you could have an object and you can add things to it.

00:06:27.480 --> 00:06:29.640
<v MicroPython>You can remove things from it dynamically.

00:06:29.640 --> 00:06:34.380
<v MicroPython>So that sometimes gets a little harder and you, you can still model that and convert that

00:06:34.380 --> 00:06:36.580
<v MicroPython>into, you know, C and things like that.

00:06:36.720 --> 00:06:40.680
<v MicroPython>But yeah, it gives you a little more flexibility when you're really still dealing with that interpreted

00:06:40.680 --> 00:06:41.060
<v MicroPython>language.

00:06:41.060 --> 00:06:43.820
<v MicroPython>Like you can kind of control the state of it in different ways.

00:06:43.820 --> 00:06:46.680
<v MicroPython>Uh, that's, you know, it gets a little more advanced for it.

00:06:46.740 --> 00:06:49.840
<v MicroPython>So, but yeah, it's not necessarily like a, uh, the, the only way to do it.

00:06:49.880 --> 00:06:53.440
<v MicroPython>I mean, like you said, for performance cases, you know, you definitely might want to look

00:06:53.440 --> 00:06:58.440
<v MicroPython>at how do you go and actually have like native code that's going to be faster, uh, and works

00:06:58.440 --> 00:06:58.880
<v MicroPython>a little better.

00:06:58.880 --> 00:07:02.600
<v MicroPython>And that's actually one of the strengths of Python too, that I didn't really mention is

00:07:02.600 --> 00:07:08.020
<v MicroPython>that, uh, when I say Python for the desktop, it's really C Python.

00:07:08.020 --> 00:07:11.640
<v MicroPython>Like the letter C in front of it is the implementation that everyone uses.

00:07:11.900 --> 00:07:12.660
<v MicroPython>Oh, okay.

00:07:12.660 --> 00:07:18.440
<v MicroPython>They call it C Python because really most of Python is written in C. Uh, a lot of it is

00:07:18.440 --> 00:07:22.360
<v MicroPython>written in Python, like some of the libraries and things, but the core functions are really

00:07:22.360 --> 00:07:23.320
<v MicroPython>just C functions.

00:07:23.320 --> 00:07:27.340
<v MicroPython>So like, you know, things like outputting to your terminal or like doing any kind of

00:07:27.340 --> 00:07:30.660
<v MicroPython>graphics processing or even like advanced scientific processing.

00:07:30.660 --> 00:07:34.960
<v MicroPython>So there's this whole system called numpy and scipy, which are all these libraries to

00:07:34.960 --> 00:07:37.360
<v MicroPython>do, you know, advanced like Fourier analysis.

00:07:37.680 --> 00:07:41.940
<v MicroPython>Those are implemented in C because they need to be really fast and efficient and use all the

00:07:41.940 --> 00:07:45.100
<v MicroPython>features of your hardware, but then they give a nice Python interface.

00:07:45.100 --> 00:07:49.500
<v MicroPython>So you use that in your Python script to say, okay, I want to do a Fourier transform.

00:07:49.500 --> 00:07:53.180
<v MicroPython>So I'll just call this little function and maybe pass in, you know, big buffer of data

00:07:53.180 --> 00:07:56.080
<v MicroPython>to it and I get back my results and I go and process it from there.

00:07:56.080 --> 00:07:57.780
<v MicroPython>So that is the nice thing about Python.

00:07:57.780 --> 00:08:02.240
<v MicroPython>And then it's really made to work with native code, at least the desktop versions like that,

00:08:02.240 --> 00:08:06.220
<v MicroPython>so that you can plug in where you need the optimizations, uh, that kind of code and go

00:08:06.220 --> 00:08:06.880
<v MicroPython>from there with it.

00:08:06.880 --> 00:08:08.540
<v MicroPython>So it gives you a lot of flexibility like that.

00:08:09.440 --> 00:08:09.600
<v Chris Gammell>Yeah.

00:08:09.600 --> 00:08:10.000
<v Chris Gammell>Interesting.

00:08:10.120 --> 00:08:14.940
<v Chris Gammell>The dataset stuff is definitely what I usually think about because the data scientists, I

00:08:14.940 --> 00:08:19.220
<v Chris Gammell>know they all are using it for their, you know, just for a very handy kind of

00:08:19.220 --> 00:08:21.420
<v Chris Gammell>pushing data around type of type of tool.

00:08:21.520 --> 00:08:23.820
<v Chris Gammell>It seems like that, that is the go-to.

00:08:24.400 --> 00:08:27.500
<v Chris Gammell>I don't know how I never, I never really got into it because I guess I was never doing like

00:08:27.500 --> 00:08:31.680
<v Chris Gammell>the processing at the, you know, at the web level or the, even the computer level.

00:08:31.680 --> 00:08:36.680
<v Chris Gammell>But it's interesting to hear about the, the interplay with C as well, because I think that

00:08:36.680 --> 00:08:41.880
<v Chris Gammell>that ultimately makes it compelling from the hardware standpoint, right?

00:08:41.920 --> 00:08:45.080
<v Chris Gammell>I mean, that's what a lot of people are going to immediately say, well, why not just

00:08:45.080 --> 00:08:45.780
<v Chris Gammell>program in C.

00:08:47.160 --> 00:08:52.140
<v Chris Gammell>So maybe, maybe could you start to contrast some of the, the, how, how it operates differently

00:08:52.140 --> 00:08:54.180
<v Chris Gammell>than C in the MicroPython version?

00:08:54.860 --> 00:08:55.220
<v MicroPython>Yeah.

00:08:55.380 --> 00:08:57.240
<v Dave Jones>And maybe, first of all, what is MicroPython?

00:08:57.360 --> 00:08:57.720
<v Dave Jones>Exactly.

00:08:57.860 --> 00:08:58.600
<v Dave Jones>What is the difference?

00:08:58.780 --> 00:08:58.900
<v MicroPython>Right.

00:08:58.960 --> 00:09:01.160
<v MicroPython>So I'll give you just a quick kind of overview of MicroPython.

00:09:01.160 --> 00:09:07.260
<v MicroPython>So MicroPython, it's an implementation of Python for microcontrollers or really just

00:09:07.260 --> 00:09:08.800
<v MicroPython>memory constrained environments.

00:09:08.800 --> 00:09:14.560
<v MicroPython>Uh, because Python and C Python, like I was mentioning, those were really built for desktop

00:09:14.560 --> 00:09:18.040
<v MicroPython>environments where memory is effectively free.

00:09:18.240 --> 00:09:18.640
<v MicroPython>Exactly.

00:09:18.860 --> 00:09:22.000
<v MicroPython>You know, you've got a gigabyte, might as well be infinite memory.

00:09:22.220 --> 00:09:28.240
<v MicroPython>Uh, so Python does things like, you know, it's basic numeric type is just an infinitely

00:09:28.240 --> 00:09:29.140
<v MicroPython>large integer.

00:09:29.140 --> 00:09:35.300
<v MicroPython>So you could have, you know, giant numbers, whereas that's usually not going to be very

00:09:35.300 --> 00:09:37.600
<v MicroPython>performant if you're doing small math operations.

00:09:37.600 --> 00:09:38.760
<v Dave Jones>Performance oriented.

00:09:39.100 --> 00:09:39.360
<v Dave Jones>Yeah.

00:09:39.420 --> 00:09:44.720
<v Dave Jones>If, if, if people don't know the tight, like in C, for example, the, the data type you

00:09:44.720 --> 00:09:50.100
<v Dave Jones>choose, whether it's an eight bit integer, a 16 bit 32 bit, 64 bit integer, et cetera,

00:09:50.100 --> 00:09:55.580
<v Dave Jones>that determines how many registers in your processor are going to be used and how many processor

00:09:55.580 --> 00:09:57.800
<v Dave Jones>operations and hence speed and everything else.

00:09:57.800 --> 00:09:59.580
<v Chris Gammell>And battery power and everything that's tied to that.

00:09:59.780 --> 00:09:59.860
<v Chris Gammell>Yeah.

00:10:00.060 --> 00:10:00.460
<v MicroPython>Exactly.

00:10:00.740 --> 00:10:04.320
<v Dave Jones>And if Python's in what you're saying, infinite size integer, how does that work?

00:10:04.600 --> 00:10:05.240
<v MicroPython>Exactly right.

00:10:05.300 --> 00:10:06.960
<v MicroPython>So it just has a big integer implementation.

00:10:06.960 --> 00:10:11.400
<v MicroPython>So it's, as soon as you get above a certain value, you know, it can just, uh, add on more

00:10:11.400 --> 00:10:12.240
<v MicroPython>precision for it.

00:10:12.240 --> 00:10:17.260
<v Dave Jones>Uh, but they actually dynamically based on the number that's already stored in there.

00:10:17.260 --> 00:10:18.660
<v Dave Jones>It dynamically allocates.

00:10:18.660 --> 00:10:19.100
<v Dave Jones>Yeah.

00:10:19.100 --> 00:10:23.920
<v MicroPython>It can, it can add more, uh, more digits to it, but it actually has optimizations because

00:10:23.920 --> 00:10:28.600
<v MicroPython>for small values, you don't want all this overhead of like doing this more complex math.

00:10:28.600 --> 00:10:33.040
<v MicroPython>So it has to be smart enough to say, okay, if your integer is below this range, then we

00:10:33.040 --> 00:10:37.660
<v MicroPython>actually have like special, uh, they, they keep like one instance of each number below

00:10:37.660 --> 00:10:40.300
<v MicroPython>255 or do lots of little tricks like that.

00:10:40.400 --> 00:10:40.800
<v MicroPython>Interesting.

00:10:41.120 --> 00:10:41.320
<v MicroPython>All right.

00:10:41.340 --> 00:10:45.460
<v MicroPython>But that type of stuff is really difficult on these little microcontrollers where, you

00:10:45.460 --> 00:10:49.380
<v MicroPython>know, you don't want to waste all of this memory to store arbitrary precision numbers.

00:10:49.380 --> 00:10:52.420
<v MicroPython>If you know, you're only dealing with maybe small numbers that you're talking to some

00:10:52.420 --> 00:10:55.280
<v MicroPython>hardware or some driver, uh, that, that has to deal with that.

00:10:55.280 --> 00:11:00.760
<v MicroPython>So, so micro Python looked at all these cases where Python was using a lot of memory.

00:11:01.020 --> 00:11:06.140
<v MicroPython>So, uh, you know, numbers are one example, um, just the objects themselves in Python have

00:11:06.140 --> 00:11:08.320
<v MicroPython>a lot of extra state associated with them.

00:11:08.660 --> 00:11:12.820
<v MicroPython>Uh, I think even the reference counting that Python does, they looked at using a garbage

00:11:12.820 --> 00:11:16.780
<v MicroPython>collector instead of that in micro Python, because when you do a reference count, every

00:11:16.780 --> 00:11:20.200
<v MicroPython>object has to have a count of like how many instances are out there and that's going to

00:11:20.200 --> 00:11:20.960
<v MicroPython>take up some memory.

00:11:20.960 --> 00:11:27.860
<v MicroPython>So they really focus on how to, uh, slim down Python, but still implement the core language

00:11:27.860 --> 00:11:32.160
<v MicroPython>itself so that, you know, if you do a for loop in normal Python, that should be exactly

00:11:32.160 --> 00:11:33.800
<v MicroPython>the same in micro Python.

00:11:33.800 --> 00:11:38.480
<v MicroPython>And even things like defining a function and classes and all kinds of the features that

00:11:38.480 --> 00:11:41.940
<v MicroPython>Python has are also meant to be supported in micro Python.

00:11:41.940 --> 00:11:43.320
<v MicroPython>And they're pretty close.

00:11:43.320 --> 00:11:49.060
<v MicroPython>It's about, I think like 90% or so compatibility with the Python core language, uh, that they've

00:11:49.060 --> 00:11:49.820
<v MicroPython>gotten so far with it.

00:11:49.820 --> 00:11:54.120
<v MicroPython>And I guess I shouldn't really say they, uh, it's really just one person who created micro

00:11:54.120 --> 00:11:57.720
<v MicroPython>Python initially, uh, Damian George, uh, he's actually from Australia.

00:11:57.720 --> 00:12:00.100
<v MicroPython>I forget exactly where, but somewhere in Australia these days.

00:12:00.560 --> 00:12:02.420
<v MicroPython>Uh, and so he's a really cool guy.

00:12:02.480 --> 00:12:06.460
<v MicroPython>There are a couple of videos out there of a talk that he's done a few times at different

00:12:06.460 --> 00:12:07.340
<v MicroPython>Python conferences.

00:12:07.580 --> 00:12:10.940
<v MicroPython>So you can search for those and see where he just talks through a lot of his motivations

00:12:10.940 --> 00:12:15.860
<v MicroPython>and goes into more detail about how he actually got Python to fit, you know, in these small

00:12:15.860 --> 00:12:17.100
<v MicroPython>memory constrained environments.

00:12:17.100 --> 00:12:20.680
<v MicroPython>Uh, but that, so that's the big difference is that, you know, it's, it's a new implementation.

00:12:21.400 --> 00:12:26.740
<v MicroPython>He didn't just take the C Python code from the desktop Python and just port it over to

00:12:26.740 --> 00:12:28.460
<v MicroPython>work on, uh, other processors.

00:12:28.620 --> 00:12:32.560
<v MicroPython>The, the other big difference too, is that it can run in kind of these bare metal environments

00:12:32.560 --> 00:12:34.680
<v MicroPython>where you don't have an operating system.

00:12:34.680 --> 00:12:39.180
<v MicroPython>So you don't have the typical kind of like Linux system calls and things that you might

00:12:39.180 --> 00:12:40.240
<v MicroPython>want to have available.

00:12:40.540 --> 00:12:42.740
<v Chris Gammell>Which requires memory management and stuff like that, right?

00:12:42.840 --> 00:12:43.160
<v MicroPython>Exactly.

00:12:43.260 --> 00:12:46.580
<v MicroPython>Or it might just even limit you because, you know, like in a Cortex M processor, you're not

00:12:46.580 --> 00:12:49.460
<v MicroPython>going to be running a full operating system on necessarily.

00:12:49.840 --> 00:12:50.360
<v Chris Gammell>So yeah.

00:12:50.360 --> 00:12:53.800
<v Chris Gammell>Cause I guess you could these days, I mean, you could just get a BeagleBone Black or something

00:12:53.800 --> 00:12:55.860
<v Chris Gammell>like that and just run regular Python on it, right?

00:12:55.860 --> 00:12:56.220
<v Chris Gammell>That's not.

00:12:56.380 --> 00:12:56.840
<v Chris Gammell>Oh yeah, exactly.

00:12:56.960 --> 00:13:00.380
<v Chris Gammell>That's, that's kind of the modus operandi of processing on there anyways.

00:13:00.380 --> 00:13:03.500
<v Chris Gammell>As far as I've seen Adafruit has a bunch of tutorials about that too, right?

00:13:04.280 --> 00:13:04.420
<v Chris Gammell>Yeah.

00:13:04.420 --> 00:13:08.100
<v MicroPython>Or even just like a Raspberry Pi, like the Pi zero, you know, tiny little Linux computer.

00:13:08.100 --> 00:13:13.240
<v MicroPython>And I'm sure like this time next year we'll be like covered in more tiny little Linux computers

00:13:13.240 --> 00:13:15.240
<v MicroPython>and things, you know, uh, small processors.

00:13:15.240 --> 00:13:17.540
<v MicroPython>And that's a perfectly valid option though, too.

00:13:17.640 --> 00:13:21.680
<v MicroPython>You know, if you want to do Python stuff on, uh, embedded or small systems, sure.

00:13:21.680 --> 00:13:26.780
<v MicroPython>Like a Linux running or a real kind of desktop operating system running machine is, is an

00:13:26.780 --> 00:13:27.020
<v MicroPython>option.

00:13:27.060 --> 00:13:30.060
<v MicroPython>It's, you're going to pay more for it probably with like power consumption.

00:13:30.060 --> 00:13:31.320
<v MicroPython>And maybe costs and things.

00:13:31.820 --> 00:13:35.740
<v MicroPython>Uh, but it is something to think about too, is, you know, maybe another extreme of when

00:13:35.740 --> 00:13:37.980
<v MicroPython>you need more power, uh, potentially or more memory.

00:13:38.400 --> 00:13:42.020
<v Chris Gammell>So what, what is, what is the relative, can you give us an idea of relative size?

00:13:42.020 --> 00:13:46.060
<v Chris Gammell>Like, so maybe just giving it in, well, I guess you could, you could talk about it in memory,

00:13:46.060 --> 00:13:48.880
<v Chris Gammell>but also just talking about it in processors would be the easiest thing.

00:13:48.980 --> 00:13:49.080
<v MicroPython>Right.

00:13:49.160 --> 00:13:52.080
<v MicroPython>So some of those processors that MicroPython runs on would be interesting.

00:13:52.280 --> 00:13:57.120
<v MicroPython>So the very first board that it was made for, uh, something called the Pi board, and it's

00:13:57.120 --> 00:13:58.960
<v MicroPython>a Cortex M4.

00:13:59.160 --> 00:14:01.260
<v MicroPython>It's an STM chip, uh, if I remember correctly.

00:14:01.620 --> 00:14:04.140
<v MicroPython>And so it's a pretty beefy, um, uh, processor.

00:14:04.300 --> 00:14:09.000
<v MicroPython>I forget exactly how much memory, uh, it has, but you know, more than I'm guessing like at

00:14:09.000 --> 00:14:12.580
<v MicroPython>least like 64 K or, uh, yeah, it's got 32, 64, 128.

00:14:12.580 --> 00:14:13.560
<v Dave Jones>Is that order?

00:14:14.060 --> 00:14:14.160
<v MicroPython>Right.

00:14:14.760 --> 00:14:14.940
<v MicroPython>Yep.

00:14:15.060 --> 00:14:19.600
<v MicroPython>So pretty decent size, uh, uh, processor for that, but certainly not big enough to run like

00:14:19.600 --> 00:14:22.640
<v MicroPython>a real operating system or a Linux or, you know, something like that.

00:14:22.960 --> 00:14:24.840
<v MicroPython>Uh, so that's kind of the first processor.

00:14:25.120 --> 00:14:30.260
<v MicroPython>And then, uh, the ESP 8266 came along, which is like the really popular wifi microcontroller

00:14:30.260 --> 00:14:31.080
<v MicroPython>from Espressif.

00:14:31.240 --> 00:14:35.840
<v MicroPython>Just kind of took off last year and people found that you could port MicroPython to that.

00:14:35.920 --> 00:14:38.760
<v MicroPython>Uh, they actually did a Kickstarter, had a bunch of success with that.

00:14:38.760 --> 00:14:41.960
<v MicroPython>And so that again is a relatively fast processor.

00:14:42.080 --> 00:14:44.920
<v MicroPython>I think it's like 84 megahertz, like 96 kilobytes of memory.

00:14:45.120 --> 00:14:46.140
<v MicroPython>So decent size.

00:14:46.620 --> 00:14:50.540
<v MicroPython>Uh, but a really interesting thing on the low end, they actually got MicroPython to run

00:14:50.540 --> 00:14:56.660
<v MicroPython>on the BBC micro bit, which is this tiny little, uh, computer that every, I think seventh grader

00:14:56.660 --> 00:14:58.160
<v MicroPython>in England received.

00:14:58.260 --> 00:15:01.520
<v MicroPython>And so it was kind of a initiative from the governor, uh, government to say, okay, we want

00:15:01.520 --> 00:15:03.280
<v MicroPython>to get more computer science education.

00:15:03.280 --> 00:15:05.920
<v MicroPython>And so every kid gets to have one of these little boards to learn with.

00:15:05.920 --> 00:15:10.840
<v MicroPython>And initially I think that was meant to run, uh, just kind of bare metal, like C Arduino

00:15:10.840 --> 00:15:13.840
<v MicroPython>kind of style code, but they got MicroPython to run on that.

00:15:13.900 --> 00:15:19.280
<v MicroPython>And that's an NRF 51, if I remember correctly, which only has 16 kilobytes of memory.

00:15:19.920 --> 00:15:24.040
<v MicroPython>And I can't remember exactly the processor speed that it runs at, but pretty impressive that

00:15:24.040 --> 00:15:27.460
<v MicroPython>they got Python to run just in that 16 K of memory.

00:15:27.620 --> 00:15:31.960
<v MicroPython>And apparently when you do have a program that runs there, you only have around four kilobytes

00:15:31.960 --> 00:15:32.360
<v MicroPython>of memory.

00:15:32.360 --> 00:15:33.360
<v MicroPython>Yeah.

00:15:33.360 --> 00:15:34.660
<v Dave Jones>I was going to say how much left.

00:15:34.660 --> 00:15:34.900
<v Dave Jones>Right.

00:15:34.980 --> 00:15:38.340
<v MicroPython>You're not going to be doing a whole lot of things with that, but it's still for, for

00:15:38.340 --> 00:15:42.220
<v MicroPython>learning for, you know, showing someone like, okay, here's how you blink an LED or here's

00:15:42.220 --> 00:15:45.840
<v MicroPython>how you maybe make like, uh, you know, a relay activator or something like that.

00:15:45.920 --> 00:15:48.980
<v MicroPython>That's just a few kilobytes is really all you need to do stuff like that.

00:15:49.300 --> 00:15:49.700
<v MicroPython>That's great.

00:15:49.700 --> 00:15:53.380
<v Dave Jones>Now comes the question, like, why?

00:15:54.140 --> 00:15:55.180
<v Dave Jones>Why do that instance C?

00:15:55.180 --> 00:15:56.480
<v Dave Jones>We don't get into that now.

00:15:56.600 --> 00:15:57.000
<v Dave Jones>Yeah, yeah, yeah.

00:15:57.000 --> 00:15:57.620
<v Dave Jones>Sure, sure.

00:15:57.780 --> 00:15:59.960
<v Chris Gammell>We're going to get a couple more questions in before we go deep.

00:15:59.960 --> 00:16:00.220
<v Chris Gammell>Yeah.

00:16:00.540 --> 00:16:00.840
<v Dave Jones>All right.

00:16:01.040 --> 00:16:04.180
<v Dave Jones>Well, what other processes is it available on by the way?

00:16:04.260 --> 00:16:10.220
<v Dave Jones>Like, does it, you mentioned Arduino before, is it available on an 8-bit, um, an 8-bit

00:16:10.220 --> 00:16:10.400
<v Dave Jones>Yeah.

00:16:10.400 --> 00:16:11.080
<v MicroPython>Great question.

00:16:11.200 --> 00:16:15.720
<v MicroPython>So no, not that I've seen, uh, I don't know of an AVR implementation for those kinds of

00:16:15.720 --> 00:16:16.900
<v MicroPython>8 or 16-bit processors.

00:16:17.200 --> 00:16:22.560
<v MicroPython>Uh, it does run on the CC3100, I believe that's the Wi-Fi.

00:16:22.720 --> 00:16:22.960
<v MicroPython>Yep.

00:16:22.960 --> 00:16:24.760
<v MicroPython>Uh, and so that's a nice little processor.

00:16:25.200 --> 00:16:26.420
<v MicroPython>Uh, and then we're actually working at 8-bit.

00:16:26.420 --> 00:16:27.500
<v Dave Jones>That's a TI one, isn't it?

00:16:27.500 --> 00:16:28.400
<v MicroPython>A TI, exactly.

00:16:28.480 --> 00:16:28.620
<v MicroPython>Yeah.

00:16:28.620 --> 00:16:28.680
<v MicroPython>Yeah.

00:16:29.120 --> 00:16:35.300
<v MicroPython>Uh, and then we're working on, uh, the Atmel, the SAMD21, which is a Cortex-M0.

00:16:35.600 --> 00:16:37.340
<v MicroPython>So it's kind of similar to the microbit.

00:16:37.440 --> 00:16:39.320
<v MicroPython>That's a Cortex-M0 that the microbit had.

00:16:39.660 --> 00:16:44.100
<v MicroPython>Uh, the SAMD is just an Atmel's version of a Cortex-M0, uh, really popular.

00:16:44.100 --> 00:16:47.140
<v MicroPython>Like, you're starting to see that in a lot more boards and chips and things, uh, these

00:16:47.140 --> 00:16:47.400
<v MicroPython>days.

00:16:47.860 --> 00:16:49.720
<v MicroPython>Uh, but it's also kind of a lower-end chip.

00:16:49.820 --> 00:16:55.220
<v MicroPython>So this one, uh, ours, the one we're using has 32 kilobytes of memory, um, and, uh, runs

00:16:55.220 --> 00:16:56.940
<v MicroPython>at 48 megahertz, I want to say.

00:16:57.140 --> 00:17:01.520
<v MicroPython>So we're kind of, you know, shooting for that lower end, um, because that's maybe makes it

00:17:01.520 --> 00:17:02.580
<v MicroPython>a little more accessible to people.

00:17:02.660 --> 00:17:07.800
<v MicroPython>You know, it'll be less cost, um, less capabilities, but also if you can get more boards out there

00:17:07.800 --> 00:17:09.280
<v MicroPython>that people are using, it'll be more interesting.

00:17:10.280 --> 00:17:12.480
<v Chris Gammell>So this is right up front.

00:17:12.600 --> 00:17:14.220
<v Chris Gammell>So this is a constrained list, right?

00:17:14.260 --> 00:17:16.500
<v Chris Gammell>There's what, six or seven on this list right here.

00:17:16.500 --> 00:17:23.060
<v Chris Gammell>So unless someone's willing to port MicroPython themselves and the processor has sufficient

00:17:23.060 --> 00:17:27.940
<v Chris Gammell>memory, you are constrained to a subset of all boards out there, right?

00:17:28.000 --> 00:17:30.320
<v Chris Gammell>I mean, that is an important thing to know up front.

00:17:30.400 --> 00:17:30.680
<v Chris Gammell>Definitely.

00:17:30.940 --> 00:17:31.100
<v Chris Gammell>Yep.

00:17:31.200 --> 00:17:36.960
<v MicroPython>And they are actually working on, um, I believe there's a port for some of these new, uh, I

00:17:36.960 --> 00:17:41.760
<v MicroPython>don't want to necessarily say RTOS is, but like Zephyr and Minutes and some of these,

00:17:41.760 --> 00:17:47.520
<v MicroPython>uh, you know, higher level abstractions, uh, like HALs, like a common HAL across a whole

00:17:47.520 --> 00:17:48.020
<v MicroPython>bunch of chips.

00:17:48.020 --> 00:17:51.760
<v MicroPython>I believe they've got, they have a Zephyr port that's kind of in progress.

00:17:51.760 --> 00:17:55.520
<v MicroPython>And so that might open it up to more boards and more chips because, you know, in theory,

00:17:55.520 --> 00:17:58.620
<v MicroPython>if any board supports like Zephyr or some of these other operating systems.

00:17:58.900 --> 00:18:00.140
<v Dave Jones>I haven't heard of any of these.

00:18:00.300 --> 00:18:00.900
<v Dave Jones>Too many.

00:18:01.060 --> 00:18:01.420
<v Dave Jones>Stop it.

00:18:01.580 --> 00:18:02.160
<v Dave Jones>Yeah, exactly.

00:18:02.400 --> 00:18:03.140
<v Dave Jones>They're kind of new.

00:18:03.260 --> 00:18:06.620
<v MicroPython>I think Zephyr is like from the Linux foundation and Minutes, I think it's from Apache.

00:18:06.620 --> 00:18:08.940
<v MicroPython>So if you haven't heard of them, you'll hear about them soon, I bet.

00:18:09.100 --> 00:18:09.520
<v MicroPython>So, yeah.

00:18:10.180 --> 00:18:11.860
<v Dave Jones>I don't want to hear about them.

00:18:12.040 --> 00:18:12.460
<v Dave Jones>Right, right.

00:18:12.500 --> 00:18:13.340
<v Dave Jones>Dave, you're not going to use it.

00:18:13.480 --> 00:18:15.180
<v Dave Jones>You and I will not be using that stuff.

00:18:15.280 --> 00:18:15.620
<v Chris Gammell>We'll be fine.

00:18:16.360 --> 00:18:17.660
<v Chris Gammell>So, so here's my question then.

00:18:17.720 --> 00:18:17.860
<v Chris Gammell>Okay.

00:18:17.900 --> 00:18:18.600
<v Chris Gammell>So now, okay.

00:18:18.600 --> 00:18:20.800
<v Chris Gammell>So there's six boards, seven boards listed here, whatever.

00:18:21.660 --> 00:18:29.580
<v Chris Gammell>Uh, does that mean now that if I pull in any normal Python code and I properly map a

00:18:29.580 --> 00:18:36.400
<v Chris Gammell>pin and the, uh, the underlying resources, like, uh, if there's a, uh, I squared C macro

00:18:36.400 --> 00:18:42.460
<v Chris Gammell>or some kind of hardware piece is there and is mapped any Python code that I import should

00:18:42.460 --> 00:18:43.100
<v Chris Gammell>pretty much work.

00:18:43.100 --> 00:18:44.720
<v Chris Gammell>Is that, is that a fair statement or no?

00:18:45.280 --> 00:18:45.680
<v MicroPython>Yeah.

00:18:45.820 --> 00:18:47.540
<v MicroPython>And so that's a great kind of point.

00:18:47.640 --> 00:18:50.840
<v MicroPython>Maybe the differences between like desktop and MicroPython also.

00:18:50.840 --> 00:18:55.240
<v MicroPython>So, you know, the syntax of the core Python language is exactly the same.

00:18:55.320 --> 00:18:59.560
<v MicroPython>So if you wanted to blink an led in a loop, you know, you would write a loop exactly the

00:18:59.560 --> 00:19:01.420
<v MicroPython>same way you would do it in normal Python.

00:19:01.860 --> 00:19:05.840
<v MicroPython>Uh, but where some of the differences come in are with the libraries, because that's

00:19:05.840 --> 00:19:08.140
<v MicroPython>another big thing that desktop Python is known for.

00:19:08.220 --> 00:19:13.200
<v MicroPython>They call it batteries included where in the standard Python library, there's pretty much

00:19:13.200 --> 00:19:14.320
<v MicroPython>a module for everything.

00:19:14.320 --> 00:19:20.320
<v MicroPython>So if you want to go talk to your email server and download all of the, uh, email over like

00:19:20.320 --> 00:19:25.100
<v MicroPython>the IMAP protocol and process those and do certain things, almost all of that stuff is

00:19:25.100 --> 00:19:26.000
<v MicroPython>in the standard library.

00:19:26.000 --> 00:19:30.380
<v MicroPython>But it's really hard to fit all that into MicroPython because again, you're running on

00:19:30.380 --> 00:19:31.080
<v MicroPython>these tiny chips.

00:19:31.080 --> 00:19:32.100
<v Dave Jones>I was going to say what, yeah.

00:19:32.200 --> 00:19:36.260
<v Dave Jones>Does anyone who implements a new version, do they include everything or do they just

00:19:36.260 --> 00:19:37.620
<v Dave Jones>include the stuff that they want?

00:19:37.820 --> 00:19:38.820
<v Dave Jones>And then you miss out.

00:19:39.060 --> 00:19:43.220
<v MicroPython>Ideally, when you implement a new version, you really just have to implement, uh, the access

00:19:43.220 --> 00:19:45.900
<v MicroPython>to your hardware because that's always going to be specific to your chip.

00:19:46.080 --> 00:19:47.420
<v MicroPython>You've got to have all your peripheral access.

00:19:47.760 --> 00:19:50.940
<v Dave Jones>So you've got to have IO, you've got to have I squared C, SPI.

00:19:50.940 --> 00:19:51.340
<v Dave Jones>Exactly.

00:19:51.340 --> 00:19:53.740
<v MicroPython>You've got to have, you know, basic access to that stuff.

00:19:53.740 --> 00:19:54.180
<v MicroPython>USB.

00:19:54.900 --> 00:19:55.300
<v MicroPython>Right.

00:19:55.420 --> 00:20:00.100
<v MicroPython>And then there are libraries on top of that that are relatively common and can be shared

00:20:00.100 --> 00:20:00.920
<v MicroPython>across the board.

00:20:01.100 --> 00:20:06.000
<v MicroPython>So, uh, for example, like JSON, uh, the data format, that kind of parsing that doesn't even

00:20:06.000 --> 00:20:06.800
<v MicroPython>involve IO.

00:20:07.020 --> 00:20:09.900
<v MicroPython>Uh, so there's like a module built into MicroPython for that.

00:20:09.940 --> 00:20:13.540
<v MicroPython>And so all of the ports can use that, uh, for other types of processing.

00:20:13.700 --> 00:20:18.500
<v MicroPython>Like if you want to talk to a web service, uh, there's a library called requests in Python.

00:20:18.500 --> 00:20:19.300
<v MicroPython>That's really popular.

00:20:19.420 --> 00:20:21.740
<v MicroPython>And so they have a port of that to MicroPython.

00:20:21.740 --> 00:20:24.680
<v MicroPython>And so this is something kind of on their GitHub repository.

00:20:24.680 --> 00:20:29.400
<v MicroPython>They have this MicroPython library, uh, repository where they're putting all of this common code

00:20:29.400 --> 00:20:32.860
<v MicroPython>where you can pick and choose, you know, you might be more limited and maybe you can only

00:20:32.860 --> 00:20:35.400
<v MicroPython>fit so many libraries onto your board and your chip.

00:20:35.660 --> 00:20:37.940
<v MicroPython>So you choose, okay, yeah, I'm going to talk to web service.

00:20:38.060 --> 00:20:41.220
<v MicroPython>So I need this web service library and maybe the JSON processing.

00:20:41.220 --> 00:20:45.200
<v MicroPython>And I pull those in as modules into my, uh, code and use them from there.

00:20:45.200 --> 00:20:46.460
<v MicroPython>So it's a little bit different.

00:20:46.460 --> 00:20:49.680
<v MicroPython>Whereas in like the desktop Python world, it's just there and available and you just use

00:20:49.680 --> 00:20:51.240
<v MicroPython>it and go crazy with it.

00:20:51.620 --> 00:20:54.380
<v Chris Gammell>So what about if I, okay, so the JSON is a great example, right?

00:20:54.380 --> 00:20:58.380
<v Chris Gammell>Cause a lot of people use that for, for web processing of like being able to pull out,

00:20:58.380 --> 00:21:00.340
<v Chris Gammell>you know, it's like key value pair, right?

00:21:00.340 --> 00:21:01.700
<v Chris Gammell>That's how a lot of that stuff works.

00:21:01.700 --> 00:21:05.340
<v Chris Gammell>So it would be like temperature 25 C, right?

00:21:05.340 --> 00:21:06.720
<v Chris Gammell>That would be like key value pair.

00:21:06.720 --> 00:21:14.520
<v Chris Gammell>Um, so if I wanted to implement that and see though, that would be a lot harder.

00:21:14.520 --> 00:21:19.800
<v Chris Gammell>Cause then I'd have to go like, I'd have to manually, are there similarly like C libraries

00:21:19.800 --> 00:21:20.740
<v Chris Gammell>that can do that same kind of thing?

00:21:20.740 --> 00:21:23.080
<v Chris Gammell>Cause like I'm, I'm never doing that kind of stuff anyways.

00:21:23.080 --> 00:21:24.040
<v Chris Gammell>That's what I'm really getting at.

00:21:24.200 --> 00:21:29.540
<v MicroPython>It's, it's a lot easier in Python because in Python you have a native dictionary type.

00:21:29.540 --> 00:21:31.780
<v MicroPython>So a dictionary is like a name value store.

00:21:31.780 --> 00:21:36.080
<v MicroPython>You know, I have an object and I want to put like a temperature inside of it.

00:21:36.120 --> 00:21:40.220
<v MicroPython>And so I can assign a position in that dictionary of, you know, this is called temperature and

00:21:40.220 --> 00:21:43.880
<v MicroPython>here's the current value, which maybe it's a floating point value, or maybe it's a whole

00:21:43.880 --> 00:21:44.600
<v MicroPython>other object.

00:21:45.040 --> 00:21:47.960
<v MicroPython>Um, it's really easy and just a few lines of code to do that.

00:21:48.040 --> 00:21:49.280
<v MicroPython>And that's really nice too.

00:21:49.300 --> 00:21:55.720
<v MicroPython>And that when you parse JSON in Python, it effectively just turns this string of, uh, that data that

00:21:55.720 --> 00:21:59.420
<v MicroPython>you might've gotten from a web service request into a dictionary that you just immediately

00:21:59.420 --> 00:22:00.420
<v MicroPython>start operating on.

00:22:00.420 --> 00:22:04.700
<v MicroPython>Whereas if you want to do that in C, you're probably going to want to find a library.

00:22:04.700 --> 00:22:08.600
<v MicroPython>Like you could write your own JSON parser, but then, you know, make sure that you're

00:22:08.600 --> 00:22:10.020
<v MicroPython>checking all the links of your buffers.

00:22:10.020 --> 00:22:10.340
<v MicroPython>Yeah.

00:22:10.500 --> 00:22:12.280
<v MicroPython>That you're doing any kind of text processing.

00:22:12.380 --> 00:22:12.960
<v MicroPython>It's always fun.

00:22:13.400 --> 00:22:16.140
<v MicroPython>Uh, but it's going to be a little bit more different in the syntax.

00:22:16.260 --> 00:22:21.260
<v MicroPython>You know, I haven't used a lot of the C JSON libraries, but usually it's a very verbose

00:22:21.260 --> 00:22:26.540
<v MicroPython>kind of thing of you have to, uh, you know, process, initialize this thing and then start

00:22:26.540 --> 00:22:28.480
<v MicroPython>asking, okay, I've got this object.

00:22:28.480 --> 00:22:30.860
<v MicroPython>Does it have a temperature field inside of it?

00:22:30.920 --> 00:22:31.480
<v MicroPython>Yes or no.

00:22:31.580 --> 00:22:34.480
<v MicroPython>And then, okay, now pull out the value of that as a floating point or something like

00:22:34.480 --> 00:22:34.680
<v MicroPython>that.

00:22:34.720 --> 00:22:38.820
<v MicroPython>So it just turns into more code, a little bit more complexity, uh, in some cases for it.

00:22:39.020 --> 00:22:42.900
<v MicroPython>Whereas, you know, a few lines of Python might be like 10 or 20 lines of C code potentially

00:22:42.900 --> 00:22:44.280
<v MicroPython>to, to get the same result.

00:22:44.680 --> 00:22:44.800
<v MicroPython>Huh?

00:22:44.800 --> 00:22:45.300
<v MicroPython>Yeah.

00:22:45.300 --> 00:22:48.800
<v Chris Gammell>So it's possible in both, but it's just easy.

00:22:48.960 --> 00:22:55.000
<v Chris Gammell>It's just less over, well, more overhead, but less, uh, less details that you have to implement

00:22:55.000 --> 00:22:56.540
<v Chris Gammell>yourself in Python.

00:22:56.620 --> 00:22:57.000
<v Chris Gammell>Is that right?

00:22:57.380 --> 00:22:57.780
<v MicroPython>Exactly.

00:22:57.880 --> 00:22:58.040
<v Chris Gammell>Yeah.

00:22:58.040 --> 00:23:02.200
<v MicroPython>So it's just, you know, simpler syntax, less code that you might have to write, uh, makes

00:23:02.200 --> 00:23:05.820
<v MicroPython>it, uh, simpler to maintain potentially for it and easier to learn too.

00:23:05.900 --> 00:23:09.920
<v MicroPython>You know, if it's just a few lines of code to talk to web service, then that's a lot simpler

00:23:09.920 --> 00:23:13.820
<v MicroPython>than maybe explaining to someone, okay, here's how you initialize all these objects and how

00:23:13.820 --> 00:23:15.240
<v MicroPython>to, you know, fire off these requests.

00:23:15.260 --> 00:23:17.840
<v Chris Gammell>I think this is why it tickled my brain in the first place.

00:23:17.880 --> 00:23:20.720
<v Chris Gammell>This whole idea is because, okay, so like hackathons, right?

00:23:20.800 --> 00:23:25.700
<v Chris Gammell>The thing for me at hackathons is you get people coming in who are doing like JavaScript stuff

00:23:25.700 --> 00:23:29.220
<v Chris Gammell>on the web and they're like, okay, what, what, what libraries are out there?

00:23:29.280 --> 00:23:30.000
<v Chris Gammell>What can we use?

00:23:30.040 --> 00:23:31.800
<v Chris Gammell>Let's look at the APIs and just implement it.

00:23:31.800 --> 00:23:32.000
<v Chris Gammell>Right.

00:23:32.280 --> 00:23:32.980
<v Chris Gammell>And that's great.

00:23:32.980 --> 00:23:33.200
<v Chris Gammell>Right.

00:23:33.200 --> 00:23:37.400
<v Chris Gammell>And that allows you to really quickly prototype things and, and put things together and then focus

00:23:37.400 --> 00:23:42.020
<v Chris Gammell>more on the design aspect and stuff like that in hard, like I think about doing that for

00:23:42.020 --> 00:23:42.260
<v Chris Gammell>hardware.

00:23:42.360 --> 00:23:43.240
<v Chris Gammell>It's like, oh, well crap.

00:23:43.240 --> 00:23:46.620
<v Chris Gammell>I got to like, you know, figure out all the low level processing stuff, make sure all that

00:23:46.620 --> 00:23:47.240
<v Chris Gammell>stuff works.

00:23:47.500 --> 00:23:53.080
<v Chris Gammell>And it's, you know, with, with an, uh, Arduino or something like it is possible, but it's not

00:23:53.080 --> 00:23:57.980
<v Chris Gammell>necessarily, uh, it doesn't seem like it's quite as elegant either.

00:23:57.980 --> 00:23:58.200
<v Chris Gammell>Right.

00:23:58.200 --> 00:24:02.840
<v Chris Gammell>So like you thinking now comparing Arduino and, and Python, you know, it's similar in that it's,

00:24:02.920 --> 00:24:03.780
<v Chris Gammell>it's high level.

00:24:03.780 --> 00:24:09.580
<v Chris Gammell>It's, it's easy to read and stuff like that, but it doesn't seem like there's as much stuff

00:24:09.580 --> 00:24:09.820
<v Chris Gammell>there.

00:24:10.040 --> 00:24:11.220
<v Chris Gammell>Maybe you can compare those two.

00:24:11.300 --> 00:24:11.580
<v Chris Gammell>I don't know.

00:24:11.860 --> 00:24:12.040
<v Dave Jones>Yeah.

00:24:12.160 --> 00:24:17.100
<v Dave Jones>Well, and that's, that's C, but the one thing there, Chris, is that's, uh, the, the Arduino

00:24:17.100 --> 00:24:18.420
<v Dave Jones>language is C.

00:24:18.940 --> 00:24:19.300
<v Dave Jones>Right.

00:24:19.380 --> 00:24:20.400
<v Dave Jones>It is compiled C.

00:24:20.560 --> 00:24:20.840
<v Chris Gammell>Correct.

00:24:20.900 --> 00:24:21.040
<v Chris Gammell>Yeah.

00:24:21.420 --> 00:24:21.600
<v Chris Gammell>Right.

00:24:21.600 --> 00:24:23.080
<v Chris Gammell>So it has you to go to like a lower language.

00:24:23.080 --> 00:24:25.240
<v Dave Jones>It's just, it just uses libraries.

00:24:25.420 --> 00:24:26.700
<v Dave Jones>It just uses C libraries.

00:24:26.700 --> 00:24:29.000
<v Dave Jones>That's, you know, it, but it does actually compile.

00:24:29.140 --> 00:24:32.080
<v Dave Jones>It's not interpreted or anything else.

00:24:32.080 --> 00:24:38.240
<v MicroPython>Arduino opened up electronics to a lot of beginners, like people that wouldn't really know how to

00:24:38.240 --> 00:24:43.360
<v MicroPython>set up an AVR GCC tool chain to compile code, to run on these little processors.

00:24:43.760 --> 00:24:43.920
<v MicroPython>Yeah.

00:24:43.920 --> 00:24:44.760
<v MicroPython>It made it really simple.

00:24:44.860 --> 00:24:49.100
<v MicroPython>You just download the IDE, you open it up, you type in your code, you press upload, and

00:24:49.100 --> 00:24:50.220
<v MicroPython>it pushes out to the board.

00:24:50.780 --> 00:24:54.540
<v MicroPython>And MicroPython, I think we'll make it a little bit easier and even open it up to more people

00:24:54.540 --> 00:24:59.520
<v MicroPython>because, uh, with MicroPython, since it's an interpreted language, it gives you a lot

00:24:59.520 --> 00:25:03.160
<v MicroPython>of flexibility so that you can actually run code without having to compile it.

00:25:03.260 --> 00:25:06.680
<v MicroPython>So you don't need to have this whole compiler set up.

00:25:06.820 --> 00:25:10.060
<v MicroPython>You don't have to have a whole IDE even connected to this.

00:25:10.060 --> 00:25:14.180
<v MicroPython>You can just open a serial connection that talks to your board, like over a USB to serial

00:25:14.180 --> 00:25:18.480
<v MicroPython>connection and, uh, get a prompt that just lets you type in Python code.

00:25:18.480 --> 00:25:23.380
<v MicroPython>And so they call it a REPL in the Python world, R-E-P-L, a read, evaluate, print loop.

00:25:23.700 --> 00:25:25.700
<v MicroPython>And that's basically just a Python prompt.

00:25:25.880 --> 00:25:27.680
<v MicroPython>So you type in Python code, you press enter.

00:25:27.680 --> 00:25:29.680
<v Dave Jones>Why do these call it a Python prompt?

00:25:29.840 --> 00:25:30.660
<v MicroPython>Uh, good question.

00:25:30.740 --> 00:25:30.900
<v MicroPython>I don't know.

00:25:30.900 --> 00:25:31.860
<v MicroPython>Everything has to be complex.

00:25:32.080 --> 00:25:33.640
<v MicroPython>So yeah, it has to have a fancy acronym.

00:25:34.080 --> 00:25:35.960
<v MicroPython>Uh, so you can get that REPL though.

00:25:35.980 --> 00:25:39.180
<v MicroPython>And as a beginner, that's really nice because you connect to your board.

00:25:39.420 --> 00:25:42.460
<v MicroPython>You don't have to worry about, okay, I have to go find all this software.

00:25:43.020 --> 00:25:47.140
<v MicroPython>Uh, and even in the Arduino world, it's a little more complex usually because you might want

00:25:47.140 --> 00:25:48.640
<v MicroPython>to use like a piece of hardware.

00:25:48.640 --> 00:25:51.780
<v MicroPython>And so you have to go find the library for that and then how to install that library.

00:25:52.220 --> 00:25:56.420
<v MicroPython>Uh, whereas with MicroPython, just connect to the board, start typing in some commands.

00:25:56.420 --> 00:25:58.680
<v MicroPython>Like you could just do the basics, you know, print hello world.

00:25:58.680 --> 00:25:59.480
<v MicroPython>And it'll do that.

00:25:59.540 --> 00:26:02.380
<v MicroPython>But you can also say, okay, I want to create an I squared C device.

00:26:02.380 --> 00:26:06.120
<v MicroPython>And now I want to maybe read a register or write some data to it and go from there with

00:26:06.120 --> 00:26:06.240
<v MicroPython>it.

00:26:06.240 --> 00:26:10.380
<v MicroPython>So that's kind of cool that it's something you can't really do with an Arduino or some of

00:26:10.380 --> 00:26:14.060
<v MicroPython>these platforms where you have to compile that code ahead of time and push it out to the

00:26:14.060 --> 00:26:14.340
<v MicroPython>board.

00:26:14.340 --> 00:26:18.620
<v MicroPython>You know, this gives you a lot more flexibility to just play with the hardware and experiment

00:26:18.620 --> 00:26:19.120
<v MicroPython>with it.

00:26:19.120 --> 00:26:20.480
<v MicroPython>Uh, and see how it goes there.

00:26:20.480 --> 00:26:23.220
<v Chris Gammell>It kind of reminds me of actually like Dave brought up is kind of reminds me of basic

00:26:23.220 --> 00:26:26.980
<v Chris Gammell>where you could write, you could write a program in basic, but you could also just, you know,

00:26:27.240 --> 00:26:29.300
<v Chris Gammell>10, 10, go to whatever, you know, like you just.

00:26:29.300 --> 00:26:30.240
<v Chris Gammell>Yeah, exactly.

00:26:30.700 --> 00:26:31.060
<v MicroPython>Exactly.

00:26:31.180 --> 00:26:32.600
<v MicroPython>And that's, that's maybe the fun of it too.

00:26:32.740 --> 00:26:36.940
<v MicroPython>Uh, you know, as you get in and start playing with it, it's, it gives you that kind of sense.

00:26:36.940 --> 00:26:40.100
<v MicroPython>Like actually Q basic was the first language I learned how to program on.

00:26:40.160 --> 00:26:43.940
<v MicroPython>And so it's, it's, it's fun to come back and it's like, well, you know, Python isn't so

00:26:43.940 --> 00:26:44.720
<v MicroPython>different from that.

00:26:44.720 --> 00:26:47.740
<v MicroPython>It's, you know, it's like different syntax, but it's the same kind of fun.

00:26:47.840 --> 00:26:49.220
<v Dave Jones>It gives you that immediate feedback.

00:26:49.220 --> 00:26:55.160
<v Dave Jones>So you can just go, you know, I equals 10 and you don't have to put, and then it assigns

00:26:55.160 --> 00:26:57.180
<v Dave Jones>that and knows that's a variable and it assigns it.

00:26:57.180 --> 00:26:58.800
<v Dave Jones>Does that, does it work immediately?

00:26:58.800 --> 00:27:00.780
<v Dave Jones>Like, and then you can go print a, does that?

00:27:00.900 --> 00:27:01.260
<v MicroPython>Exactly.

00:27:01.360 --> 00:27:01.500
<v MicroPython>Yep.

00:27:01.540 --> 00:27:02.080
<v MicroPython>You can do that.

00:27:02.180 --> 00:27:05.700
<v MicroPython>So there's a whole global state and you can, you know, create variables and they'll stay

00:27:05.700 --> 00:27:06.280
<v MicroPython>inside of there.

00:27:06.320 --> 00:27:09.720
<v MicroPython>You can make functions, uh, cause Python's a very dynamic language.

00:27:09.720 --> 00:27:13.780
<v MicroPython>You can make classes at the REPL, uh, anything you can do with Python code.

00:27:13.780 --> 00:27:18.600
<v MicroPython>You can just type it in there and go from, uh, yeah, it's very basic like, yeah.

00:27:18.600 --> 00:27:24.280
<v Chris Gammell>I was, I was just, I was following Tony's tutorials today and I had it plugged into a little led

00:27:24.280 --> 00:27:27.600
<v Chris Gammell>shield and it was really nice because, or they called feathers, I guess, for a fruit,

00:27:27.680 --> 00:27:27.820
<v Chris Gammell>right?

00:27:28.160 --> 00:27:28.380
<v Chris Gammell>Right.

00:27:28.460 --> 00:27:28.600
<v Chris Gammell>Yeah.

00:27:28.600 --> 00:27:29.740
<v Chris Gammell>The feather kind of form factor.

00:27:29.940 --> 00:27:30.060
<v Chris Gammell>Yeah.

00:27:30.360 --> 00:27:32.560
<v Chris Gammell>And it was just like, Oh, I have, I have it here.

00:27:32.620 --> 00:27:33.120
<v Chris Gammell>What does it say?

00:27:33.120 --> 00:27:39.200
<v Chris Gammell>It was, uh, uh, display dot fill and then zero in brackets and then display dot, dot fill

00:27:39.200 --> 00:27:40.620
<v Chris Gammell>with one 27 in brackets.

00:27:40.620 --> 00:27:43.660
<v Chris Gammell>And that just turned the whole whole display on the way, all the way on, all the way off

00:27:43.660 --> 00:27:44.120
<v Chris Gammell>real simple.

00:27:44.120 --> 00:27:44.500
<v Chris Gammell>Right.

00:27:44.560 --> 00:27:49.180
<v Chris Gammell>And it was just, just those two lines allowed me to toggle the whole thing on and off and

00:27:49.180 --> 00:27:50.080
<v Chris Gammell>get immediate feedback.

00:27:50.080 --> 00:27:50.860
<v Chris Gammell>So that was really cool.

00:27:51.540 --> 00:27:51.900
<v MicroPython>Exactly.

00:27:52.000 --> 00:27:52.160
<v MicroPython>Yeah.

00:27:52.160 --> 00:27:56.480
<v MicroPython>And so that's where we think with beginners, especially it's going to be super powerful and

00:27:56.480 --> 00:27:59.840
<v MicroPython>super compelling, uh, because we've also gotten a lot of feedback from people that

00:27:59.840 --> 00:28:03.100
<v MicroPython>have used Arduino, uh, and tell us, you know, Hey, I did a workshop.

00:28:03.820 --> 00:28:08.280
<v MicroPython>And the first hour was just explaining to people how to install the software and how

00:28:08.280 --> 00:28:10.520
<v MicroPython>to get it set up and how to connect the boards.

00:28:10.840 --> 00:28:15.120
<v MicroPython>And so if you can get rid of some of that stuff, just get right to the meat of, okay,

00:28:15.120 --> 00:28:20.420
<v MicroPython>here's how you control an led or here's how, you know, you talk to this device, then that's

00:28:20.420 --> 00:28:22.000
<v MicroPython>going to make it more interesting to people.

00:28:22.320 --> 00:28:25.600
<v MicroPython>Uh, you know, you'll get less people tuning out and just rolling their eyes of, okay,

00:28:25.600 --> 00:28:26.700
<v MicroPython>this is way too complex.

00:28:27.100 --> 00:28:30.820
<v MicroPython>Uh, so, you know, we're excited about that, but on the flip side too, like micro Python

00:28:30.820 --> 00:28:33.240
<v MicroPython>is also a pretty capable language.

00:28:33.240 --> 00:28:38.080
<v MicroPython>And so maybe something interesting to talk about is, uh, especially around combining

00:28:38.080 --> 00:28:40.320
<v MicroPython>both C and Python code.

00:28:40.420 --> 00:28:42.280
<v MicroPython>And that's, I definitely, I definitely want to talk about that.

00:28:42.360 --> 00:28:43.320
<v Dave Jones>Can you do it?

00:28:43.320 --> 00:28:45.220
<v Dave Jones>Can you do inline code?

00:28:45.300 --> 00:28:45.700
<v Dave Jones>Wait, wait, wait.

00:28:45.740 --> 00:28:46.100
<v Dave Jones>Inline C?

00:28:46.180 --> 00:28:46.620
<v Dave Jones>Yeah, yeah.

00:28:46.620 --> 00:28:47.740
<v Chris Gammell>This is a huge discussion.

00:28:47.880 --> 00:28:50.800
<v Chris Gammell>I definitely want to talk about this, but I think that the thing I just wanted to bring

00:28:50.800 --> 00:28:54.440
<v Chris Gammell>up real quick is just that the, the prototyping piece, right?

00:28:54.460 --> 00:28:57.280
<v Chris Gammell>Because we were talking about that already, like the immediate feedback stuff.

00:28:57.280 --> 00:29:01.200
<v Chris Gammell>I ended up started doing that just with an Arduino anyways, right?

00:29:01.260 --> 00:29:07.840
<v Chris Gammell>Because for, for, and, and actually I remember linear tech, they started developing Arduino

00:29:07.840 --> 00:29:11.840
<v Chris Gammell>shields for their parts, which is like, that's really weird.

00:29:11.840 --> 00:29:16.060
<v Chris Gammell>But, uh, I didn't expect linear tech to do that, but yeah, yeah, no, but like, that's

00:29:16.060 --> 00:29:16.280
<v Chris Gammell>great.

00:29:16.280 --> 00:29:16.440
<v Chris Gammell>Right.

00:29:16.440 --> 00:29:21.100
<v Chris Gammell>Because it's just like immediately being able to kind of peek and poke at registers on a,

00:29:21.100 --> 00:29:24.760
<v Chris Gammell>on a ADC or something like that for someone like me, that's all I need, right?

00:29:24.760 --> 00:29:27.720
<v Chris Gammell>I just need to be able to pull data back out of an ADC.

00:29:28.120 --> 00:29:30.600
<v Chris Gammell>I'll put all the front end stuff in front of it, whatever.

00:29:30.860 --> 00:29:33.480
<v Chris Gammell>I just need to quickly get the data stream and put it somewhere.

00:29:33.880 --> 00:29:40.600
<v Chris Gammell>And that seems like where this is exciting for a hardware person is quickly getting data

00:29:40.600 --> 00:29:44.320
<v Chris Gammell>streams out of, get it, getting out of the heart, getting it out of the digital realm

00:29:44.320 --> 00:29:46.880
<v Chris Gammell>and into something that makes sense for me as quick as possible.

00:29:47.400 --> 00:29:47.500
<v MicroPython>Right.

00:29:47.600 --> 00:29:47.720
<v MicroPython>Yeah.

00:29:47.740 --> 00:29:51.760
<v MicroPython>And being able to process that data, you know, and having even like a lot of libraries and

00:29:51.760 --> 00:29:53.580
<v MicroPython>things to use, uh, can make it more interesting.

00:29:53.700 --> 00:29:54.260
<v MicroPython>So yeah, totally.

00:29:54.260 --> 00:29:56.940
<v MicroPython>You know, even if you aren't a beginner, uh, could be useful.

00:29:57.040 --> 00:30:00.220
<v MicroPython>And like you said, the, the hack, uh, hackathon kind of scenario, that's a perfect example

00:30:00.220 --> 00:30:01.380
<v MicroPython>too of like, sure.

00:30:01.380 --> 00:30:05.640
<v MicroPython>Maybe if I wanted, I could spin my own board and like bring this whole thing up bare metal,

00:30:05.640 --> 00:30:07.780
<v MicroPython>but you know, we've got 24 hours.

00:30:07.780 --> 00:30:11.700
<v MicroPython>And so I've got a MicroPython board and I can just start throwing some code on there and

00:30:11.700 --> 00:30:13.760
<v MicroPython>evolving it and making it work as we go with it.

00:30:13.760 --> 00:30:18.760
<v MicroPython>So, you know, uh, a speed or just the, the ability to get started faster, uh, is useful

00:30:18.760 --> 00:30:19.620
<v MicroPython>in a lot of cases.

00:30:19.920 --> 00:30:20.700
<v MicroPython>Yeah, definitely.

00:30:20.700 --> 00:30:21.020
<v MicroPython>Okay.

00:30:21.100 --> 00:30:21.780
<v Chris Gammell>So, okay.

00:30:21.820 --> 00:30:22.260
<v Chris Gammell>So sorry.

00:30:22.480 --> 00:30:26.900
<v Chris Gammell>I, I had, I had to say my piece there, uh, C and Python interoperability then.

00:30:27.080 --> 00:30:27.540
<v Chris Gammell>So, yeah.

00:30:27.560 --> 00:30:31.880
<v MicroPython>And so this is kind of the second kind of audience I would say for MicroPython.

00:30:31.980 --> 00:30:35.020
<v MicroPython>So the first is the true beginner, totally new to electronics.

00:30:35.020 --> 00:30:39.700
<v MicroPython>You know, the interactivity of a MicroPython is great for them, but for the more advanced

00:30:39.700 --> 00:30:44.540
<v MicroPython>users, I think there's a compelling case for MicroPython because it does allow you to

00:30:44.540 --> 00:30:47.100
<v MicroPython>mix C and Python code.

00:30:47.100 --> 00:30:52.640
<v MicroPython>So even like desktop Python is very good about letting you write, uh, functions and extensions

00:30:52.640 --> 00:30:57.960
<v MicroPython>in C that you can just call from your Python code and your Python code doesn't really even

00:30:57.960 --> 00:31:00.120
<v MicroPython>have to know that it's a C function.

00:31:00.120 --> 00:31:02.060
<v MicroPython>It just looks like a Python function.

00:31:02.240 --> 00:31:05.860
<v MicroPython>You pass in all the arguments the same way, but underneath, you know, you're actually running

00:31:05.860 --> 00:31:06.700
<v MicroPython>native code for that.

00:31:06.800 --> 00:31:09.240
<v MicroPython>And same exact thing happens with MicroPython.

00:31:09.360 --> 00:31:13.720
<v MicroPython>And actually, I mean, most of MicroPython stuff is implemented as C functions because

00:31:13.720 --> 00:31:17.380
<v MicroPython>you're going to access like your hardware, yeah, your registers, your peripherals.

00:31:17.540 --> 00:31:21.720
<v MicroPython>Uh, so you need to drop down and get low level access for that, but you can add your own

00:31:21.720 --> 00:31:25.740
<v MicroPython>functions and things, which gives you a bunch of flexibility so that, you know, maybe when

00:31:25.740 --> 00:31:30.500
<v MicroPython>you're developing some, uh, piece of hardware, you've got a lot of this high level logic of,

00:31:30.600 --> 00:31:34.420
<v MicroPython>and especially for devices today that are all like IOT, internet connected, your internet

00:31:34.420 --> 00:31:39.140
<v MicroPython>connected toaster or whatever, uh, that kind of thing, it needs to talk to web services.

00:31:39.140 --> 00:31:44.360
<v MicroPython>It needs to process all this data from those services, uh, do certain things like, you know,

00:31:44.420 --> 00:31:49.180
<v MicroPython>authentication with these services, which gets pretty complex and gets to be a lot of text

00:31:49.180 --> 00:31:49.680
<v MicroPython>processing.

00:31:49.940 --> 00:31:52.880
<v MicroPython>It's the kind of stuff that's not like critical real time.

00:31:52.880 --> 00:31:55.460
<v MicroPython>You know, you're not generating some kind of signal at a really fast rate.

00:31:55.560 --> 00:31:57.220
<v MicroPython>You're just doing this mundane processing.

00:31:57.500 --> 00:32:00.820
<v MicroPython>And that's the perfect type of thing that you could put into Python code.

00:32:00.820 --> 00:32:06.140
<v MicroPython>That's a little bit simpler, easier to, uh, write it, maybe easier to test it, easier to

00:32:06.140 --> 00:32:06.640
<v MicroPython>manage it.

00:32:06.860 --> 00:32:10.540
<v MicroPython>And then when you need to actually call in and talk to your specialized piece of hardware

00:32:10.540 --> 00:32:15.240
<v MicroPython>and, you know, generate that fast signal or do some real low level access, you add in

00:32:15.240 --> 00:32:18.100
<v MicroPython>the functions that you need to do that as extensions to MicroPython.

00:32:18.260 --> 00:32:22.860
<v MicroPython>So you create some C functions and there's a little bit of like a macro syntax to say, okay,

00:32:22.880 --> 00:32:23.860
<v MicroPython>here's my C function.

00:32:23.860 --> 00:32:28.340
<v MicroPython>And here's how it can take in parameters from Python and what it expects and that type of

00:32:28.340 --> 00:32:28.640
<v MicroPython>stuff.

00:32:29.100 --> 00:32:33.120
<v MicroPython>Uh, but you do that implementation and then your Python code can call into it and say, okay,

00:32:33.240 --> 00:32:36.140
<v MicroPython>now go talk to my special hardware, do my magic thing.

00:32:36.320 --> 00:32:37.160
<v MicroPython>Um, in this case.

00:32:37.160 --> 00:32:41.840
<v MicroPython>And so that's a cool area that I, uh, hasn't been explored a whole lot yet, but I think

00:32:41.840 --> 00:32:45.760
<v MicroPython>you're going to see a lot more of that with MicroPython as it kind of catches on that people

00:32:45.760 --> 00:32:50.040
<v MicroPython>are doing this mix of like the low level and the high level where it makes sense.

00:32:50.040 --> 00:32:53.420
<v MicroPython>You know, you kind of pick like how low you want to go and how high you want to go with,

00:32:53.500 --> 00:32:55.240
<v MicroPython>uh, your, uh, your Python code for it.

00:32:55.300 --> 00:32:55.600
<v Chris Gammell>So, yeah.

00:32:55.920 --> 00:33:00.160
<v Chris Gammell>Well, I think that the, I mean, so the piece that I would have seen in the past would like,

00:33:00.180 --> 00:33:02.060
<v Chris Gammell>if you wanted to add internet to something, right.

00:33:02.060 --> 00:33:03.700
<v Chris Gammell>Or say wifi specifically, right.

00:33:03.700 --> 00:33:08.340
<v Chris Gammell>You want to add wifi, what you could easily do is you could have, you know, a small micro

00:33:08.340 --> 00:33:13.680
<v Chris Gammell>or even Arduino or something, you know, uh, peeking and poking at registers on your ADC

00:33:13.680 --> 00:33:14.020
<v Chris Gammell>again.

00:33:14.220 --> 00:33:19.060
<v Chris Gammell>And then you're just interfacing that with a serial link link between the two, but basically

00:33:19.060 --> 00:33:20.580
<v Chris Gammell>now you can smush them together, right.

00:33:20.580 --> 00:33:26.100
<v Chris Gammell>So you can, you can have the same thing happening on a, on a capable chip, like the ESP8266 can

00:33:26.100 --> 00:33:30.700
<v Chris Gammell>handle the wifi piece, but then also has that low level access like you're talking about.

00:33:31.240 --> 00:33:31.340
<v MicroPython>Right.

00:33:31.420 --> 00:33:31.820
<v MicroPython>Exactly.

00:33:31.900 --> 00:33:32.080
<v MicroPython>Yeah.

00:33:32.080 --> 00:33:34.000
<v MicroPython>So just put everything all in the same processor.

00:33:34.120 --> 00:33:34.220
<v MicroPython>Yeah.

00:33:34.280 --> 00:33:37.780
<v MicroPython>Where as before you might've broken it out into like dedicated things that's talked to each

00:33:37.780 --> 00:33:41.420
<v MicroPython>other, yeah, this could simplify it a lot so that you've got your main kind of business

00:33:41.420 --> 00:33:44.720
<v MicroPython>logic in Python and then talking to all your hardware where you need it.

00:33:45.080 --> 00:33:45.260
<v Chris Gammell>Yeah.

00:33:45.280 --> 00:33:45.680
<v Chris Gammell>That's cool.

00:33:45.800 --> 00:33:51.480
<v Chris Gammell>What about like the, um, so I know the, the Adafruit NeoPixel library, uh, actually has

00:33:51.480 --> 00:33:52.120
<v Chris Gammell>stuff in assembly.

00:33:52.800 --> 00:33:54.860
<v Chris Gammell>And so can it do that as well?

00:33:54.860 --> 00:33:56.240
<v Chris Gammell>I mean, I mean, I guess that's kind of.

00:33:56.380 --> 00:33:56.480
<v Chris Gammell>Yeah.

00:33:56.600 --> 00:33:57.260
<v Chris Gammell>Great question.

00:33:57.760 --> 00:33:58.020
<v Chris Gammell>Right.

00:33:58.160 --> 00:34:01.420
<v MicroPython>So you, you can drop down to assembly if you need to.

00:34:01.560 --> 00:34:05.400
<v MicroPython>Uh, I mean, ultimately you just have to be able to link in the code to, uh, your micro

00:34:05.400 --> 00:34:06.080
<v MicroPython>Python firmware.

00:34:06.080 --> 00:34:10.320
<v MicroPython>And, uh, as long as you've got it all set up the right way with all the, um, kind of,

00:34:10.320 --> 00:34:13.480
<v MicroPython>it has like a table of all the functions that make up an object, things like that.

00:34:13.860 --> 00:34:16.780
<v MicroPython>Uh, but there is actually a simplification and we don't use it yet.

00:34:16.780 --> 00:34:23.340
<v MicroPython>I think on our, uh, Sam D 21 micro Python port, but on the, uh, the PI board port, the,

00:34:23.340 --> 00:34:28.820
<v MicroPython>the STM, uh, port of micro Python, it does actually have the ability to write a Python

00:34:28.820 --> 00:34:33.160
<v MicroPython>function where you put a special decorator on it that says, okay, this is actually assembly

00:34:33.160 --> 00:34:37.080
<v MicroPython>language and you can write arm assembly language inside of that function.

00:34:37.480 --> 00:34:42.000
<v MicroPython>And it will compile that down into assembly when you, when it builds the firmware and will

00:34:42.000 --> 00:34:43.400
<v MicroPython>give you a nice optimized function.

00:34:43.500 --> 00:34:44.540
<v MicroPython>So it's a cool thing.

00:34:44.540 --> 00:34:47.980
<v MicroPython>It's, uh, I haven't seen a lot of people using it yet, but it's something to kind of

00:34:47.980 --> 00:34:48.520
<v MicroPython>explore there.

00:34:48.520 --> 00:34:52.520
<v MicroPython>And it's just neat to see that that's possible because yeah, like why shouldn't you be able

00:34:52.520 --> 00:34:53.660
<v MicroPython>to mix in assembly language?

00:34:53.800 --> 00:34:54.720
<v MicroPython>You know, if you're building the firmware.

00:34:55.260 --> 00:34:59.500
<v Dave Jones>Although C is reasonably close to assembly language.

00:34:59.500 --> 00:35:01.440
<v Dave Jones>I know all the assembly language.

00:35:01.440 --> 00:35:03.300
<v Dave Jones>You're fishing on those will jump down my throat, but you know, it's good enough.

00:35:03.300 --> 00:35:04.980
<v Dave Jones>Someone's about to talk about milliseconds, Dave.

00:35:05.340 --> 00:35:06.940
<v Dave Jones>They're going to talk about milliseconds.

00:35:07.440 --> 00:35:07.660
<v Dave Jones>Yeah.

00:35:07.660 --> 00:35:07.780
<v Dave Jones>Yeah.

00:35:07.780 --> 00:35:08.440
<v Dave Jones>Microseconds, whatever.

00:35:08.680 --> 00:35:09.820
<v Dave Jones>Flight of the moon in milliseconds.

00:35:11.900 --> 00:35:12.920
<v Chris Gammell>About that, Tony.

00:35:12.980 --> 00:35:14.520
<v Chris Gammell>So you said it compiles down though.

00:35:14.520 --> 00:35:18.740
<v Chris Gammell>So like, does that mean that it's, so the assembly piece that's happening, it has to

00:35:18.740 --> 00:35:19.460
<v Chris Gammell>happen before.

00:35:19.900 --> 00:35:20.020
<v Chris Gammell>Right.

00:35:20.100 --> 00:35:24.460
<v MicroPython>And so this is, you actually have to build the micro Python firmware, uh, and it will

00:35:24.460 --> 00:35:29.120
<v MicroPython>do kind of like a pre-processing step to say, okay, these are certain Python functions that

00:35:29.120 --> 00:35:31.600
<v MicroPython>are tagged as assembly implementations.

00:35:31.600 --> 00:35:35.600
<v MicroPython>And so now I'm going to actually do some extra steps to say, okay, let's actually turn this

00:35:35.600 --> 00:35:39.340
<v MicroPython>into assembly and, you know, make sure that it works with the chip and linking it and

00:35:39.340 --> 00:35:39.800
<v MicroPython>things like that.

00:35:39.800 --> 00:35:44.500
<v MicroPython>So yeah, it's not something where you can actually do at the Python REPL typing in, you

00:35:44.500 --> 00:35:48.460
<v MicroPython>know, the assembly code and creating that object, at least as far as I know right now, who knows,

00:35:48.600 --> 00:35:50.520
<v MicroPython>they might be adding stuff like that in the future.

00:35:51.000 --> 00:35:54.940
<v MicroPython>Uh, but yeah, it's, it's, it's like a pre-step for the, the firmware building.

00:35:55.380 --> 00:35:55.500
<v MicroPython>Gotcha.

00:35:55.620 --> 00:35:55.860
<v Chris Gammell>Okay.

00:35:56.060 --> 00:35:56.280
<v Chris Gammell>Okay.

00:35:56.280 --> 00:36:00.340
<v Chris Gammell>So that would be that that's definitely hard mode, like advanced user kind of stuff.

00:36:00.440 --> 00:36:00.800
<v Chris Gammell>Yeah.

00:36:00.800 --> 00:36:05.240
<v MicroPython>If you want to go crazy, but like Dave said, in most cases, C is probably good enough.

00:36:05.240 --> 00:36:09.600
<v MicroPython>And you know, that's also like something that you have to build a new firmware to add that

00:36:09.600 --> 00:36:10.080
<v MicroPython>capability.

00:36:10.080 --> 00:36:13.420
<v MicroPython>And so, you know, when I say building new micro Python firmware, like you basically just

00:36:13.420 --> 00:36:18.120
<v MicroPython>have to clone their code, you know, and get it set up and you pop out a new firmware image,

00:36:18.120 --> 00:36:19.840
<v MicroPython>uh, but in their code.

00:36:19.840 --> 00:36:24.840
<v MicroPython>So you add in your functions there and it will, it has it all set up to build those as kind

00:36:24.840 --> 00:36:26.180
<v MicroPython>of extension functions and things.

00:36:26.260 --> 00:36:27.400
<v Chris Gammell>So it's like a black box.

00:36:27.400 --> 00:36:29.220
<v Chris Gammell>Like the C code would be like a black box.

00:36:29.300 --> 00:36:34.660
<v Chris Gammell>It's, uh, like the, the high level function would be like talk to ADC or some name like that.

00:36:34.660 --> 00:36:37.320
<v Chris Gammell>And it would just, you just pass it in and then it all happens.

00:36:37.320 --> 00:36:39.660
<v MicroPython>And NeoPixel is a great example.

00:36:39.660 --> 00:36:44.860
<v MicroPython>So like we added that to our SamD 21 port and we literally just took the Arduino NeoPixel

00:36:44.860 --> 00:36:49.460
<v MicroPython>code for the SamD processor, which was, uh, actually, uh, there is a little bit of assembly

00:36:49.460 --> 00:36:49.900
<v MicroPython>in that one.

00:36:49.900 --> 00:36:52.060
<v MicroPython>It's, uh, it's just using like the GC inline assembly.

00:36:52.460 --> 00:36:57.340
<v MicroPython>Uh, and so we just took that function and put it into basically the signature that micro

00:36:57.340 --> 00:37:02.480
<v MicroPython>Python needs for, uh, a function and plugged it in and pretty much worked.

00:37:02.480 --> 00:37:04.280
<v MicroPython>I mean, there's a little bit of kind of tweaking.

00:37:04.420 --> 00:37:05.800
<v MicroPython>I think you have to turn off interrupts.

00:37:05.800 --> 00:37:08.900
<v MicroPython>Uh, we had to add to that, but otherwise, yeah, it was a pretty straightforward port.

00:37:08.940 --> 00:37:12.440
<v MicroPython>And that's what most people I think are going to do where you've got, you know, something

00:37:12.440 --> 00:37:14.380
<v MicroPython>you want to talk to with a low level.

00:37:14.560 --> 00:37:18.680
<v MicroPython>You just add a C function for it and then build your firmware for that, load your firmware

00:37:18.680 --> 00:37:20.480
<v MicroPython>and call it from your Python code.

00:37:21.140 --> 00:37:25.280
<v Chris Gammell>So excuse my ignorance on this, but like what would actually be building that firmware then?

00:37:25.460 --> 00:37:25.600
<v MicroPython>Yeah.

00:37:25.700 --> 00:37:30.080
<v MicroPython>So that's like building a new version of micro Python, which, which sounds kind of scary,

00:37:30.080 --> 00:37:32.980
<v MicroPython>but I mean, you basically, you've got the source code of micro Python.

00:37:32.980 --> 00:37:35.120
<v MicroPython>And by the way, it's all, it's an open source project.

00:37:35.120 --> 00:37:36.220
<v MicroPython>It's MIT licensed.

00:37:36.360 --> 00:37:37.580
<v MicroPython>Uh, so really nice to be used.

00:37:37.660 --> 00:37:42.240
<v MicroPython>So you pull down that source code and then you add in like a new module, like a NeoPixel

00:37:42.240 --> 00:37:43.060
<v MicroPython>module, for example.

00:37:43.200 --> 00:37:48.180
<v MicroPython>So you make like a C file, uh, that has the code for your, uh, controlling your NeoPixel

00:37:48.180 --> 00:37:49.400
<v MicroPython>and it has certain functions.

00:37:49.400 --> 00:37:52.880
<v MicroPython>And there's certain macros that you have to include in there to tell Python, okay, you

00:37:52.880 --> 00:37:55.600
<v MicroPython>know, this C function should be exposed in this way to Python.

00:37:55.600 --> 00:37:58.020
<v MicroPython>And these are the parameters expects and things like that.

00:37:58.400 --> 00:38:01.320
<v MicroPython>Uh, and then you compile that whole micro Python firmware.

00:38:01.540 --> 00:38:06.100
<v MicroPython>And so that's going to compile like the core language, uh, all the core libraries that includes.

00:38:06.100 --> 00:38:09.340
<v MicroPython>And then it's also going to include the new code that you add.

00:38:09.340 --> 00:38:10.580
<v MicroPython>It's like the NeoPixel module.

00:38:10.740 --> 00:38:14.960
<v MicroPython>And then that'll just pop out a dot bin file that, uh, you'll want to load on your board

00:38:14.960 --> 00:38:19.080
<v MicroPython>effectively and say, okay, this is the new firmware that bunches bare metal on my processor.

00:38:19.320 --> 00:38:21.920
<v MicroPython>And so that's, you know, basically a new version of micro Python.

00:38:21.920 --> 00:38:27.560
<v MicroPython>And now when you connect to the Python repl, you can say, okay, NeoPixel, like change color

00:38:27.560 --> 00:38:29.060
<v MicroPython>or whatever you've added to.

00:38:29.160 --> 00:38:29.240
<v MicroPython>Right.

00:38:29.300 --> 00:38:31.660
<v Chris Gammell>So it kind of, it abstracts it out sort of, but not really.

00:38:31.660 --> 00:38:36.620
<v Chris Gammell>It's all just, it's just really the repl is, is a layer that looks like a programming interface,

00:38:36.620 --> 00:38:39.520
<v Chris Gammell>but it's actually part of the firmware that just looks like.

00:38:39.520 --> 00:38:40.860
<v MicroPython>You're just running code.

00:38:41.020 --> 00:38:45.680
<v MicroPython>And if you really want to get down to a low level, um, micro Python, I believe it's a

00:38:45.680 --> 00:38:47.320
<v MicroPython>little virtual machine that it has internally.

00:38:47.320 --> 00:38:52.980
<v MicroPython>And so that repl is really just like taking in the Python code, parsing it, figuring out

00:38:52.980 --> 00:38:57.460
<v MicroPython>the abstract syntax tree, and just executing that against a little VM that it has internally

00:38:57.460 --> 00:38:57.980
<v MicroPython>for that.

00:38:58.060 --> 00:39:02.600
<v MicroPython>And versus like, if you have a Python script that you want to run and you can save to the

00:39:02.600 --> 00:39:07.060
<v MicroPython>board, uh, you know, that it'll just process that and generate the same tree and actually

00:39:07.060 --> 00:39:08.820
<v MicroPython>execute it against the VM for that.

00:39:08.920 --> 00:39:11.240
<v MicroPython>So yeah, as far as micro Python is concerned, it's no different.

00:39:11.440 --> 00:39:15.500
<v MicroPython>All of those functions that you've added are just extra things that, uh, other code might

00:39:15.500 --> 00:39:16.060
<v MicroPython>be calling.

00:39:16.060 --> 00:39:16.740
<v Dave Jones>Right.

00:39:16.940 --> 00:39:24.140
<v Dave Jones>If you make one small change to your Python code, it doesn't have to recompile everything

00:39:24.140 --> 00:39:26.640
<v Dave Jones>else as the image for your board.

00:39:26.760 --> 00:39:26.820
<v MicroPython>Yeah.

00:39:26.820 --> 00:39:27.360
<v MicroPython>Great question.

00:39:27.460 --> 00:39:30.700
<v MicroPython>And so that's maybe a difference of, um, you know, what are you changing?

00:39:30.700 --> 00:39:35.600
<v MicroPython>Like if you're just changing your Python code, your .py file, uh, then yeah, you don't have

00:39:35.600 --> 00:39:36.420
<v MicroPython>to rebuild the firmware.

00:39:36.620 --> 00:39:40.060
<v MicroPython>And that's actually one cool thing too, that I didn't really mention with micro Python is

00:39:40.060 --> 00:39:44.880
<v MicroPython>that all of the boards support a file system internally, like a fat file system.

00:39:44.880 --> 00:39:46.600
<v Dave Jones>I would, right.

00:39:46.660 --> 00:39:47.120
<v Dave Jones>That's great.

00:39:47.120 --> 00:39:48.260
<v Dave Jones>That's maybe the missing piece.

00:39:48.320 --> 00:39:49.800
<v Dave Jones>So it's a fat file system in memory.

00:39:49.920 --> 00:39:50.720
<v Dave Jones>In flash memory.

00:39:50.940 --> 00:39:51.220
<v Dave Jones>Exactly.

00:39:51.420 --> 00:39:51.540
<v Dave Jones>Yeah.

00:39:51.920 --> 00:39:52.780
<v Dave Jones>In flash memory.

00:39:52.780 --> 00:39:52.860
<v Dave Jones>Right.

00:39:52.860 --> 00:39:54.540
<v MicroPython>And it doesn't have to be there necessarily.

00:39:54.840 --> 00:39:58.740
<v MicroPython>So like we're looking at maybe an external flash or you can even mount an SD card on some

00:39:58.740 --> 00:39:59.100
<v MicroPython>boards.

00:39:59.340 --> 00:39:59.620
<v MicroPython>Yeah.

00:39:59.620 --> 00:39:59.900
<v MicroPython>Flash.

00:39:59.960 --> 00:40:00.080
<v MicroPython>Yeah.

00:40:00.080 --> 00:40:01.700
<v Chris Gammell>For like data logging stuff would be great.

00:40:01.700 --> 00:40:06.640
<v MicroPython>And that's usually where you plug in all of your Python scripts and your code, uh, that's,

00:40:06.720 --> 00:40:07.980
<v MicroPython>you know, actually written in Python.

00:40:08.160 --> 00:40:12.480
<v MicroPython>And then your firmware itself is, yeah, the, the actual thing that runs on the chip itself.

00:40:12.480 --> 00:40:16.720
<v MicroPython>And so that's gotta be in its flash memory, but that's, you know, usually you aren't changing

00:40:16.720 --> 00:40:18.480
<v MicroPython>that as much as you are your Python code.

00:40:18.480 --> 00:40:22.560
<v MicroPython>And so, yeah, when you change your Python code, you just effectively change that Python file.

00:40:22.560 --> 00:40:27.520
<v MicroPython>And there are certain conventions in MicroPython, like if you have a file that's called main.py,

00:40:27.680 --> 00:40:31.960
<v MicroPython>then that's kind of your main code that it will run after it boots up or after it starts

00:40:31.960 --> 00:40:32.260
<v MicroPython>up.

00:40:32.600 --> 00:40:32.660
<v MicroPython>Right.

00:40:32.660 --> 00:40:35.540
<v MicroPython>So that's how you can have, you know, I want my script to start immediately.

00:40:35.700 --> 00:40:37.160
<v MicroPython>You put it into that main.py file.

00:40:37.340 --> 00:40:37.480
<v MicroPython>Yeah.

00:40:37.600 --> 00:40:42.220
<v MicroPython>But it is nice too, in that you've got a full file system and in Python, it has a whole

00:40:42.220 --> 00:40:44.980
<v MicroPython>concept of you can split up code across multiple files.

00:40:45.140 --> 00:40:49.240
<v MicroPython>You can import other files to say, okay, I, you know, I have a class in one file.

00:40:49.320 --> 00:40:51.360
<v MicroPython>So I want to import that module and start using it.

00:40:51.360 --> 00:40:53.740
<v MicroPython>And it works exactly the same in MicroPython.

00:40:53.940 --> 00:40:57.560
<v MicroPython>So if you want to structure your code and have a whole bunch of different files and put different

00:40:57.560 --> 00:41:01.120
<v MicroPython>things into different files, you can just use them and import them like you would in

00:41:01.120 --> 00:41:03.220
<v MicroPython>normal Python, which is pretty cool.

00:41:03.280 --> 00:41:06.340
<v MicroPython>Kind of an interesting thing because again, you don't really have anything like that in

00:41:06.340 --> 00:41:09.560
<v MicroPython>the Arduino world where like you're just building this project ahead of time and you can't really

00:41:09.560 --> 00:41:13.520
<v MicroPython>change it without changing the whole file and re-uploading it, for example.

00:41:13.640 --> 00:41:13.760
<v MicroPython>Yeah.

00:41:13.820 --> 00:41:14.740
<v MicroPython>Cause it gets bigger.

00:41:14.740 --> 00:41:18.740
<v Dave Jones>Can you have multiple programs in there?

00:41:18.740 --> 00:41:24.560
<v Dave Jones>So you can call up when you boot your program, like depending on a pin configuration, can

00:41:24.560 --> 00:41:26.340
<v Dave Jones>you run a physically different Python program?

00:41:26.340 --> 00:41:26.940
<v MicroPython>Do something else?

00:41:27.060 --> 00:41:28.440
<v MicroPython>Yeah, you definitely could.

00:41:28.800 --> 00:41:29.380
<v MicroPython>Something like that?

00:41:29.380 --> 00:41:31.220
<v MicroPython>You want to structure it in a little bit of a different way.

00:41:31.320 --> 00:41:33.180
<v MicroPython>Like there's only one main.py file.

00:41:33.300 --> 00:41:34.800
<v MicroPython>And so that's going to be your entry point.

00:41:34.840 --> 00:41:35.860
<v Dave Jones>I was going to say, right, there's one main.

00:41:35.940 --> 00:41:36.900
<v Dave Jones>So you'd have to do that.

00:41:36.960 --> 00:41:38.920
<v Dave Jones>But then you can call up another file.

00:41:39.060 --> 00:41:39.840
<v Dave Jones>How do you call it?

00:41:40.080 --> 00:41:41.420
<v MicroPython>Exactly how you would with Python.

00:41:41.660 --> 00:41:43.400
<v MicroPython>So Python has an import function.

00:41:43.400 --> 00:41:45.260
<v MicroPython>Well, I, yeah, exactly right.

00:41:45.340 --> 00:41:48.960
<v MicroPython>So step one, get a little background Python.

00:41:49.180 --> 00:41:49.420
<v MicroPython>Exactly.

00:41:50.000 --> 00:41:54.360
<v MicroPython>But that's kind of the cool thing with MicroPython is that once you learn Python, most of that

00:41:54.360 --> 00:41:55.460
<v MicroPython>knowledge transfers over.

00:41:55.840 --> 00:41:59.800
<v MicroPython>And so then in the Python world, yeah, there's an import command, which Python has this whole

00:41:59.800 --> 00:42:04.800
<v MicroPython>complex hierarchy of it will look at its built-in libraries and then it'll look at like third

00:42:04.800 --> 00:42:05.560
<v MicroPython>party libraries.

00:42:05.560 --> 00:42:09.360
<v MicroPython>And then if it can't find anything there, it'll look actually in the local directory to see if

00:42:09.360 --> 00:42:12.400
<v MicroPython>there's a .py file with the same name and then it'll pull it in.

00:42:12.400 --> 00:42:14.480
<v MicroPython>And so some of that stuff still works.

00:42:14.660 --> 00:42:15.740
<v MicroPython>So you would call up a file.

00:42:15.980 --> 00:42:19.000
<v Dave Jones>So you would go import file name.

00:42:19.180 --> 00:42:19.540
<v Dave Jones>Exactly.

00:42:19.740 --> 00:42:22.000
<v MicroPython>You call it program1.py and program2.py.

00:42:22.220 --> 00:42:22.400
<v MicroPython>Yeah, exactly.

00:42:22.520 --> 00:42:24.560
<v MicroPython>Let's say we had a neopixel.py file.

00:42:24.760 --> 00:42:28.920
<v MicroPython>You know, you would just say import neopixel and that will tell MicroPython, okay, go look

00:42:28.920 --> 00:42:33.800
<v MicroPython>for a file called neopixel.py and load it up and see what's inside of there.

00:42:33.860 --> 00:42:37.780
<v MicroPython>So like if there's a class inside of there, there's maybe even just function or global variables

00:42:37.780 --> 00:42:40.540
<v MicroPython>or things, it will load those and make those available.

00:42:40.540 --> 00:42:45.280
<v MicroPython>And then Python has a really good concept of namespaces so that it won't just throw all

00:42:45.280 --> 00:42:46.720
<v MicroPython>of that into your global namespace.

00:42:47.040 --> 00:42:48.640
<v MicroPython>It'll prefix that with like neopixel.

00:42:48.760 --> 00:42:53.940
<v MicroPython>So if I had like a neopixel.light function inside of there in my script, in my main.py,

00:42:54.060 --> 00:42:56.660
<v MicroPython>I'd say import neopixel and then neopixel.light.

00:42:56.820 --> 00:43:00.860
<v MicroPython>And that would say, okay, call the light function inside of the neopixel module from there.

00:43:00.980 --> 00:43:01.380
<v MicroPython>And so...

00:43:01.380 --> 00:43:06.600
<v Dave Jones>So you could have several different modules each with a routine called print.

00:43:06.600 --> 00:43:07.360
<v Dave Jones>Exactly, yep.

00:43:07.560 --> 00:43:08.960
<v Dave Jones>And then pick the right one.

00:43:08.980 --> 00:43:09.540
<v Dave Jones>And then it'd be a pixel print.

00:43:09.620 --> 00:43:10.700
<v Dave Jones>It'd be something else printed.

00:43:10.760 --> 00:43:11.440
<v Dave Jones>Exactly, yep.

00:43:12.060 --> 00:43:12.460
<v Chris Gammell>Got it.

00:43:12.720 --> 00:43:13.100
<v Chris Gammell>That's cool.

00:43:13.180 --> 00:43:13.480
<v Chris Gammell>Nice.

00:43:13.960 --> 00:43:14.740
<v Chris Gammell>Somebody's been thinking.

00:43:14.900 --> 00:43:15.580
<v Chris Gammell>Yeah, that's...

00:43:15.580 --> 00:43:19.100
<v Chris Gammell>I mean, again, to go back to the ADC example, I think that if you...

00:43:19.100 --> 00:43:19.600
<v Chris Gammell>So once you...

00:43:19.600 --> 00:43:24.020
<v Chris Gammell>The interesting thing about that is once you have that lower level firmware figured out,

00:43:24.080 --> 00:43:27.140
<v Chris Gammell>then I imagine that you could kind of hand it off to someone, say...

00:43:27.140 --> 00:43:31.700
<v Chris Gammell>I imagine like, you know, someone who's more data savvy and then basically, you know, be

00:43:31.700 --> 00:43:35.100
<v Chris Gammell>like, all right, I figured out how to peek and poke all the registers in the ADC.

00:43:35.320 --> 00:43:36.580
<v Chris Gammell>I've got the data coming out.

00:43:37.040 --> 00:43:37.720
<v Chris Gammell>Do your magic.

00:43:38.040 --> 00:43:38.940
<v Chris Gammell>You know, make this...

00:43:38.940 --> 00:43:40.360
<v Chris Gammell>You know, format this data well.

00:43:40.520 --> 00:43:42.220
<v Chris Gammell>Push it up to the network however you need to do it.

00:43:42.500 --> 00:43:44.500
<v Chris Gammell>And then there's some interesting...

00:43:44.500 --> 00:43:47.980
<v Chris Gammell>You know, you could really get to the data pieces, which is what a lot of people really

00:43:47.980 --> 00:43:48.800
<v Chris Gammell>want to do, right?

00:43:48.820 --> 00:43:52.640
<v Chris Gammell>I mean, as much as we talk about electronics on here, and we love electronics, it's really that

00:43:52.640 --> 00:43:54.600
<v Chris Gammell>people are trying to get something out.

00:43:54.740 --> 00:43:56.700
<v Chris Gammell>And a lot of times it's data, especially in the IoT world.

00:43:56.700 --> 00:43:57.740
<v MicroPython>Yeah, no, exactly.

00:43:57.960 --> 00:44:02.800
<v MicroPython>And again, it just kind of comes back to like making it easier for people who haven't done

00:44:02.800 --> 00:44:07.260
<v MicroPython>a lot of this and don't have a lot of experience with like microcontrollers, microprocessing.

00:44:07.820 --> 00:44:10.020
<v MicroPython>It's just, it's simpler to get started with this.

00:44:10.480 --> 00:44:11.940
<v MicroPython>Less scary, I would say, you know?

00:44:12.040 --> 00:44:14.000
<v Chris Gammell>I would say it's even easier to maintain all this stuff.

00:44:14.160 --> 00:44:17.960
<v Chris Gammell>Like, so I'm sure we're going to hear from people that are staunch C people and that's

00:44:17.960 --> 00:44:18.400
<v Chris Gammell>fine, right?

00:44:18.400 --> 00:44:22.040
<v Chris Gammell>But like, I mean, a lot of this data handling stuff, it just seems like it would be a much

00:44:22.040 --> 00:44:26.340
<v Chris Gammell>bigger problem to solve and maintain over time, right?

00:44:26.340 --> 00:44:29.340
<v Chris Gammell>And it'd be less flexible if you needed to change something or you'd have to change the

00:44:29.340 --> 00:44:30.720
<v Chris Gammell>whole image at that point.

00:44:30.920 --> 00:44:31.040
<v Chris Gammell>Right.

00:44:31.180 --> 00:44:31.420
<v Chris Gammell>Yeah.

00:44:31.500 --> 00:44:33.580
<v Chris Gammell>And that seems like that's where it's really interesting to me.

00:44:33.900 --> 00:44:34.080
<v MicroPython>Right.

00:44:34.220 --> 00:44:34.360
<v MicroPython>Yeah.

00:44:34.420 --> 00:44:35.440
<v MicroPython>Just having the flexibility.

00:44:35.860 --> 00:44:40.400
<v MicroPython>And the nice thing is too, like if you want to prototype that code on your desktop computer,

00:44:40.900 --> 00:44:42.240
<v MicroPython>you can just use normal Python.

00:44:42.480 --> 00:44:47.240
<v MicroPython>You know, you can write all of that out, maybe mock all the different interfaces, get it working

00:44:47.240 --> 00:44:47.600
<v MicroPython>there.

00:44:47.600 --> 00:44:51.620
<v MicroPython>You can maybe have a really nice test suite and then just take that code, port it over

00:44:51.620 --> 00:44:54.140
<v MicroPython>to your microcontroller running MicroPython.

00:44:54.720 --> 00:44:59.540
<v MicroPython>And for the most part, you know, it should work exactly the same as your normal environment.

00:44:59.640 --> 00:45:01.460
<v MicroPython>You still want to test it, obviously, on your hardware.

00:45:01.960 --> 00:45:05.420
<v MicroPython>But that's another kind of interesting case too of, right, you know, you aren't limited

00:45:05.420 --> 00:45:10.940
<v MicroPython>so much to just always having to do this in C and against this like constrained environment.

00:45:10.940 --> 00:45:11.380
<v MicroPython>Yeah.

00:45:11.840 --> 00:45:19.580
<v Dave Jones>But having said all this, it's, you know, there's no one universal best programming tool.

00:45:19.700 --> 00:45:24.880
<v Dave Jones>It's like if you're familiar with programming Python on the desktop, it's natural.

00:45:25.000 --> 00:45:28.480
<v Dave Jones>You're going to want to use Python on an embedded platform.

00:45:28.640 --> 00:45:32.080
<v Dave Jones>If you're a, you know, a C person, you're going to be, you're going to be familiar with

00:45:32.080 --> 00:45:32.300
<v Dave Jones>C.

00:45:32.420 --> 00:45:34.960
<v Dave Jones>Basic, you're going to be familiar with Basic, et cetera.

00:45:35.020 --> 00:45:36.200
<v MicroPython>Yeah, I totally agree with that.

00:45:36.200 --> 00:45:40.540
<v MicroPython>I think that's a great way to put it is, you know, like MicroPython isn't out there to

00:45:40.540 --> 00:45:41.540
<v MicroPython>replace C.

00:45:42.060 --> 00:45:45.400
<v MicroPython>You know, it's not trying to be like the new language that everyone uses.

00:45:45.620 --> 00:45:48.480
<v MicroPython>It's just another tool in the toolbox, like you said.

00:45:48.820 --> 00:45:54.280
<v MicroPython>And, you know, I think it has good use cases for the beginner and even the advanced users.

00:45:54.680 --> 00:45:59.040
<v MicroPython>But yeah, it's perfectly fine to evaluate and say like, oh, it's not the right tool for

00:45:59.040 --> 00:45:59.760
<v MicroPython>this job.

00:45:59.860 --> 00:46:04.560
<v MicroPython>You know, it's maybe not capable enough or I need more performance or, you know, it does

00:46:04.560 --> 00:46:07.980
<v MicroPython>use a lot more memory and there is more overhead when you're doing an interpretive language

00:46:07.980 --> 00:46:08.400
<v MicroPython>like that.

00:46:08.400 --> 00:46:11.160
<v MicroPython>So yeah, there's certainly cases where it's not going to make sense to use it.

00:46:11.160 --> 00:46:15.680
<v Chris Gammell>Can we go back to the compilation one more time real quick?

00:46:16.320 --> 00:46:22.040
<v Chris Gammell>I was just a little confused about, okay, so you said it can do assembly or it can do C and

00:46:22.040 --> 00:46:25.440
<v Chris Gammell>you have to recompile the actual dot, the binary image.

00:46:25.680 --> 00:46:26.280
<v Chris Gammell>The firmware for it, yeah.

00:46:26.280 --> 00:46:26.400
<v Chris Gammell>Yeah.

00:46:26.840 --> 00:46:32.300
<v Chris Gammell>So does that mean though that that piece is done with Python or it's then calling GCC or

00:46:32.300 --> 00:46:33.660
<v Chris Gammell>it's calling some other compiler?

00:46:33.880 --> 00:46:35.040
<v Chris Gammell>What is actually happening there?

00:46:35.040 --> 00:46:40.200
<v MicroPython>Yeah, I'm not exactly, I can't remember exactly how they did that actual inline assembly.

00:46:40.320 --> 00:46:45.100
<v MicroPython>So there's a great talk that Damian George, the creator of MicroPython did, where he went

00:46:45.100 --> 00:46:46.800
<v MicroPython>into more detail about this.

00:46:46.860 --> 00:46:48.660
<v MicroPython>And it's a more advanced feature.

00:46:48.660 --> 00:46:51.580
<v MicroPython>I don't think they're actually invoking GCC.

00:46:51.980 --> 00:46:57.520
<v MicroPython>I think he actually just has a, effectively, I think he wrote like a real simple compiler

00:46:57.520 --> 00:47:01.460
<v MicroPython>that just takes, you know, that op code and just converts it into, okay, this is, you

00:47:01.460 --> 00:47:05.280
<v MicroPython>know, the binary equivalent of that, that I should make, you know, the language.

00:47:05.280 --> 00:47:05.620
<v MicroPython>Oh, really?

00:47:05.940 --> 00:47:11.160
<v MicroPython>For the C code though, it is using GCC because you're basically, like GCC itself is building

00:47:11.160 --> 00:47:12.160
<v MicroPython>the MicroPython firmware.

00:47:12.680 --> 00:47:17.480
<v MicroPython>And so when you add a function in C, you're basically just pointing GCC at, okay, here's

00:47:17.480 --> 00:47:18.480
<v MicroPython>all the MicroPython firmware.

00:47:18.480 --> 00:47:22.680
<v MicroPython>And then here's my extra .c files that have my, you know, new modules that I added.

00:47:22.800 --> 00:47:26.460
<v MicroPython>And so it's compiling that just as if it was compiling the rest of MicroPython.

00:47:26.680 --> 00:47:27.880
<v MicroPython>So you do use GCC in that case.

00:47:27.880 --> 00:47:30.700
<v MicroPython>Yeah, because at a certain point, it needs to know what processor is there, right?

00:47:30.780 --> 00:47:34.200
<v Chris Gammell>You need to have something that understands which processor you're talking to.

00:47:34.200 --> 00:47:35.880
<v Dave Jones>Everything defaults back to GCC.

00:47:36.100 --> 00:47:36.700
<v Dave Jones>Exactly, yeah.

00:47:36.700 --> 00:47:38.660
<v Dave Jones>I mean, that's what's doing the whole business.

00:47:38.660 --> 00:47:38.860
<v Dave Jones>Okay.

00:47:39.200 --> 00:47:40.500
<v Dave Jones>That makes a lot of sense then.

00:47:40.820 --> 00:47:41.320
<v Chris Gammell>That's great.

00:47:41.940 --> 00:47:45.160
<v Chris Gammell>So some of that might be abstracted from you when you're doing the compilation process,

00:47:45.160 --> 00:47:46.620
<v Chris Gammell>but it's still under the hood.

00:47:47.260 --> 00:47:51.100
<v Dave Jones>That's like the Arduino thing works exactly the same way.

00:47:51.100 --> 00:47:51.800
<v Dave Jones>Exactly, that's true.

00:47:51.800 --> 00:47:56.000
<v Dave Jones>People don't realize that they're using GCC because it's all handled by the nice little

00:47:56.000 --> 00:47:57.640
<v Dave Jones>GUI and everything else.

00:47:57.780 --> 00:48:01.100
<v Dave Jones>And you go, you know, download, you know, but it's actually calling GCC.

00:48:01.280 --> 00:48:01.460
<v Dave Jones>Turn on Verbose.

00:48:01.840 --> 00:48:02.320
<v Dave Jones>Yep, exactly.

00:48:02.320 --> 00:48:05.540
<v MicroPython>Turn on Verbose and see all of the things happening behind the scenes.

00:48:05.620 --> 00:48:05.800
<v MicroPython>Right.

00:48:06.120 --> 00:48:06.300
<v Dave Jones>Yep.

00:48:06.500 --> 00:48:06.720
<v MicroPython>Okay.

00:48:06.980 --> 00:48:07.180
<v MicroPython>Okay.

00:48:07.320 --> 00:48:11.300
<v Dave Jones>Now, what it comes down to, though, at the end of the day, when you want to get something

00:48:11.300 --> 00:48:16.320
<v Dave Jones>done with your embedded platform, the language doesn't matter a rat's ass.

00:48:16.420 --> 00:48:18.140
<v Dave Jones>It's what libraries are available.

00:48:18.280 --> 00:48:23.760
<v Dave Jones>That is the pain point for getting stuff done on embedded platforms.

00:48:23.760 --> 00:48:28.060
<v Dave Jones>So if you're trying to talk to the internet and your Arduino doesn't have a library that

00:48:28.060 --> 00:48:33.420
<v Dave Jones>talks to the internet or your Python board doesn't have a library that talks to this or

00:48:33.420 --> 00:48:37.100
<v Dave Jones>it doesn't talk to NeoPixels that you want to talk to or it doesn't talk to some accelerometer

00:48:37.100 --> 00:48:37.940
<v Dave Jones>you want to talk to.

00:48:38.100 --> 00:48:39.080
<v Dave Jones>That means you're writing it.

00:48:39.620 --> 00:48:40.200
<v Dave Jones>Yeah, exactly.

00:48:40.200 --> 00:48:43.960
<v Dave Jones>That means you're writing the damn thing or you're searching the internet to find if somebody

00:48:43.960 --> 00:48:47.400
<v Dave Jones>else has written this library, you know, that you can sort of hack in there.

00:48:47.400 --> 00:48:50.940
<v Dave Jones>And it's, you know, it's all about the stuff that's available.

00:48:51.180 --> 00:48:57.240
<v Chris Gammell>Or you're talking to your firm or person very nicely and you're saying, hey, can you help

00:48:57.240 --> 00:48:57.720
<v Chris Gammell>me out?

00:48:58.460 --> 00:48:59.140
<v MicroPython>Yeah, exactly.

00:48:59.260 --> 00:49:03.480
<v MicroPython>The library thing is definitely a big, important part of it.

00:49:03.480 --> 00:49:08.340
<v MicroPython>Just having, you know, access to, like you said, any hardware you want to talk to, having

00:49:08.340 --> 00:49:09.040
<v MicroPython>a library for it.

00:49:09.440 --> 00:49:13.220
<v MicroPython>And it's one interesting thing about MicroPython, though, is that it's still a pretty young

00:49:13.220 --> 00:49:13.700
<v MicroPython>project.

00:49:13.700 --> 00:49:17.260
<v MicroPython>So it was created originally in 2013.

00:49:17.600 --> 00:49:18.780
<v MicroPython>So it's about three years old.

00:49:19.120 --> 00:49:21.560
<v MicroPython>And that's pretty young in the scale of projects.

00:49:22.040 --> 00:49:22.080
<v MicroPython>Oh, yeah.

00:49:22.480 --> 00:49:23.080
<v MicroPython>Yeah, it's...

00:49:23.080 --> 00:49:23.120
<v MicroPython>Right.

00:49:23.300 --> 00:49:25.820
<v Chris Gammell>As people are thumbing through their K&R copies right now.

00:49:25.880 --> 00:49:26.060
<v Chris Gammell>Right.

00:49:26.220 --> 00:49:26.380
<v Chris Gammell>Yeah.

00:49:26.480 --> 00:49:30.780
<v MicroPython>So it's, you know, it's pretty darn mature as far as like the language.

00:49:31.180 --> 00:49:33.220
<v MicroPython>You know, I'm really impressed with how stable it is.

00:49:33.280 --> 00:49:36.400
<v MicroPython>I've used it a lot and haven't run into like weird head scratching.

00:49:36.400 --> 00:49:37.820
<v MicroPython>Like, wow, why did it crash there?

00:49:37.860 --> 00:49:38.820
<v MicroPython>Like, it's pretty stable.

00:49:39.200 --> 00:49:42.440
<v MicroPython>But things like library support are still kind of being figured out.

00:49:42.440 --> 00:49:47.420
<v MicroPython>So there's not, certainly not as many libraries as like Arduino and some of those other platforms.

00:49:47.840 --> 00:49:48.560
<v MicroPython>But they're coming.

00:49:48.640 --> 00:49:51.000
<v MicroPython>I think in the next year or so, we'll get a lot more things out there.

00:49:51.020 --> 00:49:55.340
<v MicroPython>And like, we're starting to do a bunch of libraries from the Adafruit side of just a lot of the

00:49:55.340 --> 00:49:56.160
<v MicroPython>hardware that we have.

00:49:56.280 --> 00:49:58.400
<v MicroPython>We want to make it easy for people to use in MicroPython.

00:49:58.400 --> 00:50:02.460
<v MicroPython>But yeah, that is also a good thing to look at when you're evaluating some of these languages.

00:50:02.460 --> 00:50:03.900
<v MicroPython>It's like, you know, what is out there?

00:50:03.960 --> 00:50:05.420
<v MicroPython>What can I use to get started with?

00:50:05.720 --> 00:50:07.640
<v MicroPython>And it's a little bit early right now with MicroPython.

00:50:07.840 --> 00:50:13.740
<v MicroPython>But the community is growing very fast, especially with the ESP8266 and some of these newer chips

00:50:13.740 --> 00:50:15.720
<v MicroPython>that have all this Wi-Fi capability.

00:50:15.960 --> 00:50:20.140
<v MicroPython>That's getting a lot of really interesting kind of projects and more people interested in it.

00:50:20.140 --> 00:50:24.100
<v MicroPython>And so we're pretty much every day just seeing new stuff coming out for it.

00:50:24.460 --> 00:50:26.420
<v MicroPython>It's, I think, going to continue going forward.

00:50:26.980 --> 00:50:29.760
<v Chris Gammell>What about the, so like, okay, so say I go to write a library.

00:50:29.860 --> 00:50:32.800
<v Chris Gammell>So I got a new ADC and there's no library for it.

00:50:32.900 --> 00:50:34.300
<v Chris Gammell>And I want to go write it myself.

00:50:35.000 --> 00:50:42.160
<v Chris Gammell>Is there any reason to think it's any easier to write a library for here versus in C or any other language?

00:50:42.260 --> 00:50:42.980
<v MicroPython>Yeah, good question.

00:50:43.860 --> 00:50:47.840
<v MicroPython>So to do it in MicroPython, it's a little bit interesting.

00:50:47.840 --> 00:50:50.420
<v MicroPython>So ultimately, you need to talk to your hardware.

00:50:51.000 --> 00:51:00.500
<v MicroPython>And there are APIs in the MicroPython firmware for talking to like I2C devices or SPI or even just like digital I.O. and stuff like that.

00:51:00.620 --> 00:51:07.160
<v MicroPython>So if you can code against those interfaces, then you can use MicroPython entirely to talk to your hardware.

00:51:07.660 --> 00:51:14.620
<v MicroPython>But that assumes that your hardware doesn't have like maybe timing constraints, you know, where you have to do something really quickly.

00:51:14.620 --> 00:51:18.500
<v MicroPython>Because again, you know, if you're doing this in Python, it's going to be running in this virtual machine.

00:51:18.660 --> 00:51:19.120
<v MicroPython>It's interpreted.

00:51:19.400 --> 00:51:20.520
<v MicroPython>There's some overhead there.

00:51:20.580 --> 00:51:21.600
<v MicroPython>So it's not going to be as fast.

00:51:22.480 --> 00:51:27.900
<v MicroPython>So, but for a lot of devices, like if it's just a simple ADC, for example, you know, maybe you just want to get a reading and that's it.

00:51:27.940 --> 00:51:30.580
<v MicroPython>You don't care about like all kinds of continuous readings or things like that.

00:51:30.580 --> 00:51:39.000
<v MicroPython>It's probably good enough to just make a quick little I2C call to it, get your register back and then convert it into temperature or whatever and go from there with it.

00:51:39.060 --> 00:51:40.300
<v MicroPython>So you can definitely do that.

00:51:40.620 --> 00:51:45.400
<v MicroPython>The other tricky thing, though, with libraries is that how do you actually distribute them?

00:51:45.460 --> 00:51:47.000
<v MicroPython>Like how do people use them?

00:51:47.120 --> 00:51:47.220
<v MicroPython>Yeah.

00:51:47.420 --> 00:51:49.540
<v MicroPython>And that's still kind of being figured out.

00:51:49.540 --> 00:51:58.460
<v MicroPython>So in the Python world, they have this whole infrastructure called PIP, the Python Package Manager, or there's also PYPI.

00:51:58.940 --> 00:51:58.960
<v MicroPython>Aha.

00:51:59.060 --> 00:52:02.160
<v Dave Jones>So you could submit your contribution to it.

00:52:02.160 --> 00:52:02.340
<v Dave Jones>Yeah.

00:52:02.380 --> 00:52:03.120
<v MicroPython>In the Python world.

00:52:03.160 --> 00:52:03.400
<v MicroPython>Exactly.

00:52:03.400 --> 00:52:09.860
<v MicroPython>So you can say like, you know, I created this really cool data processing library and I put it up on the Python Package Index.

00:52:10.400 --> 00:52:13.780
<v MicroPython>And then people with one little command on their computer can go and download it and start using it.

00:52:13.780 --> 00:52:22.700
<v MicroPython>And there isn't anything like that yet in MicroPython, but there is a lot of talk and there is some start to adding this PIP Package Manager to MicroPython.

00:52:22.880 --> 00:52:30.660
<v MicroPython>And so in the future, that might be something to look at and see, you know, what is out there is will there be a world where, okay, I want to talk to NeoPixel.

00:52:30.800 --> 00:52:35.740
<v MicroPython>So I just run a command and I get a NeoPixel module that downloads to my computer.

00:52:35.840 --> 00:52:37.760
<v MicroPython>Maybe I copy that onto my board and use it from there.

00:52:38.200 --> 00:52:40.960
<v MicroPython>So that could be maybe the future that they get to eventually with it.

00:52:40.960 --> 00:52:49.840
<v MicroPython>But even just in the interim, you know, most of the MicroPython libraries are just raw .py files that you can copy over to your board's file system and import them.

00:52:50.300 --> 00:53:02.360
<v MicroPython>And then they do have this concept of a .mpy file, which is basically the Python code, but pre-processed into that abstract syntax tree so that it's just storing the byte code.

00:53:02.460 --> 00:53:04.380
<v MicroPython>It's not storing the actual text of your program.

00:53:04.640 --> 00:53:05.440
<v MicroPython>So it's a little bit smaller.

00:53:05.560 --> 00:53:06.880
<v MicroPython>It doesn't have to load as much stuff in memory.

00:53:06.880 --> 00:53:11.960
<v Dave Jones>It's kind of like a dynamic link library for the DLL type thing, except it's kind of.

00:53:12.660 --> 00:53:15.120
<v Dave Jones>It's sort of like in the way that it's actually pre-compined.

00:53:15.140 --> 00:53:15.540
<v MicroPython>Exactly.

00:53:15.660 --> 00:53:15.780
<v MicroPython>Yep.

00:53:15.820 --> 00:53:20.120
<v MicroPython>And so it just, it saves memory because again, they're always trying to focus on how to reduce the memory usage with it.

00:53:20.240 --> 00:53:22.660
<v MicroPython>And so that's kind of what we're doing right now with our libraries.

00:53:22.840 --> 00:53:28.320
<v MicroPython>You know, we have some libraries to control like the Charlie Flex LED display that Chris has.

00:53:28.320 --> 00:53:28.760
<v MicroPython>That's what I was using.

00:53:28.760 --> 00:53:29.320
<v MicroPython>Exactly.

00:53:29.800 --> 00:53:31.700
<v Dave Jones>So, so here's a question.

00:53:31.920 --> 00:53:35.200
<v Dave Jones>The, okay, so it's interpreted code, right?

00:53:35.480 --> 00:53:39.740
<v Dave Jones>And it runs a little micro kernel inside that interprets your text thing.

00:53:39.780 --> 00:53:42.640
<v Dave Jones>And it's saved as like a file operating system kind of thing.

00:53:42.680 --> 00:53:44.360
<v Dave Jones>Is it actually saved as a text file?

00:53:44.500 --> 00:53:51.100
<v Dave Jones>So if you include all the comments in your code, are they taking up space in your micro?

00:53:51.100 --> 00:53:51.800
<v Dave Jones>They are, yeah.

00:53:51.920 --> 00:53:53.800
<v Dave Jones>And actually, oh, that's evil.

00:53:53.800 --> 00:53:55.660
<v MicroPython>And it's even kind of worse too.

00:53:55.860 --> 00:53:56.760
<v Chris Gammell>It's easy to read though, Dave.

00:53:56.760 --> 00:53:57.540
<v Chris Gammell>You don't need a comment.

00:53:57.540 --> 00:53:58.300
<v Chris Gammell>Don't run anything.

00:53:58.580 --> 00:53:58.680
<v Chris Gammell>Yeah.

00:53:58.820 --> 00:53:59.520
<v MicroPython>It's bad too.

00:53:59.580 --> 00:54:00.880
<v MicroPython>And that when you import that file.

00:54:01.000 --> 00:54:01.680
<v MicroPython>It's self-documented.

00:54:02.060 --> 00:54:02.120
<v MicroPython>Yeah.

00:54:02.160 --> 00:54:02.180
<v MicroPython>Yeah.

00:54:02.180 --> 00:54:02.360
<v MicroPython>Right.

00:54:03.620 --> 00:54:04.680
<v MicroPython>It's the dream.

00:54:05.000 --> 00:54:05.180
<v MicroPython>Yeah.

00:54:05.500 --> 00:54:07.200
<v MicroPython>Well, so actually two good things.

00:54:07.380 --> 00:54:11.580
<v MicroPython>So, but the first thing though is, yeah, it's, it's, it is bad in the sense that it's going to take up more flash memory.

00:54:11.900 --> 00:54:16.100
<v MicroPython>And when you import it, I believe right now it loads the entire file into RAM.

00:54:16.260 --> 00:54:17.720
<v MicroPython>And so, you know, yeah.

00:54:18.400 --> 00:54:21.100
<v Dave Jones>So you've got to have the RAM for all your comments as well.

00:54:21.100 --> 00:54:26.440
<v MicroPython>But that's, that's why they have the .mpy file because when you preprocess it.

00:54:26.440 --> 00:54:29.720
<v Dave Jones>I'm starting to twitch just to lack of efficiency of this thing.

00:54:29.840 --> 00:54:30.380
<v Dave Jones>I'm starting to.

00:54:30.380 --> 00:54:31.400
<v Chris Gammell>No, here's the thing about this.

00:54:31.580 --> 00:54:31.800
<v Chris Gammell>Convulsive hits.

00:54:31.800 --> 00:54:33.400
<v Chris Gammell>Here's the point I wanted to make this whole time too.

00:54:33.780 --> 00:54:40.820
<v Chris Gammell>This is, the reason this is going to be successful in my opinion is because like this stuff isn't getting any more expensive.

00:54:40.940 --> 00:54:41.900
<v Chris Gammell>It's getting so much cheaper.

00:54:42.480 --> 00:54:42.640
<v Chris Gammell>Yes.

00:54:42.640 --> 00:54:42.980
<v Chris Gammell>Yeah, I know.

00:54:42.980 --> 00:54:43.920
<v Chris Gammell>Batteries are a big deal.

00:54:43.920 --> 00:54:50.380
<v Chris Gammell>But like the only thing that chip companies have left to do is give us more processing power and more, more RAM and more flash, right?

00:54:50.380 --> 00:54:52.520
<v Chris Gammell>That's all they can do to try and sell more chips.

00:54:52.680 --> 00:54:53.780
<v Chris Gammell>And that's what they're going to do.

00:54:54.000 --> 00:54:54.760
<v Chris Gammell>So yeah.

00:54:54.940 --> 00:54:55.500
<v MicroPython>Power, sure.

00:54:55.600 --> 00:54:58.100
<v MicroPython>Definitely you will, yeah, start to see a lot more higher memory chips.

00:54:58.220 --> 00:55:02.820
<v MicroPython>But you don't have to live in a world where, you know, you are just only running that raw Python code.

00:55:03.060 --> 00:55:07.000
<v MicroPython>Like the, the preprocessing, like I mentioned, the .mpy files, that strips out the comments.

00:55:07.000 --> 00:55:09.460
<v MicroPython>That kind of boils it down to here's the core code.

00:55:09.460 --> 00:55:13.040
<v MicroPython>So you can work around those issues in some cases with that.

00:55:13.040 --> 00:55:14.060
<v Chris Gammell>It kind of sounded like an infomercial.

00:55:14.360 --> 00:55:18.000
<v Chris Gammell>Like, are you, does your, does your Python code have too many comments?

00:55:18.000 --> 00:55:18.920
<v Chris Gammell>Right, there you go.

00:55:18.980 --> 00:55:19.320
<v Chris Gammell>Yeah, yeah.

00:55:19.440 --> 00:55:21.180
<v Dave Jones>Instead of have comment bloat, you know.

00:55:21.540 --> 00:55:22.680
<v Dave Jones>Do you suffer from comment bloat?

00:55:22.680 --> 00:55:28.780
<v MicroPython>The flip side though is that it is actually kind of cool that you've got your script on the board in a text format.

00:55:28.920 --> 00:55:29.280
<v Dave Jones>Right.

00:55:29.360 --> 00:55:36.320
<v MicroPython>Because like in Arduino, for example, you open the Arduino IDE, you plug in your board, you don't really know what was the code that was running on it beforehand.

00:55:36.460 --> 00:55:36.660
<v MicroPython>Right.

00:55:36.660 --> 00:55:38.100
<v Dave Jones>Oh, so you can list it.

00:55:38.100 --> 00:55:43.120
<v Dave Jones>Can you go in via the command prompting you, whatever it's called, thingy, and then list your program?

00:55:43.120 --> 00:55:43.880
<v MicroPython>You can, exactly.

00:55:44.000 --> 00:55:45.140
<v MicroPython>You can pull the file out.

00:55:45.140 --> 00:55:45.400
<v MicroPython>Oh, that's pretty sweet.

00:55:45.420 --> 00:55:49.660
<v MicroPython>And so, you know, a MicroPython Arduino IDE of the future might be pretty cool.

00:55:49.740 --> 00:55:55.460
<v MicroPython>You plug in your board and it just shows you, here is your program, and then you just start tweaking it, re-upload it, whatever, and go in there.

00:55:56.020 --> 00:55:57.860
<v MicroPython>So there's an open source card out right there, right?

00:55:57.900 --> 00:55:59.480
<v MicroPython>I mean, like, that's pretty great.

00:55:59.600 --> 00:56:00.380
<v MicroPython>Yeah, so it is kind of neat.

00:56:00.500 --> 00:56:02.680
<v MicroPython>I mean, it is, you know, it's good and bad, like you said.

00:56:03.000 --> 00:56:05.520
<v Dave Jones>Unless you've got the pre-compiled libraries, right?

00:56:05.520 --> 00:56:06.860
<v MicroPython>And then you don't get the code.

00:56:06.860 --> 00:56:07.960
<v MicroPython>But exactly right.

00:56:08.040 --> 00:56:10.920
<v MicroPython>The .mpy files, yeah, you're not going to be able to see with those.

00:56:11.280 --> 00:56:18.720
<v Dave Jones>So if you're a real purist and you want to use the minimum amount of memory, et cetera, possible, then you're going to compile everything.

00:56:18.880 --> 00:56:22.460
<v Dave Jones>You're going to write everything as routines, compile them all, and then just include.

00:56:22.560 --> 00:56:25.100
<v Chris Gammell>Or you're probably not going to use MicroPython in the first place, right?

00:56:25.260 --> 00:56:26.420
<v Dave Jones>Right, right, okay.

00:56:26.420 --> 00:56:28.620
<v Chris Gammell>Yeah, yeah, or drop down to C functions if you need.

00:56:28.840 --> 00:56:29.840
<v Chris Gammell>Yeah, lots of options.

00:56:30.880 --> 00:56:32.100
<v Chris Gammell>What about the overhead stuff?

00:56:32.200 --> 00:56:35.180
<v Chris Gammell>I mean, how much – I don't really have – I mean, I don't have a feel.

00:56:35.240 --> 00:56:44.480
<v Chris Gammell>You said before that one of those processing things that had 16K on board and there was four left, so I assume 12K just to be running on the micro bit.

00:56:44.480 --> 00:56:49.140
<v MicroPython>Yeah, yeah, and it kind of comes down to what features you want to turn on.

00:56:49.700 --> 00:56:56.080
<v MicroPython>So there's a lot of switches in the MicroPython firmware where you can add and remove different functionality.

00:56:56.380 --> 00:56:57.080
<v MicroPython>Like it has –

00:56:57.080 --> 00:57:00.160
<v Dave Jones>Right, so if you've got floating point support or something, you can remove it.

00:57:00.160 --> 00:57:04.040
<v MicroPython>You might be able to turn that on or like longer integers or things like that.

00:57:04.360 --> 00:57:07.340
<v MicroPython>So there are a lot of knobs to tweak with that.

00:57:07.660 --> 00:57:13.700
<v MicroPython>With the micro bit, I'm not super familiar with it, but I think they had to turn a lot of things off and just get it down to the core language.

00:57:14.480 --> 00:57:15.120
<v MicroPython>I suspect that.

00:57:15.120 --> 00:57:16.200
<v MicroPython>But it does kind of tell you that –

00:57:16.200 --> 00:57:16.900
<v MicroPython>String support.

00:57:17.520 --> 00:57:20.640
<v Chris Gammell>We can tell that this is a .py file and that's about all we can do.

00:57:20.840 --> 00:57:21.380
<v Chris Gammell>Right, yeah.

00:57:22.020 --> 00:57:22.740
<v MicroPython>Definitely limited.

00:57:23.220 --> 00:57:29.360
<v MicroPython>But it does kind of tell you that, yeah, like you can get it down to like just a few tens of kilobytes of overhead for that.

00:57:30.160 --> 00:57:36.000
<v MicroPython>On the other boards, I think – let's see, on our SAMD21, we have 32K of memory.

00:57:36.300 --> 00:57:41.880
<v MicroPython>We took 16K of that for the heap, which is kind of what Python uses, and then the rest is stack.

00:57:42.400 --> 00:57:46.160
<v MicroPython>And we haven't run into a ton of issues using that 16K on the heap.

00:57:46.240 --> 00:57:51.000
<v MicroPython>I think only a few kilobytes or so seem to be used by our MicroPython firmware right now.

00:57:51.120 --> 00:57:58.440
<v MicroPython>So it's not like you're paying a huge price for it, but there is certainly some overhead for having that up there.

00:57:58.440 --> 00:58:07.220
<v Chris Gammell>Right, you're not going to be getting the same performance as you would if you were writing Assembly or even C probably because you have – there is some cost to it.

00:58:07.480 --> 00:58:08.020
<v Chris Gammell>Yep, exactly.

00:58:08.200 --> 00:58:10.440
<v MicroPython>It's not free, but the advantage is –

00:58:10.440 --> 00:58:10.680
<v MicroPython>Right.

00:58:10.680 --> 00:58:20.640
<v Chris Gammell>I mean, this seems like it's really – I mean, like I said, I think this is really targeted towards prototyping at the beginning, but that's what seems right to me where it's like you want to iterate fast.

00:58:20.720 --> 00:58:21.900
<v Chris Gammell>You want to try a bunch of different things.

00:58:21.940 --> 00:58:25.600
<v Chris Gammell>You want to get your data out and to some other thing to prototype with.

00:58:27.460 --> 00:58:38.120
<v Chris Gammell>You're not going to be using that as your – maybe a couple people will ship it in production, but probably you would pay to send it to – bring an embedded person in and tighten that whole thing up.

00:58:38.120 --> 00:58:38.720
<v Chris Gammell>Maybe, yeah.

00:58:38.720 --> 00:58:39.780
<v MicroPython>I mean, it's a good question.

00:58:39.920 --> 00:58:43.240
<v MicroPython>It depends on how complex the thing is that you're trying to create with this.

00:58:43.340 --> 00:58:52.920
<v MicroPython>Like if it's just a simple thing that like talks to a web service and then maybe actuates something on some results, you might not have to drop down into low-level stuff for that.

00:58:52.920 --> 00:59:11.020
<v MicroPython>One kind of interesting thing related to that is MicroPython, the .org or the Damien and his project, I believe the ESA, the European Space Agency, is actually looking at MicroPython to use on satellites potentially in the future.

00:59:11.720 --> 00:59:11.860
<v MicroPython>Wow.

00:59:11.980 --> 00:59:16.980
<v MicroPython>And it was a little surprising to me to think like, wow, okay, they want to use like this newish project for this.

00:59:16.980 --> 00:59:22.920
<v MicroPython>But it kind of made sense because they like the idea with satellites that are out in space.

00:59:23.460 --> 00:59:28.800
<v MicroPython>You know, when they update the firmware, it's a very scary nail-biting process of like, oh, boy.

00:59:29.020 --> 00:59:30.440
<v MicroPython>Put the wrong bit when you're updating firmware.

00:59:30.440 --> 00:59:32.460
<v MicroPython>I hope all those bytes, yeah, get sent up there correctly.

00:59:32.860 --> 00:59:37.480
<v MicroPython>So they like the idea of having an interpreted language where you don't really need to change that firmware.

00:59:37.720 --> 00:59:39.660
<v MicroPython>You've got your Python core up there.

00:59:40.020 --> 00:59:42.560
<v MicroPython>But, okay, we want to change the satellite functionality a little bit.

00:59:42.560 --> 00:59:46.320
<v MicroPython>Let's upload a new file and then let it run that file and go from there.

00:59:46.320 --> 00:59:48.040
<v MicroPython>And not to say that that's necessarily any better.

00:59:48.160 --> 00:59:50.460
<v MicroPython>There's all kinds of other problems and things that might go wrong.

00:59:50.780 --> 00:59:51.500
<v MicroPython>But it is kind of cool.

00:59:51.640 --> 00:59:55.200
<v MicroPython>You know, that would be a good case of like you've got some product or something.

00:59:55.720 --> 00:59:57.080
<v MicroPython>And you want to change the functionality.

00:59:57.080 --> 01:00:03.600
<v MicroPython>And so it's a little bit easier when you've got a language that's just interpreting your code and able to swap out that code pretty easily.

01:00:04.060 --> 01:00:06.360
<v Chris Gammell>So a firmware change, would that be so?

01:00:06.600 --> 01:00:07.880
<v Chris Gammell>It wouldn't be native, right?

01:00:07.900 --> 01:00:10.280
<v Chris Gammell>The easiest way to switch out firmware is to plug in.

01:00:10.400 --> 01:00:11.960
<v MicroPython>Just change the Python code.

01:00:12.060 --> 01:00:12.380
<v MicroPython>Exactly.

01:00:12.660 --> 01:00:13.060
<v Chris Gammell>Right.

01:00:13.060 --> 01:00:18.640
<v Chris Gammell>But in theory, it would be possible to load it into Flash, like a new firmware image into Flash.

01:00:19.060 --> 01:00:20.680
<v Chris Gammell>Like when people are doing like field updates.

01:00:21.040 --> 01:00:21.400
<v Chris Gammell>Exactly.

01:00:21.600 --> 01:00:21.680
<v Chris Gammell>Yeah.

01:00:21.720 --> 01:00:22.900
<v Chris Gammell>You totally could do that too.

01:00:23.000 --> 01:00:23.800
<v Chris Gammell>Same kind of thing, right?

01:00:23.840 --> 01:00:23.960
<v Chris Gammell>Yep.

01:00:23.960 --> 01:00:26.740
<v Chris Gammell>So NASA could still do the scary thing.

01:00:26.800 --> 01:00:30.800
<v Chris Gammell>But then for everyday operational stuff, they could do the easy thing.

01:00:30.900 --> 01:00:31.300
<v Chris Gammell>Exactly.

01:00:31.440 --> 01:00:31.560
<v Chris Gammell>Yep.

01:00:31.560 --> 01:00:36.580
<v MicroPython>So it's nice to have that flexibility for it, which is also good too for beginners.

01:00:36.580 --> 01:00:45.020
<v MicroPython>Like all of the boards that support MicroPython, at least the Atmel, SamD, and the ESP, they also support Arduino.

01:00:45.280 --> 01:00:50.420
<v MicroPython>So it does give you a lot of options in that, okay, if you want to experiment with MicroPython, you can play with it.

01:00:50.840 --> 01:00:55.120
<v MicroPython>And then if you realize like, okay, this Python thing isn't for me, it's still an Arduino.

01:00:55.120 --> 01:01:03.100
<v MicroPython>You know, you can still use the Arduino IDE to program the board and like, you know, completely erase the MicroPython firmware and just run like your bare metal code on top of it.

01:01:03.160 --> 01:01:04.840
<v MicroPython>So you do have some options there too.

01:01:05.040 --> 01:01:08.320
<v MicroPython>The flexibility of, you know, if you want to use it or if you don't want to use it.

01:01:09.020 --> 01:01:09.380
<v MicroPython>Yeah.

01:01:09.380 --> 01:01:10.240
<v Chris Gammell>So, okay.

01:01:10.260 --> 01:01:13.600
<v Chris Gammell>So the last thing I want to bring up was the ESP because I had tried using it.

01:01:13.660 --> 01:01:18.440
<v Chris Gammell>I had tried one before, but I didn't have, I didn't, I didn't get it working before.

01:01:18.500 --> 01:01:20.100
<v Chris Gammell>Not that that, that, that was on me.

01:01:20.440 --> 01:01:26.960
<v Chris Gammell>But, um, uh, finally, I, so I, I got this featherboard thingy with the ESP 8266 on it.

01:01:27.160 --> 01:01:28.480
<v Chris Gammell>Oh, the Huzzah, it's called.

01:01:28.540 --> 01:01:28.820
<v Chris Gammell>Is that right?

01:01:28.920 --> 01:01:29.060
<v Chris Gammell>Right.

01:01:29.160 --> 01:01:29.320
<v Chris Gammell>Yeah.

01:01:29.420 --> 01:01:30.780
<v Chris Gammell>The ESP 8266.

01:01:30.880 --> 01:01:31.040
<v Chris Gammell>Yep.

01:01:31.300 --> 01:01:34.520
<v Chris Gammell>And that was shockingly simple.

01:01:34.960 --> 01:01:35.580
<v Chris Gammell>Oh, that's good.

01:01:35.580 --> 01:01:35.820
<v Chris Gammell>Yeah.

01:01:36.120 --> 01:01:36.440
<v Chris Gammell>Yeah.

01:01:36.440 --> 01:01:37.920
<v Chris Gammell>I mean, so basically I got it.

01:01:37.920 --> 01:01:39.580
<v Chris Gammell>I, all I had to do is reprogram.

01:01:39.720 --> 01:01:41.860
<v Chris Gammell>So Tony has all these tutorials and we'll link to all of them.

01:01:41.960 --> 01:01:47.700
<v Chris Gammell>But, um, all I had to do was reprogram to get it, to get the firmware image updated, to

01:01:47.700 --> 01:01:49.180
<v Chris Gammell>put it on my network basically.

01:01:49.580 --> 01:01:54.900
<v Chris Gammell>And then it was right now I am talking to, there's a web repl, right?

01:01:54.920 --> 01:01:56.880
<v Chris Gammell>So that's the re-evaluate.

01:01:57.080 --> 01:01:57.420
<v Chris Gammell>What is it?

01:01:57.520 --> 01:01:58.640
<v Chris Gammell>The re-evaluate print.

01:01:58.940 --> 01:01:59.260
<v Chris Gammell>The prompt.

01:01:59.380 --> 01:01:59.500
<v Chris Gammell>Yeah.

01:01:59.500 --> 01:02:00.100
<v Chris Gammell>The command prompt.

01:02:00.160 --> 01:02:00.240
<v Chris Gammell>Yeah.

01:02:00.240 --> 01:02:00.600
<v Chris Gammell>The prompt.

01:02:00.760 --> 01:02:00.860
<v Chris Gammell>Yeah.

01:02:01.820 --> 01:02:02.180
<v Chris Gammell>Yeah.

01:02:02.700 --> 01:02:04.780
<v Chris Gammell>And, uh, super simple.

01:02:04.880 --> 01:02:05.060
<v Chris Gammell>Right.

01:02:05.060 --> 01:02:10.860
<v Chris Gammell>And so now I basically am just talking to a, a board with the Python interface.

01:02:11.040 --> 01:02:11.360
<v Chris Gammell>Exactly.

01:02:11.520 --> 01:02:11.680
<v Chris Gammell>Yep.

01:02:12.260 --> 01:02:12.800
<v MicroPython>Over wifi.

01:02:13.000 --> 01:02:17.080
<v Chris Gammell>The thing that really tripped me up was I didn't, I didn't realize, uh, I didn't have,

01:02:17.240 --> 01:02:23.020
<v Chris Gammell>I didn't, you know, it's just pretty much like just a web-based serial terminal, but I

01:02:23.020 --> 01:02:25.020
<v Chris Gammell>didn't have the, um, the library.

01:02:25.020 --> 01:02:27.920
<v Chris Gammell>And I thought, oh, I'm going to have to go like pull it off the other part of my desk

01:02:27.920 --> 01:02:30.960
<v Chris Gammell>and come plug it in, whatever, whatever, plug it into my computer, get the serial terminal

01:02:30.960 --> 01:02:31.180
<v Chris Gammell>up.

01:02:31.180 --> 01:02:33.060
<v Chris Gammell>And I'm like, oh no, there's actually a send to device.

01:02:33.160 --> 01:02:36.200
<v Chris Gammell>You could just send another library to it.

01:02:36.200 --> 01:02:36.220
<v Chris Gammell>Yeah.

01:02:36.220 --> 01:02:39.600
<v MicroPython>You can copy files through the web-reple, which is a really nice, a handy thing.

01:02:39.700 --> 01:02:41.940
<v MicroPython>And again, it just goes onto the file system on the board.

01:02:42.440 --> 01:02:46.920
<v MicroPython>Um, you know, you can copy the library file, or if you had like a text file, you know, with

01:02:46.920 --> 01:02:48.740
<v MicroPython>maybe some data in it, you could copy that over.

01:02:49.020 --> 01:02:53.980
<v MicroPython>And then, you know, in your code to open that file, it's just like opening a file in Python.

01:02:53.980 --> 01:02:58.360
<v MicroPython>Like there's an open command, there's a read command, a write command, uh, to, to process

01:02:58.360 --> 01:02:58.580
<v MicroPython>it.

01:02:58.580 --> 01:03:03.220
<v MicroPython>So that's, uh, you know, another cool thing too, is just, you've, you've got files that

01:03:03.220 --> 01:03:05.960
<v MicroPython>you can put on there and you can use them in your program.

01:03:06.480 --> 01:03:11.700
<v Chris Gammell>Yeah, no, that, that piece is, um, again, like this is, this is not new stuff for most

01:03:11.700 --> 01:03:12.240
<v Chris Gammell>people, I think.

01:03:12.300 --> 01:03:16.880
<v Chris Gammell>But I think that the reason that I've been so excited about this is it feels like it's

01:03:16.880 --> 01:03:20.380
<v Chris Gammell>very enabling for a hardware person like me, who I, I'm not going to take the time to,

01:03:20.380 --> 01:03:22.020
<v Chris Gammell>to do all the other stuff.

01:03:22.020 --> 01:03:25.440
<v Chris Gammell>You know, like people are like, oh, well you can do like a Lua server on an ESP, or you can,

01:03:25.440 --> 01:03:29.740
<v Chris Gammell>you know, you can talk to a, you know, you can set up a micro to talk to a, a secondary,

01:03:29.740 --> 01:03:32.360
<v Chris Gammell>um, wifi shield and talk to that.

01:03:32.400 --> 01:03:36.180
<v Chris Gammell>And it's like, yes, but this is, it feels really simple.

01:03:36.400 --> 01:03:36.400
<v Speaker ?>

01:03:36.420 --> 01:03:37.900
<v MicroPython>Just a few steps, right.

01:03:38.020 --> 01:03:42.640
<v MicroPython>Load the firmware and then connect to the REPL effectively and you're ready to go to start

01:03:42.640 --> 01:03:43.240
<v MicroPython>running code.

01:03:43.460 --> 01:03:47.780
<v MicroPython>Uh, and, and that's exactly why I think we like it so much, uh, at Adafruit because,

01:03:47.780 --> 01:03:50.340
<v MicroPython>you know, we want to help more people get interested in electronics.

01:03:50.340 --> 01:03:55.040
<v MicroPython>And we've just seen even with Arduino and that, you know, it's opened up a lot of doors

01:03:55.040 --> 01:03:57.600
<v MicroPython>to more people, but there's still a little hard.

01:03:57.680 --> 01:03:59.660
<v MicroPython>It's still challenging to get started with that stuff.

01:03:59.660 --> 01:04:03.100
<v MicroPython>And so, like you said, you know, just you plugged in the board, loaded the firmware and

01:04:03.100 --> 01:04:05.000
<v MicroPython>you've got Python code running on it.

01:04:05.320 --> 01:04:08.840
<v MicroPython>Uh, that's kind of the dream hopefully to get to, you know, making it that easy for people

01:04:08.840 --> 01:04:10.000
<v MicroPython>to play with electronics.

01:04:10.480 --> 01:04:13.900
<v Chris Gammell>Well, that's the shift that I've been making too, is that no one wants to run code, right?

01:04:14.360 --> 01:04:15.820
<v Chris Gammell>No one wants to build electronics.

01:04:15.820 --> 01:04:16.960
<v Chris Gammell>No one wants to run code.

01:04:17.020 --> 01:04:18.600
<v Chris Gammell>No one wants to do most of that stuff.

01:04:18.600 --> 01:04:20.860
<v Chris Gammell>Well, not no one, but most people don't want to do that stuff.

01:04:20.860 --> 01:04:25.480
<v Chris Gammell>What they want to do is make a thing blink or make a motor move, right?

01:04:25.560 --> 01:04:28.260
<v Chris Gammell>I mean, they want the output or they want the data out of something, right?

01:04:28.280 --> 01:04:28.820
<v Chris Gammell>Out of a sensor.

01:04:29.080 --> 01:04:34.900
<v Chris Gammell>They don't care about the details and the closer you get people to there, once they can do it

01:04:34.900 --> 01:04:39.000
<v Chris Gammell>once, they're going to dig down and figure out how they can do it faster or better or

01:04:39.000 --> 01:04:40.980
<v Chris Gammell>in a, you know, a larger scale or something.

01:04:41.060 --> 01:04:43.180
<v Chris Gammell>And that is when they start learning electronics.

01:04:43.560 --> 01:04:44.180
<v Chris Gammell>Yeah, true, right.

01:04:44.240 --> 01:04:46.160
<v Chris Gammell>Like the gateway drug maybe of electronics.

01:04:46.440 --> 01:04:46.640
<v Chris Gammell>Exactly.

01:04:46.640 --> 01:04:46.980
<v Chris Gammell>Right.

01:04:47.180 --> 01:04:47.360
<v Chris Gammell>Yep.

01:04:47.520 --> 01:04:47.740
<v Chris Gammell>Yep.

01:04:48.020 --> 01:04:48.420
<v Chris Gammell>That's it.

01:04:48.780 --> 01:04:49.220
<v Chris Gammell>Yay, drugs.

01:04:52.140 --> 01:04:53.740
<v Chris Gammell>Dave, you got any other questions about this stuff?

01:04:54.480 --> 01:04:56.260
<v Chris Gammell>I'm sure I'm going to talk about it more.

01:04:56.320 --> 01:04:59.560
<v Dave Jones>I'm all firmware to out and command prompt.

01:04:59.560 --> 01:05:01.300
<v Chris Gammell>I thought we did pretty good this episode.

01:05:01.580 --> 01:05:02.020
<v Chris Gammell>We did.

01:05:02.640 --> 01:05:04.600
<v Dave Jones>Considering that we know Jack all about Python.

01:05:04.600 --> 01:05:04.920
<v Dave Jones>Yeah.

01:05:05.100 --> 01:05:07.640
<v Dave Jones>I think we asked sensible questions, Chris.

01:05:07.800 --> 01:05:08.400
<v Dave Jones>Well done us.

01:05:08.400 --> 01:05:08.820
<v Dave Jones>Hey, hey.

01:05:09.180 --> 01:05:12.300
<v MicroPython>The big question, are you going to go off and are you going to learn Python now?

01:05:12.420 --> 01:05:15.820
<v MicroPython>You know, did I sell it enough to you that this is something that, you know, you want

01:05:15.820 --> 01:05:17.220
<v MicroPython>to try out and experiment with?

01:05:17.220 --> 01:05:17.660
<v Chris Gammell>No.

01:05:17.660 --> 01:05:17.700
<v Chris Gammell>No.

01:05:17.780 --> 01:05:18.340
<v Chris Gammell>I mean, no.

01:05:18.440 --> 01:05:20.300
<v Chris Gammell>I'm not going to go like sit down and learn Python.

01:05:20.300 --> 01:05:20.300
<v Speaker ?>

01:05:20.320 --> 01:05:20.580
<v Chris Gammell>Okay.

01:05:20.720 --> 01:05:21.880
<v Chris Gammell>But I'm going to use it as a tool.

01:05:22.040 --> 01:05:22.500
<v Chris Gammell>There you go.

01:05:22.640 --> 01:05:22.860
<v Chris Gammell>There you go.

01:05:23.100 --> 01:05:24.420
<v Dave Jones>I might use it as a tool.

01:05:24.620 --> 01:05:27.460
<v Chris Gammell>And that's where that's the same argument as before, right?

01:05:27.520 --> 01:05:30.300
<v Chris Gammell>Like someone tells me, someone hands me a book that says go learn Python.

01:05:30.420 --> 01:05:31.020
<v Chris Gammell>It's like, eh.

01:05:31.280 --> 01:05:31.500
<v Chris Gammell>Right.

01:05:31.500 --> 01:05:32.640
<v Chris Gammell>I've been handed that book a bunch of times.

01:05:32.640 --> 01:05:34.700
<v Chris Gammell>I don't have a project in mind.

01:05:34.760 --> 01:05:39.780
<v Chris Gammell>But when I need to go talk to a sensor or light up a thing, I will get that done.

01:05:40.120 --> 01:05:40.260
<v Chris Gammell>Very quick.

01:05:40.440 --> 01:05:40.600
<v Chris Gammell>Yeah.

01:05:40.760 --> 01:05:41.120
<v Chris Gammell>That's it.

01:05:41.320 --> 01:05:41.480
<v Chris Gammell>Yeah.

01:05:41.560 --> 01:05:41.920
<v Chris Gammell>Exactly.

01:05:42.700 --> 01:05:43.180
<v Chris Gammell>That's great.

01:05:43.700 --> 01:05:45.820
<v Chris Gammell>Well, we always love this.

01:05:45.920 --> 01:05:47.040
<v Chris Gammell>The stuff that Adafruit's doing.

01:05:47.300 --> 01:05:48.820
<v Chris Gammell>I'm glad that you're doing this stuff at Adafruit as well.

01:05:48.940 --> 01:05:53.360
<v Chris Gammell>That's, you know, you guys are doing a great job in the education and electronic space.

01:05:53.440 --> 01:05:54.000
<v Chris Gammell>We love you guys.

01:05:54.240 --> 01:05:54.240
<v Speaker ?>

01:05:54.400 --> 01:05:54.820
<v Dave Jones>Oh, excellent.

01:05:54.900 --> 01:05:55.000
<v Dave Jones>Yeah.

01:05:55.000 --> 01:05:55.420
<v Dave Jones>Keep it up.

01:05:55.800 --> 01:05:57.180
<v Dave Jones>Thank you very much for joining us, Tony.

01:05:57.260 --> 01:05:57.740
<v Dave Jones>It's been awesome.

01:05:57.780 --> 01:05:58.240
<v Dave Jones>Oh, thank you.

01:05:58.280 --> 01:05:58.400
<v Dave Jones>Yeah.

01:05:58.420 --> 01:05:59.000
<v Dave Jones>Great to be here.

01:05:59.200 --> 01:05:59.540
<v Chris Gammell>All right.

01:05:59.600 --> 01:06:02.040
<v Chris Gammell>Well, we'll keep looking out for new projects.

01:06:02.420 --> 01:06:06.120
<v Chris Gammell>And I'll probably be talking about this more in the show in the future and bugging Dave about it.

01:06:06.220 --> 01:06:07.380
<v Chris Gammell>So thanks again for being on the show.

01:06:07.900 --> 01:06:08.180
<v Chris Gammell>Excellent.

01:06:08.240 --> 01:06:08.380
<v Chris Gammell>Yeah.

01:06:08.380 --> 01:06:08.660
<v Chris Gammell>Thank you.

01:06:09.020 --> 01:06:09.700
<v Dave Jones>Catch you next time.

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:09.700 --> 01:06:09.700
<v Speaker ?>

01:06:25.000 --> 01:06:26.760
<v Speaker ?>Bye.

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:26.760
<v Speaker ?>

01:06:26.760 --> 01:06:40.760
<v Speaker ?>administered administered administered

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>

01:06:40.760 --> 01:06:40.760
<v Speaker ?>
