Four Topics and an Interview
S02:E10

Four Topics and an Interview

Episode description

Paul and Tod chat about Professor Gallaugher’s CircuitPython tutorial videos, Embedded Swift, a special interview with Justin Myers, the author of the new CircuitPython ConnectionManager library, and more.

For detailed show notes and transcripts visit The Bootloader.net

Show Notes:

00:21 CircuitPython videos by Professor John Gallaugher

4:58 Embedded Swift

8:53 Accessibility Matters

11:55 CadQuery

16:47 Interview with Justin Myers, author of CircuitPython’s ConnectionManager library

Download transcript (.srt)
0:00

Welcome to The Bootloader. I'm Paul Cutler.

0:06

And I'm Tod Kurt. We have a special episode for you today with an interview with Justin

0:10

Myers, the author of the CircuitPython Library Connection Manager. Before we get to that,

0:14

though, Paul and I each have a couple of things to share with you, each not more than a few

0:18

minutes long. What's your first one, Paul?

0:20

My first one is how to level up at CircuitPython. Professor John Gallaugher of Boston College

0:25

recently released two videos I wanted to share, one for how to migrate from using Mu and

0:29

CircuitPython to using PyCharm with Teal and a video on using Circup to install and update

0:34

CircuitPython libraries. If you're not familiar with Professor Gallaugher, I talked to him

0:38

way back in episode 3 of the CircuitPython Show, which I'll link to in the show notes.

0:43

He teaches a class called Introduction to Physical Computing, which uses CircuitPython

0:47

along with microcontrollers to teach students computing concepts. He has other YouTube playlists

0:52

worth checking out on his YouTube channel, especially if you're newer to CircuitPython.

0:55

I'll link to those as well.

0:57

But back to his new videos. The first one is how to correctly set up PyCharm on MacOS

1:02

to use with CircuitPython. Most of this is applicable to Linux, too, and I learned a

1:06

few new things. It's a longer video at about half an hour, but the professor walks you

1:10

through how to correctly configure PyCharm, and he's using the free community edition

1:14

in the video. Next, he covers using the new and updated CircuitPython setboard so you

1:19

have code completion for your microcontroller in PyCharm. That might be brand new to a lot

1:24

of people and is definitely worth watching. From there, he covers using Teal, an open

1:28

source serial program that is way better than using Screen. It's got auto-reconnect as

1:33

its killer feature, and I think it's pretty cool that he included Teal as the serial monitor

1:37

in Mu is one of its key features.

1:40

Next up is a 15-minute video on using CircUp to install CircuitPython libraries. If you've

1:44

used CircuitPython, chances are you've downloaded the Adafruit library or the community library

1:49

bundle, and then you have to find the right library out of hundreds. But what if you could

1:53

easily use the command line? He walks you through how to use CircUp from the command

1:57

line, and then for Mac OS users or for Linux users using the ZSH shell, he shows you how

2:03

to add tab completion by updating your ZSH configuration file.

2:07

CircUp has also been getting some love over the last few months. Shout out to Tim, aka

2:11

Foamy Guy in the Adafruit community. He's been doing some refactoring and adding new

2:15

features as well. I know I learned a few things, and if you use CircuitPython and you're looking

2:19

to level up your CircuitPython workflow, I highly recommend checking out these videos

2:23

from Professor Gallaugher.

2:24

I love CircUp. It's sort of like, if you've never heard of it, it's sort of like Pip,

2:29

the Python package manager, but for CircuitPython. And it hooks into the two big package repositories

2:34

that exist for CircuitPython, the Adafruit one and the community one. It's so good, but

2:38

it's a little bit hard to set up if you've never done any sort of Python setup before.

2:42

So this video is like super handy because I get people asking me all the time, "How

2:46

do you install a CircuitPython library?"

2:48

Right.

2:49

And I'm like, "The answer is just use CircUp." But then the question becomes, "Well, how

2:53

do you install CircUp?"

2:55

And I think it's really cool that he actually walks you through on how to update your ZSH

2:59

shell for the tab autocompletes, because there's hundreds of libraries, and it makes it just

3:06

that much easier to find the library you're looking for.

3:08

I really want to follow his steps on how to set up that PyCharm IDE, because I don't really

3:13

