View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

Learn about porting an audio monitor to the WiiO terminal, featuring a built-in microphone, gyroscope, accelerometer, light sensor, and infrared emitter. Check out the simple base class used for the display and the efficient template class implementation to swap out between two different display libraries.

Related Content
Transcript

[0:00] i recently got sent one of these wii o
[0:02] terminals from seed studio it’s a nice
[0:04] little device it’s got a 2.4 inch lcd
[0:07] screen along with a five-way button on
[0:09] the top
[0:10] along the base we’ve got two grove
[0:12] connectors and there’s an sd card slot
[0:14] along with three more buttons on the top
[0:17] on the bottom there’s a 40 pin gpio
[0:19] connector that is compatible with the
[0:21] raspberry pi
[0:22] looking under the hood we’ve got a cpu
[0:25] that is different from the boards we
[0:26] normally play with the wiio terminal
[0:28] uses an atsamd51p19
[0:31] with an arm cortex m4f core this runs at
[0:34] 120 megahertz but you can boost this
[0:36] clock speed up to 200 megahertz if you
[0:38] need to
[0:40] connectivity is provided by a realtek
[0:42] rtl870
[0:44] which gives this dual band 2.4 and 5
[0:47] gigahertz wifi along with bluetooth
[0:49] there’s an inertial measurement unit so
[0:51] you’ve got a gyroscope and an
[0:52] accelerometer and it has a light sensor
[0:55] and infrared emitter
[0:57] more interesting for our projects it’s
[0:59] got a built-in microphone and a buzzer
[1:01] now the buzzer is not that useful at the
[1:02] moment and is only suitable for playing
[1:04] tones but the built-in microphone seems
[1:06] to be usable
[1:08] we’ve got a screen and a microphone so i
[1:10] thought it would be fun to port over my
[1:12] audio monitor code to it
[1:14] there’s a couple of things that need to
[1:15] be modified the first thing is there’s
[1:17] no i squared s peripheral for getting
[1:19] samples from the microphone the
[1:21] microphone is connected to an analog pin
[1:23] and we need to use analog read to get
[1:25] the current value
[1:26] i did find some examples of using dma to
[1:28] read this value but to keep the code
[1:30] simple i’m using a timer to read the
[1:32] samples i’m only going to sample the
[1:34] audio at 8khz which is good enough for a
[1:37] nice audio display and won’t tax the cpu
[1:40] too much
[1:41] so my first attempt at getting it
[1:42] working was a bit lackluster and after
[1:45] instrumenting the code with some timings
[1:46] i found this was due to the siege studio
[1:48] fork of the tft library it’s taking
[1:50] around 150 milliseconds to render the
[1:53] frequency bar chart
[1:54] weirdly when showing the spectrogram
[1:57] which is rendered at full screen is
[1:59] pretty good taking just 30 milliseconds
[2:01] to render the whole screen so this leads
[2:03] me to suspect it’s a fairly simple fix
[2:05] on their side so i imagine there will be
[2:07] an update at some point to fix this
[2:09] performance problem
[2:11] fortunately in the meantime there’s an
[2:13] alternative library that supports the
[2:14] display and can render all the screens
[2:16] in around 30 milliseconds which is more
[2:19] than fast enough for us
[2:20] the two display libraries are pretty
[2:22] much compatible in terms of method calls
[2:24] so it’s a pretty straightforward swap
[2:26] out
[2:27] what i’ve done is make a very simple
[2:29] base class for the display that defines
[2:31] the methods i need to call i’ve made all
[2:33] my code depend on this class
[2:35] and then to swap out the two different
[2:36] displays i’ve got a wrapper class that
[2:38] derives from this base class and
[2:40] delegates on to the real library
[2:43] to reduce writing lots of boilerplate
[2:45] code i’ve used a template class this
[2:47] takes advantage of the fact that both
[2:49] libraries implement pretty much the same
[2:51] methods so i just need to write the code
[2:53] once and the c plus compiler works out
[2:55] what i’m trying to do
[2:56] if you like this kind of coding then
[2:58] you’d probably enjoy the previous video
[3:00] on improving your arduino code using c
[3:02] plus
[3:03] it works pretty nicely i really like
[3:05] these devices with displays and
[3:07] microphones there’s lots of potential as
[3:09] a shame the speaker is not a bit more
[3:11] useful but there is a bolt-on module
[3:13] that will give you a proper speaker i’ve
[3:15] put the code up on github so you can
[3:16] give it a go if you want and if you’ve
[3:18] got a wii terminal let me know how it
[3:20] works i think we’ll be exploring this
[3:21] device in the future


HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts