Sam Blenny
S06:E49

Sam Blenny

Episode description

Sam Blenny joins the show and shares his work with the Fruit Jam, including USB Host, a Color Checker, a Gamepad tester, and more.

Follow the show on Mastodon or Bluesky.

Show Notes

00:00 Intro

00:24 Sam’s start with computers and electronics

5:34 Discovering CircuitPython

7:06 Working with the Fruit Jam and the Gamepad tester

9:24 USB Host MIDI Tester

11:12 The Fruit Jam Color Checker

13:49 USB Host

16:42 Which board?

Download transcript (.srt)
0:03

Welcome to the CircuitPython Show. I'm your host, Paul Cutler. This episode, I welcome

0:07

Sam Blenny to the show. Sam is the author of more than 30 playground notes on Adafruit's

0:12

Learn Playground with topics including 3D printing, the Adafruit Fruit Jam, Zephyr, and

0:18

more. Sam, welcome to the show.

0:22

Hi, good to be here. Thanks for having me.

0:24

How did you first get started with computers and electronics?

0:28

As a little kid, starting in the 80s, then going on to the 90s as I got into middle school

0:35

and high school, I was from a musical family, so there were lots of choir and orchestra

0:40

concerts and musicals and plays and things going on around me.

0:43

And I spent some time entertaining myself, waiting for rehearsals or whatever.

0:49

And during all this, I noticed they were using lots of interesting equipment, lights and

0:54

sound and microphones and mixers and lots of stuff.

0:59

And so that caught my attention early on and I was always interested in that.

1:04

And then another thing that sort of got me going early on electronics was, you know,

1:10

this was back in the 80s and we actually shopped at shopping malls.

1:13

And so, you know, you'd go in through one store and you'd have to look at all their

1:17

stuff and then you'd have to go past all the other stores to get to the thing you were

1:20

actually trying to find like in the middle somewhere or whatever.

1:22

So we passed by the toy display at Radio Shack a lot as we were just going about our business.

1:28

And I always was sort of interested in that.

1:31

And that led to further interest in electronic project lab kits.

1:36

I'm pretty sure I got a couple of those for Christmas at different years in the Forrest

1:40

Mimps books and all that stuff.

1:42

So this was like early on setting the stage.

1:45

There were electronics around me and I found those interesting.

1:49

And for the computers, we got a hand-me-down Atari 400.

1:54

This was back in the 80s, and had it hooked up to a black and white TV, and that was the

2:00

ones with the keyboard.

2:02

So it was an 8-bit computer, not just a video game thing.

2:05

And it had ROM Basic and Facemaker and Frogger and probably, I don't know, some Asteroid

2:11

thing.

2:11

I don't know.

2:12

So that got my attention.

2:14

And there was also desktop publishing stuff around me for the music people, because, you

2:19

know, if you're doing a musical, you've got to have a program.

2:22

And so somebody has to make the program.

2:24

And if you've got this computer with the desktop publishing, that's a lot easier than doing

2:27

it by hand with, I don't know, copy and paste and typewriters and all that.

2:33

So people got pretty excited about the Macintosh desktop publishing stuff with the old laser

2:40

writer and whatnot.

2:42

Then we had a Mac 5 12K E at home, so there was some Dark Castle and Crystal Quest and

2:50

Mac Paint and MacWrite and those things.

2:54

So that was just setting the stage.

2:56

Then come the 90s, I got kind of serious about all of this.

3:01

People knew I was interested in things, so I'd get hand-me-down equipment and old computers.

3:06

I had a RadioShack TRS-80 Model 100 with ROMBASIC,

3:12

and that was a pretty pivotal thing.

3:14

I spent a lot of time there.

3:17

And so TRS-80 ROMBASIC spent a lot of hours on that.

3:20

And then at some point I got a Turbo C compiler,

3:25

and by that point it was maybe a Mac Plus

3:27

or maybe it was still on the 512k.

3:29

I think it was a Mac Plus.

3:31

And then I had some old PCs that ran MS-DOS,

3:37

And so that got me going on QBasic and I did a lot of programming for school stuff.

3:45

I had a hard time with algebra.

3:46

I got sick.

3:48

I don't know, it was maybe like seventh grade or something.

3:50

I got sick and missed one week when they went over something and it was just blowing my

3:54

mind.

3:54

I couldn't figure it out.

3:55

And then at some point, somebody got me this book and I got started like doing some graphs

3:59

and things in QBasic.

4:00

And it's like, "Oh, so that's what functions do."

4:04

It's like you put this number in and you do this math and you put that number and then

4:07

you make a pixel there and then you get these curves.

4:10

And somehow in school that just never made any sense to me.

4:13

But when I got going in QBasic, it was like, "Oh, that's what this is."

