Developing for the Fruit Jam
S07:E58

Developing for the Fruit Jam

Episode description

Paul is joined by three former guests: Tim Cocks, Dan Cogliano, and Cooper Dalrymple who share their experience developing apps, games, and screensavers for the Adafruit Fruit Jam and Fruit Jam OS.

Show Notes

00:00 Welcome

00:38 FruitJamOS

3:44 Cooper’s excitement for the Fruit Jam

7:24 Dan’s interest in the Fruit Jam

8:52 Dan’s screensavers for the Fruit Jam

10:48 Coding for othe Fruit Jam

12:20 The Fruit Jam app library

18:02 GPIO and expansion

19:44 Display support

24:07 Challenges to look out for when developing for the Fruit Jam

31:01 What advice for someone creating a game or app for the Fruit Jam?

36:48 Wrap-up

Download transcript (.srt)
0:02

Speaker 1: Welcome to the CircuitPython Show.

0:04

Speaker 1: I'm your host, Paul Cutler.

0:05

Speaker 1: This episode, I'm joined by three former guests on the show,

0:08

Speaker 1: Dan Cogliano, Tim Cox, and Cooper Dalrymple.

0:12

Speaker 1: They've joined me to chat about the Adafruit Fruit Jam,

0:14

Speaker 1: which was first released last July

0:16

Speaker 1: and shipped to Adabox subscribers this past November.

0:19

Speaker 1: The Fruit Jam runs CircuitPython

0:20

Speaker 1: and is a credit card-sized microcomputer

0:23

Speaker 1: with display support, USB host for mice keyboards and game pads,

0:27

Speaker 1: and SD card, expansion GPIO, and more.

0:31

Speaker 1: Tim, Dan, and Cooper, welcome to the show.

0:34

Speaker 1: Hey, Paul.

0:35

Speaker 1: Hey, Paul.

0:35

Speaker 1: Thanks for having us.

0:37

Speaker 1: Thanks.

0:38

Speaker 1: Tim, we'll start with you.

0:39

Speaker 1: The Fruit Jam hardware can run Fruit JamOS, which is a new way to load a circuit

0:43

Speaker 1: Python application.

0:44

Speaker 1: What was the inspiration for Fruit JamOS and how does it work?

0:48

Speaker 1: Yeah, good question.

0:49

Speaker 2: So for Adafruit generally, one of our big goals going into Fruit JamOS was to make something

0:55

Speaker 2: that sort of harkens back to like the Commodore 64 era of devices.

1:00

Speaker 2: sort of all-in-one devices that you write the programs on there, you run the programs on there.

1:05

Speaker 2: Back in those days, they had the keyboard built in.

1:06

Speaker 2: They had the little display built in.

1:08

Speaker 2: So everything was ready to go for you.

1:10

Speaker 2: Just kind of plug it in, start programming and do your thing.

1:13

Speaker 2: So that was a big inspiration going into Fruit Jam OSbroadly for all the Adafruit folks.

1:19

Speaker 2: And then for me specifically, I would say also there was emphasis on Q Basic.

1:24

Speaker 2: QBASIC was one of the first programming languages that I ever interacted with.

1:28

Speaker 2: So it's always held a sort of nostalgic place in my heart.

1:32

Speaker 2: And as I was working on Fruit JamOS, I kind of got, you know,

1:35

Speaker 2: it took me back to that era of Q Basic IDE where it was similar.

1:40

Speaker 2: It had the editor built in.

1:41

Speaker 2: You could pop over and run your code real fast right there.

1:44

Speaker 2: And it was just this all in one sort of package, write your code, run your code,

1:48

Speaker 2: see what it does right there and iterate through very quickly.

1:52

Speaker 2: So that was another big one for me was QBASIC.

1:55

Speaker 1: What's involved that add support to a normal CircuitPython program to run on Fruit Jam OS?

2:01

Speaker 2: Yeah.

2:01

Speaker 2: So it's pretty straightforward, especially if your program is already set up for the Fruit Jam,

2:06

Speaker 2: if you're already making use of the Fruit Jam peripherals and stuff like that.

2:09

Speaker 2: If you have something completely unrelated, like it's a Pi portal program or something,

2:13

Speaker 2: there's a little bit more converting that needs to take place.

2:16

Speaker 2: But if you've got an app that you have already used on a Fruit Jam today by just saving it in code.

2:22

Speaker 2: It's very straightforward.

2:23

Speaker 2: You can just create an icon for it, or even,

2:25

Speaker 2: even just leave it the default one if you want.

2:27

Speaker 2: Create a little metadata file that has the name of your app.

2:30

Speaker 2: It has the file path to the icon.

2:32

Speaker 2: You store that alongside your code and you copy your code with a folder into the

2:37

Speaker 2: app's directory on CircuitPy.

2:39

Speaker 2: And that's all you need to do.

2:40

Speaker 2: The next time you launch the Fruit Jam OS launcher, it scans that folder.

2:43

Speaker 2: So it will automatically find your app along with all the other ones.

2:47

Speaker 2: We'll show your icon right on the launcher there.

2:49

Speaker 2: User can launch it.

2:50

Speaker 2: And as soon as they launch it, it just executes right into your code.

2:52

Speaker 1: code.pye file. I know Cooper you I had Sean Carolan on the show recently who did the

2:57

Speaker 1: Pac-Man clone in CircuitPython and you reached out to him and gave him a hand to and submitted a PR

3:02

Speaker 1: I believe to get it on the fruit jam. Yeah and actually I want to add to that I did create a repository

3:09

Speaker 3: and if viewers aren't familiar with how GitHub works basically repository is like a project right

3:14

Speaker 3: I did create a project that's just fruit jam application I was trying to make it as basic as possible

3:19

Speaker 3: just to be a place to store all those best practices of how to work with this hardware.

3:25

Speaker 3: Of course, many users have contributed applications in their own way that may do things a little bit differently.

3:30

Speaker 3: But it's always good to have a good foundation of where to start.

3:34

Speaker 3: And that does stuff like initializing the display properly, handling different resolutions,

3:39

Speaker 3: taking it in keyboard and mouse input and stuff, which I know we'll get into later.