use IDEs in the normal sense. I just use a text editor with code syntax highlighting.

3:17

But there's so many people that have been trying to use the VS Code CircuitPython extension,

3:21

and it's been sort of perennially broken.

3:24

The people are so frustrated using it. And it looks like PyCharm is really well done.

3:31

And there's this nice now intro video on how to actually meld it with CircuitPython, which

3:34

is a little weird because most of the times when you're editing Python with an IDE, you're

3:40

editing the files sort of in a project, say.

3:44

And CircuitPython is a little bit different in that the code lives on a device, and you

3:48

edit the device.

3:49

And so maybe your actual project is in a GitHub repo that lives on your computer somewhere.

3:53

So how do you deal with those two separate views of your code?

3:57

And I think PyCharm can help you with that.

3:59

It can, but you're still writing directly to the microcontroller in the way that it's

4:03

set up in this example.

4:05

Because I know I use PyCharm, and I did learn a couple of things, but there's still a lot

4:08

of copy-paste.

4:09

Yeah, yeah.

4:10

Because I commit everything to my GitHub repo, so I'm writing locally, saving it there, and

4:15

then copying it over to the drive as soon as I hit save, running the code.

4:19

Yeah, that's usually how I work as well.

4:22

But I see all these people that try to use Mu, because it's easy to use, but Mu's getting

4:25

kind of crusty.

4:26

And Thonny, I don't know, Thonny just always seems like it breaks my CircuitPython install

4:32

whenever I try to use it.

4:34

Sure.

4:35

Yeah, it's too bad that Mu's getting a little long in the tooth.

4:38

It's an open source project, it needs a little love, but it's nice to see other alternatives

4:42

out there that are well documented.

4:44

Yeah, no doubt.

4:45

Yeah, I mean, the cool thing is that because it's all just a text file, you can use anything

4:49

that can edit text files to edit your CircuitPython code.

4:53

But it'd be nice to have a really good IDE for those people who need IDEs.

4:57

What's your first one?

4:58

All right, so kind of related, Professor Gallaugher also does a lot of how to program iOS apps

5:04

for Apple devices.

5:06

And so those are written in Swift.

5:08

Swift is a programming language that Apple has been developing for the last 10 years.

5:11

They use it on all their platforms.

5:13

It's the officially recommended way for writing apps for iPhones, iPads, Apple Watch, things

5:17

like that.

5:18

And Swift is a really interesting language.

5:19

It's heavily influenced by Haskell and Rust, these sort of academic languages that emphasize

5:26

type safety and functional programming, where the compiler itself can catch a lot of bugs

5:31

as it compiles your code down, which is kind of foreign to how Python and JavaScript work,

5:35

where you just kind of run your code and see if it crashes or not.

5:40

And so there's this whole academic effort in computer science that we should be able

5:44

to make provably correct programs, or programs that we can prove will not crash for certain

5:50

classes of crashes.

5:51

That's what Haskell and Rust kind of comes from.

5:53

That's where Swift came from as well.

5:56

And it's a really interesting language.

5:57

It looks a little bit like C, but with all these sort of extra neat things on top of

6:02

it.

6:03

If you look at Chris Lattner, who developed LLVM and the Clang compiler, which you've

6:07

probably seen in various places when you've installed things, it's been the sort of revolution

6:12

how to compile C-based or C-like languages.

6:15

And so you'll see, I think you'll see LLVM and Clang a lot more going forward.

6:19

But Swift uses those two things underneath to do its magic as well.

6:25

And the reason why I'm bringing all this up is because Apple just released something they

6:29

call Embedded Swift, which is a version of Swift that runs on microcontrollers, which

6:34

is amazing.

6:35

This is a super high-level language, in many ways higher level than Python or JavaScript.

6:42

And we can run it on a microcontroller on things that are even some ways smaller than

6:47

what CircuitPython type controllers can do.

6:50

And not only did they release here's Embedded Swift, but they also released working demos

6:54

for the Raspberry Pi Pico, the ESP32C6, the InterF52-840, which is a Beely chip, and the

7:01

STM32 chips.

7:02

And they've also released a bunch of examples on how to participate in Matter, a Matter

7:07

network, which is the new standard for home automation that Apple's HomeKit API does.

7:14

And I think Google's Echo platform also does now.