4:19

And so a lot of my experience with computers in middle school and high school is it's a

4:23

thing that has extended my ability to understand stuff.

4:30

And this was all like pre-internet.

4:32

Most of this was pre-internet at home before the like scourge of AOL CDs, like carpet bombing

4:39

everything and it's before all that.

4:42

So it's like reading printed manuals when that was a thing and looking, figuring out

4:47

how to do stuff for books and a little bit of bulletin board.

4:50

So that's what got me going on computers and electronics.

4:54

And then there's a third component of this, which was really significant to me, was my

5:00

high school didn't have FIRST Robotics, but a friend from across town did.

5:03

And one time I got to visit them and that was another sort of mind blowing, "Oh, this

5:08

thing exists.

5:09

Why didn't somebody tell me this earlier?"

5:11

kind of experience.

5:12

And I got to help them debug some of their code.

5:15

I think they were having troubles with the dead zone on their joystick or something,

5:18

because it was an actual analog joystick.

5:20

And that was kind of more important with that.

5:24

So I learned about these basic stamp microcontrollers and that was a life-altering experience.

5:31

And that was all a long time ago.

5:32

Much has happened since then.

5:34

How did you discover CircuitPython?

5:37

So if you do anything with I2C sensors for whatever purpose and you're reading about

5:44

them, it's pretty hard not to come across Adafruit stuff.

5:47

Adafruit drivers are going to come up if you start searching for things.

5:52

And so I'd been aware of that for, I don't know,

5:56

I don't even remember when.

5:58

And then I think maybe about eight years ago

6:04

or sometime around then,

6:06

I was trying to do some data logging stuff

6:11

for indoor plant things.

6:14

I wanted to know what the temperature was

6:16

and make some graphs.

6:18

I used, I can't even remember which board,

6:22

but it was one of the boards that is capable

6:24

of running CircuitPython.

6:26

And I used some sensors,

6:28

I don't know if it was Adafruit sensors

6:30

or SparkFun sensors, but at that time,

6:32

I was researching a lot of what was on the market.

6:35

And so I probably, I can't remember,

6:38

this is when CircuitPython wasn't all that far along

6:40

and it was a lot more Arduino things.

6:43

Ever since then, I had been paying increasingly

6:45

more attention to what Adafruit was up to.

6:48

And then last year I got going on the circuit Python stuff a lot more seriously.

6:57

You've written over 30 Playground Notes on Adafruit's Playground sites.

7:00

A number of them are about Adafruit's new RP2350 powered

7:04

microcomputer, the FruitJam.

7:06

Tell me about the GamePad tester and how you started working with the FruitJam.

7:10

Okay.

7:11

Yeah.

7:11

So with the playground guides, I enjoy technical writing and I had been watching the Ask an Engineer show.

7:21

I follow Adafruit stuff on YouTube fairly regularly and PT, aka Mr. Lady Ada on that show, he mentioned that they were doing all this playground guide stuff, that they built this system and they were hoping to get writers interested in putting content there.

7:39

and I thought about that and I was like,

7:40

yeah, that sounds like a good idea.

7:42

I'm gonna do that.

7:43

And so I did that and I started off just doing some projects

7:48

with the boards I had on hand

7:49

and I have a limited parts budget.

7:52

I don't let myself just spend wildly on this.

7:55

So I started off with what was laying around

7:58

and eventually that worked out to doing a game pad tester

8:03

on an ESP32 S3 with the TFT display,

8:07

the little feather boards.

8:08

And I think they may have mentioned that on their Asking an Engineer show.

8:12

And then later I did this pumpkins and skeletons game on that same board and

8:17

they thought that was interesting.

8:18

And so I had, I had this conversation going by email with BT and then at some

8:23

point it was like, Hey, this fruit jam board, you want a prototype?

8:28

You want to do some projects with it?

8:29

And I was like, yes, please.

8:31

That sounds awesome.

8:33

And so they sent me one of those and they had mentioned that it would be

8:37

interesting to have a USB gamepad tester for Fruit Jam. And I was like, yeah, that'd be good.

8:42

So I did that. And because it has the USB host and the DVI display, it's possible to do a lot

8:51

more than with the little tiny squinty little display on the feather. That's so hard to see.

8:56

Like you can get it with a camera to put it in a guide, but you got to get your lighting careful.

9:02

Like you got to do the side lighting carefully so that the display doesn't wash out the exposure on

9:07

rest of the board and it's all so tiny and if somebody tries to do it, they're like,

9:11

"Wow, the screen is really small."

9:14

But if you use the DVI output on the Fruit Jam, you can just put it on a monitor and

9:17

plug in a gamepad or a keyboard and it's just fabulous.

9:21

That's how I got started on that.

9:24