3:44

Speaker 1: Cooper, you were one of the first in the community to release a game for the Fruit Jam, Frutris, a Tetris clone.

3:50

Speaker 1: You've also done some work behind the scenes working on USB host for game pads, fruit jam OS, and more like you just mentioned.

3:57

Speaker 1: What grabbed you and excited you about the fruit jam?

4:00

Speaker 1: So I remember when the fruit jam first came out.

4:02

Speaker 3: This was last year, was it August or something?

4:06

Speaker 3: It was July.

4:06

Speaker 3: Is that, okay.

4:07

Speaker 3: Yeah, yeah.

4:08

Speaker 3: And I really wanted to be a part of that like first initial push on it, that wave.

4:14

Speaker 3: And I was playing around with Fruit JamOS because at that time, Tim, you had already had it working.

4:19

Speaker 3: and a few applications bundled in from the Learnn guides.

4:22

Speaker 3: And I have to admit, I wasn't in on the Metro 2350B days, the really early development.

4:29

Speaker 3: But a lot of that I know came from that era, I would say.

4:33

Speaker 3: And I knew I was like, I have to do something here, you know, something that I can turn around, turn and burn very quickly,

4:39

Speaker 3: just because I was excited to be a part of everything.

4:41

Speaker 3: And we were lacking Tetris.

4:43

Speaker 3: You know, we had a lot of other things.

4:44

Speaker 3: I think mine sweeper, breakout, so on.

4:46

Speaker 3: And Testris is a different beast.

4:49

Speaker 3: because there is some math involved

4:51

Speaker 3: and a little bit more management

4:53

Speaker 3: in order to make it a really good

4:55

Speaker 3: Tetris experience, right?

4:57

Speaker 3: And so I did my best.

4:58

Speaker 3: And actually, the work on that,

5:00

Speaker 3: I had actually kind of stolen for myself.

5:02

Speaker 3: I don't know if anyone here is familiar

5:04

Speaker 3: with Look Mum, no computer.

5:06

Speaker 3: It's kind of a techie, YouTuber, crazy guy.

5:10

Speaker 3: He did a thing forever ago

5:12

Speaker 3: called the Mega Machine,

5:14

Speaker 3: which was, gosh, it was like a 10 by 10 array

5:18

Speaker 3: of Game Boys in which you could control the screen of each one of them.

5:24

Speaker 3: And he was looking for input back then for like applications, stuff.

5:29

Speaker 3: He could run on these like 100 Game Boys, right?

5:33

Speaker 3: And I just thought it was very meta to make Tetris that played on like 100 Game Boys, right?

5:38

Speaker 3: Anyway, even though that was kind of a silly thing, a lot of the code came from that for the actual

5:43

Speaker 3: rotation, the different Tetraminos, things like that.

5:47

Speaker 3: So that was very important to contribute in that way.

5:50

Speaker 3: And I was able to get that out in, like, I think, less than a week or something, just, you know, off the ground.

5:55

Speaker 3: I was really happy with how, you know, people, you know, started playing around with that.

5:58

Speaker 3: It was pretty fun.

5:59

Speaker 3: And as for those other developments, I mean, there's been a lot of foundation developed by Adafruit, U-Tem, especially.

6:06

Speaker 3: For, like, I mean, USB host is really where everything goes down to because CircuitPython has a lot of features on it out of the box, but it's not an operating system.

6:17

Speaker 3: really and operating systems typically handle a lot of USB handle I mean obviously keyboard I believe is handled by the supervisor right yep but things that are a little more complex like game pads especially because you know every game pad operates a little bit differently I mean you have X input D input you have it's escaping me now but um it's not X input input there's a there's a mode for K joystick's

6:47

Speaker 3: that operate like that that you have to support.

6:49

Speaker 3: And then some game pads, including the Adafruit, SNES gamepad,

6:53

Speaker 3: operate like in their own weird mode.

6:55

Speaker 3: That's just kind of difficult to support.

6:57

Speaker 3: So obviously, for every application to include its own driver

7:01

Speaker 3: for each one of these devices, it's just not feasible.

7:04

Speaker 3: So that's one thing that I was able to contribute

7:07

Speaker 3: is creating a library to at least combine that a lot together

7:11

Speaker 3: so people just don't have to worry about it.

7:13

Speaker 3: And I think that's when CircuitPython shines,

7:16

Speaker 3: and you just don't have to worry about it, right?

7:18

Speaker 3: You just make your own fun code,

7:19

Speaker 3: and you don't have to think so much about, you know,

7:21

Speaker 3: specific device input and stuff.

7:24

Speaker 1: Dan, what about you?

7:25

Speaker 1: What excited you about the Fruit Jam?

7:28

Speaker 4: Well, first of all, thanks for having me.

7:31

Speaker 4: I'm more on the application end of it

7:33

Speaker 4: as opposed to the operating system,

7:35

Speaker 4: and so I do a lot of application and user applications.

7:39

Speaker 4: And I was really excited about it.

7:41

Speaker 4: I mean, I grew up, you know,

7:43

Speaker 4: with arcade games, retroarchic.

7:45

Speaker 4: arcade games and I guess I could consider myself retro because I'm at that age.

7:51

Speaker 4: But that really excited me with the or the different emulators that come out with it.

7:59

Speaker 4: I think it's great.

8:00

Speaker 4: So I decided to write some games in CircuitPython for it.

8:04

Speaker 4: The first one was the Zork Z-Machine, which was something I wrote five or six years ago in Arduino.

8:14

Speaker 4: And I decided, well, I'm going to convert that to CircuitPython, see if I can get reasonable performance out of it.

8:21

Speaker 4: And I did.

8:21

Speaker 4: So I went from there, and then I wrote a moon miner game, which is kind of like the Lunar Lander, if you remember that from the arcades back in the 80s.

8:32

Speaker 4: So it's similar to that.

8:34

Speaker 4: And then I wrote a couple screensavers.

8:36

Speaker 4: So doing a bunch of fun projects, at least for me, I really enjoyed writing them.

8:42