7:18

And so there's a, and it's all on GitHub, you can just go to their Swift Matter examples,

7:25

see the smart light example that you can run and control.

7:29

You can make a controllable smart light with Siri and about 60 lines of Swift code.

7:33

And it's all, it has a lot of the same features of real Swift of the type safety, the functional

7:38

programming, that kind of stuff.

7:40

And it's just sort of amazing that we're getting this super high-level language running on

7:44

tiny chips.

7:45

And I've not looked at it too much yet, but in the show notes, there'll be some links

7:49

to some other articles describing it and links to the GitHub that has some examples.

7:53

So you can actually try some of this stuff out on your Pico or ESP32.

7:58

I only know Python, and this has me really intrigued, especially the Matter integration,

8:02

right?

8:03

We don't have that in CircuitPython yet.

8:05

I don't think Arduino has Matter integration that I've seen.

8:08

So actually being able to write my own smart home apps on microcontrollers would be a really

8:13

cool use case and actually has me thinking of learning a second language.

8:18

Yeah, it's like, supposedly there's Matter APIs in the latest ESP IDF, the SDK that you

8:25

use when you're writing C code for the ESP32 chips.

8:28

And I think that's what these Swift Matter examples are using under the hood.

8:33

But do you really want to be mucking around with C code when you could use a high-level

8:37

language like Swift?

8:38

Yeah.

8:39

And so, you know, it'd be nice if we get Matter support in CircuitPython someday.

8:44

There's no reason why we can't.

8:45

And I think Jeffler might actually be working on that really, really early stages.

8:50

Nice.

8:51

Yeah, yeah.

8:52

I would love to see that.

8:53

All right, Paul, what's your number two?

8:55

My number two is accessibility matters.

8:58

When I first started contributing to open source about 20 years ago, one of the first

9:01

projects I contributed to was the GNOME project, the Linux desktop environment.

9:06

One of the core pieces of GNOME's culture is accessibility, which includes everything

9:10

from the Orca screen reader to how we wrote documentation back then.

9:14

You know, the worst disability that I have personally is being extremely colorblind,

9:18

but that focus on accessibility has always stuck with me, which is why I'm excited to

9:22

see a project like this.

9:24

The first is the AccessBit from Dr. John Vidler in the UK.

9:29

The Micro:bit Educational Foundation commissioned a report on accessibility, which included

9:33

a speculative section on how to improve the Micro:bit platform for those with limited or

9:37

different mobility.

9:38

If you're not familiar with the Micro:bit, it's a microcontroller primarily made for

9:42

education, popular in the UK and Australia, that features two buttons, a 5x5 LED grid,

9:48

and connections for alligator clips.

9:50

It can run MicroPython, CircuitPython, and MakeCode.

9:53

The report included a few sketches and possible solutions for potential 3.5 millimeter audio

9:58

jacks, which are the industry de facto standard for accessibility, like what are found on

10:03

Microsoft's Xbox Adaptive Controller.

10:06

Dr. Vidler decided to design a PCB as a minimum viable product to add five adaptive switches.

10:12

He walks through various iterations of his design, landing on a final design that includes

10:16

an edge connector to connect to the Micro:bit and room for five 3.5 millimeter jacks.

10:22

It's pretty cool the thought that he put into the design, from how the add-on board connects

10:26

using the 40 pin Micro:bit controller to the curved design of the board.

10:30

He had JLCPCB make a handful of boards and sent them off, and they were shown at the

10:33

Blockly Summit in Cambridge earlier in June.

10:36

Check out the show notes to the link to his blog post detailing the process, including

10:40

photos.

10:41

The second product is a new Adafruit product, the TRRS Trinkey.

10:45

Adafruit's Trinkey line includes a USB-A port to plug it into a host computer, and a small

10:50

board maybe the size of a flash drive, so it's pretty small.

10:53

The TRRS Trinkey has a SAMD21 chip, has one 3.5 millimeter jack, and can run CircuitPython

11:00

or Arduino.

11:01

I think it's great that those who might need it have more options for accessibility, especially

11:07

using microcontrollers, which they can program to their needs.

11:10

I'm excited to see what people can think up using tech like this, especially if it makes

11:14

their lives easier.

11:15