What about the USB host MIDI tester?

9:28

So the Fruit Jam thing, you know, if you look through my Playground Guide author page, there's

9:34

like fruit jam this, fruit jam that, fruit jam the other thing. And it's kind of, I do one project

9:38

and I go, "Oh, there's this other thing I'm curious about, but that's too much to put in this

9:43

one because I got to write this up and I want to have it finished in a reasonable time. So put it

9:47

on the list of things to do next." And you know, one of the obvious things, once I had gotten the

9:51

game pad stuff sort of figured out, I was like, "Oh, what about MIDI?" And you know, like as I

9:57

said, I come from a musical family, so I'd been aware of MIDI since, you know, a long time ago.

10:03

And, you know, it's always been kind of interesting.

10:08

And it's also a pretty good stress test for the USB stack because you have to pull because

10:14

of the way things are set up with this to get MIDI input.

10:17

You got to pull and you got to pull fast and you also have to do the display updates and

10:21

there's all this stuff going on.

10:22

It's like, yeah, this would be a good stress test.

10:25

And so I did that.

10:27

And yeah, it worked out pretty nice.

10:30

One of the things that I enjoyed doing with that is since I had so many pixels to spend,

10:35

I made a grid of USB channels and notes.

10:41

So you can see as you blink on it, which channel stuff is coming in on and which note number

10:49

it's coming in on.

10:52

And sometimes, like if you're doing a percussion thing or a keyboard, you won't necessarily

10:58

have the note range mapped where it needs to be for the software instrument that you're using.

11:03

And so you like you you'll bang on stuff but you're on the wrong octave so nothing happens or

11:07

you know it can be confusing. So it's nice to have stuff like this where you go "oh that's what's

11:11

going on". What about the Fritjam color checker? So one of the things that came up when I was

11:18

working on that pumpkins and skeletons game or maybe maybe it was the original USB tester that

11:23

that I did for the Feather ESP32 S3 TFT thing.

11:28

I had made my sprites for display IO tile grid using,

11:34

oh, I can't remember the name of the app,

11:35

but one of the iPad apps for working on pixel art,

11:38

or maybe I used something on Linux.

11:42

I can't remember, but it was on a color managed display

11:47

using 24 bit colors,

11:49

and I just picked out some stuff that looked good.

11:52

And then when I got it onto the display and I looked at it,

11:54

I was like, whoa, that is not color matched

11:57

to what I was doing, what happened?

11:59

That had puzzled me and I couldn't really figure out

12:02

what was going on.

12:03

And at that point, I didn't understand

12:05

that when you're doing the eight bit color

12:08

or the 16 bit color, which can happen with display IO,

12:11

depending upon the hardware and how you initialize things,

12:15

that you're actually getting RGB 332.

12:18

So three red bits, three green bits, two blue bits, I guess.

12:25

And then there's all this quantization and filling

12:29

of the low bits when it gets moved

12:31

to actually display on hardware that uses more colors.

12:36

And then there's the 16-bit version of that,

12:38

where you have RGB 565, 5-bit, 6-bits, 5-bits.

12:44

And what you really want, if you're

12:46

doing a color match thing is RGB 888,

12:51

but that's not how these displays work.

12:53

And I didn't understand that until I did

12:56

that Fruit Jam color checker thing

12:58

and really worked through it

12:59

and tried out the different video modes

13:02

and saw what it did.

13:05

That process for me was about how do I get sprites

13:09

that have the colors that I want

13:11

when I'm trying to make a little thing that uses sprites?

13:14

And so people who are trying to make games for Fruit Jam,

13:21

if they understand that the RP 2350 is doing these things

13:28

when it does the DVI output,

13:30

then they can make sprites with colors

13:32

that they'll end up being happier with hopefully.

13:35

And like one of the things that can happen

13:37

is they can be dimmer

13:39

because the hardware does a zero fill

13:41

when it does bit extension to go from,

13:43

say five bits up to eight bits,

13:45

you get zeros on the low bits,

13:47

which means things can be darker.

13:49

- For CircuitPython's upcoming 10.0 release,

13:51

you've done some work to improve USB host.

13:54

What kind of improvements have you been working on?

13:57

- So as I was doing all this stuff

13:59

and playing with all these gamepad things

14:01

and all I noticed in the MIDI stuff,

14:03

sometimes there would be a dropped note or a stuck note,

14:07

or as people are building things

14:09

with the USB host on Fruit Jam,

14:11

you definitely need to catch exceptions.

14:14

There will be exceptions.

14:16

There'll be timeouts because not all USB devices

14:19

will answer you every time you ask them for something.

14:22

You have to pull them

14:23

and they won't always have something ready

14:24

and then you'll get the timeout maybe, or maybe not.