Speaker 4: We've got four screens savers so far, and I'm looking at maybe adding more as I find ideas for them.

8:50

Speaker 4: And so, yeah, it's been a lot of fun.

8:52

Speaker 1: Tell me a little bit more about the four screensavers you've written.

8:56

Speaker 1: Can you describe them a little bit?

8:57

Speaker 1: And, you know, what worked well about writing them for the fruit jam?

9:00

Speaker 1: And were there any challenges that you encountered?

9:03

Speaker 4: Well, you know, screensavers go back since the dawn of PCs.

9:08

Speaker 4: You know, there was actually a real purpose for them at one time.

9:12

Speaker 4: you didn't want to have the screen burn in.

9:13

Speaker 4: So now it's more of a fun thing to see on the screen.

9:17

Speaker 4: So I wrote four of them.

9:19

Speaker 4: I did Starfield screensaver,

9:23

Speaker 4: which is kind of like the Star Trek screen,

9:25

Speaker 4: you know, with the stars going on the screen.

9:28

Speaker 4: And I wrote a maze creator and a real-time solver.

9:35

Speaker 4: And that actually came from an Arduino project I wrote for Adafruit,

9:40

Speaker 4: probably six years ago, that was also Arduino.

9:43

Speaker 4: And that was on a e-paper device.

9:46

Speaker 4: So I thought, well, I want to do that one, rewrite that one for CircuitPython.

9:53

Speaker 4: And that one turned out really well.

9:55

Speaker 4: Then the recent ones I've done is a 15 puzzle screensaver.

10:01

Speaker 4: If you ever know the child's toy where you have numbers from 1 to 15 in a grid

10:06

Speaker 4: and you slide the tiles around, and I thought, well, this would be great for circuit.

10:10

Speaker 4: at Python because it has tile grid and it's really the same concept except you're just taking pieces

10:18

Speaker 4: of one image and moving around and I thought well that would be kind of a neat challenge so I did that

10:23

Speaker 4: and that turned out really well the latest one I did was just a weather clock it's very stagnant

10:29

Speaker 4: there's not much going on other than showing the updating the time and the current weather conditions

10:36

Speaker 4: and the temperature so that seemed to be a good screensaver because

10:41

Speaker 4: when you're not doing anything

10:44

Speaker 4: the time comes up and the weather comes out.

10:46

Speaker 4: I thought, that'd be pretty good too.

10:48

Speaker 1: Cooper, you mentioned earlier

10:50

Speaker 1: that you've done some work about keyboard input and game pads.

10:54

Speaker 1: For someone who's used to writing a normal code.

10:56

Speaker 1: code.py in CircuitPython and maybe has hooked up a few sensors over

10:59

Speaker 1: STEMAQT, how hard is it to code for the Fruit Jam

11:02

Speaker 1: to set up things like the display or to use keyboards or game pads?

11:07

Speaker 3: Well, if you've ever used display I.O.

11:10

Speaker 3: at all for, you know, little OLED displays, black and white, all that kind of, it's the exact same

11:17

Speaker 3: API.

11:17

Speaker 3: So, loading up bitmaps, drawing shapes with vector, vector I.O, whatever.

11:25

Speaker 3: All that kind of stuff, it all uses the exact same principles using tile grid, et cetera.

11:30

Speaker 3: In fact, Tim, I know you helped, I believe you helped create a lot of those APIs, right?

11:35

Speaker 3: And tile grid in a way almost acts like a Game Boy or something like that in the way that.

11:40

Speaker 3: you pick different sprites from a sheet and stuff like that too.

11:45

Speaker 3: And then, of course, I know the Adafruit display text library is one that I use on basically every project.

11:53

Speaker 3: If you want to write out displays without, I believe you can use terminal I.O. directly.

11:57

Speaker 3: And I have done that once or twice.

11:59

Speaker 3: But for the most part, you want to use that to get started to write text out to your display,

12:05

Speaker 3: depending on what you're trying to do.

12:07

Speaker 3: like what those screensaver stand was talking about you probably do principles a little bit

12:11

Speaker 3: differently you know you're not working directly with input and stuff like that you kind of needs

12:15

Speaker 3: to run itself and so you might not use some of these resources which by the way I did want to

12:21

Speaker 3: mention which I love the displays a lot of times I have my fruit jam just running the background while

12:26

Speaker 3: I'm working and just running through all those screensavers sometimes random mode and stuff like

12:31

Speaker 3: that if you're interested in any of these projects which I know a lot of these resources

12:36

Speaker 3: sources come bundled in with Fruit Jam OS, but I do have another application that I know Tim

12:42

Speaker 3: and I have been talking about, the library, Fruit Jam library application, which gives you an

12:48

Speaker 3: opportunity, because the Fruit Jam, one of the cool things about it is that it has all the bells

12:52

Speaker 3: and whistles in it, right? You have Wi-Fi, you have audio, you have HDMI, you have USB host,

12:58

Speaker 3: etc. It's its own little computer, right? Neopixel even and GPIO expansion. So that Wi-Fi adds a whole

13:06

Speaker 3: new capacity. Well, now you can basically run things on the device itself and get information

13:11

Speaker 3: from the web, et cetera, as long as you're connected to Wi-Fi. And so I've been developing this

13:16

Speaker 3: library application to make it so that you can download kind of third-party applications,

13:21

Speaker 3: maybe outside of the Adafruit space, or maybe in the future, Adafruit would want to host

13:25

Speaker 3: some of their own applications through that that are maybe a little bit too big to host directly

13:30

Speaker 3: on Fruit Jam OS, you know, in that one download. And so you can download this one. And so you can download

13:36

Speaker 3: application, which will allow you to download all the applications, right? It's the idea, right?

13:40

Speaker 3: So I know Dan's, a lot of his projects, Z-machine, Moon Miner, right? And those screenshots,

13:47

Speaker 3: it actually supports screensavers as well, are all downloadable through there. And eventually,

13:53

Speaker 3: I know Tim, we plan on integrating that into the core OS. We're not there yet. Just it's more

13:59

Speaker 4: on my plate than anything. But, you know, those are future plans there. Yeah. I think it's great.

14:06