These are a great sort of combo, because the Adafruit TRRS Trinkey is purely just a USB device.

11:22

It looks like a little USB thumb drive almost, it just has a 3.5 millimeter jack on the back.

11:27

But the Micro:bit, it has Bluetooth.

11:30

It has USB as well, but it has Bluetooth.

11:32

And so you can now make a Bluetooth accessible controller with this little add-on board by

11:38

just snicking the Micro:bit into it, and then plugging in some of these accessibility controllers

11:43

into that, and then pairing it with your phone with a little bit of code, with make code

11:47

or something.

11:48

That's incredible.

11:49

I think there'll be a lot of fun things being created with this.

11:52

I agree.

11:53

What's your next one?

11:54

So my next one is about CAD query.

11:57

So I've been on a journey to move to open source tools for my engineering work.

12:01

I've mentioned before I've gone from using Eagle to KiCAD.

12:08

I use Fusion 360 for my 3D CAD modeling, and it's pretty good, but I'm always irritated

12:13

after using it for a lot of different reasons.

12:18

What are the open source alternatives?

12:19

If you're going for a gooey 3D experience, there's things like Blender, but I like parametric

12:24

modeling.

12:25

One of the nice things that Fusion 360 does is you can make everything parametric, where

12:29

you just define a set of constraints, and then you create solid bodies from those constraints.

12:36

Blender's not really that.

12:37

Blender's more of like an artist's tool.

12:40

It can do a little bit of it.

12:42

So for the longest time, there's been this thing called OpenSCAD, which is a textual

12:46

3D parametric modeler.

12:49

And it's a gooey app where you've got two panes.

12:52

One pane is the text of the OpenSCAD language you write to create cubes and pyramids and

12:58

cones and ways to combine them in different ways to make your 3D object.

13:04

And then on the right is a render of what that thing looks like.

13:07

And so from that, you can, and people have done this to great effect, make enclosures

13:13

and other 3D things that can be 3D printed.

13:16

Like I think all of the Prusa components in the Prusa 3D printers are all actual SCAD

13:22

models that somebody has designed as text files.

13:26

And so if you need to make the screw holes a little bigger because you're building it

13:30

by hand and you're 3D printing the pieces and you only have M5 screws instead of M3

13:35

screws, you can maybe just go into the OpenSCAD file and change one little parameter and change

13:39

all the screw hole sizes.

13:41

But I've always bristled at OpenSCAD because it's got its own special language.

13:45

And I've been looking at other things.

13:47

And I just discovered recently this thing that's been around for a long time called

13:51

CAD Query, which is like OpenSCAD, but it's all in Python.

13:55

It uses standard Python syntax, and it is mostly a library that you can then express

14:01

via various ways.

14:03

You can just run a main.py and have that output a file, but you can also run this thing called

14:10

CQ Editor, which is a GUI editor, kind of like the OpenSCAD editor where you have multiple

14:13

windows and you can edit text in one and see a render in the other window.

14:18

And I've been using that and it's kind of working.

14:22

I don't know, even though I've been using CircuitPython for so many years, I'm still

14:25

not a very good Python person.

14:26

So this is like kind of diving into more Python.

14:29

The reason why I discovered this is Luke Wren, who is one of the ASIC designers, sorry, at

14:34

Raspberry Pi.

14:35

He's one who has helped us do some of the clever PIO things that we've done with the

14:40

Raspberry Pi RP2040 chip, like the cool SynthIO and PWM and touch sensors and stuff is all

14:48

kind of because, oh, and most especially the HDMI output from a little $4 microcontroller

14:56

is because of some of his hints that he's given us.

14:59

But he has a GitHub repo of a bunch of CAD query files.

15:04

So if you want to see how CAD query things look, what the Python looks like, you can

15:09

just go to his repository and go, oh, look, there's a little vacuum adapter and here's

15:13

an air duct plate or whatever.

15:17

So there's a nice little library of things for you to kind of browse through and see

15:21

what CAD query feels like from a language point of view.

15:25

But one of the best things about CAD query is that unlike OpenSCAD and unlike the similar

15:31

OpenJS CAD, which is the same thing as OpenSCAD in some ways, but with JavaScript, CAD query

15:37

outputs step files, which are object files, not STLs, which are like tessellated, triangulated

15:45

