 Hello everyone, sit tight as we get going here. If you are not watching this live, make sure you check the description below for time codes to skip around the video. They do tend to be about two hours or so. We'll see how this this one goes. I don't have a whole lot to talk about, so it might be a bit quicker today. But yeah, we'll get going in just a few minutes after we make sure that everything is going and and we do some hellos. So I will pause the playbacks that I've got going. Let me know that you can hear me. I'm Ostafa. Hey, Mr. Certainly. Unexpected makers up early. So sorry in advance for the chats. I know they're gonna be small today. They're gonna be small on the stream. I Yeah, the camera angle slightly different as well. Good eye unexpected maker. I'm sitting a little further back because I now have Actually, I can use cat cam to show you my my current setup. I don't know where those spooks under the chair anyway. So there's the kitty. So what I have here is now I have these Like tripod mounts so the C-clamp to like a little tripod arm on the my keyboard. So I'm sitting back further which means that I moved my monitor forwards, which meant that I had to adjust to where my camera was. That's why it's a little different. And I Hey Paul. Hey Brian. Hey David. Yeah, I got this idea from the the model 100 Kickstarter, which is the newer version of this keyboard. Somebody had that there. I'm kind of small on the side, aren't I? So I've been messing I was the reason I started like a little later than I normally do is I was messing with OBS Because I installed the version with the browser source. So the chats on this side are Was I putting the chats on the other side before? I was wasn't I? I totally was. Okay, that explains why that's over there. So let's just do some rearranging while we're at it because I remember I put it like this so that it was small. So I just discovered if I hold alt it allows me to clip and And I haven't figured out how to make it bigger. So I'm sorry about that in the first place, but So if I hold alt I can clip it down There we go, that's better I Remember I had it. Yeah, I had it set up so that when I'm Reading the chat on my monitor it makes me look like I'm looking at the chat there, too I haven't figured out If anybody knows in the in OBS with the browser source how you Ooh, there you go Clamps and magic arms. I love the factory. Thanks for the link. Mr. Certainly. That's exactly what I was modeling and after If you know how to do like the control plus to make the font size bigger in the browser Source in OBS, let me know. That's what I need to know That's why the text is so small and I don't know if you can see it But Yeah, it's not that bad if you have it big It's gonna be bad on but on small screens, but we'll deal I'll see if I can't figure it out Most office from Iran and it's night now. Yeah, time zones are wild. Thanks for joining in Thanks for Joining us Let's kick this thing off. Shall we? Unexpected maker says you can't I don't think it's really poorly supported. Yeah, the interact thing doesn't Mr. Certainly says it's legible on a 24 inch screen with two-thirds of the window. Yeah, I Do like it a little bit bigger. We'll see one thing the browser source does allow is it Control scroll wheel. I can try that Sorry, we'll get we'll get going in just a second here Control scroll wheel. I have it set up weird It doesn't seem to work one thing you can do is you can change this the CSS oh from the forums Yeah, let's see Whatever we could just do Is that for discord or for YouTube? So this is for discord that I'm And of course it makes me go You choose the render size and the options and then scale it with usual scaling I know but like that means that I would be scaling pixels bigger. I'm kind of like I Prefer it if I could render it bigger That might be for YouTube. I'll keep playing with this. I don't need to do this on the stream It's it's okay enough. All right, like It's not the end of the world Simon says hey Scott from the UK house Seattle. It's pretty good pretty nice day out not super hot Went to the Oregon coast on Monday and Tuesday, so I actually had like a two-day week But I guess we'll get into that in just a bit. Let me let me do housekeeping and then we can start chatting so David at 715 timecode. Hello everyone. My name is Scott I work for Adafruit on circuit Python Adafruit is an open-source hardware and software company based out of New York City I work remotely for them. So I'm in Seattle here Which is why you'll see times in Pacific because that's that's the time zone that I'm in This circuit Python is a beginner friendly version of Python designed for microcontrollers, which are little inexpensive computers You can get them for like five between anywhere from five and like a hundred dollars Most of the ones are tend to be about 20 or 30 dollars So that's that's briefly what circuit Python is. This is a deep dive So it's a chance to ask me questions. I'll go over some of the stuff that I've been working on And we'll just have a good casual time and talk about circuit Python and other random stuff so if you want to support me and I'm or These deep dives happen every week at 2 p.m. Pacific on Fridays next week looks like it will be on Friday as well Typically they're two hours or more. That's why they're totally casual If you want to support me you can go to Adafruit comm purchase something there I don't think we have any hot-ticket items going into the store today, but any purchases are welcome And they are I'm paid by Adafruit to do these streams along with all the development I do If you'd like to chat with me and a bunch of others check out the discord server the Adafruit discord server by going to the URL adafru.it slash discord That's what the That's what the gray box here is And last piece how it's keeping before we get into some stuff the kitty in the Kind of shade here. His name is spook. He is epileptic, but he's been doing really well Just it's just a heads up in case he does have a seizure which he did early on in the stream But hasn't recently so he's been doing really good I'll just like take my headphones off mute everything and just keep an eye on him until he's done So that's the housekeeping I got one question from Fed A2 says what would be the most expensive Circuit Python board the TI calculator. Maybe the Sony one. Yeah, I don't know how much they run for There's also This presence is kind of pricey And we do run on some We do on run on some dev boards that might be a little bit pricier as well Yeah, I don't actually know Like I don't think anything Adafruit does is over a hundred dollars Yeah, generally not not too much And thank you to Thank you to David in advance DCD for doing the time codes. It's really yeah, maybe the CubeSat And that would be a good one. I think we have more than one satellite actually But yeah, I know that At least the Cube some of the versions of the CubeSat have M-RAM magnetic RAM Is that what it is on them and that stuff is pretty pricey just on its own But it's radiation It's better for radiation environments. That's why That's why it's worth it for a satellite. All right. Well, if you have more questions, feel free to ask them Kind of where I'm at is This week has been kind of a blur, right? So Oh and Unexpected maker is offering to make a $500 circuit Python board for anyone who wants to pay a lot for a circuit Python board And DCD points out that there is the USB hub from crowd supply from Capable robotics that is more expensive and it's a USB hub as well Not really a dev board though Yeah, so I streamed last week and then I took Monday Tuesday and both like pretty much all a Wednesday off Because we went and did the Oregon coast which is like a state next to Washington It's about a four-hour drive and it's the Pacific coast of Oregon so That's what I was doing for those of you who don't know exactly what it is and So I only had like basically like I had to do email catch up And so I basically had two days of work this week. So not a lot to report. Well, oh Perfect. Yes. I do have some questions that we'll do But Besides that, well, we'll see what we end up doing So, yeah, okay, so Jason Rahm is here, which is great asked me a question on Twitter and we'll cover that in just a bit But I did see one other question come in before that. So let's do that one first From LinkedIn Joshua Gold asks Does the circuit Python slow down the microcontroller in any significant amount versus C or C++? Especially with video processing So circuit Python does slow down the microcontroller whether it's significant enough or not is dependent on what you're doing Circuit Python itself does not do any video processing right now. So it's not really relevant But in C Python land on a Raspberry Pi like Generally what you'll be using is a C library that does any sort of processing that you want So in general, it doesn't actually slow it down that much Because Python can use C to do the things that it needs to do All right Hopefully that answers your question Joshua. Thanks for asking it and Thanks for dropping by we're also on YouTube and Twitch and LinkedIn or kind of the places that we're streaming. So let's Talk about Jason's Jason's question Jason added me on Twitter and said hey look I'm looking at this pinout Let me switch to the desktop I'm looking at this pinout here and Can you explain to me what everything means what the nomenclature on this is? So I don't know why it does that weird Scaling thing, but it must be my graphics card So what I did is I linked them to this page here that has all of the explanation for everything But I thought what we would do and what I offered over Twitter is just take a look at this and go into more Detail about like what every little thing means. I thought that'd be really useful. I think it's it's a great request So let's just pull up this and I will actually drop this in the Notes as well and if folks want to follow along I'll drop the link in the Chats as well Okay, so what do we have here? This is a really common thing Pinout diagrams are very common in development boards. What they're what they're geared towards is they're geared to show you The capabilities of all the different pins Does Adafruit do mask giveaways still Not sure what you mean my mask giveaways Is there a typo in there Making that make less sense So pinout diagrams are all what they're meant to explain to you is like Here's the places that you can connect to a board and here are all the things that you can do with it So let's kind of just go Ah mask giveaways, okay, right No orders do not include masks. Yeah, okay So this is for the circuit playground express And now here what we have is these are IO so these are internal These are internal things. These are not things that go out on the pad But maybe this makes it a little bit easier and maybe I will even just make it giant so These are these are things that are connected to Pts is hi everyone There's two people that can chat as Adafruit in YouTube or more So let's just go by column so the reason that that there's multiple columns here is because It's because uh individual pins on the microcontroller. So what I mean by that is So the microcontroller on the circuit playground is this box here And each of these little gray things is a pin And uh And what this is largely documenting is what each of these individual little pins can do Um, so if we go here and look at IO this first column, I believe is just the the numbering from The numbering that you use in Arduino So if you're doing like a digital input digital output or whatever it's called an Arduino I think this first number here is the number that you would use in Arduino Um, so this is a mix of like how you would refer to it and what it can do So the second column here these pbs and these pa's and the numbers um Are are the microcontroller. So if you looked at the microcontrollers data sheet Those are the names that they would reference the individual pins by Um, and it's important to note that the names are not necessarily Numbers like pin position um So You might see like a pa 30 on a device. That's only 24 pins So the pa the pa is like port a So if you Like want to address a certain set of pins from the gpio perspective You would have them like all in one 32 bit word if they're on the same port generally So the that's what the p the a bit is and then you would b c d e different ports And then the numbers after that are like the position in that 32 bits And you have control registers that like because the the output pins can do multiple things You'll have control registers that say like oh for pa 8 or pa 9 like let's connect it to this internal function Um, and that's kind of what the rest of this is showing so um These uh kind of golden boxes these e int 7 to 9 11. Those are external interrupts So this is a function. This is functionality in a microcontroller that allows um you to take in a level of an external signal and um Interrupt the cpu so inner as the cpu interrupt means it basically like stops what it's doing Saves its state and then starts doing some other function Based on that Hello, minnesota mentat and g3 holiday. I don't think I said how do you either So that's what e int is and then the number after this is the um position I think Like which bit in Typically I think on this handy. It's like 16 different interrupt lines. Um, and so that's what the number is Um, okay, so for here um DAC DAC is a digital audio converter So this means that it's an output um and There there's an output and then I think these here are I'm actually not sure what this number is The a's are typically these a zeroes and stuff are typically what we refer to them in circuit python as um But I'm not it does this diagram tell us. Oh, yeah, so here we have um The physical pin. Okay, so I was wrong. This first column is the physical pin. So that's the position um It's DAC is digital to analog um Digital to analog. I think hi carlos Yeah, and then the the purple and green things are uh Our ide which I assume is um Arduino names like dishipu was saying um Yeah, so port pin is the name This is the name of of it that you would see in the See in the datasheet and then yeah, the gold is interrupt Um, so if we're just going through this a little bit more so we did the ants this i squared c here Um is pretty vague and I don't know exactly why um Oh, did I say digital audio? Sorry. It's commonly used for audio um, okay, so i2s here i2s is a digital audio format um And so this is just telling you like mc is master clock D1 is data sck is clock usually So that's specific to the i2s standard um This ship is says in circuit python the green ones are usually d number and then the purple ones are usually a number Right, so that's what these are so these lighter green a n's those are Those are the analog input so there's a When you have your analog to digital converter You have different inputs that you can connect to that analog input system And so that's what these numbers are the a n's are like which number that pin matches into the analog stuff um That's what a n is so these s uh two colon three and s two colon one um What these are is these are terminology. This is terminology specific to um the samd series they have this uh thing called a uh sr com which is a serial communication peripheral so there's this other piece of hardware into it with its um Other piece of hardware within the system on a chip that can do serial communications And that basically encompasses uart i2c and spy And so the the first number i assume is the instance so circum two and then the second number Is what's called the pad number um and depending on whether you're doing i2c You are or spy like the pad number can do certain things Really you don't need to like this stuff is really detailed and especially in circuit python you don't need to know all of this Um what you can do in circuit python is you can just try to create a uart and it will tell you if it works or not um So Sof i don't know what sof means um Okay, css seems to work for youtube chat. Oh nice I will have to Let me just try it I'll take a break from this So jason let me know If that is making sense Aha Thank you that looks better um Okay, what else have we covered so that's these internal things And yeah, so for circuit python generally you don't need to know this stuff um Because circuit python will just tell you whether it works or not. It will try it it works in all combinations um Arduino has like some more limited stuff. So let's just take a glance most of this is the same Um, so let's just take a look at this further. So total current of each port should not exceed 65 milliamps Um, so yeah, you don't want to drain a lot of stuff um Micro type b so these three pan these are uh pads on the back And the thing that's most useful about them is like their reset line And then also sw clock and sw dio Um, those are debug things. So these are they're they're exposed on the back because when they test it They press it down on pins that like loads the first version of all the code over those debug um Yeah, that's a good point s o f is start a frame for i2s maybe Yeah, that sounds plausible um Okay, so 26 we have a light bulb which must mean it's an led we talked about this other stuff 3v3 is 3.3 volt power Um touch so there's only certain pins that can do uh native touch support So that's what they're designated for Here's the power constraints more touch another DAC pin So the samd This is the samd 21 um Yeah, and it's actually the same pin. So if we look here speaker pao 2 and then you can see pao 2 here It only has one DAC pin. So I was gonna be kind of blown blown away by that um So here we have extra designations for rx and tx and those are just common designations for uart Um, it's the same data that's kind of encompassed in this vague s It's just being more explicit that like those work for uart connectivity um Yeah, I think that's about it I think that's about it. There are these like color designations here and that says port power group. So those are the pa and pb um But yeah, I think that's I think we covered it all um Awesome unexpected maker snag that css as well um Okay, let's we got some questions here Um carlos made an awesome microbit game. That's awesome jason says that's helpful great Okay, unexpected maker says Out of curiosity, is there a way to change io that has specific functions? Like using a crossbar bar or iomux in the sandy outside of bootloader settings um, I'm not exactly sure what you mean Because all of the iomux stuff in circuit python is done automatically um The one thing that you can't change is like if you have a spy flash connected to it But um circuit python is meant to be dynamic. So it should be able to switch different things Um, maybe you want to clarify unexpected maker Was the content one was supposed to work on the discord screen because I don't think it did I usually do 150 but 140 looks pretty good too looks a lot tighter after having it small Okay, so that is a go over of this pinout thing Um, we do have a new system for pinouts. This is kind of an old it's 2017 um Sorry, so to assign pin functions like move hardware i squared c to other pins than set up in the bootloader So we don't care what the bootloader does in circuit python Um, you might be confusing it with arduino arduino I think tends to have like a designated i squared c in a desi or and then maybe like a designated secondary i squared c But in circuit python, you can do as many as you want as long as they don't conflict with each other So you could theoretically have like five On samd you could have like five hardware i squared c's Um bus io like does all this logic for you Like if we dive deep into the code here So here's the circuit python source and uh the place to look is ports samd since we're talking about samd um common how bus io i squared c dot c um So what you'll see here is here's construct So it takes a a pin object for scl and a pin object for sda And then it calls to this i squared c get circum um And if it can't find one then it says invalid pins So here you here we can see what it's doing. So it's taking um scl and sda and then it's producing the circum and the pin muck settings So it's just going over the number of circums per pin um If it has uh So I think that's typically two so that think of this is this is the number two So it checks the first circum on the sda pin And then it sees so it uses the state of the peripheral itself the enable bit to know whether it's already in use um If it's not in use And this is the pad check as well um So so this will fail if the circum that we're checking is already in use or if the pad match Doesn't match what we need for sda And then secondarily what we'll do is we'll pick the pin mucks depending on whether it's um Like index i is zero or one and then what we do is we check the Second pin the scl pin that you're given and see if it has the correct pad Um, we already know the circums are the same. So we're checking to see if like it's the same Either like there's two circums connected to a particular pin So we see if any of them match the same index and then also we checked that the pad is the same And we set the pin box for that second uh pin and then we return um So yeah, we do it all dynamically um And that's true for basically all the stuff that we do Um, there's different ways that we do this internally But um, we try to like the idea with circuit python is you just give the pins you want and then and then we We try our best to make it work Um, unexpected maker says right. So I thought that That I thought that was something set in the boot loader for sandy that was fixed once booted But obviously no boot loader for circuit python. So yes, that would only apply to arduino makes sense um So Right, so so circuit python does have a boot loader, but we don't preserve any of this state of it Right, like we typically use the uf2 boot loader before circuit python um But yeah, we're and and this the This is kind of one of the core reasons that circuit python can't rely on a lot of existing embedded code It's because even projects like zephyr like what they'll do is they'll have a A macro or a define in sea land that will just say like this is the pin i'm going to use and compile it down Just like our dado does Um, whereas in circuit python, we don't do that. We we try to be as dynamic as we can Um, which is pretty neat and I think it's pretty powerful. Um, you can even look if we look at, um I think it's in the circuit python essentials guide I think in the circuit python essentials guide if you do like circuit python i squared c Um, it tells you how to wire it And an example case But there's this section. Where is my i squared c? And uh, it will actually try all the combinations of all the pins that are broken out. Um So it does that by just uh, it tries to Tries to do bus i o the i squared c and if it doesn't work it just de-nits it Or if it does work it de-nits it so Um, it can get you this listing of like here's all of the combinations of of pins that you could use for i squared c And there are equivalents for u arts as well um Welcome Carl Carlos Armando and angry cub to the discord Beata says, oh right. I was wondering about naming conventions regarding stemma i squared c Did I cover what you're talking what you're referring to? Or are you asking me about naming conventions? Ooh, I can add dark theme for you're talking about for youtube Oh, okay. Let me pull that up beata Um Boom now we have dark youtube. Thank you Um, okay. Let's pull up this bug that beata is talking about 46 38 What i'm gonna do is i'm just gonna click this and then change the number Add stemma i squared z singleton on boards with stemma connectors We can add a stemma i squared c singleton analogous to board i squared c to designate the i squared c bus attached to the stemma connector um We will call it stemma i squared c instead of stemma qt i squared c because some older boards have the larger non qt version So would you like me to give you tips on how to implement this? Is that what you're suggesting? Um, so the question the related question is how does board i squared c work? Yeah, um Carlos Armando the uh a great place to share uh microbit games would be like the show and tell channel in particular Um to show off what you've done. I don't know if we have a microbit channel. I don't think we do So, okay, so relatedly to this i squared c stuff. Um Neurodox says I made a branch for adding stemma i squared c But I don't want to pr it until seven is stable There is only one board that needs it anyways just an alias on every other one Are there reasons to prefer one name over the other? Uh I guess I would say One thing to think about is Tab completion. So if you did i squared c underscore stemma, you would be able to tab complete um if you do like If you did like board dot i2 tab you would get both, right? um, whereas if you If you didn't then then it you wouldn't get both so, I mean Carlo, I don't want Stuff shared privately with me You gotta share with the group or not at all well or not with me private stuff should only be for like private things, um Don't DM me Okay, so I think I covered that I think I made a point. Um Christian says let's talk about that bug report you opened first two Uh, what bug report? I opened lots of bug reports What is the oldest one we have now? I guess I could make sure that help test cutting edge builds Breakpoints is the we still don't do that. We don't do that We don't do that ability to redirect replout but Oh, yeah Let's consider it for 40 after three hours already Uh, the one by this ship about the flickering pew pew display Uh, Dan Dan's been working on the display issues I don't have a whole lot of context. We can pull it up I think this is the one you're talking about What I usually do is I categorize them So it's display IO and it's on a pew pew, which is a sandy and seven So keeping them in mechanic frames I think we're seeing this on 80 fruit boards as well. Oh, it's not display. Oh, it's matrix driven by the pew library so How similar of a matrix is that to the micro bit? Because I was just thinking about Maybe it's time. We actually have a Native Native driver for that Because with the micro bit like I probably want to like do some stuff on it from the internals I can see the display flicker with my eyes even was stable. I thought it might have been the charge pump Yeah, I would be open to doing a display Thing especially because I think it would apply to the matrix as well or to the micro bit as well Um, okay, I will remove This display IO Yeah, I haven't looked into it too much, but I it's been yeah The micro bit's kind of a weird weird thing Yeah, the micro bit has a five by five display, but the circuit playground has 10 LEDs Yeah, we're not talking about the circuit playground though. I'll show you what we're talking about We're talking about the pew pew So if you go here and type pew Uh talking about this So this is a lot similar. It's actually more it's going to be more pixels than what the micro bit has But it it's going to be connected in a similar way Uh, so yeah, it's going to be it's going to be more similar All right, uh Somebody just pinged me on the mods channel, but I cannot see it. So totally different display. I yeah Sorry, I don't Yeah, so it's not what dan's looking at dan's looking at some OLED stuff. Okay. Thanks, mr. Certainly Our mods and discord are great. Thank you mods Including mr. Certainly um Yeah, I don't know Sorry, I don't even I think I do have one of these Let me read let me read that I won't be able to look at it, but Maybe I can give some First impressions Where did it go? Because I read it off as dan would do Clitchy display random bright lines Display is very stable He's got a bad cough Oh, it looks like citrus Okay, so that's what it looked like About something disabling interrupts I mean, I think generally like Maybe what I would do is um put uh Like use a logic analyzer and when Interrupts get disabled and disabled enabled and disabled set a line high and then use a logic analyzer to see how often that happens um That'll at least confirm that that's your problem and then figuring out like What's the source of that? Uh would be kind of a separate Separate thing Yeah, so that's probably what I would do to interesting speed has been too Get bisect will get you there Yeah, yeah, just figure out like where it's gotten worse Katia wants to play I know right Okay, um Yeah, sorry. I Like the sandy stuff hasn't changed a lot um In terms of execution speed I don't know I you're following all the changes that we're doing um Yeah, it's just one of those things where it's like you could put effort in to make it faster and And you'll be able to make it faster. It just takes a lot of time Um, okay, so let's uh If folks have questions feel free to drop them in the chat and I'll answer them um I'll try to answer them but maybe I Let me update on the on the Microbit first So that's where we left off last time and that's something I could work on but I don't think it's that interesting um, so What I have here, I'm just going to use this to do it spooks in his bed now Here I have my microbit Just a product showcase mode And I'm going to plug it in and what you should see is there's actually an led or about here for the microphone That I have co-opted So that's circuit python starting up on the microbit and then It should be discoverable now So I've made progress. I had to figure a couple things out um One of the things that I had to figure out was that um It didn't have The oh come on. I don't know how to use android. So here's android and there's serpi So I will hit connect and it found it and then I can do UART service I think I can So now I should be getting stuff And if I write you can't quite it's kind of hard to see But um under this tx characteristic you can see the value l o So that's the like last line that was sent for the serial connection revealing So bluetooth is working But obviously we don't have a great Great way to see everything If you want to follow along with this microbit stuff, this is the first build that um First build is circuit python that doesn't have usb And you can see my monitor now that i'm in well in product showcase mode because It clips it a little bit when I'm doing that um So one thing I had to figure out was that um you couldn't Uh, it was trying to start up a low frequency oscillator that the board doesn't have So the flashing that it does right at the start was like super slow and I was like this is wrong Um, and I was debugging it. So when I was debugging it I was also noticing it was like in that weight for the oscillator to get going So I just turned it off and it seems to be going well now. So which is awesome um and then Uh, the second thing I had to figure out was that um When you drag a hex over it erases the entire nrf, which is going to be really really unfortunate for preserving like your file system um But what it meant was like I couldn't drag like the soft device that is like the blob that That we get from Nordic for BLE and then drag circuit python I had to actually merge the two things and then drag the the whole hex file over So that's kind of like the last things I had to do before making a pull request is like I've got a well, I've got to do the The pin naming which we started last week and I just haven't finished and then I've got to figure out how to have like a type of of artifact for circuit python that is like The merge of these two hex files the soft device and circuit python and then um Make sure that that ends up on like circuit python.org um, so that's Progress on the micro bit which led me to this thing of like obviously like connecting to the serial is not really um a thing So what I was actually working on is uh Is working on The code dot circuit python.org. So if you just go I showed this last week as well But if you do code dot circuit python.org You get this like terribly formatted. Um But like is getting all the functionality. Oh, you can't see that um Terribly formatted but getting all the functionality of uh, the web bluetooth stuff going Um now this this won't work on well, this is firefox. So this will definitely not work. Um But I also have chrome up here and I haven't gotten the web bluetooth stuff working from linux on chrome Um, but here you can see that I now have a serial spot as well um So this is what I thought I'd work on just because I was starting to work on it. Um before um is adding serial support into this web uh This web page that will be code dot circuit python.org and um also trying web serial which is a uh Is a usb serial sort of communication thing as well And that reminds me as well Also that I was trying to get the the pass through serial stuff working on the micro bit But I wasn't able to do that So that was a little frustrating But yeah, so let's take a look at um I want to just work on this stuff because I just I just got it working So here you can see like I can't type into it. All right, let's get this going I am not I am definitely not a uh web developer By any stretch of a of the imagination Hey, johnny, it's not letting me type Just not good It did manage to print which is good. So let's open Developer tools and see where we're at So it should it's like detecting That we're there, but it's not actually typing anything in Which I wonder why? Oh, I guess I should also plug that. Um, I was on a podcast yesterday with Damian Who's the creator of micro python and uh, it's talk python with me so, um youtube.com So here's the like Live recording of it. So if you missed it and want to get it before it's actually on the podcast Thank you. Thank you nair doc for linking to that Um And I'll put it in the discord chat as well So if you uh, I'll just plug that if you want to see uh the discussion we had I thought it was really good I'm sorry I'd recommend it I almost got it live Yeah, we had a good crowd. It was funny like, um, I have like 42 concurrent viewers on youtube right now And uh, we had like 16 maybe 20 and michael was saying that was like a lot for him So uh, check it out. He he records it live every week. Um, if you want to see more like c python-y stuff generally All right, let's see if we can't get this. Um Serial input working better So here's the source I'm using h term, which is a a google thing that does all the terminal stuff. So that makes it really easy Um So we did this install keyboard Hi, the art of dhg 79 Ha ha unexpected maker says it was all of us ossees making up the numbers it was So on vt keystroke Let's see what this does When the user pastes a string I'm like such a noob to javascript I want to get like all the pieces together and then have somebody who's actually good at javascript come along and make it pretty That's my goal Okay, resize 90 40 and then key So we are getting that but we're not um having it show up again so This is probably That we like generally I think what happens is that it gets round trip. So Um, when you press a key, we would send it to a device and then it would send us back that that same key um So I think what we want to do is what I was thinking is we could actually try to connect a web serial Um into all of this hodgepodge of stuff. Um, and then maybe we'd be able to do like, uh To a usb circuit python device. So Um, let's give that a shot Shall we? Um, so I think we're going to need a new button You need usb serial So that's going to make a new button. So we hit save You'll see so this is one thing I think people who are not in javascript world need to really appreciate um the tooling game of javascript folks is Like industry leading like it's really good. See like if I hit save here Like see the page is automatically refreshed like When when you're looking at places to to steal some ideas from From for a circuit python like things like this are Um, where to look like the javascript people are doing really really really cool things okay, so we call that request serial device and We have it Um, let's say if navigator Dot serial. I think that's what it is So if it's able to do that then we do, um We'll make an object request serial Add event listener click Oh, I'm just so bad at javascript Um, and I'm not used to ide's giving me braces. We'll just do on request Serial device button click a lot of this stuff I crit from other things Um else request serial Disable that's true. Okay, so we don't want to let you click it And see so I just hit save and it reran I'm not sure how you embed discord and obs, but you can try this for the font size So it's just the it's the um native It's the native app Um So I just like went to discord.com slash app and then logged in So let request serial equal document dot query selector Serial I think yep the web page. That's what I tried Okay, so now if we click request it's going to complain because the function doesn't exist So now we want a request bluetooth device button click equivalent This is just kind of gross gross gross gross Right Angry cap says in the real app you can command plus I I tried to do that I'm on Linux so it would be control, but I wasn't able to do it through the like interact thing in um in uh OBS requesting any serial device. Okay, so now what we have to do is we want to pull up the web serial API concepts and usage Look at they even have the micro bit as the example So it provides attributes and methods for finding and connecting the serial ports from a web page provides access to a single serial port The following example shows how to check for available ports and allows the users to grant it permissions to access additional ports If the site doesn't have access to any connected ports, it has to wait until it has user activation to proceed In this example use a click event handler on the button for this task Okay Reading data from a port So get ports says Of the serial interface Yeah So let's just see Let's on request serial devices. Let's await navigator serial Get devices and we'll just print Like theoretically you want to connect to an existing one I am using the OBS browser embed I just switched to it So here now if I do request serial device Get devices is not it's get ports Devices is not defined Okay, so it gave me a length of zero 90 a.m. Asks does Adafruit do regular code reviews or no? uh Generally yes In circuit python, we certainly do in circuit python All of the ci tests must pass which is basically just building every board And then you have to have one reviewer's approval um We're a little less strict when it comes to like all the libraries and stuff Um, it it'll vary a bit more there One thing I wanted to do is at least get us to a world where we're doing pull requests for everything Instead of pushing directly to the repo That allows you to run the continuous integration tests Even if it's just one person that does a pull request and then merges it once it passes That's still better than just pushing directly to the repo So that meant we didn't That's okay So now we need to so this is basically like the things you've already connected to And now we want to see Um, ah request port with a usb vendor id Well, that's no fun There's a typo Can we edit it want to fix a problem yourself? I'm not logged in I'm always kind of curious to find typos I'm curious to see how quickly typos get resolved fix typo So this is bad news for us. Um It's just a typo See it even knows Bye carlos Um, okay. I did my did my diligence. I love it. I love it when Things aren't github and you can just um, okay, so Do we have to provide Do we have to provide a filter? Because what we really want We don't want to we would want we don't want to limit based on usb stuff at all because There's like 200 plus circuit by thumb boards and we want to work with all of them um So I think we just need to try requests Navigator serial requests port Hey, yo Interesting. It does have names That's neat. So let's connect to that All right Well, we didn't print anything out um But we can say So many serials, I know right Let device equals that and console log device And I'm actually curious now whether it will um Yeah, so here we already have We're gonna have this serial port Again, so we could potentially have like a reconnect mode versus I'll like pick a different device mode Um Okay, so let's do that. So once we have a serial device, what do we do with it or a serial port? get info Open Set signals close Open with a bot right Get the readable stream and writeable stream. Oh interesting I wonder if readable stream or writeable stream would be like a good, um Interface for us to target for the beely side of things So that like we can just swap in between one and the other await read So I'm curious what this get info stuff is. So I think what we should be able to do is If we just click into here Get info I thought I knew how to call it All right, well just print it off if devices Equals one device is not defined. Oh, I always do that Huh Once again, it's just giving us usp product id and that are id Which is not enough Unfortunately, so a lot or or in circuit python 7 we're we're gonna allow you to have like multiple We're gonna allow you to have multiple serials from a single device um So I was hoping that this get info would actually have more info than just the product id and that are d um Which is unfortunate. I mean it'd be cool. Like this is enough to tell us what port it is But it's not really enough to tell us like which serials which Jason asks curious on a yes. No possible. Has anyone used a circuit python board to manage led strips? I have a couple guvvy RGB strips that have an iOS app, but would like to control them without the app Hmm. I've not heard of that um if Do you know how it connects from the iOS app to the rgb strips? Because if they're if it's bluetooth Which probably is it's bluetooth or wi-fi like You could probably figure out how to connect to it So I'm not entirely sure beally controlled Some primitives in python from mac but curious You should be able to do beally from a circuit python board like an nrf That should be possible Our api is not the greatest. I made it very declarative which throws people off And I it's I haven't Explained it very well either Okay, so we get info So this is the thing with async that I don't really get and maybe somebody knows is like Here they have this while readable loop Like where do I put that? Is it I guess I can put it in an asynchronous handler and then it just sits there um Like I could just do that on connect Um like open buffer size Right, so dcd asks so when you have n starting with two devices with the same vendor and product Do you have to interact with the device or does the user need to guess? Well, the other thing that we could look up is There is actually also a web usb spec Which I think would give us a lot more um It would give us more information Yeah, this is interesting. So this is the same guy that does the web bluetooth Uh stuff And this is oh it's updated User gestures such as touch or mouse click I think if we did web usb we would be able to get um Like more information through the usb descriptor stuff I should really reach out to this guy But yeah, I think the user basically has to guess unfortunately I mean, maybe what we could do is Try to guess the right one I'm not sure. I don't think at seven we're gonna default to having two so if if somebody You know, we could also I wonder if In the web serial api, can we give multiple options to filter? Like when we request a device like we could come up with a full list of like all boards that could be circuit python Because we I had all those like ttys things as well Um filters Right, so the the filter is just an unsigned integer. I'm not sure you can give it Oh, it's a list of filters Yeah, so theoretically we could um Provide a big long list of like all the better IDs that could be circuit python um at least to like Not have a bunch of spurious ones I don't know. I I can't I can't let myself get to wrap a hold on this um No one no one knows where I should put that while true loop I guess it's okay if it's just a callback that does Um, okay, so we have a device And let's see. How did I do it here? My circuit python or my javascript knowledge is not great like maybe we want to actually have this like switch to device But let's just have a switch to it's async function Switch to Serial I would guess the device gives you an event when it becomes readable, but I have no idea It does give you event an event when it's connected But I assume that's similar to open So we have this belee device state. Let's also add a serial device So we'll say switch to serial device and then serials Device is equal to device and that's where we'll connect So in serial connected He will say Switch to serial device and return Or if we have to request one switch to serial device here I don't know. This is all terrible code. Like I'm hoping somebody's better. We'll come along and make it better um Okay, so if we hit request device We get it there We're also printing the properties Stop doing that And in here, so if we're gonna switch to serial, you know what? Maybe we want if serial device If we already have one we want to Close I think closes the term you got javascript in my circuit python show Yes Yes Yes, you did um All right, so that'll close it if it's already a thing I think And then what we want to do is we want to open it This has been really interesting to do this um javascript stuff because uh, they're doing all this async await stuff and So it's been a good forcing function for me to kind of like See I think we might want to do this on connect and on disconnect first So let's do device dot add event listener on connect And i'm gonna pass it something Mr. Bond disconnect Oh Thank you angry cub Let's see what this is Close method. Oh, yeah, look at that Port is no longer required if you can be closed and these sorts of resources released Oh, a long message that will take a while Read until closed What is this release lock? Release lock Oh, yeah, read until closed Let's say async function serial on serial connected I think it usually ticks an event, but I think serial Disconnected I love printing. I think we need to do a bind here as well like I'm basically I'm kind of like copying I guess this does it internally out of that listener I do those binds console log Console log is so nice I don't bind it to device So what bind does is it makes the this Keyword Equivalent to that it's this is like self in python Okay, boom failed to execute open on serial port One argument required, but only zero presence. Okay, so let's look at open. I think we have to give it a Oh, you know, melissa is good at this stuff too. Well, let's say we're at the The esp loader thing All right, so we need to give it a bot rate is Totally unnecessary. Just don't do 2000. I think it's 2000. There's one bot rate that will trigger your Huh? It's not doing anything. No There's one bot rate that will trigger the bootloader Okay, if we add event listener, should it be listed here? Which is open return We're awaiting it I assumed that it would call connected It returns a promise Which the await should resolve Did I do that wrong? Where was I doing the binds? You know, I was doing the binds in This JavaScript library in a class. Yeah, let's not let's not do those binds. I bet that's what's messing us up Save that's right, right? Oh, there's no on Sounds like connect is connected for usb plug and unplug Oh, that could be it too How many reviewers do we have in circuit python? We only have a maybe Five or six that do reviews All right. Well, it looks like it's connected. So maybe let's try this reader stuff So Maybe we just do it here Device is readable We can get errors Ha Reader has been canceled. Let's just I'm gonna do that Like we want to read it indefinitely Do something with value See what that does So just not it's called device Reader is not defined that looks promising So, uh, what we have here is, uh I'm actually I have a a Particle set or particulate sensor Just on my desk because we It's the summer and we usually have smoke here, so Um, what you're seeing here is it's it's actually showing the stuff that's being printed out for the particle sensor stuff Um, so now the question is how do we get it into the terminal? But I mean that'll do won't complain about that Okay, so You need to Find Set up h term Push it feels like spaghetti code to me Um Which is fine. It's really early. So what we're gonna want here is we're gonna want this print So T Let's say let's make another terminal Equals t So Way up here. What's the difference between var and let people know? I've just been using them both So now in here what we can do is we can do terminal Dot i o dot print But then when we do print what we have to do is we need a text ink Encoder decoder Um Each term actually I think I have it not here Down here Here we go We can't see most of your code behind it behind because it's cut behind the chat. Sorry about that Uh scoping rules. The main difference is scoping rules. Variables declared by var keyword or scope to the immediate function body While let variables are scoped to the immediate enclosing block denoted by braces Called block scope Thanks patrick Um, sorry about not being able to see my code. So I just copied it Um, and I was gonna do a terminal Terminal print, but I needed a text Decoder encoding each term to app at each term um When passing data to each render string should be utf 16 encoded Print Write utf 16 print lin write utf 16 as well as interpret um So I think what we want is I think that's what a text decoder does So Decoder equals new text Decoder, I think what we do is we just do Decoder dot decode So request device opened. Hey look at that It's alive And this is why I said j s is designed to make me feel bad about myself way too many things ways to do things Yeah I mean I get it from the perspective of like we we want to be able to Like we want to be able to like change the way things work over time But we don't want to have to like move people off the old thing And I assume that's kind of why it's like that All right. Well, we got that working Um Oh, and james answered on linkedin as well. Thank you james Let is scope local var is global All right, so we can request the serial device now, which probably means we don't need to Have all of this um console logging It's like dad, what are you doing dropping stuff? That's what I'm doing Um, cool. So we have serial output. Um, but I can't Click into it and like control c control c control c Uh, it doesn't do anything So now the question is how do we connect it back the other direction? And so let's comment this out. We're not going to be done um So what we need now is we have this serial device global So we're going to want to encode into that so Let's do on key Um key is a String So we want to if Serial device if we don't have a serial device we don't care and Serial device writeable Then we do serial device dot write Thanks angry cub Okay Oh, and we reading data from the port writing to it Writeable dot get writer new text encoder Writeable dot get Sorry Oh, it's great. I'll just copy all this Ha, that's simplest, right? We should probably make a function for this because Send string is going to want to do this same thing or we could just copy and be bad. Okay And let's be bad about it. This is This is why you should test before you copy and paste James says I like to prototype in node red workflow ish But can inject javascript in the workflow works great with home assistant too The custom web page is a must if you want a web page Yeah, we do want a web page. We're trying to be trying to make code.circuitbython.org um At least set the basics expected reserved word unexpected reserved word At 346 I don't see any reason Does that make sense to anyone? It's a syntax error Bio is saved We have the right number of parentheses I don't know Is that The wrong hand People are typing It's in there because it Went down to this line Is there really no way to test the code syntax without loading it into a browser? I don't think so Where did I copy that code from? from here 459 is the same copy You could test on the browser repel The other thing I'm thinking is if I just comment out like portions of this What if I do those last two lines? p59 So that is okay And this await Uh When the awaits there It has a problem unexpected reserved word I wonder if it's the str Like it's kind of silly to call it str Like in python that would be unhappy Unexpected reserved word. Oh, you know, I wonder if it's Uh, I think this is what it is we're not this function is not asynchronous It is That was the problem You have to say you're in an async function before you can do a wait So we're still going But what happens if I do control c? Oh, look at that It is javascript with semicolons. Should I not be doing semicolons? I got some python in your javascript I want to see party popper emoji Oh That worked I'm like all about like Using emoji as variable names Agricup I got back from a social false alarm just in time to see the magic Awesome. Well, thank you for the help Um Aaron says you haven't specified the async function Lost connectivity totally delayed my previous message. You were right on I built a console key logger. I did didn't I I should turn that off It's only when there's focus on it, I think So I'm curious Let's connect back up and control d I'm curious to see what happens when I pull it Dom exception the device has been lost We didn't get the disconnect event, but we did right. I think then we would have to say request device again And it's back The other thing that I was thinking would be cool is to have um And you can scroll back and stuff too I was thinking it would be neat To have some like connectivity messages go in there as well Um, okay, so now this This page is definitely a mishmash So I can do web serial It can't do bluetooth serial It can do bluetooth files, but I can't do Web files like local files But yeah, I think it looks cool and we tested that we can write to it Um, so maybe what I'll do is I'll just like coat up high so terrible right now that I think I'll just check it all in And be okay with how terrible it is Is this the time where I need to order a micro bit v2? You don't necessarily need a micro bit v2 Um anything with an nrf is fine Um like this serial web serial stuff is working with a feather nrf feather Okay, I'm just gonna add all this stuff Even though htermjs is from the other thing I see a github pull in my life soon angry cub if you want to help me that would be so welcome Um, because clearly I'm a little out of my depth But Now you need to write an hgtp server and sacrifice on via the web repl and connect it to another tab I'm open to suggestions for how to do this workflow stuff over wi-fi Um I think bluetooth is more interesting Yeah, we could yeah before we commit it we can make it taller. I just like All of this layout stuff is is tbd And I want to make sure that it's not soup so tall that it's a pain on I'll double it I don't want it so tall that it's going to be a pain on mobile Oops It insists on opening it in firefox, which is not Now that has that that's a bit bigger Change your s back to string Was it not working? I mean, it's all terrible code I think it works just fine Like I changed all the s's With wi-fi isn't that a normal web repl? Yeah Yeah, that's one option It's just to do the standard web repl stuff Um Much better Yeah, thanks for the suggestion. Okay, let's um get this committed And that will automatically push it to code.circuitbython.org Web serial All right, I'm gonna have to wrap up. We're gonna get out of here. We're going Uh camping this weekend as well So that has been pushed and um If you look on github, if you want to check it out, let me advertise this before we go It's at github.com.circuitbython slash web-editor Um, you can see that it was just pushed 30 seconds ago Ryan says I think wi-fi provisioned over bly would be the best of both worlds Yeah Oh interesting james says, uh, I know more node red but translate bluetooth to arrest api and consume it I don't know. I think no node red integration would be really cool james if you wanted to Do that Um Yeah, yeah, sorry Um, so this is where it is any help is much like really welcomed Um, yeah, thank you dear doc for the reminder. Let's just do that Uh, we're gonna make the discord chat CSS better I should figure out how to get it. All right. Hey, there we go What's better? Thank you Shipshoop says These are awesome streams lurking and learning awesome and yeah, thank you all so uh Let's wrap up. This has been another circuit python not when I was gonna say circuit pipe on weekly meeting This has been another deep dive. Uh, thank you everybody for joining me on this adventure into javascript land Which is new for me We do these deep dives pretty much every week it On fridays at 2 p.m. Pacific Here on the discord channels twitch youtube LinkedIn Periscope for a while. I'm not sure that's going right now Um, if you want to join us on the discord, we chat there all week You can go by join that by going to a da fru.it slash discord Um, that'll get you in there. If you want to support me Financially, please just support adafruit at adafruit.com. Um, if you don't have any ble devices. I that's what I would recommend Um, picking up something with an nrf 52 8 40 if you want to follow along with what we've been doing um Yeah, and they pay me to do all this. So any any benefits to adafruit, uh come my way as well um next week should be on friday and uh, thanks as always again to dcd David for doing the time codes It's really appreciated especially for the folks that are watching this after the fact And with that I'll pet the cat and we'll get out of here. Um, and thank you everybody for dropping links in the in the discord chats So let's do cats and I'll wake him up Have a great weekend everyone. We'll see you next week He doesn't realize he's uh Gonna get thrown in his crate to go in the car to my parent's house All right, we'll see y'all next week Have a good one