Speaker 4: It's a wonderful idea, and I hope you get that out there and incorporate it in a fruit jam.

14:12

Speaker 4: I think it's great.

14:14

Speaker 4: I think of it more as an app store than a library because you can go and pick and choose what you want to download.

14:21

Speaker 3: So it's great.

14:22

Speaker 3: It basically is, I don't think we'd want to use the term store per se.

14:27

Speaker 3: There's no cash transactions.

14:30

Speaker 3: Yeah.

14:31

Speaker 2: I'm super excited about the library as well.

14:33

Speaker 2: I'm glad you brought it up, Cooper.

14:35

Speaker 2: And yeah, for folks listening, the goal is we're going to move that into Fruit JamOS.

14:39

Speaker 2: So then that will be the library itself will be bundled in and you'll be able to launch it right out of the gate and then download further stuff from there.

14:46

Speaker 2: And yeah, I did, I think I suggested to change name.

14:49

Speaker 2: And maybe even was App Store originally.

14:53

Speaker 2: And I wanted to change it to library for both the reason Cooper mentioned.

14:57

Speaker 2: We don't intend to sell anything through there, but also just we don't want to run a foul of Apple necessarily.

15:02

Speaker 2: Right.

15:02

Speaker 2: They already have App Store lockdown.

15:03

Speaker 2: But to your point, Dan, it definitely is like exact same concept of App Store, Google Play Store, exact same idea where you can distribute apps through there.

15:13

Speaker 3: I think you're right.

15:14

Speaker 3: I think we did change it at one point.

15:16

Speaker 3: But I like library.

15:17

Speaker 3: It's like you're checking out a book.

15:19

Speaker 2: Yeah, I liked library as well.

15:21

Speaker 2: Yeah.

15:21

Speaker 3: And on top of that, some of the applications, like there's another game that I helped develop with my partner who did all the writing and everything called Speed Dating, right?

15:30

Speaker 3: Which is like a dating sim kind of featuring.

15:33

Speaker 3: featuring Blinka, well, kind of featuring Blinka and a bunch of other snakes and stuff.

15:37

Speaker 3: And that, there's just, there's just too much graphically and audio-wise.

15:41

Speaker 3: Some, the audio files are kind of big.

15:43

Speaker 3: I don't think it wouldn't necessarily max out the flash memory on the device or anything,

15:48

Speaker 3: but it would be significant enough that would be over half of the Fruit JamOS.

15:52

Speaker 3: So it's just not a good idea to bundle in with the core download.

15:57

Speaker 3: And plus the library, there's still more work to be done, but you can download.

16:03

Speaker 3: to either the flash storage directly on the device

16:06

Speaker 3: or to an SD card, right?

16:08

Speaker 3: So then you kind of remove the limits

16:11

Speaker 3: of what, you know,

16:11

Speaker 3: the flash storage limits of the device.

16:15

Speaker 3: And one of these days,

16:16

Speaker 3: I could see somebody starting to dive

16:18

Speaker 3: into more intensive graphically applications

16:21

Speaker 3: and things like that

16:22

Speaker 3: that may exceed the base storage

16:25

Speaker 3: of even the fruit jam,

16:26

Speaker 3: which I think, was it eight, 16 megabytes?

16:29

Speaker 3: I believe it's 16 megs flash, yeah,

16:31

Speaker 3: it's quite big.

16:33

Speaker 3: It's quite big, but you put in a 4-gigabyte SD card,

16:37

Speaker 3: then you have basically infinite storage in a way.

16:40

Speaker 2: To your point there, I think the SD card and the Wi-Fi as well,

16:42

Speaker 2: the Wi-Fi was mentioned earlier with the weather screensaver.

16:45

Speaker 2: I think those two things bring a lot to the table for the Fruit Jam,

16:48

Speaker 2: being able to get stuff off of the internet

16:50

Speaker 2: and being able to cache media files,

16:53

Speaker 2: either downloaded stuff from the internet to cache,

16:55

Speaker 2: or like you're saying, apps with pre-built assets or stuff like that,

17:00

Speaker 2: those could fit on the SD card and free up a lot of.

17:03

Speaker 2: of space and flash. So those are two of my top picks for peripherals on the fruit jam. And the Wi-Fi,

17:09

Speaker 2: worth mentioning, the Wi-Fi was a relatively late addition to the Fruit Jam. There were a couple of

17:15

Speaker 2: revisions that came out, not publicly, that they were never sold, but there were internal ones we

17:20

Speaker 2: were working on where there was no Wi-Fi. There was originally an I-SPI cable connector to be

17:26

Speaker 2: able to connect like TFT cables over SPI. And then Lady Ada was playing around with it and decided,

17:32

Speaker 2: Wi-Fi would be super cool to have this whole little mini-computer.

17:36

Speaker 2: And I definitely think that was the right call in hindsight.

17:39

Speaker 2: The Wi-Fi adds a lot to it for sure.

17:41

Speaker 3: I think so too.

17:42

Speaker 3: I mean, there is GPIO expansion, and I believe there's some I-2C ports and stuff.

17:46

Speaker 3: And heck, I think there's a STEMA QT port too.

17:50

Speaker 3: Yep, definitely.

17:51

Speaker 3: So if really having another display on top of the HTML output is necessary,

17:57

Speaker 3: I'm sure you could just throw on a little SSD 1306 or something.

18:02

Speaker 2: Yep, yeah, we've talked about like shields for the top as well.

18:05

Speaker 2: There's two rows, I don't know if it's 20 pins or however many pins,

18:08

Speaker 2: but there are two rows of GPIO pins.

18:11

Speaker 2: At some point, we may have a little shield or a hat or something that you could stick on the top

18:15

Speaker 2: to add TFT screen.

18:17

Speaker 2: And I'm hoping for a little sort of game style, like game gear with the screen in the middle

18:23

Speaker 2: and then Dpad and A.B button on the right.

18:26

Speaker 2: So maybe something like that.

18:29

Speaker 2: Do you think there's no battery?

18:32

Speaker 3: capabilities on the device, is there?

18:34

Speaker 2: That is correct. Yeah, as far as I know, there's no charging.

