 All right. Hello, everyone. Happy Friday. Looks like I've got sound from the microphones. We look good on my end. If anybody is on either of the streams, let me know if there's any issues or anything with the audio level or anything like that. We can adjust it as we go. Beyond that, though, we'll shuffle a couple of these chat screens around. Let me double-check if I did the YouTube one. I don't want to forget to do the YouTube one again. Thank you, Beata. Heads up there in the YouTube chat, which I assume means that I did. I am actually still going to go back and double-check. Okay. Yeah, we definitely did start up the fire up the YouTube machine there. Okay. So let me bring the chats back to the front here. Hide some of this other stuff and then we'll get the show on the road. Okay. There we are. And I got my screen up. Yes. Hello, everyone. My name is Tim. I go by FOMIGuy on GitHub and Discord. This is the Deep Dive program. This is a weekly live stream program where we are diving into the innards of Circuit Python. Sometimes we're working on the Circuit Python core. Sometimes we're working on Circuit Python libraries. Sometimes we're working on infrastructure surrounding the project. All sorts of different stuff just depends on what's going on that particular week. But the common thread is that it's all going to revolve around Circuit Python. If you are new for anybody that might not have seen this stream or anything like it before and you don't know what I'm talking about, the kind of high-level version is that Circuit Python, which is what we're working on, this is an implementation of Python that runs on tiny computers called microcontrollers. These tiny computers are able to execute that Python code and interact with other hardware that's connected to them. So if we click on over to the downloads page over here, we can see a bunch of different pictures of all these different microcontrollers that support Circuit Python. There's all different shapes and sizes. There's different capabilities. They have different ways that you can connect stuff up to them. But again, the common thread here is that all these devices run Circuit Python, which means you can plug them into your computer. They'll show up like a thumb drive. In the case of the ones with the USB port, some of them will use Web workflow or Bluetooth or other ways, but the sort of stock standard way is plug it in with USB. It'll show up like a thumb drive. There's a Python code file on that thumb drive, and that is just how you run your code. Once you save that, it will restart the device and run your new version of the code file. That's kind of a high-level look at Circuit Python. This is the main website for the project, CircuitPython.org. You can learn more about the project there. If you're interested in learning more or getting help with Circuit Python hardware or software, CircuitPython.org is always going to be a good place to start. The other thing you can do is definitely come join us on the Discord. It is linked down below on the screen somewhere down there, adafru.it-slash-discord. You can also, if you do come to CircuitPython.org, you can also just click on over Discord right there that will bring you into the Discord also, which actually in my case did just change my Discord to a different channel. So let me switch that back over. There we go. Can I restock the Macropad Starter Kit? Very good question, unfortunately. I do not have anything to do with stock or any physical hardware, so I can not really... I can not only not really put it back in stock for you, I can't even really offer any kind of insight about when it might be back, so yeah, sorry about that, but totally separate from me. The best thing I could say is if you sign up for notifications on the product page, that's really the best thing you can do, because you'll get the email whenever it does come back in stock, but that's about the only thing I can tell you. Let me do... Head on over to adafruit.com. This is their website, adafruit.com. Adafruit is a hardware and software company based out of New York in the United States, and Adafruit is the company that's paying the folks that work on CircuitPython. So CircuitPython is an open-source project. You don't actually have to pay money to use it. You don't have to pay money to port it to your device or use it on your device. It's totally open-source free to use, free to put on your device and then write code for, but Adafruit is the company that's actually paying the folks who are doing the development on it. So it's an open-source project, but they're paying people to work on it and then publish that code into open-source. So if you like CircuitPython, if you use it for your projects, if you think it's a neat thing and you want to see it continue to get better and move forward into the future, one of the ways you can help do that is by just purchasing hardware from Adafruit. So head over to Adafruit.com, get yourself some toys to play with. They have the microcontrollers themselves, so the devices that run CircuitPython. They also have pretty much every kind of little electronic doodad that you could imagine to connect up to those microcontrollers and interact with your CircuitPython code. So head over there, buy yourself some goodies. In particular, I'll pull up some of the stuff we'll be working with today. Today I'll be taking a look at the PyGamer microcontroller device, which is an all-in-one device that's like a little handheld gaming device. I also have an edge badge device, which is a very similar form factor, kind of handheld gaming form factor type thing. This one's a little bit more rectangular and square edges and stuff, but it's a very similar form factor. I also have a couple others here. I don't know if Adafruit sells this one. The Pico system, do they sell that? Yeah, they do, okay. Only one left in stock, though, so if anybody wants that one, you got to jump on it quick. That's another little gaming one, so as you could probably tell, today's topic we're going to be kind of diving into the world of handheld games just a little bit. Let me catch up on the chat, though, before I do get into that stuff. So how's it going? Devo Dessa. Happy Friday. Thanks for tuning in over there in the YouTube, as well as Cgrover and Jose David over on Discord. How's it going to YouTube as well? So specifically what I'd like to work on today is a system for writing a game for Circuit Python that can run on different hardware, but you hopefully not have to, like, write too much different code. So for instance, the Pico system here, I want to be able to write a Circuit Python game that runs on the PyMaroni Pico system and takes input from, you know, the D-pad there for the arrows and the A, B, X, Y buttons there. I want my game to be able to make use of those inputs, but I want the exact same game to also run on the PyGamer, right? Totally different piece of hardware. It has different buttons, in this case only A and B, right? There's no X and Y, so it doesn't even have actually all of the same buttons. But, you know, it does have A and B and it does have a joystick, which kind of is a lot like a D-pad, but obviously, you know, different type of hardware, but, you know, same type of input, essentially. So I want to be able to make a game that runs on these different microcontrollers, which all have their own different inputs available and not really have to worry about it in the code. In the code, I want to be able to just say, you know, up, down, left, right for the D-pad or the joystick. You know, A, B, if they exist, those will be the main two buttons. X and Y, you know, if they exist, then those are extra, you know, maybe start and select as well. But ideally, I'd like a layer to abstract these things away so that we don't have to worry about it in our game code. Our game code should be able to just say, when the user presses the up arrow, you know, the up direction, then move their character up or whatever, right? We shouldn't have to care about the fact that on this device, the up is actually a joystick, but on this device, the up is actually a button, whereas on another device, maybe it's a button, but it's connected to a shift register instead of directly on its own pin or whatever, right? All these different hardware configurations can exist. We want a hardware agnostic layer that's going to allow us to interact with that hardware without having to actually micromanage which device it is, what pins is it on, is it analog or digital, is it a joystick or buttons, all this kind of stuff. Today's multitasking during DeepDive is refactoring the precision VCO Eurorack module, third revision, hopefully the final, there we go. It looks like it has a feather that rides along there. And then I don't know the name of this little pin-out thing, but the little 10-pin, it's like a debug pin in some situations, a debug connector. And so that's a Eurorack module, which will then have some inputs and outputs to essentially manipulate audio. Nice, cool. Yeah, just a little blink of icon on that one, there we go. Okay, so that's kind of the high-level problem that we'd like to solve, and there are actually a couple things in place that are sort of solutions to this problem, but none of them, it turns out none of them are kind of the one we want to go with for the long term. So I'll talk about some of the solutions that do exist. One of them is not really intended for this purpose, but there is this library here called Pi Badger. This is a badge-focused CircuitPython helper library. So this runs on some of those pieces of hardware, like the Pi Gamer, the Pi Badge, a couple other devices. And it's really meant for, like, making an easy-to-use conference badge application. So, you know, hello, my name is whatever, right? Hello, my name is Type of Badge, and then you could press the button to cycle to another image, you know, play with some other stuff on there, right? One of the things that this library has in it, though, is this idea of what we're talking about, where it's hooking up to the hardware and giving us a common interface to actually interact with it. So let's see, keys, and then buttons, which is a key state, and then it has a property called button, and button you can call this property, and then on this property you can actually access the different buttons. So you can say, like, the example code is here, right? You can say, like, ifPiBadger.button.a, this will be either true or false based on whether or not that button is currently being pressed. Same thing for button B, start, select. You can also do the up, down, left, right. So this actually does have some parts of what we're after, but it has a bunch of stuff that's not actually what we're after. It has all of the actual, like, conference badge, you know, hello, my name is Graphics, has all of that stuff, and it has the primary focus of this library. It just happens to run on a few of these pieces of hardware, you know, kind of the same deal where it runs across a couple of these different pieces of hardware and it makes them all behave the same. So it's got this functionality in it, but it's got a bunch of extra stuff that we don't necessarily want or need for the use case of games. The other one that I am aware of that solves this problem to an extent currently is in the core and it's part of the stage module. Oh, well, let me see. I don't know the right breakdown. Maybe it's part of U-game or Micro-game rather than stage. Stage is the drawing. Bit of it, is that right, or do I have that wrong? Let's see here. Where's the buttons? It must not be here. I need four modules. U-game. Not there. Is it not U-game? I think maybe it's in here. The Dematrix driver. I swear there's one. Get a device plugged in here to the REPL. Ooh, I had a bunch of projects. We don't really need this stuff. TO. Oh, it's not done yet. Hold on. Okay, yeah. U-game. Is it not showing up in the docs? I mean, I know this exists. I guess, I mean, it's not a core module, technically, but I mean, I know I've seen the docs for it before. I don't know where it's from, I guess. There we go. Okay. Trigger Python on stage. U-game.buttons. This is another, again, attempt at the same thing, you know, solving the same problem. This is a... It's not exactly a built-in module, actually. It turns out it's a bit trickier than that. It's actually a library, but it's a library that is frozen into pretty much every device. So it behaves a lot like a built-in module, a core module, even though it is actually technically Python code. And I believe technically it's just a library that happens to be frozen in. This one, though, also has its ups and downs. It's actually not the best that it's inside the core. It might be better if it was in a library so that the way that you install it is normal, the same way that you install other stuff, right, with SyrCup or with copying it out of the bundle and everything. And also it would be easier for people to add more devices to it collectively as a community if it were in its own library, I think. Whereas in the core here, it's kind of buried. You have to know a lot about the SyrCup Python project and how things get put together when builds get made in order to kind of know where to go and change this at inside there. It's a sub-module, they call that, I think. It's a sub-module inside of the core project, so it's in there. But right now the thing is that you see this UGameButtons. This is the part that handles the buttons like I want to do, but there's also UGameDisplay, which is its own whole way for displaying stuff separate from DisplayIO. It's its own whole display framework that works differently, and right now these two are coupled. You can't use the buttons without the display. You used to be able to, but I think somewhere along the way it stopped working that way, and now they're pretty much tied together to where if you use the buttons, it will initialize the display, which means then that you can't use the display for DisplayIO. It's kind of stuck once the display gets initialized here. You can no longer use DisplayIO. So I want this button functionality decoupled from the display so that we can use it, decoupled from Pi Badger as well. I don't want all the other stuff in Pi Badger. So that's why we're kind of trying to tackle this, even though there are a couple of things that either could work or have worked at certain times, none of them are necessarily ideal. We're going to try to make what will hopefully become ideal. So that's hopefully enough jabbering away. If the idea is unclear at all, let me know. I'm happy to try to clarify further, but I think with that I'm just going to jump right in here and start getting dirty with some code. So I'm actually, I think going to start with, I think I'm going to do this the way that Pi Badger does, which is kind of nice. If we look at an example code, in your example code you just do this import from Adafruit Pi Badger import Pi Badger. Once you have imported this, you're able to start doing like Pi Badger.button in order to access the hardware values, whether or not the buttons are pressed. In this particular example, it's also bringing the debouncer library into the mix. If we go back to like a more simple test type one, it won't have debouncer in it, but you can still do the Pi Badger button A and all that. How's it going Nassim? And it's actually really nice because the import works the exact same way on every single device, and then the name for the buttons is the exact same on every single device. So if you run this import on a Pi Gamer, it will work and the buttons will show up as expected, and if you run the exact same import on a Edge Badge or a Pi Badge, it will show up as the same thing. Even though the hardware is technically different, this import will actually work for both. It will figure out which is which and it will import the right thing. And the magic for making that happen is actually right here. So inside of a knit, it's basically just checking os.uname.machine. And then it's just an if statement like if it is this device, then load this thing. If it's the other device, then load this thing. And I think the exact same structure as this, I believe. So I am gonna... I think just start on a device, which in my case I happen to have the Pi Gamer device as the one that is loaded up right now. I don't know what this will end up being called for right now. I think I'm just gonna say... I am just gonna say, I think game controller or game controls, game controls. I do want a knit Pi. And then to start with, I'm actually gonna make a Pi Gamer.Pi. So we're basically gonna use a very similar thing here. I think the code should switch to board.board.id. I am certainly open to that. I don't necessarily know the pros and cons or even differences or anything about it. I will steal this one to start with. Us.uname.machine gives us this name and then board. Okay, gives us lowercase one. So the statement will have to change, but the... And this is guaranteed unique, right? This must be unique across all devices. Let's try one more just to make sure. I'm gonna do the... Well, we'll try a few more actually. I've got a handful of devices here to try this on. Try the edge badge as well. It doesn't seem to power on. It does have a switch, which I do trick myself with a lot. But I checked the switch and it seems like it's turned on. I'm running PicoSystem. I'm running PicoSystem. Nice. Okay, that's the directory and the idea in circuitpython.org. Interested in seeing your approach. Similar for PiBadget, PiPortals, featherwings, creating some classes of buttons, controllers. Sounds and displays. So I am focused just on controls now. Not really worried about displays and sounds right now. Mostly, like, for displaying, I'm trying to get it to work with DisplayIO. So I'm trying to just get the controls straightened out. But yeah, once we do have controls, it would be nice to have a larger sort of game framework all of these types of things are things that are typically handled by a game framework so it would be nice to to get to a point where we have one that kind of does a lot of that stuff for us oh why did that close oh cuz I unplugged it it's unfortunate I don't think I saved either so I'm pretty sure we just lost not that I had written that much but pretty sure we just lost whatever I had written I wonder why the edge badge didn't turn on it doesn't turn on either that's awkward now this is on so my USB hub has buttons for each plug in it which are supposed to turn on and off the ability for that plug to work however the plug that I've been plugging these things in with is technically off but some of them were working so apparently off it's a bit more like a suggestion hi badge okay I was going Brian Gregory over there on the YouTube there's a front view of the Eurorack mount module we were talking about before so yeah unfortunately we did I did lose lose the code so we're gonna have to try to be a little more careful I guess I'll start I guess I think I'm gonna start off of the devices I'm gonna do it on on my PC and then I'll copy it over game controls let's bring back our in it guess we could just rewrite it if board up board ID and right now I have edge badge which says pie badge as it's one and what we want to be doing is importing a thing from a file as something we will have one file for each type of device so I'll make a pie gamer file I'll make a pie badge file start with those two once those are working we'll move on to some others inside of here let's get back to here first let's say from how does it work they have a dot there interestingly from dot pie gamer import controls game controls we give it the full name they could always do as they say pie badger base which comes from here I guess we'll want that as well we don't really have anything to extend and I don't know I mean eventually like we'll have buttons these this one actually has a property that's called but on singular but a button dot be ours would be game controls that do we want keep that the same and just do dot button so technically we also get to make some choices here as well we don't like we can do it the same way as pie badger we could do it the same way as you game or we could also kind of shift it be some mix of whatever makes the most sense in the new way personally I think I prefer pie badger as far as using properties to access the values whereas with the you game one you there's not an example of the code here but you have to use a bit it shifting I think bit shifting you have to like get the value and then check if the shifted value is equal to something in order to find out if a button was pressed which is not too bad if you have done it or are good with Python and stuff oh yeah there you go with that and excuse me not with the bit shifting I guess with whatever that is bitwise maybe not sure I think properties though honestly are probably easier for folks who are newer so I think I like this very better where it's just properties do we want to have it like this where it's game controls dot button dot a or do we want just controls dot button underscore a so the way this works is it calls update which on this device is a key states which actually comes from base this one's using keypad under the hood we do get to decide if we want to use we I mean we get to decide much everything we get to decide if we do want to use keypad or we could just drop back to digital IO and if we go back to digital IO then we actually don't have the problem that this class is solving which is the fact that with keypad it's not really storing the state it's giving you a way to access the events so like when a key gets pressed you can be notified by calling you know a property to check on it but you can't really just say at any given time like is the a button pressed no scratch recovery file I think I closed it or something there sometimes are but in this case it it went away it may still be in there somewhere if I went and dug through temp files or somewhere it may still be there but it wasn't enough code to really worry about I think I I'm I think I actually want to just switch back to digital IO instead of keypad because if we just use digital IO then we actually don't need to have this whole class so in controls base did not want this so another thing I would kind of like to avoid if we can this is creating a tuple every time we call button which is I'm sure probably not the end of the world but if we can write this in such a way where we don't create a new tuple every time it gets called and I think we save a bit of RAM probably or really what we save is like time that the GC will have to run because we'll we'll use the RAM and then we'll throw the variable array and eventually it will get GC'd but we'll have to GC more because we're using it to keep creating that tuple if we can keep an object in memory and just use that object I think we won't grow and therefore we won't trigger the GC when using the pie charm for circuit Python can you run the code with it and print data to pie charm yeah good question so a couple of things I'll answer your question that's as I can but another thing I'll say that's really good if you're interested in pie charm and circuit Python is in the welcome to circuit Python guide there is a page called under advanced setup there's a page called pie charm and circuit Python I'll link this in the chat here for you this page will I actually wrote this page and it explains in detail exactly how I set up my pie charm to work the way that it works so this will help you get set up to answer your question more directly though yes so I so currently the code that I'm writing like this exact code right here this is actually just code on my PC it's not on the device yet but what I have set up is I can see the device so this is my circuit pie drive for my device that's connected which right now it's the edge badge if I scroll down on there and look inside code pie we can see the actual file which in this case it is radio mail CLI thing which I probably have a backup of maybe CLI messenger let's compare that so I'll go compare with code pie and they are actually they are actually a little bit different not by much couple typos fixed different numbers a print removed a new line a couple of changes anyway I'll keep another backup of it so I'm gonna take code pie I'm gonna copy it as RFM mail CLI now I'm gonna go back to code pie can delete everything that's in here we can go print hello deep dive I'm gonna save it I'm gonna do control s the way you can tell visually is the asterisk here so I'm gonna do control s and then on my device currently right now I am in the repel so therefore when I saved my code didn't run but if I go control D inside of here now the code will run so the print out hello deep dive now executed on the device that's connected printed this out and it printed it into the serial oh that was it printed it into the serial output which I then have connected into this terminal window inside pie charm specifically I'm connected with program called to which is a serial monitoring program so I get connected in there and then I can see all of the outputs from my program I can also do control C to get to the repel to test stuff out so hopefully that answers the the question and so yeah like I said before yep I was originally I was editing these files these are on the PC so eventually I'll move these over to the device and then we'll be editing them live there as well but I'm starting off here that way I don't accidentally unplug it and then lose my work again eventually we'll probably want to define in here like the property but I think I'm gonna mess with it just yet I'm actually gonna go in here first and just say how do we want to do this we definitely needed a knit here so inside of here we're only ever gonna be getting to here on the pie badge so in here we just need to set up the digital IO stuff go circuit Python essentials really now but maybe the answer I think the answer is different things like I think we have button a button be button up button right button left rather than like button dot up down whatever we have underscore we have different variables I think is how I'm gonna tell I'm thinking at least so far so we basically want to set up the digital and out we will set the direction to input we'll set the pull actually no I guess I mean we could mimic what's in well but this is keypad is it say the pull direction well it's also on the shift register I guess is that on a shift register I thought those are they not just wired direct we should update circuit Python as well okay yeah no those are on shift register button clock latch out okay so we don't need digital IO we need we need shift register stuff which that have one of those in here doesn't actually this is making keypad shift register keys is that the only isn't isn't is there a non keypad way to do shift registers only two matches shift register keys how did it work before is that a library something is like weird here it's all dark I can't scroll right this is being used as outputs is that actually how these are connected so actually thought these were just direct but it turns out they're not okay so we got a we'll have to see I'm gonna try this library are any of these inputs these are all outputs it seems like this do inputs okay it has a digital in out so I would assume it could do inputs maybe we'll also submit an example of inputs it doesn't have one yet so I am actually just gonna try this in code pie so for the spy bus we're gonna use button clock button out except it would be me so wouldn't it because we're going from the shift register we're going out of the shift register and into the microcontroller microcontroller in s thing out I don't know what the s stands for serial latch pin is button the latch I didn't know that was a is it tech I didn't know that was a spy bus is that actually technically a spy bus SR import this all right we need to install a library I am going to do it in style here I could use circa or I could go download the library bundle there's the thing I'm looking for like me so is a kind of soup I believe you're right yeah I think so just go to a circuit Python manager shout-outs near a doc what's the command to run it npm does that it just npm start yeah I think it was right vice libraries we want the 7s I think it's this one but I'm not sure 7 4 hc 5 9 5 and 4 hc 5 9 5 yeah install install what's devices technically built in to the core these days we don't really need to print this anymore let's also just go while true time that sleep if in one value say just pin one true I don't really know if it's like higher low import that I've no idea which one pin one would be but let's give this a try so I'm gonna save that we are still in the repel so it's not gonna run so I'm gonna control the invalid pins line 10 okay so it does not it does not actually spy bus it seems like I mean should we still do this we should still do the actual ones this this is base test a badge shift register keys clock data latch he counts value when pressed so this doesn't use the spy bus is there any way to I mean there has to be a way to read a shift register other than keypad right is there not there must be a way for me to read this with a different core module or oral or a library but it's not this one it seems like unless if I did this wrong should this actually be like that didn't change that invalid pins well already trickier than I thought it was gonna be but that's how it goes sometimes I mean we could just use the keypad one but then we have to have that whole key states class if possible I'd love to not need that what was the old way but the old way I guess was game pad or something game pad and pad shift I believe does not exist anymore maybe I'm wrong well but also on an old version here how do I set up terminal with screen or to the guy doesn't say I'll try to go back and add it but all you do is so terminal that window is built into pie charm you should have access to that by default you might need to go like view windows and find it in there and turn it on once you get it showing though you just you just run the command to so you have to get to installed I think I did that with either apt or maybe I downloaded it via get and then installed it that way I don't recall for certain once you get it installed though you just go to and then you point it to the TTY which on my computer the first circuit Python device I plug in always shows up as the exact same name here TTY ACM zero so what I tend to do is just go up enter because it just stays in my history in this terminal so his game pad shift still around we could be updating also maybe it says no documents I'm thinking not so we might have to use keypad I guess which means we're gonna have to have the states thing I really thought I'm surprised there's not a more general way to read the shift register yeah I'm really surprised there's no other way to reach it I mean I maybe I'm wrong but I'm that does that that would surprise me if there are no other ways to read shift registers somehow broke the search again well so we pretty much so we got to use keypad which means we have to have the states thing or we have to change the API to not be kind of like property based date based so do we want do we care do we want to have it be state based or do we want to just move it to be more event based I feel like state based is easier for people who are new to programming to be able it's it's easier to convey the concept of like you just ask it like hey is the a button pressed and it will tell you true or false at any given time and just when you ask it it will check and if it's true it will tell you true and if it's false it will tell you false whereas keypad is actually not really state based you can't just say at any given time you know hey is the B button pressed right now or not all you can say is like hey are there any events if there are events you can iterate through them and find out like is one of the events a key press event and if so is it for the key number that corresponds with the a button but you you only get the event that it that it has happened that it that it's in the process of happening rather than being able to say you know the state is the B button pressed currently think it's worth I think it's worth bringing it over I think the state I think the way that it works with the state makes it easier to understand for folks that are new one thing is to this could move out of pi badger into game controls and then pi badger could use game controls so then we're gonna be taking very much almost the same code from here that case initialize keys initialize key states I have a button property so this actually it's twofold actually it creates a tuple here but then it also creates a new one of these buttons class which is a named tuple here so it's making two tuples and one of them has names is there some way we can do that without having to create two tuples this has pressed we could keep a dictionary and just updated yeah I think I like that might come up with a better name for it eventually is that creating a copy of the dictionary each time if I return this at the end here is that creating a copy technically gotta call it a day now thanks Tim good night all yep take it easy Dave Odessa we'll see you next time have a good night so this was going for I in range I didn't know the order of these all the guide said was connect to your device using screen or to you then you can see output to interact with it in the repel how would I get screen or to you and set it up on Windows unfortunately I don't know how to do it on Windows yeah sorry I only really have experience using those things on Linux on Windows last time I used Windows I did not use the same workflow I think to you is maybe not I think it's Linux only or Linux and Mac I should say it doesn't work on Windows means you got to use something other than it really what you need is a terminal based serial program anybody else if anybody else is in the chat that happens to know one that works on Windows definitely drop it in the chat fortunately all of my Windows knowledge is kind of outdated at this point real-term engineer terminal see the tricky bit is like you don't like like last time I did use Windows I would have used something like putty putty is its own whole terminal program really what you want is like a command line program that you can run in an existing terminal but I don't know I don't know of one so yeah sorry I unfortunately I cannot for you too much help there I'll try to do some more research but I cannot really promise that I'm gonna come up with much I would encourage you to drop that question maybe in the help with circuit Python room in addition to like you got it in the YouTube here but if you put it on the discord in the help with circuit Python room you might have luck with somebody who's on Windows having some more insight into a good tool to use I just don't know don't know what they are has a go and love the factory over there in the the land of the mountains let's see here so how does it know the order of these things it's kind of interesting right it just I guess I mean it's just hard-coded to say EA start select right down up left happens to be the order of this one how do you do make the discord once you get in there there's different channels and one of the channels is help with circuit Python just the perfect place for that kind of question so this was EA start select right down up left we have too many we should only have we should be zero through seven zero one two three four we skip five those should be in the right order for this device they'll have to change for other devices when we call update dick we're basically just gonna go actually left out those we're gonna do that so that's looping and it's just saying buttons that was pressed I don't know we might not need these trying to think I mean a loop would be concise way to do this but perhaps I close go be right back hope they're right here actually nice loop would be a concise way to do it but just writing them out would probably be easier to understand less magic numbery so basically just do this for each one of these probably some way this could be a loop instead but it's alright I think it's like very easy to understand this way it's like quite literal doing what it's saying the order doesn't really matter since we did the order up there in the correct order for this device it doesn't really matter down here which order we do it in okay so then this will update the key states objects it will then update the dictionary object why is this yellow unresolved what oh I see good enough we'll then call this it will then return dictionary the current state of the dictionary okay I think we're almost possibly usable at this point so I'm gonna take this put it inside lib here and I'm gonna start writing code pie to try to use it so to start with we're just gonna say import game controls no for we want from from game controls import game controls which would then import from the specific one of these that it found which actually needs to be declared here so this defines the class and then initializes an instance of the class in this variable called game controls which is what will get imported here and in turn what will get imported here um I don't know I gotta run to the restroom though so I'll be RB sorry cannot import that's such a generic error cannot import name like this is basically the same let's make sure this is working I guess print on high badge we get that printed or one thing we're still I'm editing the one on the EC close all maybe I had my statement broken on that one so they're not on self technically they're also not visible this way you need to be outside of this or control R for replace oh unfortunately we have a bunch of extras actually that's not very helpful is it well okay got running on pie badge it's not spamming the terminal already are these crossed out oh because I excluded them yeah yeah okay so theoretically if I start pressing buttons you appear to have lost discord oh you're right I must have shifted the that's annoying and how long ago that was but be back there now thanks for the heads up there who was that by the way I appreciate that the other over on YouTube yeah appreciate the heads up any anytime anybody sees if anything is wonky or if the chat stop working if they're not scrolling if they disappear feel free to let me know on whatever channel happens to be convenient so definitely appreciate it so I will don't have the camera loaded up yet but I'll get that just so we can at least kind of all enjoy the moment of truth together if it does actually work out for us which maybe it will maybe it won't always part of the fun okay edge badge so theoretically if we start pressing buttons we should be seeing some things get printed and we did everything right there's no d bouncing so it is probably just gonna spam yeah start select okay so all of those are working that is kind of the core structure of the library each device will have its own one of these files we have pie badge we have pie gamer they'll all extend from base and they will all provide a dot button property and that property will return the same type of object so in our case a dictionary but the different implementations inside of a knit and update well inside a button really and a knit those will be different for each device so did I actually edit these I don't remember now so what I'm gonna do is just take a copy of that stuff back just it there overwrite these so now we've got the latest version in both places I'm gonna do the pie gamer one which is actually gonna start as a copy of this except we'll change pie gamer game controls and then we will need to go look at how it works also this we should erase it because docs are not correct anymore this works differently it's not button dot a or b it's now a dictionary so you need to access it by a key which is a string erase those for now we'll do that and I think this one does it have a shift register also it does but it doesn't have as many buttons on it it it only has a B start select it does not have the D pad because instead it has a joystick so the start of our setup is gonna be the same but then our joystick is gonna be a bit different off that joystick oh I guess we can have that I wonder if I can like okay I wonder if I can tell my pie charm to always wrap that and try catch somehow that I mean I will say if we are trying to avoid creating tuples this is not the best because this will just create a tuple maybe let's just do it this way let's copy these let's go here with them let's take that out so this is all part of update essentially these three things are about updating the actual like getting new data from the hardware and then this one is about updating our dictionary to have the correct states right you would actually need to get those inside of here I guess I got the whole thing commas radically that should work you are back on the PC so I'm gonna unplug the pie game no the pie badge we're gonna plug in the pie gamer you know it would have been nice though is if I could have kept the script from the pie badge yeah I'm actually gonna plug it back again and I'm actually just gonna copy this and go inside of here and paste it and call it simple test for right now eventually we'll make a full repo we'll have an examples folder we'll have the correctly named simple test all that stuff will happen eventually but to start with I'm just gonna do it this way it's refresh here no module named game controls okay so I'm gonna close these I'm gonna open the code on the device we have the original one which has files but no code so this was the one that I unplugged and we lost the code from initially so I'm actually just gonna delete that and we're gonna take the latest copy of this here drop it into lib we don't have a printout for pie gamer but it didn't crash so that's a good sign a button you button start elect so we actually lucked out on the order of those as well theoretically we might have needed to change those but in this case it turns out we didn't the real question on this one is the joystick so I'm gonna go up nice right and down and left and then theoretically like diagonal we should be able to get like upright upright like that which we do so that should work as well all of those are looking good hi gamers good to go we did not actually edit the code any so the version that is on the PC is still good up to date I should say so next device primary Pico system Pico system board board board ID it'd be primarily Pico system do we think we could ever run into a situation where there's a different Pico system I was going Nick Quinn man 16 hi y'all from YouTube and discord has gone my friend thanks for tuning in hanging out in the chat here so on this one we have what we have SW down left right up SWX SWY SWA SWB so in this case on this device it looks like it's not on a shift register instead there's just eight individual IO pins four of them are ABXY four of them are up down left right and on this device there actually is no start and select so those would not exist here so one question that we do get to consider at this point is what do we do how do we want to treat it in situations where the buttons don't actually match up theoretically we could probably take that down to four on the pie gamer as well it seemed to work but technically I think there should only be four on the gamer since the joystick is analogs I think it's worth considering how to treat the differences like because this one has X and Y but no start and select do we add X and Y to the dictionary do we just reuse start and select even though that's not how they're labeled I don't think I like that idea so I think we add X and Y to the dictionary and it's just up to the user to kind of check like if the board has a start button then you can pull it otherwise you could try a different button maybe I think D pad and A and B I think those should be the buttons that we strive to have implemented on every single device that uses this library D pad A and B XY start select are like more on the optional side so this one's not connected with a shift register it's actually just connected straight up so we may as well still use keypad though theoretically we could just use digital I oh which is how I had thought about doing it originally and we could still do that but we already have to have the key states thing like my main motivation for wanting to do it that way was to not need the key states thing since we're gonna need the key states thing either way I'm just leaning towards using key pad here as well and basically want something like this that out here I guess he pens people and we'll try to keep it I guess in the same same order order as we have up here I guess so SWB was the name on this one SWA we don't actually have start and select so that's where it gets weird though I guess yeah cuz these would be they don't exist so then I guess we get to I guess that's where we would put our X and Y then don't know that it necessarily makes more sense one way or the other as far as which one comes first but go XY and then write down are you impressed I don't know about the poll theoretically I think that should work okay so these are just constantly tripping everything probably that means that we have the wrong value for this that's still spamming when perhaps let's stop spamming at least so don't know if it'll work but up in the right direction I suppose a button you button we want so we actually I pushed the Y button you got select in the X button start maybe Y X left up right so that is good we did have to change the code a little bit so I'm gonna copy it back where we get the updated one with X and Y instead how we got this back even though I deleted that I thought in both of them that there so that it's actually I must have saved it on the device okay ecosystem is good the other device that I have here to try and implement is Pew Pew M4 which I think pretty similar to the Pico system in that I believe it has all the pins we have a much much much much older version although I it doesn't reset button hey whoa geez you guys see that I don't know if you came through in the video but cat totally just jumped up basically like to my shoulder essentially he jumped up to the top of my chair here yeah where was I okay so it's much older I'd have to use a wire though because it doesn't have a reset button we're just gonna leave it for now yeah yeah button down button left button right button up and then it doesn't call them a B X Y calls them O X and Z and I think what we'll do is we will try to keep the same order that the Pi badge library did which is using O as B and X as a this one pretty much will just be a copy of Pico system there's no board ID it's too old we have to update it all right so I need a wire at least one wire we could probably get by with one wire this one's tricky show this and a tough week pretty much just have to like oh wow I cannot believe I'm pretty sure you have to double tap that and I don't think I did intentionally I double tap it so I am beyond surprised that we just got to the bootloader on the first try right there but not gonna complain usually that is a much more involved process for me on this device here we go oh still disconnected I wonder if it came back as TTYACM1 or just like not at all it's gone all together is it doing stuff it's like still partially there I'm gonna reboot it this will work right I don't know why we would not have a serial port I mean it was connected before we had an even older I forget what version it said but I think it was 7.00 something it was this like just a thing where newer ones have a broken serial or can you double tap with the switch here no I can't go fast enough for that there's no way I don't know if it works that way anyway honestly get at that time for that time for that time it's more like what I'm used to on this one I'm like bending my pin here as well on my wire it's not very good I getting the bootloader on this one oh but I can't get the serial I was gonna say isn't there a command and repel to get to bootloader but I can't get the serial that doesn't help me all right we got it I am very confused that that's just gone now not updated I copy the wrong one that's where I copied 733 yeah I did copy 733 because I rebooted and now it's got 733 just didn't reboot I guess but it's still not connected here I've gone pole okay happy Friday um well we have kind of ground this one to a screeching halt haven't we I mean I need I pretty much need to be able to get to serial if I can't get the serial it makes the whole rest of this a lot heck of a lot harder because without being able to get to serial I can't see the printouts from the test script to know if it's working and I can't get to repel to look at the output of like dirt board and board dot board ID but I'm very confused because like we had a serial connection before I did dirt board that's how we found the name of the pins here we we definitely had a serial connection here but I updated circuit Python and then we never got it back after that we were on 700 alpha 5 which is very very old but let's try it again I need to wire a button in here so I can try that time not too bad 7000 how's going DJ Devon 7000 so somewhere between 700 and 733 the serial port stopped working on this device feels very very weird if I'm honest but let's download a few more so we'll spend the last few minutes of the stream here's trying to see if we can tell at least the major version where this stopped working unfortunately that means we get to play more of can Tim get to a bootloader maybe not the phonest game but getting better I can't believe I got it on the first try the first time let's do 710 next it's gone so between 700 and 710 which are basically these well except for the two there's a two alpha in there so beta 0 beta 1 beta 2 beta 3 and then RC 0 RC 1 beta 0 only going to check one or two more of these and then I think I'll sign out for the night if anybody's got any other questions or comments or anything definitely now's the time to try to get those in the discord or the YouTube chat somewhere in the chat that I can see got it first try again for anybody interested I will be back in the morning tomorrow tomorrow morning at 10 a.m. central time I'll be back streaming again over on my own channel when we go underscore twitch I will post links in the live broadcast chat in the morning when I'm getting ready to start so if you want to watch on YouTube you can just watch for those links because the YouTube link changes each time I don't pre-schedule it so I can't give out the link ahead of time if I sag nested game controls sounds perfect nice that's interesting now we got stuck on blinker I wonder if it's did it not reboot all the way I think it didn't reboot all the way I probably will work on this a little bit tomorrow as well as maybe some other stuff too the pipeline like getting back into bitmap tools I implemented a few more of the bitmap tools functions that I worked on last week on this stream I think so now I don't know I don't recall for sure but definitely last week it was either on the deep dive stream or on the Saturday morning stream I worked on bitmap tools I did implement a few more of those off stream last night I think it was I was working on that we have just the harder ones are left so I may try to tackle one of those on the stream tomorrow but I also want to work on this some more 710 didn't I 710 beta 0 okay now that is right 710 beta 0 and it does show up of course it does have a few more to try here beta 1 this again I should say shout out to I think Todd but I'm pretty sure Todd bot is who made this asteroids game if I recall right I if I'm incorrect and I do apologize I hope I got that right but I want to say that was a Todd bot creation from a couple of months back Todd bot released it and then I tweaked the code ever so slightly just to get it to work on this device or like stuck