shapes.

15:46

And I was really frustrated that like OpenSCAD doesn't have a step export feature because

15:50

if you have a step file, you can now import that into another CAD program like Fusion

15:56

360 and then do additional edits on it.

15:59

Whereas it's really hard to do edits on meshes.

16:01

The STL format is made for just output, for 3D printing.

16:05

It's like the bitmap version of your vector file.

16:10

And so having a step is really important to me.

16:13

And so, yeah, so I'm going to be playing with CAD query over the next whatever months or

16:17

so and see if I do anything with it.

16:19

I share your excitement for that.

16:21

As I mentioned earlier, Python is the only language I know.

16:23

So looking through some of those examples, it's started to click for me.

16:27

I've tried to use OpenSCAD and never could figure it out.

16:30

I can't use FreeCAD because they don't have a colorblind mode and Fusion 360, I've never

16:35

really gotten the hang of.

16:36

I've had some luck with Onshape, but actually having the ability to actually program it

16:41

is and with the examples that they've got, looks really cool.

16:45

Thanks, Tod.

16:46

And now we have a special guest, Justin Myers.

16:49

Back in episode seven for the CircuitPython 9 release show we did, I mentioned Connection

16:53

Manager, but kind of guessed how it worked.

16:56

Well, I reached out to the author of the new library, Justin Myers, and asked him about

17:00

it.

17:01

Here's the interview.

17:02

Justin, welcome to the show.

17:03

Thanks, Paul.

17:04

I'm excited to be here.

17:05

To be honest, it's my first time I've been on a podcast, so I'm really excited about

17:09

it.

17:10

It's great that you're here.

17:11

What is the new CircuitPython library Connection Manager and what was your inspiration in creating

17:15

it?

17:16

Yeah, so basically late 2023, I had decided to spend some of my, let's call it extra time

17:23

working on CircuitPython and trying to see how I could help project.

17:27

I love the open source community.

17:30

And as I was kind of watching the threads, I just saw kind of user after user on Discord

17:35

having different connection issues, running out of sockets, different things like that,

17:40

memories issues and everything.

17:42

And I was like, "Hmm, seems strange.

17:46

Should be a better way."

17:47

And so as I kind of started digging in, saw like each library kind of managed sockets

17:51

differently and really think about and look at the differences between like a microcontroller

17:56

and CPython running on a PC is like on CPython, you can open sockets all day long, nothing

18:03

really happens.

18:04

But then once you get to a microcontroller, it's different.

18:08

And kind of once I started digging into that, I was like, "Oh, well, you've got the native

18:12

Wi-Fi that does it one way.

18:14

You've got like the ESP32 SPI that does it one way.

18:18

You've got the WISNET 5K that does it a different way."

18:22

And just kind of all this boilerplate and different ways to get the SSL connection and

18:27

different things.

18:28

And I was like, "This is weird.

18:30

Like there should be an easier way to do this."

18:32

And so it's kind of what started me going down this road of trying to find out like,

18:35

"Is there a better way to do this?"

18:38

And what was the better way?

18:40

So basically kind of the flow went, I asked the comment on the CircuitPython dev channel

18:46

and Discord.

18:47

I said, "Hey, I've got this idea."

18:50

Basically the requests library had this built-in session manager that kind of managed a bunch

18:57

of the sockets.

18:58

But oftentimes what users would do is they would just re-init that thing and lose all

19:02

the sockets.

19:03

And so they were still technically open, just sitting there.

19:06

And so kind of that first pass was I basically kind of separated some of that out to a separate

19:10

class and kind of shared that with the devs.

19:15

And they were like, "Nope, let's create a new library.

19:18

Like that's not a good way to do it."

19:20

Kind of break up dependencies and everything like that.

19:23

And kind of from that, there's literally days spent kind of back and forth on like, "What

19:28

should we name this?"

19:30

And so ConnectionManager was kind of where that was born and basically just started separating

19:35

a bunch of the stuff out of what was in the request library and put it into this new one.

19:41

And then building handlers that would take in whatever radio object you passed in and

19:47

try to determine, "Oh, what's the right SSL method for this one?"

19:51

Reducing imports from five or six all the way down to just the one or two that were

19:56

needed.

19:57

And that's really the key, isn't it?