18:38

Speaker 2: So unlike the feathers, which have built-in charging and stuff, there's no JST connector

18:44

Speaker 2: for a battery and no built-in charging. So you have to use, like, USB battery or something

18:48

Speaker 2: to go mobile with it.

18:49

Speaker 3: Yeah, that's a great idea, though. I know one I had, is it would be really, granted, you know,

18:54

Speaker 3: you have the USB host support, which is awesome. But it would be really cool to have a little

18:58

Speaker 3: hat that sticks on top, and you can plug in SNES controllers.

19:01

Speaker 3: or NES or something like that.

19:03

Speaker 3: That would be really cool too.

19:05

Speaker 3: Maybe not a huge difference over the USB,

19:07

Speaker 3: but it would be nice regardless.

19:09

Speaker 3: Yeah, definitely.

19:10

Speaker 4: It reminds me at the old Atari cartridge location

19:15

Speaker 4: where you stick in a cartridge where the ports are.

19:19

Speaker 4: So it goes back to the retro styling.

19:22

Speaker 3: Definitely, definitely.

19:24

Speaker 3: Yeah, and you know, there's a lot of GPIO on there.

19:27

Speaker 3: I bet you could almost do kind of a basic cartridge loading.

19:32

Speaker 3: thing. We're definitely deep dive in here.

19:37

Speaker 3: Just a few address lines, maybe some data lines. I don't know.

19:41

Speaker 3: Get an e-prom on there. Who knows?

19:44

Speaker 1: Speaking of displays, one of the things that I've seen, and I think other people may have run into as well, is that display out of resolution error that comes up if you don't have the right monitor plugged into a fruit jam.

19:56

Speaker 1: As a dev, how do you code for different display sizes?

20:00

Speaker 1: on the Fruit Jam in CircuitPython itself.

20:04

Speaker 1: Yeah, good question.

20:05

Speaker 2: So it is, it's a little tricky

20:07

Speaker 2: because it can't be done,

20:10

Speaker 2: or I will say it's not set up to be super automatic.

20:14

Speaker 2: So lots of devices, lots of modern devices,

20:17

Speaker 2: when you plug them into a screen,

20:18

Speaker 2: they'll kind of query the screen to figure out what size it is

20:21

Speaker 2: and then select something that they both agree on.

20:23

Speaker 2: The Fruit Jam has a few things that make it tricky.

20:25

Speaker 2: One is that it's working at relatively small resolutions

20:29

Speaker 2: by today's standards at least, like 640 by 480 or 320 by 240 even, which ends up getting

20:36

Speaker 2: doubled anyways. So those are relatively small sizes. There are some screens out there today if you

20:41

Speaker 2: just go to the store, your average electronics store today and you buy sort of the cheapest

20:45

Speaker 2: monitor that supports HDMI. It may not support some of those smaller ones. It may be only 1920

20:51

Speaker 2: by 1080 or 1280p, just modern sizes. And so that's when it will pop up, I think, the error like

20:57

Speaker 2: you're talking about where you'll plug it in and it will say, you know, we can't recognize this

21:01

Speaker 2: format or something like that. You can actually connect to it through I-2C. So one of the things that

21:07

Speaker 2: HDMI does is it has, I think it's called Edid. Edid, E-D-I-D is the acronym. And I'm not 100% sure

21:14

Speaker 2: what all is inside of it, but there is a little data channel inside of there. And you can query

21:18

Speaker 2: the screen to ask it like what resolutions it supports. And so you could write code that would

21:24

Speaker 2: do some of that and try to select one. The deal is that the for

21:27

Speaker 2: Jam is, again, it's only doing those smaller screens.

21:31

Speaker 2: And so then even if you ask the screen what it supports, it may still not support something that

21:36

Speaker 2: works for that smaller size.

21:38

Speaker 2: So that's one of the tricky bits.

21:39

Speaker 2: And then in terms of like, what is the developer actually, what do you have control over that's

21:44

Speaker 2: easy to do?

21:45

Speaker 2: It's super easy to change the resolution between the ones that are supported by the fruit jam.

21:49

Speaker 2: So there's a few different ways that works.

21:51

Speaker 2: One of them is the user gets some level of control inside of settings.

21:55

Speaker 2: Toml.

21:56

Speaker 2: You can actually set a configuration line where the user can say, you know, I prefer the 360 size screen, or I prefer the 320 by 240, or I prefer the 640 by 480.

22:06

Speaker 2: So you can put that in there.

22:08

Speaker 2: And then as a developer, when you're working on your app, you can read the setting there.

22:12

Speaker 2: And kind of like the ideal thing would be you follow whatever the user wants.

22:16

Speaker 2: But maybe if you're making a game or something and you really have to have a specific screen size for your assets, then you can go and sort of just change the configuration on the display.

22:25

Speaker 2: And inside of the Fruit Jam library,

22:28

Speaker 2: so we have a Fruit Jam library that's just AdaFruit underscore Fruit Jam.

22:32

Speaker 2: It's sort of like a Fruit Jam version of the portal-based libraries

22:36

Speaker 2: for folks that are familiar with like the Pi Portal and the bunch of the other ones,

22:41

Speaker 2: Fun House.

22:42

Speaker 2: There's a bunch of them that have those libraries.

22:43

Speaker 2: So Fruit Jam Library has a bunch of Fruit Jam hardware-specific stuff in it,

22:48

Speaker 2: and one of the things that it provides is a high-level reconfigure display.

22:52

Speaker 2: So I forget the exact name of the function,

22:53

Speaker 2: but you can call like Configure Display.

22:55

Speaker 2: pass it a width and height,

22:57

Speaker 2: and that's sort of the one-liner that you need as a developer

23:00

Speaker 2: to actually specify the size for your own app,

23:04

Speaker 2: is just pop that in and say 320, 240 or whatever size you want.

23:07

Speaker 3: And a lot of applications do default to that 320 by 240 game-wise and stuff,

23:13

Speaker 3: because that is kind of the easiest to work with in an arcade game format.

23:18

Speaker 3: However, it is, you can support all the support.

23:21

Speaker 3: There's four different resolutions, I believe,

