 Okay, sorry everyone, boy it's going. You would think I'd be on time if I started later than I normally do. Oh, this guy characterizes how my week's gone. The discord chat's not showing up, cat cam's not showing up, is it summer? Okay, I've got YouTube chat going, I've got data sheets open that I can close. Sorry folks, I'm a little behind. I started late and I'm behind. Go figure. Yeah, sorry for the trouble. I was like, oh, like I got cat cam working last time, I should get it working. And then until I did a restart and right before the restart, I realized, oh, like my audio's not working. It didn't work when it restarted, cat cam's still not working. I think I figured out why cat cam might not be working, so I'm going to try to poke it right now. Actually, I don't know why discord's not working. The discord browser extension is not working. That is, let's see if I can't just, hey, oh, like that might have worked. Sweet. You're getting an echo. I do, I do, do Esther, maybe you have two copies of the window open. That could cause an echo. All right, let's see if I can't make cat cam. Maybe it'll start randomly. You had to crank the volume up. Oh, I can test, test, test, test, test, test, test, test, test, test, test, better. A little louder. Ah, there you go, YouTube and Twitch, that would cause an echo. Is that level better? Okay, I am sorry I'm really late, folks. I was working on some stuff, I had to use the bathroom, and then OBS didn't. Okay, now it's peeking out. Okay, let me come down a notch. Is that better? Better, better, better, better, better. I turned it down and I know there's some lag, so let me just sit tight. So happy circuit python day. Sorry, everyone else has their stuff together and I'm a little scattered here. Good audio. Thank you, DCD. And thanks to DCD for taking notes. It might be a little, I could do it a hair, did I raise it a hair? Test, one, two, there. The clipping was eardrum blowing, so how about, hopefully that's good. Hi, Venkat, welcome, native of the stream. So I think I'm about ready to actually get this going. Hello, my name is Scott, I am the circuit python, sorry for the clap, I'm the circuit python lead for Adafruit. I live and work in Seattle and I work remotely for Adafruit on circuit python. They hired me in 2016, the end of 2016 to work on MicroPython and our version of MicroPython circuit python came out as a result of that work. So by extension, if you want to support me, you can go to Adafruit.com and purchase hardware there that you see and are excited about. They pay me to do these streams, they pay me to work on circuit pythons and they're very generous. So I suggest if you want to support me, support them by purchasing from Adafruit. And if, for example, a digi-key is better for shipping or availability, Adafruit sells to them, so that's a good option as well. If you don't know, I mean it's circuit python day, but circuit python is a version of python designed for microcontrollers. It's based on MicroPython which does the pythony bits and then with circuit python we've refined both like the interaction work, what we call the workflow of how you edit code and see the output and then also we've refined the hardware APIs that we build all of our drivers on. It is circuit python day, normally we don't have a discount code, but I believe it's CirquePyDay, C-I-R, let me switch to desktop and I'll scooch any windows out of the way that I need to hide that and close this. So it's CirquePyDay, I believe is the code and I think that's 10% off. So if you want to support me in Adafruit, check that out. I think there is a second C in there. So what we've got going above me in this view is we've got Discord and then on top of that is the YouTube chat. I do deep dives almost every week and while I was taking time off to have a kid, FOMI guy likes to deep dive as well. So shout out to FOMI guy for filling in for me for a lot of last year and this year. If you want to check out FOMI guy, he usually streams Saturday mornings, he also streamed earlier today on circuit python day. So check that out, he does a lot of library testing and development. What I tend to cover on this stream is more core circuit python work that's kind of my bread and butter and what that means is that circuit python is implemented under the hood with C code and a lot of that code bridges between the python world and the hardware using C and so that's kind of like the land that I live in and I'm happy to take questions about the core of circuit python. We call it deep dive because it is way down in the code. We think of low level as very close to the registers that make things do things. The way that I like to structure these deep dives is just if folks have questions, I'm happy to try and answer them. I do kind of like very much wander, which I hope is charming and informative, not annoying, but when people ask questions, I try to give pretty good answers with those. So I guess I should note, maybe I'll say this, I haven't told a lot of people, but I'm looking to move my office out of the house. So this is like this room is currently in my house, in our house and we're looking to redo this room and so I've been looking for office space and so when I mentioned like how my week's been going, it's been a lot of like imagining what a feature space for me to stream and work in will be and kind of what the requirements for those spaces are. So that's been taking a non-trivial chunk of my brain to think about. If you have any tips about it, and I am thinking about like how I want to have my desk set up and my streaming set up as well, like I was like, oh, I could get a green screen if that would be interesting. So that is one thing on my mind. That move will probably, like I haven't found a place. I've been looking at a lot of places. I haven't settled on one yet, but I'll probably end up moving hopefully in the next couple of weeks to a different space. So I don't think I'll just start deep dives because of that, but that might be the case and that might happen. We'll see. Okay, so that's kind of personal update. Cat Cam still hasn't come back. We do have Spook in the room here. I don't think Vin is. And DCV, when I first started doing deep dives, I gave caveats because Spook is epileptic and was having seizures. But a couple of years ago now, we switched him on to different medication and he hasn't knocked on wood, had a seizure basically since he switched. So that is pretty cool and why I've not been giving that warning anymore. So he's doing good. So last week, we did deep dive and we talked about the ESP IDF update. The IDF is kind of the, I'm trying not to use a bunch of acronyms, but SDK. And SDK is generally like a suite of software designed to make it easier to program to a piece of hardware or a service or something. So the IDF is software that's maintained and written by Espressif, who make the ESP32 chips. And we use that to interface to the hardware under the hood for CirclePython. So we're currently on version 4.4, I think. And we're going to be moving up to 5.0 and probably 5.1 after that. So that's what I was working on last week. And then the week before I was doing USB host, and I did a little USB host work this week as well, that I have a kind of a cool SynthIO demo actually that maybe we should start with. And then we can talk a bit about IDF 5 updates. Usually these streams, I've only committed to doing these streams for an hour now, but they do tend to, they used to be two hours. I think today I'll probably shoot for about four, so just over an hour. Because show and tell will be at 4.30, I think. So show and tell is coming up next. It's normally on Wednesdays, but a lot of the shows all got moved to Fridays. And actually, that's a reason to do this SynthIO demo is because that's what I was going to bring to show and tell. So maybe we start there, get my show and tell preview out of the way, and then we could talk about IDF stuff that I've been doing too. But first, let's just wait a little while. Are there any questions that folks have before I get into a topic? I'm happy to be interrupted later, but I really do like answered questions. I'm not always the best person to document stuff. And so I try to make myself available to answer questions kind of as a proxy for that. So before we get going on that stuff, let's. And if this looks weird, this whole here, this is where cat cam usually shows up, if cat cam was working. Which I could unplug and re-plug in and we'll see. Magically work. Okay, so we have a question from SF Dave. And they ask, how to set up Circuit Python Dev on VS Code? And we got another question from MIDI Maniac that I'll answer in just a moment. So I don't personally use VS Code. Frankly, I find it kind of heavy weight and annoying. But I do know that there is, there are other people that use it. And so the Discord's a good spot to ask. And then there is also a Circuit Python extension. So let's go Circuit Python VS Code. And I think that's this Joe DeVivo VS Code extension, I think is still working. It looks like Joe updated this in February. So take a look at that. Yeah, I just, I use Sublime Text, which I find a lot more efficient. And I don't use a lot of the fancy IDE sort of things. So and a lot of, when I've tried VS Code, a lot of the setup is dependent on these popups that say like, hey, you're working on such and such, you want to install such and such. And I'm just like, I want same defaults. I don't want to have to like go into this world. So yeah, I'm not a huge VS Code fan, even though I know that like a lot, a lot of people use it. All right, next question we have is from Midi Maniac on Discord. Oh, MCR says, sad face, the Rust risk five board is sold out. If you're really interested in risk five, there may be other risk five boards that are still available. With the same chipset. So if we look here and we say what's new, there's this ESP32C3 DevKit Rust board and you can see it's out of stat. So one thing is actually if you copy the product ID, and maybe there's a link, no, there's not link. So you could sign up, but I don't know if Digikey carries it as well. It's always a good ESP32C3 Rust. This is not a, okay, so it looks like it's not in stock. It says it's available to order, but it's in quantity 240, which is interesting. But if you really want to try a C3, like there's this other board, like this ESP32C3 DevKit, which is, they have 500 of them and they're 980 a piece. That's also risk five. It's just a slightly, it's the same chip. It's just a different form factor. Okay, sorry, Mini Maniac. I got distracted. Go figure. So have you ever added BLE to the macro pad? Well, the macro pad is an RP2040. And the answer, the quick answer is no, I have not. I suggest using BLE through the NRF. And unfortunately, like it's, it's a little, little hard to just swap one thing out for another. Like a macro, the macro pad is a pretty custom design. And you'd really want one with an NRF 52A40 on it. However, you could probably use something like this. So there's this, this NeoKey five by six. You could snap this apart to the shape that you want and then see these wires. You could connect it up to NRF 52A40 that would be able to do Bluetooth. So you could DIY it, but the macro pad as an all on one is going to be like not easy. I suppose with the macro pad, you could also like have another NRF next to it, but that would be like it's always pretty hard to manage multiple, multiple microcontrollers in the same project. Okay, next question. Thank you for all the questions. I like answering questions from David says, so to compile circuit Python, depending on the boards, you need various SDKs. What about having Docker so that it's easier to reproduce without installing all those stuff? Docker kind of fits in the same bucket for me as VS code. Like I don't find it easy. I find it like super bloated and I've just never learned it. So I would like if you're building circuit Python, like the learn guide. So this is like learn.edifruit.com slash building dash circuit Python. That's the place to go. Dan's recently added the ability to just like get the SDKs that you need. And there's just a one command that you would run to do that. Yeah, I just I just like this code. Like I've never done enough Docker to really understand it. Okay, DJ Devon three says, this might sound weird, but have you have been thinking of a way to translate Pico DVI to matrix panels? Is it possible and how might you approach it? I don't know what you mean by that. So like Pico DVI is the output, the ability to output a DVI signal from an RP2040, which you can carry over HDMI cables. So you get a nice HDMI plug that goes into an HDMI capable device and they can also do DVI signals. Like HDMI is kind of like a super set of DVI, I think. And with circuit Python, we have it so that we have display IO, which is like how you manage what is on the display. I don't see why you need to go through Pico DVI to get to a panel because we have a separate display output that does display IO to make matrix panels instead. So yeah. Going back to David about about doing Docker, that would make things more reproducible, by the way. GitHub Actions are also container running stuff. True. And in fact, somebody was, I think last week during the stream, talking about a command to run GitHub Actions locally, that could be a way to do it as well. You could also just modify your code, push it to GitHub and let the actions run. I really do like the GitHub Actions as a like de facto, like that's our supported setup, which is really nice. So yeah, maybe look into running GitHub Actions locally could be a good compromise. SF Dave says, oh cool, thanks. What serial console do you use? I use, well, I'm on Linux, so I use console, but then I use the TO command, which is very helpful and it auto reconnects. The Circuit Python Essentials Guide has kind of like recommended serial stuff for different, oh not essentials, welcome to Circuit Python. So Essentials is great as an overview of the API, but in terms of getting your setup going, the welcome to Circuit Python is the place to check out, like what apps on different OSs are best. David says, but no Circuit Python on the C3, it doesn't seem easy to type with long nails. Circuit Python does run on the C3, it just doesn't have native USB, which can be kind of hard to do, but we do have the Wi-Fi workflow, so you can edit files over Wi-Fi and you can also view the serial output over Wi-Fi. Yeah, Circuit Python is a little weird in that it needs the ARM GCC tool chain. An anecdote points out that there is a way to do a custom board build remotely. Okay, now DJ Devin 3 has some more insight on what they're trying to do. Well, let's say I want to make a project with about 72 matrix panels for an entire video wall for large resolutions. Maybe that's more of a Raspberry Pi-powered type of project. It's just a data dream after trying to connect four matrix panels together. Yeah, so at this point you don't want Circuit Python. I think these matrix panels are literally what they use in stadiums. All the big LED video walls use these panels, so I'm sure there's some solution that will take HDMI in and control a bunch of panels. It's not going to be cheap, but that's what these are used for, I think originally, is just video to matrix panels. Yeah, I don't think you want Circuit Python for that. I think there's an ECP-5 FPGA board that I think is kind of for this stuff. So yeah, that's a world that I don't really know about, unfortunately. All right, and I think I'm caught up for questions. Are there any others before I try to get some beeps and boops going? It shouldn't be too bad. And I don't have my overhead camera. I was thinking actually, like I have a pretty big desk. I was actually thinking in my new space I think I want two desks. Like one next to me instead of like for my computer. So I got this PCB byte thing where it's like to set up, capture, like this thing here where... Oh, let me switch away from desktop here in just a moment. So this is like a PC byte thing where it's a... Everything won't be covered in cat hair. I'm having a separate office either because the kitties aren't going with me. So this is like a thing where you put a board and you can use these probes to like look at signals on a board. It's really handy, but the problem is like keep moving it. When I move it, everything falls over. And so I was thinking, you know what? Like I had this desk behind me that is crowded and full. But I was thinking like if I took that desk, so all the stuff that's on this desk, like the oscilloscope, the printer, I don't know if it'll go with me, power supply, that sort of stuff. And if I could have a space next to me where I'm able to set up the boards that I'm working on that is not the same as where like my keyboard is, that would be really good. So I think I may get a second desk where I can, yeah, have like the board that I'm working on with all of the signals and stuff instead of the desk where I'm also typing. Okay, so my, let's talk USB host. So USB host is a new feature of CircuitPython 9. This is what I said I would be talking about today. So CircuitPython 9 is the next major version of CircuitPython. And when we do, and they're usually or sometimes facilitated by MicroPython updates. So we have these NPY files and the format of those files change over time. And we like to do major updates when we change that NPY format. So that's not always true. We do do major releases where we don't update NPY versions. But in this case, we're planning on upgrading or updating CircuitPython, or like the MicroPython bits of CircuitPython up to the latest version of MicroPython for CircuitPython 9. So that's three versions, one of which that's not out yet, but we're also not updated to there yet either. So that's going to be a major feature of CircuitPython 9. The IDF 5.0 update is also going to be part of that. And then the USB host support is just going to be much more mature by the time we get to CircuitPython 9. So USB host is the ability to plug another USB device into a CircuitPython device and read data from it. So I've done a couple of examples now. I've done like a USB thumb drive. The pattern that I'm using for the libraries is... And let's go back to the desktop as I pull it up. So github.com.atafruit.slashatafruitcircuitpythonusbhost. And then mass storage is the term for USB thumb drive. So here we have an example where we're using USB host. So we've tried to find the device we want and then we mount it using this library. So we can read and write files to a USB drive. That's one example. Another example is HID, so human interface device stuff. Actually, we don't have a library for this. But we do CircuitPython will automatically detect keyboards and take it as serial input, which I think is pretty neat. And that's meant to be a building block into a standalone CircuitPython editing environment. We haven't fully fleshed out yet and maybe we will for CircuitPython 9. But I think the other piece of that puzzle is having a strong way to output the display so that it's readable so that you can interact with CircuitPython. It's not just enough to have input. You also have to have a visual output. And then the other host driver that I just pushed is USB MIDI. I've got this keyboard here. And by keyboard, I mean like a MIDI keyboard, not a computer keyboard. And so CircuitPython will read the keys that you're pressing and it will generate sound. So I'll put that together in just a moment, but we've got two more questions about CircuitPython 9. So let's cover those first. So DJ Devon 3 says, does this mean updating NPY cross, which I think is what compiles the Pi files into NPY compressed files? Correct. So we'll release a version of NPY cross that is 4.9.0. And it will cover the newer changes and stuff. And yeah, they're not compressed in the compression sense, but they are a binary representation of what is captured in the Python file. Actually, NPY cross actually runs code from MicroPython. So when you load CircuitPython code, it gets parsed and then compiled the bytecode. And that's kind of what NPY cross does. And then it saves that intermediate stuff into a file so that when you load it back up, you don't have to do all that parsing. You can do much simpler loading instead, which is why NPY cross is actually, it doesn't save you memory, but it does save you mostly. There's one case where it saves you memory, but maybe not. But it saves you memory during load because you're not having to do full parsing. So yes, we will need to update NPY cross. And let's see. Somebody just rang the doorbell. All right, I'll be right back. Hold on just a moment. I'll be right back. All right, sorry about that. We're going on vacation this weekend. We got a grocery delivery, but it has alcohol in it. So they needed a check ID. Okay. Okay, so we've got some more questions. SF Dave says, when you release a new CircuitPython version, should I upgrade all my boards, all the boards in my running projects? What is the vision or do I just do it in the next project to start up? I think it's a question of whether you want to find bugs or not. If a project works, there's no reason to update. If it's connected to the internet, maybe there's some security stuff that you might have, but I don't claim that CircuitPython is secure to begin with. And then, yeah, so I think it's up to you. If you're having issues with an older version or the current version you're on, then yeah, I would recommend trying the newer one. We do really appreciate people trying the new ones because it finds issues that we hopefully fix. But I think it's a personal choice. There's nothing that's saying that you have to. I don't say that you have to. There's no reason that you would have to do it. It's up to you in terms of your risk or the likelihood of bugs acceptance. If somebody says, I'm having this bug, then yeah, it's like, well, you should try the new version because we may have fixed it. We also may have broken it again. Yeah, we may have fixed it as well. So that's kind of where I draw that line. Yeah, I wouldn't run alpha or beta builds unless you want a bug, for sure. Yes, yeah. I've been known to introduce a bug or two. For sure. Okay, let's do the demo. Yeah, I'm going on vacation for five days tomorrow. So that's another reason my brain is scattered. So what I've got here is, let's show it on my camera. So I think I showed this last time. This is a giant EVK, which is like a development board from IMX. Are you going to demo the synth keyboard? Yes, that's what I'm working on. I want you to debug mine. Yeah, then don't update. If you're not finding bugs, then don't update. This is the IMX board. It's got two USB plugs down here at the bottom. This is the one that will act as a circuit pie drive. And then this one is connected to a USB host thing. Actually, let me connect it up. So I will connect it up and we should see it pop up as a circuit pie drive. If I change the power jumper to the one that turns it on. It's so silly. Brain vacations are good for programmers. It's true. It's very true. Brain vacations are good for everyone, I think. Okay, so let's open the serial console. USB NXP. And we'll hit Control C, Control D. So it says it's looking for a MIDI device. Because I haven't plugged it in. So I'm going to plug it in now and try to find this spot on my desk. I think this is why I need another, maybe. Actually, you know what, I have my, oh my goodness. I wish I had cat cam. So I have like, cat cam was working. So when I got the groceries, anyway, when I got the groceries, then the other cat came into the room. And I happen to have a pile of clean laundry right here that I haven't put away yet. And now she is cuddled up in the laundry basket on the clean laundry. Luckily enough, though, that it's got a towel on top that she's on. So, yeah, beware, cats. Okay, so I'm going to plug in the keyboard and we'll, oh, switch back to the desktop here. Plug in the keyboard and see what happens. And then, so it says it found a device. And if I press some buttons, we see that. And then what I've got here is a, I've got a Bluetooth speaker that I bought because it has an aux input. So I should have showed, but there's a, maybe I can get it. So on this board, I'm now tethered. But on this board, there's a headphone jack. So I'm going to plug into that and we'll turn it on. Let's make this a little longer in case I need to move it to my mic so you can hear it. Oh, you know what? I was wondering if you'd be able to hear it through my audio interface. We could try to do that as well. I might blast your ears out though if I plug it directly into the computer. So I'm going to plug it in and turn it on. So that's the, did you hear that at all? How's that? Can you hear that at all? It's very buzzy. Maybe if I hold it to me. I don't actually know how to play the piano. So yeah, that is a USB, a USB MIDI keyboard going straight into CircuitPython. Let's take a peek at the code. So here's my system and I have a CircuitPyDrive and I actually have some other code.pys that are tests. David says, okay, I need that. Yeah. Yeah, it's pretty neat. There is still bugs, so beware of that. Let's reload. So one of the pitches with CircuitPython is that you can do a lot with a little. And now I complained about VS Code being heavyweight but I started Sublime Text and now it's spinning everything up. Okay, so here's the code. Let me get it. Big, big, big, big, big. Bigger. So one of the pitches of CircuitPython is that it really makes, it's really powerful, meaning it doesn't take a lot of code to do something pretty neat. So here we have nine lines of imports, so these are the libraries that we're building off of. The USB.core is the code that you use to talk to devices. Looks like that terminal shows a blue line for all the new received packets. Oh, it looks like it crashed. That's not good. Looks like it's not working anymore, does it? Well, we see a CircuitPyDrive. We can't load from it anymore though. I think we found a bug. This is how it goes. This is new code. Okay, let's go over the Python code here anyway and actually I can reset it. The reset switch only works with the one. There. There's a reset button. Okay, so let's see here. So the Adafruit MIDI library is an existing library and then the new library is this USB host MIDI library. So what we do is we say we're looking for the raw MIDI device. We look through all of the devices that are on the USB bus. So one thing to remember that we haven't tested a bunch but you can actually, just because I have one plug doesn't mean I can't use a hub to connect more than one device. So you have to look through all the devices to find the one that you want. And I'm actually relying on the fact that this MIDI class will take the device, confirm that it is actually a MIDI device and then raise an exception if it's not. So that's what this try accept is. And value error is something you raise when the thing passed in doesn't work for what you want. So it's basically like, okay, we're going to try to create a MIDI device with it. And if it doesn't work, we'll just keep going and looking for other devices. And then, so here after we've found the MIDI input device this WM8960 is a chip that's on this board that converts digital audio to analog audio that you can actually hear with the headphones. It's called like a stereo codec is the name for this sort of chip. Adafruit carries some that are neat and that you don't have to configure at all. They just, you pipe it digital audio and it figures it out. That's not the case for this one. So I had to add like a very basic library where it's like construct it and then put it in a particular mode. And I2S is the name of like the digital protocol. So this is me saying what pins to put it on. I'm doing the synthesis. So this is SynthIO, which there was a talk earlier about and I'm doing it with the sample rate 44.1 kilohertz which is what audio CDs usually think. I'm on a pretty beefy like the IMX 1060 runs at 600 megahertz so I don't think I'm having too much trouble with this. So now what I do is I take the Adafruit MIDI library. So I've set up the synthesizer so this audio.play the output of the synthesizer connects the synthesizer to the thing that connects to the actual hardware in the board which is the I2S out and then Adafruit MIDI the MIDI class here takes in a raw MIDI stream and produces like objects for messages and you can filter it based on channel. So that's all the setup. So we did 30 lines of setup and now we have another loop that's basically 10 lines and it's a while true loop which means that it just goes on forever and no exception is raised including one that like for resets. So we receive a MIDI message and we say oh if it's a note on and the velocity is not zero. We construct a synth IO note. We convert the note number to hertz and then we print a message about it and then we say hey synth press this note and then we store that note object and later if we use no objects we have to give the no object back to release the note. So we say okay in the other case if it's a note off or it's a note on with a velocity of zero and the note number is in this pressed dictionary that remembers stuff then we print another message we get the note out of the dictionary we release it and then we delete it from the dictionary and so that's all that's going on here in our demo and you'll see here's the perk for TO is it like auto reconnected although my code's not working in. Did I say USB host has bugs in it still? I just unplugged it and plugged it back in and now I found it. So that's what's going on here and these are just like this is the most basic version of synth IO where it's just like a square wave so that's why it sounds like pretty chiptuny. Oh and this thing is a sequencer so I was having fun yesterday doing there's some like sequence already remembered in it so I can... I was testing how fast it could handle so let me stop if I pause it wrong it leaves a note on so what the sequencer is doing is that it has a programmed sequence of notes and it outputs those mini messages over USB at the frequency that the sequencer is doing it so it's a great way to kind of test the USB link and like how fast we're reading it because it can potentially generate mini messages much faster than I could play the piano because it's like computer powered not human powered so let's try this again and let me know if you can't hear that well enough so I was having fun testing this so this is like the slowest actually I think I could that's like as slow as I can do it I kind of like it so now I can change the rate so yeah that was like my test that I was doing to see how well this like USB host MIDI reading could happen and I'm pretty happy with it actually I'm pretty happy with... there's a rate knob I hit it did I crash? I might have crashed oh you know what I think this USB plug is is like broken or something I think that's part of my problem can you tell if keys are dropped? I was able to tell when I was having problems because I would leave note like if you drop note off you end up with like leaving notes hanging I wonder if this either this USB cable is bad or the board that's inside here is not too happy about it and notice like it didn't notice the device was disconnected which maybe we should figure out the control C and control D now I found it again but yeah so I was happy about this it was fun so now I stopped it and it leaves a note on it so I had to stop it at the right time okay so let's see I don't know what you're talking about Keithy with my terminal showing a blue line for new stuff one cool thing about TO is that you can do time stamps and the delta time stamps are really handy so you can oh somehow I got inverted I saw this bug yesterday and I don't know what the problem is like if I yeah it's out of sync and I don't know why I did see this bug yesterday it was like if I held the key down it's quiet I lift the key up and now it's on again so I think that like I don't know where this bug is but beware there's still bugs and I think you can just control C control D it's like pretty well known in MIDI circles at some point you have to like hit the like turn everything off button SF Dave says big picture what projects you envision once you read in MIDI that's a good question I think you know an obvious one is people just want to do like MIDI conversion stuff I think that's going to be one really common use case for a circuit python is just take something in convert it to the like mouse or keyboard or something and then spit it out but all the synth IO stuff is super cool like Jeff and Todd and the person so the synth IO actually originated with a community member and then Jeff recently expanded it a lot so that's like it's super cool yeah so it's it's fun to see if people are doing that okay so now can you put a hub on the CP board and too many devices yeah you could do too many devices but in that loop where I'm looking for them you would have to like distinguish the two and read them separately it won't like it won't merge them together automatically SF Dave says Scott's roommate must not work from home yeah my my partner is upstairs I don't know oh yeah that blue line on the left that might be a TO thing I never noticed that I don't know what that blue line is yeah sorry I don't I don't know what the blue line is time stamps and TO yeah it's really handy especially like I was doing some performance stuff and it's like okay great if I'm like putting printfs in my code I can use TO to like measure how far apart they happen try opening a new tab yeah I don't I don't know what the blue it's a console thing probably not to you so that's USB host if you've tried it before it is worth updating actually let's see if this PR is it's not console doing it maybe it's TO so I do have a poll request open to upgrade tiny USB so thanks to TAC for doing a lot of bug hunting for me on the tiny USB side he added or improved what happens when when we call abort so circuit by then has this problem that you we may restart in the middle of like waiting for a USB reply so at the lowest level in this MIDI actually let's just show the MIDI library so let's let's dive a little deeper so in USB host MIDI that example is basically what I just showed you so what it's doing is close this yeah so when you pass in the device it sets up some state and then it gets the configuration descriptor so this is the thing that is a standard USB thing and it basically tells the USB host what it what just got plugged into it so now what we do is we're going to look through that configuration descriptor it's there's a bunch of different types of descriptors and there's configuration descriptor and then there's like interfaces and endpoints and endpoints are the things that you read and write to so you kind of have to like look through the descriptor and figure out like is this the MIDI interface and if so let me remember the endpoints so that's what this loop is doing it's saying like oh I'm on the configuration descriptor and I want to store config value here and then oh we found an interface and let's check the class and subclass to see if it is the MIDI interface and if it is and next so it is ordered so like all the endpoints you get after a given interface apply to that interface so like you know that like between two interfaces the endpoints apply to the one that started that region so that's how we say like oh if I'm in the MIDI interface and I'm in an endpoint then we remember that number and then we set the configuration use that one and then we detach the kernel in case CircuitPython was using it so that's only really true if it's a keyboard or an HID device that you would want to detach the kernel and then this is the simple loop so the Adafruit MIDI library takes in the thing that you gave it and says like let me read from it so we have a little bit of caching so it says like oh if we don't have anything remaining in the cache we do device.read and that's the the USB device and we read from the in endpoint that we found and we read to fill up our buffer and our buffer is 64 bytes I actually had a bug I was originally handing a buffer of the size that the MIDI library wanted to read but the USB device actually tells us like hey like we may actually give you up to 64 bytes when you do a read from us and there was some like pretty nasty bugs that happened when I was not just giving it the 64 so we read into this buffer of 64 bytes read will tell us how many bytes were actually read and that's what gets returned the first byte in USB MIDI is some like higher level thing that you can just throw away if you're appending them together at least that's what I'm doing right now maybe that's part of my bug so that's what the minus one here is so we read the remaining so it's going to give us the length that we read minus one the first byte we just will never return and then what we do is we're copying out of the buffer that we have the bytes that it actually is trying to read so we say like oh if we have so many bytes remaining we'll do the minimum of the two and then we'll so this is a slice so this will give us a portion of the buffer and then we kind of maintain our tracking where the start in the cache buffer gets moved and then the amount that's left is subtracted and then we return the slice so that's kind of like how we're interfacing how we're interfacing with this USB device if circuit python raises exception in particular you control C in the middle of this read because the read is going to wait for the USB device to actually have data to give back so we need to tell tiny USB that we actually need to abort so so we were having I was seeing some problems with aborting where like the next time your code would run it wouldn't even be able to start the read and so tacked it some work to fix that so that abort like fully clears everything and it's been working a lot better so thanks to tack for that and there's this pull request that I never got to we have this problem that like one build one build somehow got merged that is too big I'm not sure how it snuck in there and we can figure out when the build was broken and maybe while we're running out of time but we need to fix it because I have like multiple multiple things that are like waiting for this one board to build the easier way to find it is well sometimes I'll just scroll down here there's going to be a red X so the pygamer build somehow got merged into something that makes it too big and we can see here like we're building all the different languages and it says succeeded for most of them but the Japanese build was too big so we're we actually need to fix this so that everything already so that all of these things that are broken on it get fixed so maybe I'll try to do that before the end of the day SF Dave has another good question says once I have a working USB host in circuit python what kind of USB peripherals might I plug into my projects mice keyboards printers yeah so as folks are saying like you know what circuit python hosts support is going to give you is very low level it's just going to give you the ability to read and write endpoints in order to make sense of what those endpoints are doing you're going to need a driver which is what clever is talking about so circuit python has a special case for so when a device is plugged in actually tiny usb these are called kind of like classes of devices so you'll you'll find the term device class or class driver so tiny usb actually has higher level class drivers natively but when thinking about implementing circuit python support for usb host I chose to go lower level than that because I didn't want to have to compile all the different class driver code into every version of circuit python that was running usb host so instead we use the hid driver for keyboard support because we want keyboards to just work but anything besides that you would have to have a python level driver to support so kind of as I pointed out keyboards work natively internally I have a master device that a master driver I've done and now a midi one that does at least midi in there's a world where you have to do midi output as well but midi outputs actually like more complicated than than reading input because you actually have to get that first byte right I think for input so yeah like a mouse driver should be pretty straightforward hid is another complicated world where you have to like hid has reports and report descriptors and like figuring out where the values are and that report descriptor can be like it can be non-trivial if you have a weird mouse but like in a lot of cases with usb there's just like one way that is the way that like 90% of products do it and then like the other 10% is like some weird like I have five buttons and a joystick and like all that sort of stuff and if you want details on that like there's a pretty good guide about you know the reverse of being a usb device of a custom hid thing like a lot of that topic stuff is going to apply to that as well and I should say that like I think this device supports host but I think the connections I'm getting are still high speed the connections I'm seeing even on the iamax are still low speed and full speed so you know like you're only going to be able to process so much data before you run up against the limits of like what a circuit python can process through it but you know human interface devices in midi where you're like a humans pressing it like anything a humans interacting with is slow for a computer yeah man in the middle between an hid device and your keyboard maybe capturing keystrokes yeah like people have already made these projects just not with circuit python I think is totally fair game oh the other driver that I started that I haven't super polished but is a great example it's in my closet and I'm connected to the mic but there are some really old usb devices particularly in the accessibility community where it's maybe like a custom implementation of a protocol whereas and so there's this thing called the IntelliKeys which is so yeah so I bought this used IntelliKeys off eid oh my midi keyboard still plugged in and I just set the box on it okay let's unplug that gotta figure out how to tell you when it's unplugged should like raise an exception okay so this is an assisted tech device where it's got these overlays on top of this touch grid and it's pretty old they've been around a while I don't even know if there's a date it's like pretty early usb and the way this device worked is that the firmware actually gets loaded by the driver and then it reenumerates as this like custom kind of protocol so and in order for that to work with modern operating systems you actually have to have a modern driver or an updated driver and they do have a windows 10 one I don't know if there's a windows 11 one but the neat thing with circuit python is that you can do this sort of bridge thing that we were talking about where and you can like there's already a lot of code for this and Arduino as well but the idea being that you can you can interface with this custom device in a weird way that's agnostic to your OS and then convert it to a standardized mouse or keyboard which circuit python has been doing for multiple major versions since the beginning I think pretty much like we have we have the ability to be a custom usb device kind of down circuit python that works across a lot of OSes as a standard thing so being able to do like write python code that interfaces with a weirdo custom device and then gets converted to like a standardized device is super powerful so this is this is another example of like what usb host could be really valuable for so as fdave said like and this is in the same vein like what do you envision we would do with usb host I think it really is like you know it usb host conversion stuff like I'm just talking about is a big thing the other big thing is that like it's really just another way to get a human input into circuit python right so one thing I thought about is like if you wrote a game in circuit python and you wanted to use a usb gamepad like that should be easy or a joystick like that sort of thing where it's like you know interfacing with some usb hid device is like super obvious and it's still really powerful and then that's part of a bigger vision I have of just like a standalone circuit python computer where you can actually program program the computer all on its own a la like the 8 bit computers of the 80s where they're single task machines you're editing code and switching to run it back and forth there's like these modern like fantasy console versions of that sort of workflow as well and I think that's super powerful but I think part of the problems that like traditionally dev boards are bad for that like they don't they don't handle display output that well so I'm still waiting for like a really good board for that workflow and I've been trying to bug Clever in the chat to get usb I was working on regular raspberry pi chips or like broadcom chips that are on raspberry pies because like a pi zero running circuit python bare metal or a pi 400 would be super cool but you really need that like big display sort of something as well like I did a demo with like a little tft display and it's just like pretty slow pretty slow and pretty small it's kind of hard to read and interact with you know small displays are great for dashboards or like a little bit of info but they're not great for like viewing your code and editing it so I think once we have more larger displays supported hardware wise and circuit python wise I think we'll see this other case of usb host where you plug in you can plug in a usb keyboard and now you're able to edit your circuit python code all from the device itself which I think would be super cool and a great way to get people into programming like that's the whole the whole stick with circuit python is the goal is to get people into programming right like those 80s era basic computers did but with a modern language and modern hardware so yeah usb host is one piece of that okay we're just about out of time we've got 12 minutes till 4 um and I am getting it's getting hot in here it is 4.5 degrees fahrenheit so yeah I'm gonna have to take a little bit of a break before I show it to any other questions or should I do a pretty quick recap of where I'm at with the idf5 update ideally we need to fix this build 72 bytes too big let's see what broke it go to commits and now we can see here that the better alpha blend alpha blend pull request was the first one to fail it's this weird case it's a combo case so there is a race condition that happens between the cat once on my lap there's a bit of a race condition between the last build you do um ugh so like the last build on this pr was green if something else green gets merged in but like say there's like 100 bytes left and 2 prs that are pending took 75 bytes right like you merge one it's okay and you merge the other it looks okay but now you're 150 you're 150 bytes you're down 50 bytes that sort of thing is probably what happened here so it's nobody's fault but it doesn't need to get fixed um dcd says so you don't have time to fix the build or the synth bug the synth bug I don't it's gonna take some deep deep uh deep debugging to figure out how I'm getting this like inverted world it's very strange um if you summarize where you are you can watch when you get back from vacation yeah yeah and I think github now has a setting that forces this to turn on so uh yeah let's do just a quick recap esp5 idea idea 5 thing we were running into build size issues and I wanted to look into more why that was and I basically ended up um did I determine what it was well yeah wpa3 support was new I had this kdiff I had this kdiff command going kdiff um yeah so I have these two you can't see where I'm pointing there's two repos one is circuit python 8 and one is circuit python and they both have sdk config and it's always I was looking at like okay what what did they add that's new between the two because something new that's on is making it larger um and so I was taking a look through here one of them was wpa3 support um and that was like um there's also I was going to show this there's this minimizing binary size so I have another browser that's open underneath this but um they have this really good minimizing binary size page so the way that micro dev did it when they merged was that they um they just made the the room for circuit python bigger to fit the builds but I didn't want to do that um necessarily because it's like a huge pain like switching the partition uh uh allocation means that like your circuit python drive will get obliterated and everything has to be redone so fitting into the existing sizing is really helpful so I was playing around with like different options to turn off and on to get some um some space back and then I realized that like oh like they probably have a really good like they've got good tools for introspecting like uh where the size increases are coming from and they have like all these options about config that uh they recommend to make them smaller and in fact they like a lot of these we already had set the other thing I wanted to do was talk uh take a look at um like the stuff that had been turned on between 4 and 5 and so that's what this diff that I'm that I'm looking at is doing so this is SDK config is like the the complete kind of coverage of of everything and a few things were renamed but generally they weren't um you know it's an evolution like all this nimble stuff is moved um see like the nimble stuff is here like the mood detection just didn't find it um there's like these deprecation warnings and stuff that I think are just like we need to update to new apis but the one that caught my eye is one that's actually mentioned on that page 2 which is the WPA3 support um which is like a you know like a security how to get on a wifi network sort of thing um yeah so we can see here that like ESP32 wifi enable WPA is not set meaning it's off in 8.0 and then in um what will be 9.0 idea 5 it's it is on and I think that's because the default setting was changed um so I also found this page and on this page it says like hey like you can turn it off that'll save space but beware that it's mandatory for new wifi devices so it's like you probably shouldn't you probably shouldn't turn it off if you can help it here's some nimble stuff that I didn't want to touch turning off ipv6 I don't even know if we actually have it on um ipv6 LWIP ipv6 is on so like it's on in both versions which means like code changes will change uh the code size a little bit but probably not that much I think that WPA3 is probably one of the major reasons that uh we did get code size increasing I tried to do this new live nano thing and something broke so I wasn't able to try it but then under this TLS thing which is like HTTPS support basically um they do say that um a bunch of features and you don't necessarily need all of them um not recommended to disable all of these options only disable the ones that uh you don't need um and there's this note that says leave this option enabled but disable some of the elliptic curves listed in the sub menu so like elliptic curve cryptography is going and uh there's a bunch there's a bunch that they have supported for so in circuit python you go make oh and I did a reset restart so this is all not set up anymore get my environment going make and then you can do menu config and I'll show this more next week component options and embed TLS I turned off the protocol role generally we're only a client we don't really have uh we don't really have um like SSL server support uh and with 9.0 we have this opportunity to basically turn things off and see if people have problems and we'll turn the things on that they need if we have the space so I was trying to be like pretty pretty like aggressive and turning things off so there's all these different curves secp 192 224 256 and they were all on and um turns out like the ones that are less in like the numbers in there are tends to be uh the number of bits that are in the in the curve or whatever um and anything less than 256 is not really recommended so I turned those off and like got 5k back or something and I was like oh I've gotta gotta do those um so I uh yeah SSL server support please you don't get phone sensors otherwise we can turn it on if somebody's gonna add it but uh I'm not gonna do that not gonna do that work I don't think it's that much room I think we have room to turn it on if we want to um because like all of these were on some of them are insecure and some of them I don't think are commonly used so these three 256 384 and this curve 25519 I think are like the ones that are most commonly used and so I left those on and I turned these this poly 1305 and the cha cha 20 thing because I think that's the future um there's also TLS 1.3 support that I did I turn on if in these builds I have it on no I didn't turn it on so that's the future as well um but basically I found a bunch of space found a bunch of space by turning off a bunch of these uh curves that these encryption curves that I don't think people are gonna need so uh all I need to do when I get back is like do some preliminary tests that like yeah we can we can go to these certain sites or make these certain requests that it use HTTPS um that could potentially save a lot of space um and mean that means that we won't have to um won't have to change the partition table at all should be really good um and what we can talk about next time also is I've you see this is all debugging output from a script that we have so after you do menu config you get one big SDK config file and we actually want to we also want to split it apart for circuit python because we want one set of defines that apply to all boards and then we want defines that apply to a specific board and then we have a couple other ways of like breaking it down for like the S3 versus the S2 and then whether it has BLE and blah blah blah there's a script that runs after you run then you can big that splits it all apart that I've been hacking on to anyway I need a break it's 84.3 in here in the cats on my lap she has no idea like it's hot it's hot cat it's hot um so yeah so the cipher itself is separate too and yeah TLS 1.3 um we should probably try to turn it on actually we could we're running out of time next time we can play around with exactly what options and we'll have a chance during the evolution of circuit python 9 to tweak those settings and maybe find things that we don't need things that we do need that sort of stuff um and hopefully that will unlock getting this 5.0 update in by saving space anyway thanks again my name is Scott happy circuit python day if you want to buy stuff from Adafruit and support me along with the other Adafruit folks today you can use the CirquePie day code to get 10% off I don't know if that applies to everything or just some things but I really appreciate all the support personally from Adafruit and for those from everybody who supports Adafruit I really appreciate it check out DeepDive I think I'm going to do it next week 2pm pacific I'm only working Thursday Friday next week so I don't know maybe between this and the office but stuff maybe I'll ask if I'm going to step in um but I I'm planning on it I will let you know if you want to know join the discord Adafruit Adafruit.it slash discord or any of the mods to add you to the DeepDivers role and I'll ping that role if I have a schedule that I can't write anything yeah that's it happy circuit python day stay tuned show and tell starts in just under 30 minutes and we'll talk more IDF and maybe a usb host next week thank you all thank you all for the great questions as well um sorry cat can's not working I don't know what the problem is have a good night hey cat can's working hahahaha uh now it works but I have a cat on my lap can I get the camera without scaring her she's like what is that noise I'm unscrewing the camera so I can set it there's the kitty on my lap and we'll go to cat cam say hi vin if you don't watch deepdives normally I usually pet the cat at the end it's usually spook but vin is happily purring on my lap right now so have a great week thanks for joining and uh we'll see you next week and on discord happy circuit python day