19:59

If you have a PicoW, it was doing it different than an ESP32 S3.

20:04

And now for the user, that setup instantiation is almost the same across the different microcontrollers.

20:09

Is that right?

20:10

Yeah.

20:11

And that was kind of the goal, right?

20:12

Because if you think through how CircuitPython started and once connection happened, so the

20:18

ESP32 Spy was one of the first ones, developers wrote that library and then they kind of mimicked

20:25

it a little bit for the Wiznet 5K.

20:30

And then when the new ones came out, like ESP32 S2 and S3 and things, and they started

20:38

having this onboard wifi, they changed how they did it again.

20:42

And with anything that's open source, they're running forward as fast as they can.

20:46

And sometimes it's hard to go backwards to go update everything.

20:50

There were depreciation flags and comments, not flags in the code.

20:54

And all of these places were like, "Oh, we should get rid of this at some point," but

20:58

it was still there like years or months later.

21:01

And so a lot of it was like trying to trim some of that down.

21:05

What was it like to partner with the core developers on Connection Manager?

21:08

I really enjoyed it.

21:10

It was really interesting.

21:11

It's been a really interesting progress for me.

21:13

So a lot of my development started in C, 20 plus years ago when I started doing dev.

21:18

And a lot of it was for smaller systems.

21:22

And it was at a time where you had to do memory management and really think of your code for

21:28

what's going to be the fastest and most efficient ways.

21:31

And last 20 years, I've switched over to things like Python and things where...

21:36

And JavaScript and everything, where a lot of that stuff's just handled for you and you

21:39

forget about it.

21:40

And so it's actually been really fun because they'll make comments on PRs and they're like,

21:46

"Oh yeah, that's a wasteful way to do something," because there's not a lot of space.

21:51

So it's really small and trying to think through it.

21:54

But they've been great.

21:56

There's been times where a handful of them, we've jumped on calls together to work through

21:59

some things and figure it out.

22:01

They've been great on the comments and asking questions and whatnot.

22:04

And so I think the CircuitPython devs, it's a great team to work with.

22:09

Well, that's great to hear.

22:11

What's next for you and Connection Manager?

22:13

Kind of where I've been going next, I've been opening a handful of PRs to make the radios

22:18

again more similar.

22:20

So for example, they all had different ways to find out what AP am I connected to?

22:26

What's my Mac address?

22:28

And different methods of returning everything.

22:30

So I've been continuously working to try to get the different radios as close to the same

22:36

as possible.

22:37

And so really for an idea of...

22:40

A typical user probably goes out and they buy a microcontroller that's got whatever

22:45

Wi-Fi has on it, and they go run with that project and go.

22:49

But oftentimes they see a lot of the questions are someone sees a learn guide and they're

22:54

like, "Well, I don't have that stuff that's in the learn guide.

22:56

I have this."

22:57

But then they really struggle to try to figure out how to get it all to work because these

23:01

different methods are different.

23:03

So it's really been working to get all those core methods the same.

23:07

So you can, for the most part, copy paste other than initializing the radio itself.

23:14

And the work I'm doing currently now is I'm actually building out some network test code

23:21

that we can run.

23:22

And so every time a new version of requests comes out or 9.1 for CircuitPython or 9.2

23:29

or 10 or whatnot, we can actually run the same test code across the same different microcontrollers

23:35

and actually figure out like, "Oh, is SSL still working?

23:39

Can I still connect to MQTT?

23:42

Can I run a server?

23:44

Can I do requests?"

23:45

And ideally with a goal of having a kind of similar to CSS is that this like, "Can I use?"

23:52

Like so you could go look and be like, "I have this microcontroller.

23:56

I'm using this radio and I want to do this.

24:00

Can I do that?"

24:01

Well, that's great.

24:03

It's been fun and exciting to watch you partner with the core devs as you've built this over

24:07

the last few months.

24:09

Thank you so much for being on the show.

24:11

Thank you very much.

24:12

I really appreciate it.

24:13

And that's our show.

24:14

A special thanks to Justin Myers.

24:15

If you enjoy listening to the show, tell a friend or write a review.

24:16

It really does help.

24:17

For detailed show notes and transcripts, visit thebootloader.net.

24:18

Until next time, stay positive.

24:18

[Music]