23:23

Speaker 3: that the Fruit Jam really supports within CircuitPy.

23:25

Speaker 3: Python. And it is possible to have support for all those. But it can be a challenge. In fact,

23:31

Speaker 3: for the Fruit Jam version of Pac-Man that we have, which I believe I worked on with Retired Wizard,

23:39

Speaker 3: it took a lot of testing of all those different resolutions and reformatting, especially with that,

23:44

Speaker 3: because it's kind of a, was it, Tate style game, you know, with its vertical layout. It was difficult

23:49

Speaker 3: to get that to fit exactly right. But with clever use of display IOs, the group's

23:55

Speaker 3: scaling property, you can kind of achieve what you need to do. But you do get a little bit of

24:01

Speaker 3: a performance hit whenever you're scaling objects just because it has to copy all those buffers

24:06

Speaker 1: and stuff. What are some other challenges for developers to look out for when developing for

24:11

Speaker 1: the fruit jam? I will take a quick one, which would be USB stuff. I know we talked to a lot about

24:19

Speaker 2: USB hosts earlier and where the responsibility lies between CircuitPython core.

24:25

Speaker 2: handling the USB versus you as an application developer

24:29

Speaker 2: having to handle it in your own app.

24:30

Speaker 2: And so I think we mentioned before

24:32

Speaker 2: that keyboard is handled by the core.

24:34

Speaker 2: So if you just need basic keystrokes,

24:36

Speaker 2: you know, you just want to know

24:37

Speaker 2: when the user presses on the arrow keys

24:40

Speaker 2: or when they type in a message.

24:42

Speaker 2: You can do that very easily.

24:44

Speaker 2: You actually just see the input

24:46

Speaker 2: as though it came in over the serial line

24:48

Speaker 2: if you were writing a C-Python code.

24:50

Speaker 2: So you can kind of very easily query the keyboard

24:53

Speaker 2: to get those keys

24:54

Speaker 2: that have been pressed.

24:56

Speaker 2: What we don't have in the core

24:57

Speaker 2: is we don't have support for mice

24:59

Speaker 2: or any other kind of peripherals.

25:01

Speaker 2: So if you want to have a mice,

25:02

Speaker 2: a mouse, or a game pad in your game,

25:04

Speaker 2: you'll have to have code inside of your own code.

25:07

Speaker 2: code.py that initializes it and handles it.

25:10

Speaker 2: We do have helper libraries and stuff,

25:11

Speaker 2: but it's something you've got to put in your code.

25:14

Speaker 2: And then your other sort of choice

25:16

Speaker 2: is if you need really fine-grained control.

25:18

Speaker 2: So it's really easy to find out

25:21

Speaker 2: that the arrow key has been pressed

25:23

Speaker 2: or that the user typed the word,

25:24

Speaker 2: hello. But if you really, you know, if you think about some video games, you want to know up and down,

25:30

Speaker 2: right? You want to know, like, when the key is pressed, while it's held down, and then you want

25:33

Speaker 2: to know when it's released. For instance, if you want to have a character like run around a world

25:38

Speaker 2: using a D-pad, that's kind of how it works, you know, in most games by default. And if you do

25:44

Speaker 2: want that control where you need to know the down, the hold, the up, that is a little bit deeper

25:50

Speaker 2: of a level. So the way that the keyboard is hooked up by default in CircuitPython, you don't get that

25:56

Speaker 2: stuff. But what you can do is sort of, again, sort of reconfigure it. You can have it undo the default

26:01

Speaker 2: configuration and you can get lower level control where you actually get sort of raw HID events as needed.

26:07

Speaker 2: And you can definitely see, you know, key went down, key has been held down, and then key is released

26:12

Speaker 2: finally. So you could do that stuff. So that is one gotcha that I will throw out is depending on how you

26:17

Speaker 2: want to do that input. You may need to use that slightly lower.

26:20

Speaker 2: level API for the keyboard.

26:23

Speaker 3: I've actually debated extending the GamePad Library to include an option.

26:28

Speaker 3: It'd have to be a flag you turn on, but to allow it to automatically detach the keyboard

26:34

Speaker 3: and use that as a game pad input, quote unquote.

26:38

Speaker 3: Yeah, that would be cool.

26:39

Speaker 3: It would be cool.

26:40

Speaker 3: It just hasn't happened.

26:41

Speaker 3: Have you played around with that yet, Tim, in any of your applications?

26:45

Speaker 3: The GamePad Library?

26:46

Speaker 3: No, no, directly accessing keyboard events.

26:49

Speaker 2: Oh, yeah, a little bit.

26:51

Speaker 2: Yeah, so I have, I did, I don't think I have done it in any of my games.

26:57

Speaker 2: So I did, the main game that I have worked on more recently uses the D-pad.

27:04

Speaker 2: Although, you know, I think the Flappy Nyan Cat one, maybe the Flappy Nyan Cat, I think, does actually pull the lower level one.

27:10

Speaker 2: No, that's not true, though, because you don't hold the button down.

27:13

Speaker 2: I don't think that's true.

27:14

Speaker 2: Sorry, yeah, I think I misremembered that part.

27:16

Speaker 2: I don't think I have done the lower-level keyboard thing for any of my games,

27:19

Speaker 2: but I am familiar with the code for it

27:21

Speaker 2: because I did the keyboard guide

27:23

Speaker 2: whenever we first launched the fruit jam

27:26

Speaker 2: or I should say

27:27

Speaker 2: when we eventually launched the Ada box

27:29

Speaker 2: the box came with a keyboard,

27:31

Speaker 2: it came with a mouse and it came with the keyboard.

27:34

Speaker 2: And when we first got the fruit jams in stock in the store,

27:36

Speaker 2: we also got some of those other peripherals.

27:38

Speaker 2: And so we wrote guides around the mouse and the keyboard

27:41

Speaker 2: that have all the different ways you can hook them up.

27:43

Speaker 2: So I was familiar with it from that,

27:45

Speaker 2: but I don't believe I have actually used it in a game specifically yet.

27:49

