Video summary
The video introduces John Park's demonstration of using the Adafruit FruitJam library within CircuitPython, specifically focusing on simplifying hardware interaction for the RP2350-based microcontroller board known as the FruitJam. This feature-packed device is equipped with numerous peripherals including built-in buttons, NeoPixels, audio and video outputs, and extensive GPIO pins. While users can configure these components manually using standard libraries or direct setup methods, the primary advantage of the FruitJam library lies in its ability to provide higher-level access that makes code more consistent and easier to write by abstracting away complex hardware configurations.
The core example presented centers on reading the state of the board's built-in buttons with minimal effort. Instead of manually setting up digital inputs or managing pin definitions, developers simply import the `peripherals` module from Adafruit FruitJam and instantiate a device object named "FruitJam." Within the main program loop, checking for button presses becomes as straightforward as querying specific attributes like `fruitjam.button.one`, `button.two`, or `button.three`. The library returns a logical state where zero indicates a pressed button and one signifies that it is released, allowing developers to execute custom actions based on these inputs without dealing with low-level register configurations.
Beyond just buttons, the presenter highlights that importing this single module grants access to a wide array of other hardware functions through an intuitive interface. By inspecting the available attributes in the `peripherals` object, users can see direct methods for controlling audio output, adjusting volume levels via DACs, playing MP3 files from SD cards, and checking SD card status. This unified approach means that complex tasks like managing audio playback or interacting with NeoPixels are handled through simple method calls rather than intricate initialization sequences.
In conclusion, the FruitJam library serves as a powerful tool for CircuitPython users who want to leverage the full potential of the RP2350 board without getting bogged down in repetitive setup code. By encapsulating knowledge about the specific hardware layout into high-level objects and methods, it streamlines development significantly compared to traditional approaches. The video demonstrates that even basic interactions like detecting button presses can be achieved with just a few lines of clean code, encouraging developers to explore further capabilities such as audio control and file playback in future projects using this efficient library structure.
Read the full video transcript
The circuit py
>> on the circuit python parseek. Today I
want to talk about using the fruit jam
library. So the fruit jam you're
probably familiar with. It's this little
RP2350based
microcontroller board that we have. It
is feature- packed. It has a ton of
hardware on it. It's got video out. It's
got audio out. It's got a whole bunch of
GPIO. It has built-in buttons. It has
built-in NeoPixels, five of them across
here. USB and on and on and on. If you
want to use any of those peripherals,
you can do so somewhat directly with the
typical libraries for the given gizmo,
given device. Uh you can set things up
manually. But one of the conveniences
that we have is the fruit jam library.
So this is if you're familiar with the
pi portal and portal base, this is a
similar concept. It's based on a lot of
those uh ideas where since we know what
a whole bunch of the hardware is on
here, we can have kind of a higher level
access to those things to make the code
a little easier and a little more
consistent. So, I'm going to start off
with buttons today. So, if you take a
look in my ripple at the bottom there,
you'll see when I press one of the fruit
jam buttons here, it'll say pressed. So,
button three, pressing button three and
two, releasing those one, all of them.
So, I've got button presses doing a
little bit of printing to the ripple
there. You could have that do anything
you want. But the way I'm doing this is
with a much simpler bit of code than
usual. I am importing from Adafruit
Fruit Jam peripherals the peripherals uh
chunk of code. And then I'm creating a
device. I'm just calling it fruit jam
equals peripherals. And then in my main
loop, all I have to do is this little
call. If fruit jam.button button three
or if fruit jam.button two or if
fruitjamutton
one. So none of your setting up digital
inputs and this and that. It's just we
know what hardware we have on here. So
in the code we can simply request the
state of any of those buttons. So if
that is a one then it's going to be
released. If that's a zero it's going to
be pressed. And so the code just asks
for that very very simple bit of code uh
or very simple query I should say. If
you want to take a look at what we have
available here, I'm going to go to the
ripple and press control C to kind of
break out of the running code. And I'll
do this same import. I'll say from
Adafruit
Fruit Jam.
Importifals.
Okay, so we've imported that library.
And now if I look at that, I'm going to
just go do dear
peripherals.
You can see here we have access to uh
the SD check, play file, play MP3 file,
stop play, volume, audio output, button
one, button two, button three, that's
what we used here for this example,
audio, apply volume, any button pressed,
DAC, apply audio, audio output. So those
are a few of the things that we can do.
There are other things in uh the fruit
jam library that we'll take a look at in
the future. But just simply asking for
buttons is darn easy using this. Let me
restart the the program there. Uh just
by simply importing that library and
saying fruitjamutton and a number you'll
get the status of those buttons. And so
that is how you can use the fruit jam
library to get button state on the fruit
jam inside of circuit python. And that's
your circuit python parseek.