Speaker 1: Welcome to the CircuitPython Show.
Speaker 1: I'm your host, Paul Cutler.
Speaker 1: This episode, I'm joined by three former guests on the show,
Speaker 1: Dan Cogliano, Tim Cox, and Cooper Dalrymple.
Speaker 1: They've joined me to chat about the Adafruit Fruit Jam,
Speaker 1: which was first released last July
Speaker 1: and shipped to Adabox subscribers this past November.
Speaker 1: The Fruit Jam runs CircuitPython
Speaker 1: and is a credit card-sized microcomputer
Speaker 1: with display support, USB host for mice keyboards and game pads,
Speaker 1: and SD card, expansion GPIO, and more.
Speaker 1: Tim, Dan, and Cooper, welcome to the show.
Speaker 1: Hey, Paul.
Speaker 1: Hey, Paul.
Speaker 1: Thanks for having us.
Speaker 1: Thanks.
Speaker 1: Tim, we'll start with you.
Speaker 1: The Fruit Jam hardware can run Fruit JamOS, which is a new way to load a circuit
Speaker 1: Python application.
Speaker 1: What was the inspiration for Fruit JamOS and how does it work?
Speaker 1: Yeah, good question.
Speaker 2: So for Adafruit generally, one of our big goals going into Fruit JamOS was to make something
Speaker 2: that sort of harkens back to like the Commodore 64 era of devices.
Speaker 2: sort of all-in-one devices that you write the programs on there, you run the programs on there.
Speaker 2: Back in those days, they had the keyboard built in.
Speaker 2: They had the little display built in.
Speaker 2: So everything was ready to go for you.
Speaker 2: Just kind of plug it in, start programming and do your thing.
Speaker 2: So that was a big inspiration going into Fruit Jam OSbroadly for all the Adafruit folks.
Speaker 2: And then for me specifically, I would say also there was emphasis on Q Basic.
Speaker 2: QBASIC was one of the first programming languages that I ever interacted with.
Speaker 2: So it's always held a sort of nostalgic place in my heart.
Speaker 2: And as I was working on Fruit JamOS, I kind of got, you know,
Speaker 2: it took me back to that era of Q Basic IDE where it was similar.
Speaker 2: It had the editor built in.
Speaker 2: You could pop over and run your code real fast right there.
Speaker 2: And it was just this all in one sort of package, write your code, run your code,
Speaker 2: see what it does right there and iterate through very quickly.
Speaker 2: So that was another big one for me was QBASIC.
Speaker 1: What's involved that add support to a normal CircuitPython program to run on Fruit Jam OS?
Speaker 2: Yeah.
Speaker 2: So it's pretty straightforward, especially if your program is already set up for the Fruit Jam,
Speaker 2: if you're already making use of the Fruit Jam peripherals and stuff like that.
Speaker 2: If you have something completely unrelated, like it's a Pi portal program or something,
Speaker 2: there's a little bit more converting that needs to take place.
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.
Speaker 2: It's very straightforward.
Speaker 2: You can just create an icon for it, or even,
Speaker 2: even just leave it the default one if you want.
Speaker 2: Create a little metadata file that has the name of your app.
Speaker 2: It has the file path to the icon.
Speaker 2: You store that alongside your code and you copy your code with a folder into the
Speaker 2: app's directory on CircuitPy.
Speaker 2: And that's all you need to do.
Speaker 2: The next time you launch the Fruit Jam OS launcher, it scans that folder.
Speaker 2: So it will automatically find your app along with all the other ones.
Speaker 2: We'll show your icon right on the launcher there.
Speaker 2: User can launch it.
Speaker 2: And as soon as they launch it, it just executes right into your code.
Speaker 1: code.pye file. I know Cooper you I had Sean Carolan on the show recently who did the
Speaker 1: Pac-Man clone in CircuitPython and you reached out to him and gave him a hand to and submitted a PR
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
Speaker 3: and if viewers aren't familiar with how GitHub works basically repository is like a project right
Speaker 3: I did create a project that's just fruit jam application I was trying to make it as basic as possible
Speaker 3: just to be a place to store all those best practices of how to work with this hardware.
Speaker 3: Of course, many users have contributed applications in their own way that may do things a little bit differently.
Speaker 3: But it's always good to have a good foundation of where to start.
Speaker 3: And that does stuff like initializing the display properly, handling different resolutions,
Speaker 3: taking it in keyboard and mouse input and stuff, which I know we'll get into later.
Speaker 1: Cooper, you were one of the first in the community to release a game for the Fruit Jam, Frutris, a Tetris clone.
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.
Speaker 1: What grabbed you and excited you about the fruit jam?
Speaker 1: So I remember when the fruit jam first came out.
Speaker 3: This was last year, was it August or something?
Speaker 3: It was July.
Speaker 3: Is that, okay.
Speaker 3: Yeah, yeah.
Speaker 3: And I really wanted to be a part of that like first initial push on it, that wave.
Speaker 3: And I was playing around with Fruit JamOS because at that time, Tim, you had already had it working.
Speaker 3: and a few applications bundled in from the Learnn guides.
Speaker 3: And I have to admit, I wasn't in on the Metro 2350B days, the really early development.
Speaker 3: But a lot of that I know came from that era, I would say.
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,
Speaker 3: just because I was excited to be a part of everything.
Speaker 3: And we were lacking Tetris.
Speaker 3: You know, we had a lot of other things.
Speaker 3: I think mine sweeper, breakout, so on.
Speaker 3: And Testris is a different beast.
Speaker 3: because there is some math involved
Speaker 3: and a little bit more management
Speaker 3: in order to make it a really good
Speaker 3: Tetris experience, right?
Speaker 3: And so I did my best.
Speaker 3: And actually, the work on that,
Speaker 3: I had actually kind of stolen for myself.
Speaker 3: I don't know if anyone here is familiar
Speaker 3: with Look Mum, no computer.
Speaker 3: It's kind of a techie, YouTuber, crazy guy.
Speaker 3: He did a thing forever ago
Speaker 3: called the Mega Machine,
Speaker 3: which was, gosh, it was like a 10 by 10 array
Speaker 3: of Game Boys in which you could control the screen of each one of them.
Speaker 3: And he was looking for input back then for like applications, stuff.
Speaker 3: He could run on these like 100 Game Boys, right?
Speaker 3: And I just thought it was very meta to make Tetris that played on like 100 Game Boys, right?
Speaker 3: Anyway, even though that was kind of a silly thing, a lot of the code came from that for the actual
Speaker 3: rotation, the different Tetraminos, things like that.
Speaker 3: So that was very important to contribute in that way.
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.
Speaker 3: I was really happy with how, you know, people, you know, started playing around with that.
Speaker 3: It was pretty fun.
Speaker 3: And as for those other developments, I mean, there's been a lot of foundation developed by Adafruit, U-Tem, especially.
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.
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
Speaker 3: that operate like that that you have to support.
Speaker 3: And then some game pads, including the Adafruit, SNES gamepad,
Speaker 3: operate like in their own weird mode.
Speaker 3: That's just kind of difficult to support.
Speaker 3: So obviously, for every application to include its own driver
Speaker 3: for each one of these devices, it's just not feasible.
Speaker 3: So that's one thing that I was able to contribute
Speaker 3: is creating a library to at least combine that a lot together
Speaker 3: so people just don't have to worry about it.
Speaker 3: And I think that's when CircuitPython shines,
Speaker 3: and you just don't have to worry about it, right?
Speaker 3: You just make your own fun code,
Speaker 3: and you don't have to think so much about, you know,
Speaker 3: specific device input and stuff.
Speaker 1: Dan, what about you?
Speaker 1: What excited you about the Fruit Jam?
Speaker 4: Well, first of all, thanks for having me.
Speaker 4: I'm more on the application end of it
Speaker 4: as opposed to the operating system,
Speaker 4: and so I do a lot of application and user applications.
Speaker 4: And I was really excited about it.
Speaker 4: I mean, I grew up, you know,
Speaker 4: with arcade games, retroarchic.
Speaker 4: arcade games and I guess I could consider myself retro because I'm at that age.
Speaker 4: But that really excited me with the or the different emulators that come out with it.
Speaker 4: I think it's great.
Speaker 4: So I decided to write some games in CircuitPython for it.
Speaker 4: The first one was the Zork Z-Machine, which was something I wrote five or six years ago in Arduino.
Speaker 4: And I decided, well, I'm going to convert that to CircuitPython, see if I can get reasonable performance out of it.
Speaker 4: And I did.
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.
Speaker 4: So it's similar to that.
Speaker 4: And then I wrote a couple screensavers.
Speaker 4: So doing a bunch of fun projects, at least for me, I really enjoyed writing them.
Speaker 4: We've got four screens savers so far, and I'm looking at maybe adding more as I find ideas for them.
Speaker 4: And so, yeah, it's been a lot of fun.
Speaker 1: Tell me a little bit more about the four screensavers you've written.
Speaker 1: Can you describe them a little bit?
Speaker 1: And, you know, what worked well about writing them for the fruit jam?
Speaker 1: And were there any challenges that you encountered?
Speaker 4: Well, you know, screensavers go back since the dawn of PCs.
Speaker 4: You know, there was actually a real purpose for them at one time.
Speaker 4: you didn't want to have the screen burn in.
Speaker 4: So now it's more of a fun thing to see on the screen.
Speaker 4: So I wrote four of them.
Speaker 4: I did Starfield screensaver,
Speaker 4: which is kind of like the Star Trek screen,
Speaker 4: you know, with the stars going on the screen.
Speaker 4: And I wrote a maze creator and a real-time solver.
Speaker 4: And that actually came from an Arduino project I wrote for Adafruit,
Speaker 4: probably six years ago, that was also Arduino.
Speaker 4: And that was on a e-paper device.
Speaker 4: So I thought, well, I want to do that one, rewrite that one for CircuitPython.
Speaker 4: And that one turned out really well.
Speaker 4: Then the recent ones I've done is a 15 puzzle screensaver.
Speaker 4: If you ever know the child's toy where you have numbers from 1 to 15 in a grid
Speaker 4: and you slide the tiles around, and I thought, well, this would be great for circuit.
Speaker 4: at Python because it has tile grid and it's really the same concept except you're just taking pieces
Speaker 4: of one image and moving around and I thought well that would be kind of a neat challenge so I did that
Speaker 4: and that turned out really well the latest one I did was just a weather clock it's very stagnant
Speaker 4: there's not much going on other than showing the updating the time and the current weather conditions
Speaker 4: and the temperature so that seemed to be a good screensaver because
Speaker 4: when you're not doing anything
Speaker 4: the time comes up and the weather comes out.
Speaker 4: I thought, that'd be pretty good too.
Speaker 1: Cooper, you mentioned earlier
Speaker 1: that you've done some work about keyboard input and game pads.
Speaker 1: For someone who's used to writing a normal code.
Speaker 1: code.py in CircuitPython and maybe has hooked up a few sensors over
Speaker 1: STEMAQT, how hard is it to code for the Fruit Jam
Speaker 1: to set up things like the display or to use keyboards or game pads?
Speaker 3: Well, if you've ever used display I.O.
Speaker 3: at all for, you know, little OLED displays, black and white, all that kind of, it's the exact same
Speaker 3: API.
Speaker 3: So, loading up bitmaps, drawing shapes with vector, vector I.O, whatever.
Speaker 3: All that kind of stuff, it all uses the exact same principles using tile grid, et cetera.
Speaker 3: In fact, Tim, I know you helped, I believe you helped create a lot of those APIs, right?
Speaker 3: And tile grid in a way almost acts like a Game Boy or something like that in the way that.
Speaker 3: you pick different sprites from a sheet and stuff like that too.
Speaker 3: And then, of course, I know the Adafruit display text library is one that I use on basically every project.
Speaker 3: If you want to write out displays without, I believe you can use terminal I.O. directly.
Speaker 3: And I have done that once or twice.
Speaker 3: But for the most part, you want to use that to get started to write text out to your display,
Speaker 3: depending on what you're trying to do.
Speaker 3: like what those screensaver stand was talking about you probably do principles a little bit
Speaker 3: differently you know you're not working directly with input and stuff like that you kind of needs
Speaker 3: to run itself and so you might not use some of these resources which by the way I did want to
Speaker 3: mention which I love the displays a lot of times I have my fruit jam just running the background while
Speaker 3: I'm working and just running through all those screensavers sometimes random mode and stuff like
Speaker 3: that if you're interested in any of these projects which I know a lot of these resources
Speaker 3: sources come bundled in with Fruit Jam OS, but I do have another application that I know Tim
Speaker 3: and I have been talking about, the library, Fruit Jam library application, which gives you an
Speaker 3: opportunity, because the Fruit Jam, one of the cool things about it is that it has all the bells
Speaker 3: and whistles in it, right? You have Wi-Fi, you have audio, you have HDMI, you have USB host,
Speaker 3: etc. It's its own little computer, right? Neopixel even and GPIO expansion. So that Wi-Fi adds a whole
Speaker 3: new capacity. Well, now you can basically run things on the device itself and get information
Speaker 3: from the web, et cetera, as long as you're connected to Wi-Fi. And so I've been developing this
Speaker 3: library application to make it so that you can download kind of third-party applications,
Speaker 3: maybe outside of the Adafruit space, or maybe in the future, Adafruit would want to host
Speaker 3: some of their own applications through that that are maybe a little bit too big to host directly
Speaker 3: on Fruit Jam OS, you know, in that one download. And so you can download this one. And so you can download
Speaker 3: application, which will allow you to download all the applications, right? It's the idea, right?
Speaker 3: So I know Dan's, a lot of his projects, Z-machine, Moon Miner, right? And those screenshots,
Speaker 3: it actually supports screensavers as well, are all downloadable through there. And eventually,
Speaker 3: I know Tim, we plan on integrating that into the core OS. We're not there yet. Just it's more
Speaker 4: on my plate than anything. But, you know, those are future plans there. Yeah. I think it's great.
Speaker 4: It's a wonderful idea, and I hope you get that out there and incorporate it in a fruit jam.
Speaker 4: I think it's great.
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.
Speaker 3: So it's great.
Speaker 3: It basically is, I don't think we'd want to use the term store per se.
Speaker 3: There's no cash transactions.
Speaker 3: Yeah.
Speaker 2: I'm super excited about the library as well.
Speaker 2: I'm glad you brought it up, Cooper.
Speaker 2: And yeah, for folks listening, the goal is we're going to move that into Fruit JamOS.
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.
Speaker 2: And yeah, I did, I think I suggested to change name.
Speaker 2: And maybe even was App Store originally.
Speaker 2: And I wanted to change it to library for both the reason Cooper mentioned.
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.
Speaker 2: Right.
Speaker 2: They already have App Store lockdown.
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.
Speaker 3: I think you're right.
Speaker 3: I think we did change it at one point.
Speaker 3: But I like library.
Speaker 3: It's like you're checking out a book.
Speaker 2: Yeah, I liked library as well.
Speaker 2: Yeah.
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?
Speaker 3: Which is like a dating sim kind of featuring.
Speaker 3: featuring Blinka, well, kind of featuring Blinka and a bunch of other snakes and stuff.
Speaker 3: And that, there's just, there's just too much graphically and audio-wise.
Speaker 3: Some, the audio files are kind of big.
Speaker 3: I don't think it wouldn't necessarily max out the flash memory on the device or anything,
Speaker 3: but it would be significant enough that would be over half of the Fruit JamOS.
Speaker 3: So it's just not a good idea to bundle in with the core download.
Speaker 3: And plus the library, there's still more work to be done, but you can download.
Speaker 3: to either the flash storage directly on the device
Speaker 3: or to an SD card, right?
Speaker 3: So then you kind of remove the limits
Speaker 3: of what, you know,
Speaker 3: the flash storage limits of the device.
Speaker 3: And one of these days,
Speaker 3: I could see somebody starting to dive
Speaker 3: into more intensive graphically applications
Speaker 3: and things like that
Speaker 3: that may exceed the base storage
Speaker 3: of even the fruit jam,
Speaker 3: which I think, was it eight, 16 megabytes?
Speaker 3: I believe it's 16 megs flash, yeah,
Speaker 3: it's quite big.
Speaker 3: It's quite big, but you put in a 4-gigabyte SD card,
Speaker 3: then you have basically infinite storage in a way.
Speaker 2: To your point there, I think the SD card and the Wi-Fi as well,
Speaker 2: the Wi-Fi was mentioned earlier with the weather screensaver.
Speaker 2: I think those two things bring a lot to the table for the Fruit Jam,
Speaker 2: being able to get stuff off of the internet
Speaker 2: and being able to cache media files,
Speaker 2: either downloaded stuff from the internet to cache,
Speaker 2: or like you're saying, apps with pre-built assets or stuff like that,
Speaker 2: those could fit on the SD card and free up a lot of.
Speaker 2: of space and flash. So those are two of my top picks for peripherals on the fruit jam. And the Wi-Fi,
Speaker 2: worth mentioning, the Wi-Fi was a relatively late addition to the Fruit Jam. There were a couple of
Speaker 2: revisions that came out, not publicly, that they were never sold, but there were internal ones we
Speaker 2: were working on where there was no Wi-Fi. There was originally an I-SPI cable connector to be
Speaker 2: able to connect like TFT cables over SPI. And then Lady Ada was playing around with it and decided,
Speaker 2: Wi-Fi would be super cool to have this whole little mini-computer.
Speaker 2: And I definitely think that was the right call in hindsight.
Speaker 2: The Wi-Fi adds a lot to it for sure.
Speaker 3: I think so too.
Speaker 3: I mean, there is GPIO expansion, and I believe there's some I-2C ports and stuff.
Speaker 3: And heck, I think there's a STEMA QT port too.
Speaker 3: Yep, definitely.
Speaker 3: So if really having another display on top of the HTML output is necessary,
Speaker 3: I'm sure you could just throw on a little SSD 1306 or something.
Speaker 2: Yep, yeah, we've talked about like shields for the top as well.
Speaker 2: There's two rows, I don't know if it's 20 pins or however many pins,
Speaker 2: but there are two rows of GPIO pins.
Speaker 2: At some point, we may have a little shield or a hat or something that you could stick on the top
Speaker 2: to add TFT screen.
Speaker 2: And I'm hoping for a little sort of game style, like game gear with the screen in the middle
Speaker 2: and then Dpad and A.B button on the right.
Speaker 2: So maybe something like that.
Speaker 2: Do you think there's no battery?
Speaker 3: capabilities on the device, is there?
Speaker 2: That is correct. Yeah, as far as I know, there's no charging.
Speaker 2: So unlike the feathers, which have built-in charging and stuff, there's no JST connector
Speaker 2: for a battery and no built-in charging. So you have to use, like, USB battery or something
Speaker 2: to go mobile with it.
Speaker 3: Yeah, that's a great idea, though. I know one I had, is it would be really, granted, you know,
Speaker 3: you have the USB host support, which is awesome. But it would be really cool to have a little
Speaker 3: hat that sticks on top, and you can plug in SNES controllers.
Speaker 3: or NES or something like that.
Speaker 3: That would be really cool too.
Speaker 3: Maybe not a huge difference over the USB,
Speaker 3: but it would be nice regardless.
Speaker 3: Yeah, definitely.
Speaker 4: It reminds me at the old Atari cartridge location
Speaker 4: where you stick in a cartridge where the ports are.
Speaker 4: So it goes back to the retro styling.
Speaker 3: Definitely, definitely.
Speaker 3: Yeah, and you know, there's a lot of GPIO on there.
Speaker 3: I bet you could almost do kind of a basic cartridge loading.
Speaker 3: thing. We're definitely deep dive in here.
Speaker 3: Just a few address lines, maybe some data lines. I don't know.
Speaker 3: Get an e-prom on there. Who knows?
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.
Speaker 1: As a dev, how do you code for different display sizes?
Speaker 1: on the Fruit Jam in CircuitPython itself.
Speaker 1: Yeah, good question.
Speaker 2: So it is, it's a little tricky
Speaker 2: because it can't be done,
Speaker 2: or I will say it's not set up to be super automatic.
Speaker 2: So lots of devices, lots of modern devices,
Speaker 2: when you plug them into a screen,
Speaker 2: they'll kind of query the screen to figure out what size it is
Speaker 2: and then select something that they both agree on.
Speaker 2: The Fruit Jam has a few things that make it tricky.
Speaker 2: One is that it's working at relatively small resolutions
Speaker 2: by today's standards at least, like 640 by 480 or 320 by 240 even, which ends up getting
Speaker 2: doubled anyways. So those are relatively small sizes. There are some screens out there today if you
Speaker 2: just go to the store, your average electronics store today and you buy sort of the cheapest
Speaker 2: monitor that supports HDMI. It may not support some of those smaller ones. It may be only 1920
Speaker 2: by 1080 or 1280p, just modern sizes. And so that's when it will pop up, I think, the error like
Speaker 2: you're talking about where you'll plug it in and it will say, you know, we can't recognize this
Speaker 2: format or something like that. You can actually connect to it through I-2C. So one of the things that
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
Speaker 2: what all is inside of it, but there is a little data channel inside of there. And you can query
Speaker 2: the screen to ask it like what resolutions it supports. And so you could write code that would
Speaker 2: do some of that and try to select one. The deal is that the for
Speaker 2: Jam is, again, it's only doing those smaller screens.
Speaker 2: And so then even if you ask the screen what it supports, it may still not support something that
Speaker 2: works for that smaller size.
Speaker 2: So that's one of the tricky bits.
Speaker 2: And then in terms of like, what is the developer actually, what do you have control over that's
Speaker 2: easy to do?
Speaker 2: It's super easy to change the resolution between the ones that are supported by the fruit jam.
Speaker 2: So there's a few different ways that works.
Speaker 2: One of them is the user gets some level of control inside of settings.
Speaker 2: Toml.
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.
Speaker 2: So you can put that in there.
Speaker 2: And then as a developer, when you're working on your app, you can read the setting there.
Speaker 2: And kind of like the ideal thing would be you follow whatever the user wants.
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.
Speaker 2: And inside of the Fruit Jam library,
Speaker 2: so we have a Fruit Jam library that's just AdaFruit underscore Fruit Jam.
Speaker 2: It's sort of like a Fruit Jam version of the portal-based libraries
Speaker 2: for folks that are familiar with like the Pi Portal and the bunch of the other ones,
Speaker 2: Fun House.
Speaker 2: There's a bunch of them that have those libraries.
Speaker 2: So Fruit Jam Library has a bunch of Fruit Jam hardware-specific stuff in it,
Speaker 2: and one of the things that it provides is a high-level reconfigure display.
Speaker 2: So I forget the exact name of the function,
Speaker 2: but you can call like Configure Display.
Speaker 2: pass it a width and height,
Speaker 2: and that's sort of the one-liner that you need as a developer
Speaker 2: to actually specify the size for your own app,
Speaker 2: is just pop that in and say 320, 240 or whatever size you want.
Speaker 3: And a lot of applications do default to that 320 by 240 game-wise and stuff,
Speaker 3: because that is kind of the easiest to work with in an arcade game format.
Speaker 3: However, it is, you can support all the support.
Speaker 3: There's four different resolutions, I believe,
Speaker 3: that the Fruit Jam really supports within CircuitPy.
Speaker 3: Python. And it is possible to have support for all those. But it can be a challenge. In fact,
Speaker 3: for the Fruit Jam version of Pac-Man that we have, which I believe I worked on with Retired Wizard,
Speaker 3: it took a lot of testing of all those different resolutions and reformatting, especially with that,
Speaker 3: because it's kind of a, was it, Tate style game, you know, with its vertical layout. It was difficult
Speaker 3: to get that to fit exactly right. But with clever use of display IOs, the group's
Speaker 3: scaling property, you can kind of achieve what you need to do. But you do get a little bit of
Speaker 3: a performance hit whenever you're scaling objects just because it has to copy all those buffers
Speaker 1: and stuff. What are some other challenges for developers to look out for when developing for
Speaker 1: the fruit jam? I will take a quick one, which would be USB stuff. I know we talked to a lot about
Speaker 2: USB hosts earlier and where the responsibility lies between CircuitPython core.
Speaker 2: handling the USB versus you as an application developer
Speaker 2: having to handle it in your own app.
Speaker 2: And so I think we mentioned before
Speaker 2: that keyboard is handled by the core.
Speaker 2: So if you just need basic keystrokes,
Speaker 2: you know, you just want to know
Speaker 2: when the user presses on the arrow keys
Speaker 2: or when they type in a message.
Speaker 2: You can do that very easily.
Speaker 2: You actually just see the input
Speaker 2: as though it came in over the serial line
Speaker 2: if you were writing a C-Python code.
Speaker 2: So you can kind of very easily query the keyboard
Speaker 2: to get those keys
Speaker 2: that have been pressed.
Speaker 2: What we don't have in the core
Speaker 2: is we don't have support for mice
Speaker 2: or any other kind of peripherals.
Speaker 2: So if you want to have a mice,
Speaker 2: a mouse, or a game pad in your game,
Speaker 2: you'll have to have code inside of your own code.
Speaker 2: code.py that initializes it and handles it.
Speaker 2: We do have helper libraries and stuff,
Speaker 2: but it's something you've got to put in your code.
Speaker 2: And then your other sort of choice
Speaker 2: is if you need really fine-grained control.
Speaker 2: So it's really easy to find out
Speaker 2: that the arrow key has been pressed
Speaker 2: or that the user typed the word,
Speaker 2: hello. But if you really, you know, if you think about some video games, you want to know up and down,
Speaker 2: right? You want to know, like, when the key is pressed, while it's held down, and then you want
Speaker 2: to know when it's released. For instance, if you want to have a character like run around a world
Speaker 2: using a D-pad, that's kind of how it works, you know, in most games by default. And if you do
Speaker 2: want that control where you need to know the down, the hold, the up, that is a little bit deeper
Speaker 2: of a level. So the way that the keyboard is hooked up by default in CircuitPython, you don't get that
Speaker 2: stuff. But what you can do is sort of, again, sort of reconfigure it. You can have it undo the default
Speaker 2: configuration and you can get lower level control where you actually get sort of raw HID events as needed.
Speaker 2: And you can definitely see, you know, key went down, key has been held down, and then key is released
Speaker 2: finally. So you could do that stuff. So that is one gotcha that I will throw out is depending on how you
Speaker 2: want to do that input. You may need to use that slightly lower.
Speaker 2: level API for the keyboard.
Speaker 3: I've actually debated extending the GamePad Library to include an option.
Speaker 3: It'd have to be a flag you turn on, but to allow it to automatically detach the keyboard
Speaker 3: and use that as a game pad input, quote unquote.
Speaker 3: Yeah, that would be cool.
Speaker 3: It would be cool.
Speaker 3: It just hasn't happened.
Speaker 3: Have you played around with that yet, Tim, in any of your applications?
Speaker 3: The GamePad Library?
Speaker 3: No, no, directly accessing keyboard events.
Speaker 2: Oh, yeah, a little bit.
Speaker 2: Yeah, so I have, I did, I don't think I have done it in any of my games.
Speaker 2: So I did, the main game that I have worked on more recently uses the D-pad.
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.
Speaker 2: No, that's not true, though, because you don't hold the button down.
Speaker 2: I don't think that's true.
Speaker 2: Sorry, yeah, I think I misremembered that part.
Speaker 2: I don't think I have done the lower-level keyboard thing for any of my games,
Speaker 2: but I am familiar with the code for it
Speaker 2: because I did the keyboard guide
Speaker 2: whenever we first launched the fruit jam
Speaker 2: or I should say
Speaker 2: when we eventually launched the Ada box
Speaker 2: the box came with a keyboard,
Speaker 2: it came with a mouse and it came with the keyboard.
Speaker 2: And when we first got the fruit jams in stock in the store,
Speaker 2: we also got some of those other peripherals.
Speaker 2: And so we wrote guides around the mouse and the keyboard
Speaker 2: that have all the different ways you can hook them up.
Speaker 2: So I was familiar with it from that,
Speaker 2: but I don't believe I have actually used it in a game specifically yet.
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.
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.
Speaker 3: And so you kind of have to be careful when you're dealing with more complex scenarios to only update, you know,
Speaker 3: certain parts of the screen at a time.
Speaker 3: And the more that you can limit that,
Speaker 3: the better your game will feel and run.
Speaker 3: That's why puzzle games work really well
Speaker 3: because a lot of times you're only dealing
Speaker 3: one thing at a time.
Speaker 3: So it's not that hard.
Speaker 3: But when getting into action games,
Speaker 3: like if you're doing screens,
Speaker 3: you know, side scrolling and stuff,
Speaker 3: it's probably possible.
Speaker 3: But you'll have some challenges working with that
Speaker 3: to get it to run really smoothly.
Speaker 3: I know I've been able to get some action scenarios working
Speaker 3: in which you're just moving the characters
Speaker 3: around and that works really well.
Speaker 3: Actually, one example, speaking of
Speaker 3: screen savers, I did make one
Speaker 3: screen saver, it's the mystify
Speaker 3: screen saver from like the, I don't know,
Speaker 3: Windows XP days, right?
Speaker 3: Which is a little bit beyond, because I know
Speaker 3: Fruit JamOS comes with a lot of, you know, flying
Speaker 3: toasters and stuff, the more like Macintosh
Speaker 3: classics. And so I wanted to like get
Speaker 3: something from a different era, right?
Speaker 3: Although it was pretty, it was surprisingly
Speaker 3: easy to program with
Speaker 3: vectorio Polygons and stuff like that
Speaker 3: to get that effect.
Speaker 3: it runs kind of slow
Speaker 3: I'm surprising because every
Speaker 3: in order to do the polygons correctly
Speaker 3: and fill that entire screen with your
Speaker 3: I don't know if you all are familiar with that
Speaker 3: that style of screen saver
Speaker 3: but you basically have to redraw the screen
Speaker 3: for every frame so it's kind of
Speaker 3: like maybe three four frames
Speaker 3: per second but it still
Speaker 3: looks cool so I decided to publish it
Speaker 3: regardless but it's something
Speaker 3: to be aware of. Yeah I ran into
Speaker 4: the screen scrolling
Speaker 4: issue with the moon miner
Speaker 4: game. I initially wanted to have a screen scrolling when the ship is moving around the planet.
Speaker 4: And I also wanted a high resolution because I have this heads-up display of these statistics that are running.
Speaker 4: And it's 640 by 480 and sliding screens just did not work out for me.
Speaker 4: So I changed the course and went with paging one page to the other.
Speaker 4: When you get to the right side of the screen, it'll switch to the left side.
Speaker 4: So it worked out.
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.
Speaker 3: But, you know, limitations breed creativity.
Speaker 3: Yeah.
Speaker 3: So I think that's a part of the fun.
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.
Speaker 1: Well, that is the fun of working with microcontrollers.
Speaker 1: It's the constraints that you're under and what can you do with so little.
Speaker 1: Exactly.
Speaker 4: And a nice thing about screensavers, you don't have to worry about the keyboard.
Speaker 4: That's all taking care of at the operating system level.
Speaker 4: Somebody touches a key, your program's gone.
Speaker 4: And so it's doing something else.
Speaker 4: Totally.
Speaker 1: What advice would you have for someone interested in creating a gamer application for the fruit jam?
Speaker 4: Well, you'd need to get one for one thing.
Speaker 4: And right now, I'm surprised, like, they're still hard to get after, since August.
Speaker 3: That's not entirely true, though.
Speaker 3: One thing I was doing some work on recently, in order to help iteration of developing this stuff,
Speaker 3: it's actually possible to get some components of a fruit jam application running within Blinka, right,
Speaker 3: using Tim, your PyGame display library.
Speaker 3: You can kind of simulate the environment and, I don't know, work with it that way.
Speaker 3: You still should get a fruit jam, but you can at least get started.
Speaker 2: Yeah, I mean, even generally, that's one of the things that brought me to CircuitPython was that portability.
Speaker 2: Like not everything that works on PC, normal Python works in CircuitPython, but lots of the stuff is familiar.
Speaker 2: So yeah, we have some ways to try to do that development on the PC or on other hardware.
Speaker 2: Like it was thrown out earlier, the Metro, the Metro RP 2350 days before the Fruit Jam was out.
Speaker 2: We had the Metro RP 2350 and you could actually hook up enough hardware to that to where it can,
Speaker 2: basically be a fruit jam. You would need the Wi-Fi and the display,
Speaker 2: HDMI stuff. But there was USB connector, so you could do all of that.
Speaker 2: Back to the question about the advice for making a game, I think one of my big pieces of
Speaker 2: advice is kind of explore the different display API. So we talked a little bit about this,
Speaker 2: about how much your, how many different things on the screen are moving at once. And if you can
Speaker 2: limit it to just one or two things moving, you have a better time. But there's also just
Speaker 2: several different ways you can draw stuff.
Speaker 2: So we talked a little bit about display text earlier for text,
Speaker 2: and we've talked about bitmaps and tile grids and stuff.
Speaker 2: Vector I.O. was mentioned.
Speaker 2: So that's another one of the options if you're doing basic shapes and colors and stuff.
Speaker 2: And then the Bitmap Tools Library is another one that I'll call out that's in the core
Speaker 2: that can do lots of really interesting manipulations with bitmaps.
Speaker 2: Sometimes you might be able to get away with using the Bitmap Tools library
Speaker 2: instead of different sets of sprites or different assets or something.
Speaker 2: like that. That would be my advice is to explore the different ways that there are out there to
Speaker 2: display stuff. We have different ones are better suited for certain things than others. So you might
Speaker 2: have better luck using a different technique for your particular game based on how you want it
Speaker 2: to behave. And those bitmap tools you're talking about. That's like palette swapping and things
Speaker 3: like that, right? It's not quite. No. So bitmap tools, the core module, there's a bunch of functions
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
Speaker 2: bitmap and paste it into another bitmap either rotated or scaled up or scaled down. And you can
Speaker 2: even do partial scaling with that. So like groups, we mentioned before, groups in display I.O,
Speaker 2: those can be scaled, but only by a full factor, right? You can scale it by two or three or four.
Speaker 2: With bitmapTools.RotoZoom, you can do partial scales as well. So you could zoom something, scale it up
Speaker 2: by one and a half or just by 10% or something like that.
Speaker 2: So there's rotozoom, there's like draw shapes.
Speaker 2: There's a circle one, a rectangle one.
Speaker 2: I believe there's polygon one.
Speaker 2: There are stuff for alpha blending.
Speaker 2: There's stuff for dithering.
Speaker 2: And it's all implemented in C.
Speaker 2: So it's like it can go really fast to do a bunch of manipulation on a bitmap,
Speaker 2: either a whole bitmap or a chunk out of a bitmap.
Speaker 3: Yeah, it'd be awesome to see some.
Speaker 3: What was the SNES?
Speaker 3: You see mode seven.
Speaker 3: It'd be awesome to see something like that,
Speaker 3: but that might be outside of the capabilities.
Speaker 3: I mean, I'm sure we can go into a whole discussion on game design.
Speaker 3: Because that's what it comes down to.
Speaker 3: You know,
Speaker 3: the CircuitPython and the Fruit Jam provides you the platform,
Speaker 3: but game design is the same across the board,
Speaker 3: you know,
Speaker 3: how you come up with ideas and explore those ideas.
Speaker 3: And, of course, the Fruit Jam is not limited just to games.
Speaker 3: I'd say actually a majority of the application
Speaker 3: are not game related.
Speaker 3: You know, you have, well, Larzio, right, paint music thing, right?
Speaker 3: That's a great application.
Speaker 3: And that's game adjacent, I would say.
Speaker 3: And there's a lot else on the board that, you know, you can make a calculator, you know,
Speaker 3: or the speak and spell.
Speaker 3: I know that was one you did, Tim.
Speaker 3: Yep.
Speaker 3: Speaking spell, IRC.
Speaker 4: I learned by example.
Speaker 4: So I would suggest looking at other CircuitPython projects on GitHub or GitHub or,
Speaker 4: the LEAR, the Adafruit Learn system or the circuit playground group, that's a good resource for
Speaker 4: people that are looking for something similar. John Park's CircuitPython PARSEC, he's had a
Speaker 4: couple games in there. So yeah, there should be resources that I would look at.
Speaker 3: You actually just reminded me, Dan, I did create a Pong game, super basic for the Fruit Jam,
Speaker 3: with a included tutorial that goes through everything from the bootstrap to manipulating graphics and controls and USB input.
Speaker 3: And that would be a great place to start too, especially if you're not familiar with CircuitPython and how that works.
Speaker 3: Because it's about as basic as you can get.
Speaker 1: Is that available as a learn guide or where can people find that?
Speaker 3: So it is on GitHub and it has a GitHub pages thing.
Speaker 3: So it's like a website kind of thing that you go through each section of the tutorial.
Speaker 3: I think I kind of got inspired by Todd Bot's synth I.O. tutorials to do that one.
Speaker 3: I'll make sure to share a link with you, Paul, in case you aren't familiar with that.
Speaker 1: Yeah, I'll make sure that I added to the show notes. That'll be great.
Speaker 1: Well, that's all excellent advice. I'd like to thank all of you for your time this evening.
Speaker 1: Dan, Tim, and Cooper. Thanks so much for coming on the show.
Speaker 1: Yeah, thanks for having me, Paul.
Speaker 1: Thank you for having us.
Speaker 1: It has been a pleasure, as always.
Speaker 1: Thank you for listening to The CircuitPython Show.
Speaker 1: Thank you to Cooper, Dan, and Tim for joining the show
Speaker 1: and sharing their experiences developing for the Fruit Jam.
Speaker 1: To learn more about the Fruit Jam apps the panel has discussed,
Speaker 5: visit the show notes and transcript at www.com.
Speaker 5: Until next time, stay positive.