Speaker 3: Yeah, I myself, I just hadn't hit a point in which I really needed it yet, so I hadn't really worked on it.

27:57

Speaker 3: I would like to add to that question, though, you know, CircuitPython, these microcontrollers are super powerful for what they are, but there is a limit to how much of the screen you can draw in one time without, you know, without breaking that 30, you know, hertz cap or whatever.

28:13

Speaker 3: And so you kind of have to be careful when you're dealing with more complex scenarios to only update, you know,

28:19

Speaker 3: certain parts of the screen at a time.

28:21

Speaker 3: And the more that you can limit that,

28:23

Speaker 3: the better your game will feel and run.

28:26

Speaker 3: That's why puzzle games work really well

28:28

Speaker 3: because a lot of times you're only dealing

28:29

Speaker 3: one thing at a time.

28:31

Speaker 3: So it's not that hard.

28:32

Speaker 3: But when getting into action games,

28:34

Speaker 3: like if you're doing screens,

28:35

Speaker 3: you know, side scrolling and stuff,

28:37

Speaker 3: it's probably possible.

28:39

Speaker 3: But you'll have some challenges working with that

28:42

Speaker 3: to get it to run really smoothly.

28:44

Speaker 3: I know I've been able to get some action scenarios working

28:47

Speaker 3: in which you're just moving the characters

28:49

Speaker 3: around and that works really well.

28:51

Speaker 3: Actually, one example, speaking of

28:53

Speaker 3: screen savers, I did make one

28:55

Speaker 3: screen saver, it's the mystify

28:57

Speaker 3: screen saver from like the, I don't know,

28:59

Speaker 3: Windows XP days, right?

29:01

Speaker 3: Which is a little bit beyond, because I know

29:03

Speaker 3: Fruit JamOS comes with a lot of, you know, flying

29:05

Speaker 3: toasters and stuff, the more like Macintosh

29:07

Speaker 3: classics. And so I wanted to like get

29:09

Speaker 3: something from a different era, right?

29:11

Speaker 3: Although it was pretty, it was surprisingly

29:13

Speaker 3: easy to program with

29:15

Speaker 3: vectorio Polygons and stuff like that

29:17

Speaker 3: to get that effect.

29:19

Speaker 3: it runs kind of slow

29:21

Speaker 3: I'm surprising because every

29:23

Speaker 3: in order to do the polygons correctly

29:24

Speaker 3: and fill that entire screen with your

29:26

Speaker 3: I don't know if you all are familiar with that

29:28

Speaker 3: that style of screen saver

29:31

Speaker 3: but you basically have to redraw the screen

29:32

Speaker 3: for every frame so it's kind of

29:34

Speaker 3: like maybe three four frames

29:36

Speaker 3: per second but it still

29:38

Speaker 3: looks cool so I decided to publish it

29:40

Speaker 3: regardless but it's something

29:42

Speaker 3: to be aware of. Yeah I ran into

29:44

Speaker 4: the screen scrolling

29:46

Speaker 4: issue with the moon miner

29:48

Speaker 4: game. I initially wanted to have a screen scrolling when the ship is moving around the planet.

29:56

Speaker 4: And I also wanted a high resolution because I have this heads-up display of these statistics that are running.

30:04

Speaker 4: And it's 640 by 480 and sliding screens just did not work out for me.

30:10

Speaker 4: So I changed the course and went with paging one page to the other.

30:15

Speaker 4: When you get to the right side of the screen, it'll switch to the left side.

30:18

Speaker 4: So it worked out.

30:20

Speaker 4: But yeah, the higher resolution, you go, the more pixels you got to deal with, the more performance issues that you may run into.

30:30

Speaker 3: But, you know, limitations breed creativity.

30:32

Speaker 3: Yeah.

30:33

Speaker 3: So I think that's a part of the fun.

30:35

Speaker 3: If there were no limitation, if it was just a black box, I could just do anything, it wouldn't be as fun.

30:41

Speaker 1: Well, that is the fun of working with microcontrollers.

30:44

Speaker 1: It's the constraints that you're under and what can you do with so little.

30:47

Speaker 1: Exactly.

30:48

Speaker 4: And a nice thing about screensavers, you don't have to worry about the keyboard.

30:52

Speaker 4: That's all taking care of at the operating system level.

30:55

Speaker 4: Somebody touches a key, your program's gone.

30:57

Speaker 4: And so it's doing something else.

31:00

Speaker 4: Totally.

31:01

Speaker 1: What advice would you have for someone interested in creating a gamer application for the fruit jam?

31:06

Speaker 4: Well, you'd need to get one for one thing.

31:09

Speaker 4: And right now, I'm surprised, like, they're still hard to get after, since August.

31:16

Speaker 3: That's not entirely true, though.

31:18

Speaker 3: One thing I was doing some work on recently, in order to help iteration of developing this stuff,

31:24

Speaker 3: it's actually possible to get some components of a fruit jam application running within Blinka, right,

31:32

Speaker 3: using Tim, your PyGame display library.

31:35

Speaker 3: You can kind of simulate the environment and, I don't know, work with it that way.

31:41

Speaker 3: You still should get a fruit jam, but you can at least get started.

31:46

Speaker 2: Yeah, I mean, even generally, that's one of the things that brought me to CircuitPython was that portability.

31:52

Speaker 2: Like not everything that works on PC, normal Python works in CircuitPython, but lots of the stuff is familiar.

31:58

Speaker 2: So yeah, we have some ways to try to do that development on the PC or on other hardware.

32:03

Speaker 2: Like it was thrown out earlier, the Metro, the Metro RP 2350 days before the Fruit Jam was out.

32:10

Speaker 2: We had the Metro RP 2350 and you could actually hook up enough hardware to that to where it can,

32:15

Speaker 2: basically be a fruit jam. You would need the Wi-Fi and the display,

32:20

Speaker 2: HDMI stuff. But there was USB connector, so you could do all of that.

32:24

Speaker 2: Back to the question about the advice for making a game, I think one of my big pieces of

32:28

Speaker 2: advice is kind of explore the different display API. So we talked a little bit about this,

32:33

Speaker 2: about how much your, how many different things on the screen are moving at once. And if you can