14:26

Maybe you'll get something with like zero bytes.

14:29

So you got to check, otherwise your code won't work.

14:32

And then if somebody unplugs a device

14:34

or if certain other things happen,

14:36

you may get a USB error exception.

14:39

And if you don't check for that,

14:40

you won't have any way to know when the,

14:43

when somebody unplugged something.

14:44

So hot plugging won't work.

14:46

So as I was in particular trying to get hot plugging

14:49

to work reliably,

14:50

I noticed that there was some stuff

14:52

that I couldn't do anything about at the Python level.

14:55

And I wanted to get to the bottom of it

14:57

so that people could just, you know,

14:59

plug stuff in and have it work and, you know,

15:02

not have to worry about all that nonsense.

15:05

And so I got on a little quest to try and figure out

15:07

what was actually going on.

15:08

I made some issues on GitHub and I did a PR and Scott did a PR and we managed to track down and

15:16

fix. One of the things was that there was a bit of an impedance mismatch between the TinyUSB

15:22

library underneath and in CircuitPython that was using TinyUSB. They didn't quite agree on

15:29

some of the error handling. Like there were things that could come up from TinyUSB

15:34

that CircuitPython would treat as if it was something else instead of, you know, the right

15:40

error condition. I'm a little fuzzy on the details. The way I handle all this stuff is like,

15:44

you know, I write it down and then I move on with my life. But the basic idea was there were some

15:48

error codes that weren't being checked for at the interface between TinyUSB and CircuitPython. And

16:04

that was over my head and Scott sorted that out, which is related to some other things that had

16:09

been having DMA trouble. I think it's if the DMA is coming, if it's to or from the SRAM that's on

16:18

the RP-2350 itself, everything's cool. But if you're trying to use the PSRAM chip that's external,

16:25

then things can get weird. And so if you don't prevent the PSRAM from getting included in a DMA

16:32

transfer, you can have strange things happen. And we were having strange things happen and

16:36

Scott figured out how to fix that.

16:38

Well, that's pretty cool. I'll make

16:39

sure I link to some of those PRs in the show notes as well. Last question I ask each guest,

16:45

you're going to start a new project or prototype, which board do you reach for?

16:49

Scott Trent (00:36:40): It depends. There are a lot of

16:53

reasons why you might want to do one thing over another. Maybe you're broke or you've got a big

16:58

parts pile that your wife or someone is wanting you to clean up or you know what

17:03

there are reasons why it makes sense just use the thing you have if you're

17:07

just messing around and you got some stuff use what you have there are times

17:11

when you need to hit specific functional requirements like say you want to do

17:17

something to monitor plants and it's going to be potentially exposed to

17:23

moisture like if you put things outside where it's not temperature controlled it

17:27

It may be not out in the rain and the snow,

17:30

but there's gonna be condensation

17:32

because there's gonna be so much temperature change

17:34

and you're gonna have to account for,

17:37

okay, I need to put a dust cap back in there.

17:39

And when you're in that kind of a situation,

17:41

you need to think about your requirements.

17:43

Like if this is gonna run a battery,

17:45

how long do I need to go before I can charge

17:47

or swap the batteries?

17:49

What does that mean about which boards I should use?

17:51

Like the ESP32 variants do quite well on low power.

17:58

but they're not all the same. And then say, "Okay, I want to do solar." Then you're

18:04

going to have to think about, "Well, I need a battery and I need a charger, but which

18:08

board that can run on a battery is compatible with a charger?" And that will narrow you

18:12

down to a couple things. Like, Ladeata has introduced recently some feather boards that

18:17

have a jumper on the back that you can cut. It'll be like CHG or charger or something.

18:23

and you cut that and it pulls the normal feather charger out of the circuit.

18:27

So then you can use one of the solar charger boards and it won't burn anything

18:32

up. So that's just kind of a,

18:35

an engineering thing and that's how I think it's like sometimes it doesn't

18:40

matter. Then you can understand your requirements are do whatever you want.

18:44

And then sometimes other things do matter. You've got a budget, you've got,

18:49

you know, maybe you've got a deadline, you know,

18:51

Maybe it makes sense to spend more and get something done fast, or maybe you need to

18:56

make a lot of them.

18:56

So you really need to think about how much it costs, or maybe you have some weather thing

19:00

that you're like, you need to make sure it won't get wet and die on your second day out

19:06

or whatever.

19:07

So it depends.

19:10

Sam, thanks so much for coming on the show.

19:12

Thanks for having me.

19:14

Thank you for listening to the CircuitPython Show.

19:17

For show notes and transcripts, visit www.circuitpythonshow.com.

19:21

And if you're enjoying the show, please leave a review.

19:24

It really does help.

19:25

Until next time, stay positive.