32:39

Speaker 2: limit it to just one or two things moving, you have a better time. But there's also just

32:44

Speaker 2: several different ways you can draw stuff.

32:46

Speaker 2: So we talked a little bit about display text earlier for text,

32:49

Speaker 2: and we've talked about bitmaps and tile grids and stuff.

32:52

Speaker 2: Vector I.O. was mentioned.

32:53

Speaker 2: So that's another one of the options if you're doing basic shapes and colors and stuff.

32:57

Speaker 2: And then the Bitmap Tools Library is another one that I'll call out that's in the core

33:01

Speaker 2: that can do lots of really interesting manipulations with bitmaps.

33:05

Speaker 2: Sometimes you might be able to get away with using the Bitmap Tools library

33:11

Speaker 2: instead of different sets of sprites or different assets or something.

33:14

Speaker 2: like that. That would be my advice is to explore the different ways that there are out there to

33:19

Speaker 2: display stuff. We have different ones are better suited for certain things than others. So you might

33:24

Speaker 2: have better luck using a different technique for your particular game based on how you want it

33:29

Speaker 2: to behave. And those bitmap tools you're talking about. That's like palette swapping and things

33:35

Speaker 3: like that, right? It's not quite. No. So bitmap tools, the core module, there's a bunch of functions

33:41

Speaker 2: in there, the ones that I use the most, it's like rotozoom is one. So you can take a chunk out of one

33:47

Speaker 2: bitmap and paste it into another bitmap either rotated or scaled up or scaled down. And you can

33:54

Speaker 2: even do partial scaling with that. So like groups, we mentioned before, groups in display I.O,

33:58

Speaker 2: those can be scaled, but only by a full factor, right? You can scale it by two or three or four.

34:04

Speaker 2: With bitmapTools.RotoZoom, you can do partial scales as well. So you could zoom something, scale it up

34:09

Speaker 2: by one and a half or just by 10% or something like that.

34:12

Speaker 2: So there's rotozoom, there's like draw shapes.

34:16

Speaker 2: There's a circle one, a rectangle one.

34:18

Speaker 2: I believe there's polygon one.

34:20

Speaker 2: There are stuff for alpha blending.

34:23

Speaker 2: There's stuff for dithering.

34:25

Speaker 2: And it's all implemented in C.

34:26

Speaker 2: So it's like it can go really fast to do a bunch of manipulation on a bitmap,

34:31

Speaker 2: either a whole bitmap or a chunk out of a bitmap.

34:36

Speaker 3: Yeah, it'd be awesome to see some.

34:37

Speaker 3: What was the SNES?

34:38

Speaker 3: You see mode seven.

34:40

Speaker 3: It'd be awesome to see something like that,

34:41

Speaker 3: but that might be outside of the capabilities.

34:46

Speaker 3: I mean, I'm sure we can go into a whole discussion on game design.

34:51

Speaker 3: Because that's what it comes down to.

34:52

Speaker 3: You know,

34:52

Speaker 3: the CircuitPython and the Fruit Jam provides you the platform,

34:56

Speaker 3: but game design is the same across the board,

34:59

Speaker 3: you know,

35:00

Speaker 3: how you come up with ideas and explore those ideas.

35:03

Speaker 3: And, of course, the Fruit Jam is not limited just to games.

35:07

Speaker 3: I'd say actually a majority of the application

35:09

Speaker 3: are not game related.

35:11

Speaker 3: You know, you have, well, Larzio, right, paint music thing, right?

35:16

Speaker 3: That's a great application.

35:17

Speaker 3: And that's game adjacent, I would say.

35:20

Speaker 3: And there's a lot else on the board that, you know, you can make a calculator, you know,

35:25

Speaker 3: or the speak and spell.

35:26

Speaker 3: I know that was one you did, Tim.

35:28

Speaker 3: Yep.

35:29

Speaker 3: Speaking spell, IRC.

35:31

Speaker 4: I learned by example.

35:33

Speaker 4: So I would suggest looking at other CircuitPython projects on GitHub or GitHub or,

35:39

Speaker 4: the LEAR, the Adafruit Learn system or the circuit playground group, that's a good resource for

35:47

Speaker 4: people that are looking for something similar. John Park's CircuitPython PARSEC, he's had a

35:53

Speaker 4: couple games in there. So yeah, there should be resources that I would look at.

35:59

Speaker 3: You actually just reminded me, Dan, I did create a Pong game, super basic for the Fruit Jam,

36:06

Speaker 3: with a included tutorial that goes through everything from the bootstrap to manipulating graphics and controls and USB input.

36:14

Speaker 3: And that would be a great place to start too, especially if you're not familiar with CircuitPython and how that works.

36:20

Speaker 3: Because it's about as basic as you can get.

36:23

Speaker 1: Is that available as a learn guide or where can people find that?

36:26

Speaker 3: So it is on GitHub and it has a GitHub pages thing.

36:30

Speaker 3: So it's like a website kind of thing that you go through each section of the tutorial.

36:34

Speaker 3: I think I kind of got inspired by Todd Bot's synth I.O. tutorials to do that one.

36:41

Speaker 3: I'll make sure to share a link with you, Paul, in case you aren't familiar with that.

36:44

Speaker 1: Yeah, I'll make sure that I added to the show notes. That'll be great.

36:48

Speaker 1: Well, that's all excellent advice. I'd like to thank all of you for your time this evening.

36:53

Speaker 1: Dan, Tim, and Cooper. Thanks so much for coming on the show.

36:56

Speaker 1: Yeah, thanks for having me, Paul.

36:57

Speaker 1: Thank you for having us.

36:58

Speaker 1: It has been a pleasure, as always.

37:01

Speaker 1: Thank you for listening to The CircuitPython Show.

37:03

Speaker 1: Thank you to Cooper, Dan, and Tim for joining the show

37:05

Speaker 1: and sharing their experiences developing for the Fruit Jam.

37:09

Speaker 1: To learn more about the Fruit Jam apps the panel has discussed,

37:11

Speaker 5: visit the show notes and transcript at www.com.

37:16

Speaker 5: Until next time, stay positive.