 JP it's time for John Park's workshop. That glare is going to bother me we'll move this later. Asking I am gonna pop over to the Discord chat there and I'll also say if you're wondering where the chat is at and you are somewhere like Twitch or Facebook you might want to head over to our Discord it's right there it's adafru.it-discord and that will take you to our server then look for the live broadcast chat channel you can see it highlighted right there that's where the conversation is happening during the show so come on by and say hi hi I had a question from how's the construction and someone asked about the roof it is ongoing but after some major noise and dust and insulation particles everywhere I have cleared out and cleaned up a bunch of stuff in fact it gave me an opportunity you might not be able to tell but this has previously been an enormous mess of stuff that just gets shoved to the side and I managed to do some organization and cleaning of that so I'm actually better better than I started and the workshop now has insulation on the roof and a new roof and a vent fan and I'm curious if you can hear that vent fan they told me last night they couldn't hear it over the iMac mic and I doubt you can hear it over the lav but there is a vent fan there was not before there was just one of those whirligig things you may remember when it would sometimes squeak before I oiled the thing it was that one is gone and a nice new one with an actual fan that I can switch on and off is in place and that'll help a lot with just pulling out some of the heat during the warmer months which is most of them so yeah let me know I'm curious if that's a if that's an ambient background sound that's that you can perceive over the mic it's probably not too loud I'm guessing I see I see it on my little mic meter that it's it's aware that there's background noise but hopefully it's not too bad also I want to say hello to the people over in our YouTube chat so hello to Davo Dessa, Bart Zercher, Gary T, thanks for stopping by, thanks Andy, Andy Callaway says about the same as the AC which I'm not even running right now I had it running earlier it's in the 70s here so not too bad but now I've just got the fan pulling some air out alright so that's enough about that what's going on in the show today so I've got a coupon code for you if you want to go and buy some cool stuff over on the Adafruit store today at a discount that'll get you 10% off I'll show you that in a second I have a little one minute wrap up of this week's product pick I've got a circuit python parsec for you what else is happening the project status so we're about to I'm almost done with the code for the power wash simulator controller which is really exciting a lot of fun it's been a cool collaboration with C Grover Cedar Grove over there in our chat on a bunch of cool stuff about calibration and offsets for this nine-dof sensor I'm gonna put a guide together on that I've actually started it already should be pretty quick and then I'll be jumping on to the Pokemon auto automator using a Pico also that should be a pretty quick project so I hope to get a couple of learn guides out pretty quick for your viewing pleasure then after that I've got some neat stuff more stuff involving Lego I think I'll be doing another Lego project for the holidays done done done and there's something else in there too so lots of cool stuff coming up so let's see first off I'll say if you want to go over to the store head to Adafruit.com I know some people were able to pick up a Raspberry Pi 5 last night during the Ask an Engineer so hopefully we'll be getting more of those in stock I think we sold through a couple hundred of them just Pi 5 just get you there Raspberry Pi I get you to the there it is yeah so the four gig was the one that was in stock last night's out of stock now and then there'll be an eight gig coming at some point I did not bother picking one up yet because I don't have any any bandwidth or plans to do a Pi 5 project for a while so I'll wait but hopefully if you're excited about getting one keep an eye on our social media and watch our live streams I think that's the best way to be aware when those come into stock we don't take pre-orders on those Phil talked about this last night we don't want to take your money when we don't have something to ship you and have you play that frustrating game so it's the policy of the Adafruit store that you can buy it when it's in stock otherwise you can get on a waiting list but we're not gonna accept your order no pre-orders so I've teased it there it is filthy that is the coupon code today so if you want to go over to the store pick up some cool stuff you can tell I've got construction dust on my mind as well as the power wash simulator game they are coinciding nicely and so that's why your coupon code today is filthy if you want to save 10% off go to the Adafruit store buy some cool stuff throw it in your cart and at checkout time you will fill in the little coupon code form with the word filthy sorry I know speaking of the Adafruit store you can also get some free stuff so the coupon code that applies here let me let me move that make it look like it's part of my shirt there you go so you can use the coupon code for 10% off but you can also get some free stuff if you spend certain amounts of money if you spend 99 or more you will get a PCB coaster with the gold Adafruit logo hey how are there still mosquitoes around you can get the kb2040 for free if you spend 149 or more and that stacks so you'll get the coaster as well at 199 or more in the continental United States free UPS ground shipping and for orders 299 or more you'll get all of those and the circuit playground expressed for free so those are the free offers if you're wondering about those you can go to Adafruit.com slash free there's nothing you have to do to make these happen they just automatically populate in your cart when you hit those those certain price points so go buy some cool stuff if you want and I mean I'm not gonna make you do anything but if you want and save 10% with filthy that's your coupon code for the day and that is good until about midnight tonight east coast time so you have a little bit time to use that let's see speaking of saving money that is one of the key features of my Tuesday show which is JP's product pick of the week stop by every Tuesday at this same time one o'clock Pacific four o'clock Eastern except this past week actually had to get pushed an hour due to some construction stuff that was happening so I pick a product I am able to get the new product team to put aside a lump of them usually a hundred or so will get stashed before the show so even if you see that it's out of stock right right is right before the show starts you'll know what the product is because the YouTube thumbnail gives it away in some other places but if you go and you look and it's already asked in fact it'll go in stock right when the show starts and we have usually put a 50% discount on it if it's an Adafruit product because I can't always do that with with stuff that is an Adafruit we don't have the margin for that usually but on Adafruit stuff usually 50% off and then I'll give you a demo of it and I show you some code and then I like to do a one minute recap and this is it right here it is the piezo driver amp stemma PAM 8904 here are the little gain switches this actually is a AC element and so it doesn't really matter which wire gets plugged in where we have a three pin JST and plugging that into a Metro RP 2040 there and you can see I've got my three volt power ground and then I'm running off of pin D5 do a little reboot you should be able to hear that pretty well quiet this thing a bit so that's the 1x gain and that'll turn it off and that is it that is my product pick of the week this week it is the stemma piezo driver PAM 8904 yes indeed that was the product pick and I'll actually be using that inside of the what do you call it there pressure washer gun I'm using that now for some feedback which is really helpful in fact I'm really starting to get addicted to having little beeps as feedback for things like when your microcontroller is restarted or when you need to do a certain thing it's actually really helpful so I'm really enjoying having that driver board plugged in on this cutie pie for this project you might see me do that more in the future because it's super helpful all right next up how about a circuit python parsec sorry if there was an echo there the song I forgot to turn my mic off during the song all right for the circuit python parsec today I wanted to show you how to use a special type of print debug in your code so what you'll see here I have a pie badge and right now when I press the buttons you'll see it's printing out both onto the screen and onto my code window repl there the name of the button that's pressed and you'll also see I am blanking out some of those LEDs when I press a button I also have some dimming happening based on the little light sensor that's on the front of the pie badge so this is typical print statements which let's say I want these this is what I want this to do but sometimes when I'm debugging I want more info so you can see right now at the top of the code it says debug equals false I'm gonna change that to true and resave the code it'll restart here pretty quickly and now you'll see I'm doing more I'm printing out light values and I'm also printing out when I release a button besides just when I press it so I'm getting more info here and you can imagine there can be lots and lots of info you're doing in your project you want to see for debugging purposes that you normally don't want to see so what this debug print process involves is a special function that's been created here it's actually pretty simple function is defined as print D and then it has an input of a line it's going to be a string that's going to print and then this is the key thing here this function will only do something if debug is true so when that was set to false it just kind of does nothing but when it is set to when it is set to true it will print the line so you can see here I've got my pressed button line in the sort of normal way print and then in parentheses whatever I want to print but you can see here for both the LED yeah so here for the LED light sorry so here you can see for the button release as well as the light sensor value those aren't a regular print statement those are actually calling that function so they say print D and then we're using f string formatting so that we can put inside of quotes any variable names we need as well as plain text and those are inside of one single line so now with that debug true we get lots and lots of info but in the end if we want to calm that down we're done developing then we're going to set debug to false and resave and now we don't get flooded with information we just have the key stuff that we need for the project and that is how you can use print debugging in your code inside of circuit Python and that's your circuit Python parsec and I wanted to say this was something that as I've been collaborating with C grover on the power washer project using the nine-off sensor we had tons and tons of possible things to look at while debugging and sometimes it was nice to quiet those all down sometimes you'll go and you'll say okay I'll make a debug statement at the top and then each time you go and print you have to put it wrap it inside of an if debug this really saves you from having to have those sort of three extra lines in your code and instead just change all your print statements that you don't want to see when you're not debugging to print D and it it takes all of that off of your plate which is really nice so thanks to Jan C grover for this idea of doing a little special print function for debugging purposes all right let's see what have we got next so one thing I wanted to do as actually just a little kind of fun update going back to some of the Lego color stuff so if you if you're not aware of it this is I'm going to go to Adafruit learn second let's go to Rick tunes that's the Lego synthesizer glove I made when I was working on this project I wanted to identify 12 in this case colors that would work really well for sensing with the color sensor and I wanted to dive into what is the current state of brick colors what's the retired colors out there so I did a big deep dive into that and actually if you look in the guide I have some info including a link here check out this link this is on brickset.com and this is a really nice list that you can sort it based on solid transparent and some of the other specialty colors you can also say I just want to see the current colors there are 42 current colors as well it that are solid as well as go and whoops I don't want to coupon code as well as change the status to retired colors or 60 retired colors so this part of the info that that was interesting that showed up here was the fact that Lego did not publish their color names for a long time and I mentioned this in the guide so there are differences between the names of the colors that you'll find on bricklink and on user made creations even the bricklink studio program these color names the community came up with before Lego had made official what what they call the colors internally they might have been in 2011 that they they published something or maybe a little little earlier than that so you'll see I have referred to both the bricklink color names and that's what you'll find in most of the used auction market as well as the Lego color names one thing that I thought was really cool is in 2016 Lego updated their color chart this is the Lego molding color palette 2016 and this gives you the solid colors there's a glow in the dark in the upper right corner there there are excuse me some metallic colors over here and then the transparent colors I really love this sort of periodic table the elements thing and I looked through this stuff that I'd collected largely for this project and found that I had enough colors to replicate that plus the I removed I think a color that got retired from that list and added a couple that had been that had been introduced since then so this is the current complete color chart from Lego but this is temporary because what I really want to do is the flat tiles to look a lot like that chart so I'm working on a periodic table of the colors chart there there are actually there are some online this company who sells a pretty nice looking chart that you can you can find online if you look around but I wanted to build my own with with these square tiles or maybe even make them four times bigger and do a big one we'll see so anyway that continues to develop my Lego color obsession so I wanted to show you the latest progress on that and you can check out the rest of the guide here for info on how to build that how to code that and how to play that so that also I had mentioned that I would include the brick link instructions for putting together that base plate thing that I built to display the colors and to play on so this you can now click on the build on brick link this is a you can go to the full parts list on here you can buy parts do the easy buy and and it'll find us a few stores as possible to get all the parts in a build I think cost about $50 to get all the parts that are shown there and you can go through the building steps either right here and these are neat because these are actually 3d models in in the build so you can take a look at how this was put together you can also download I think I just included the PDF download link in in the guide if you want to get a PDF of it so you can just view that on an iPad or something while you're building it's a nice way to do things but this is a lot of fun to use brick link studio to build your model as well as to develop the instruction guide for it let me see if I go back a step here's the yeah this brick tunes instructions that will open up the PDF which can use images as well so that's our 3d render I had done of the the build and then you can see it it puts together the instructions really really similarly to the way Lego does their official instructions which is great including things like highlighting in red the parts that got put on during that step so you don't get confused about which ones are the new ones in a in a step and I'll scroll quickly through this you can see this well overbuilt unnecessarily engineered robust thing you could just throw these colored Legos on your Lego on your desk and and use them without this this thing so I'm not I'm not encouraging you to build this I just wanted to share what I put together but really a lot of fun to put these together so that's my update on that and now that brings us to power wash simulator updates the first thing I want to do let's jump over to the bench I added you if you saw this on move some stuff out of the way here you want to clean there's still stuff with too much stuff you may have seen on ask an engineer we get that out of the way last night that I've got the we chuck that's the Nintendo we none Chuck add-on controller is all run over I square C we have a little adapter board that makes it easy to use over stem a QT so plug-and-play this plugs into that little board and you can use the we chuck for added control so I've got the pressure washer handle this has all the parts in it we'll take this apart and and look at it and talk about the current state of it so this has the IMU the 9-doff sensor that that we're using for the the targeting stuff but that other than tap detection which I've got working there for changing out my nozzles which is kind of cool you can just shake it to do it the that's not a lot of control not not a lot you could do in the game that you need to do adding the we chuck gives us pretty much all we need for regular run-and-gun type of play in a first-person shooter it's limited of course compared to a hundred and something keys on a keyboard or 87 I think in this case but by adding the we chuck we get WASD WASD for movement for back strafe left strafe right we have a trigger button the Z button there the big one for actually shooting the water or not shooting the water in this case we have the little C button here which I'm using for a few different things so Z is always always going to shoot the water C we use for rotating the nozzle so if you have like a wider spread nozzle in this game that's shooting water sometimes the side-to-side direction you want to flip that water pattern to be wide this way so this just toggles the nozzle this way however I've also got the accelerometer that's built in here so we can use that as a modifier in one case so I can tip it back like this and if it's tipped all the way back like this and then I press C instead of flipping the nozzle it actually allows us to enter the targeting offset mode which is what we're going to use to reorient in case we are in a different room playing or we move the laptop or whatever it is so to trigger a thing we don't use that often I'm having having this point straight up and then I'll press C when I tilt this down it is toggling the sort of dirt overlay you can highlight the dirt in the power washer game pressure power wash simulator so I do the down action to just highlight briefly all of the the dirt in yellow so you can find that one little missing bit that you you can't seem to get but I'm also using when it's in the down position if I add the modifier of the C button we are I can't remember what I'm doing now we'll look at the code I haven't played with that much I've just been testing it and then we also have roll so I'm able to use these for crouch go prone and stand up it's just a toggle that cycles through those three states and this is jump so adding this gives us a ton of extra control it's the you can see why Nintendo came up with this to add to the Wii we remote which you know often you can use it like that as a pointing mechanism so one thing I wanted to do is and I think I've done this in a long time and jam was asking about this is go ahead and take it apart and see what's in there so let's let's go over to the workbench I'm gonna focus this camera first and we'll get we'll get it pretty close pretty good let's head over here and I promise I will do a demo of the actual gameplay so we can see this in action in a second I just want to set my phone here to show me discord so I don't miss any any questions or things let's see where is the screen control I just have to tell it not to turn off auto lock oh you're already set to never okay that should be good so let's set that that's good okay so here get some things out of the way here bricks this by the way was my previous color palette of all of the current colors this is the one brick that comes in every I think in every or the most the most current and retired colors so I'm gonna move the blaster gun there off to the side and here we go so I don't know if this is one of the after market ones that we sell on Adafruit sorry I'm gonna tighten up that focus a little more the official Nintendo one may use a tri-wing screwdriver I can't remember so I've got one around here somewhere if you run across a after market one it's probably a small Phillips if you have an Nintendo one it may be the tri-wing which they used to kind of keep people from going inside of stuff and breaking it so this one is just requires a fairly long and small Phillips might be a zero or a zero zero might not be marked it is not and oh look the screwdriver is magnetized enough to store my screws for me so let's leave that there so I'm guessing we've got a little clip little plastic clip here so I'll grab a little spudger type of thing and see if I can release that clip without breaking it there we go yeah so there's some just some little retention clip right there that clicked into there just need a little squeeze so there's the top molded piece and you can see a lot of effort is put into supporting the board that the thumbstick is on so a lot of this is pressed into this board where the thumbstick lives so that it doesn't wiggle or snap then we have pretty much the whole thing on one little assembly that pulls out so a little strain relief on the cord should just pull out so then the base of the case again more supports and bosses and screw hole cutouts and then there are two buttons in here so these are the Z and the C button molded plastic that actuate the little soft buttons and these look like they're just a typical conductive pill type of button we have three of a ground and two switch lines running from there to the little board this is clipped onto the little PCB again with a little clever plastic hook it would actually kind of interesting to see how close this third-party one is to the Nintendo design because sometimes it's easier to just copy as much as possible then come up with an original design sometimes third-party manufacturers want to do something different or want to make it less expensive to manufacture because they're not as worried about the the qualities Nintendo is so the little button PCB is pretty much just slid into this support and that you can see there's a little hole that the plastic a little plastic stud comes up through so I don't think I'll pull that out because there's a decent chance I'll break something trying to get that that's in there snug then we have a two potentiometer thumbstick with a little hat switch on there and you can see with these these are nice a lot of the design of this is actually just sort of dust protection for not getting junk inside of the controller so this is pretty snug up to here on the top of the case the joystick part is really just this little bit here at the very top so that's two potentiometers that get twisted as the stick moves and it's got spring return on both axes let's zoom back in a little closer and by the way if you're noticing me looking over the top of these glasses these are just some of my reading glasses because I scratched the heck out of my regular progressive ones that have no magnification up top which is I don't need it for seeing the monitor but I do need it for the closed stuff so I've got glasses on order but in the meantime I'm just going to be using readers and doing like this sorry okay so now here's here's where pretty much everything is on here and I don't what I don't have is actually decent enough magnification to look very closely at that let me see if I can find a lens I may just use let me grab a second pair of glasses I have like a visor with some good lenses but it is not here in the shop right now and I've also got a microscope which is really helpful for these part numbers let's see what we can and the iPhone helps a lot too so let's see what we can see yeah I'm gonna need alright let's try it with the phone I'm just gonna use the camera in fact alright so here's what we have you may want to look at these two so ATM HK 218 and the BM 807 v6 from Shanwan you can see here the I square C line so voltage zero clock serial data and ground that is the set of lines along with I guess there's a doubled one there that's listed as R1 R2 I'm not sure how they're using that if it's an address thing maybe for having two of these two players not quite sure well no these don't plug right into the console though these go into the Wiimote so I'm not sure that however most of that there is what you'd expect from a normal I square C but there is one extra line so that's kind of a question I have if anyone in the chat knows by the way I can't look at my phone now I'd be curious what the fifth wire is on the Wii Chuck standard there and then up on this end let's take another a new picture so yeah so there's the ground Z and C ribbon cable for those buttons this is mysterious to me I do not know why this little unnecessarily cool little set of traces lives here without any solder mask what the heck is going on there I do know and then this guy is actually a little too blurry CY6A is this marked as U2 on here and this is not a Nintendo one so it might not be as well documented on the internet so but let's look and see I'm gonna go back over here for a second let's look and see if we can get any info on the chips that are on there because I'm assuming one of those is the IMU and one must be dealing with I square C so let's jump back over here I'll bring my chat back up case anyone has info about this or thoughts on this that would be cool actually I'm gonna bring up my my browser and very dangerously just browse for the name of the so how about let's try this one Shanwan BM 807 I got two dashes in there V6 someone on the reverse engineering stack exchange has a game pad with this in it I have a game pad with the Chinese Shanwan BM blah blah blah okay it's a different one MCU clone so that may be the microcontroller there and then let's look up take some letters off of there sometimes that helps no this is getting us crisper virus stuff all right not a lot out there that let's see what this other ATM HK 218 it's a two-wire automotive serial e-prom no not quite the same number though let's try it quotes here's a digi-key forum question similar part number is past produced from at mel says that is a I square C chip all right well that's as far as I'm gonna take that then something in there is is accelerometer something in there is a little brain and it may be that the I square C yes probably just built into whatever this microcontroller is so I'm gonna guess that maybe no that Shanwan looks suspiciously large to be an accelerometer could be that little what was this guy's name that little one looks a little more accelerometer like CY 6A you can really lead the witness and I don't have a clear enough image of that to know if that's oh CY 6 accelerometer yeah I think that is the that is the accelerometer sure looks looks like that type of package GY 6 yeah okay it looks like maybe that's one that we have on our one of our boards there triple axis accelerometer yeah GY CY let's see yeah thank you Jeff in the comments said that has six connectors oh was I not counting right four of them are active ground three volt data and clock okay yeah and on my board the ones that are labeled R1 and R2 were jumper together those pins were blobbed across so all right so that's all that all that we need to look at there you know like a lot of these it's not unfortunately too exciting to look at because it's just a couple of this is no epoxy blob but it's just a couple parts on a little tiny PCB so now what I want to do is let's look at I'm gonna set up for the squeeze this in a bit set up for demo of the power wash simulator so you can see that let's go to a full screen of that and what I have running it I've just got a Windows PC gaming laptop here and has HDMI out which I'm gonna run to this monitor so we can see things a little more clearly power this off of its ginormous power brick I don't know what battery life this gets running it's a g-force card in there but it's probably not much plugged in then I've got a HDMI cable if it sends that signal out all right there it is I'm sorry this isn't very bright I don't know if I can do any brightness stuff it's at full brightness there okay I'm gonna turn this light off here so it makes a little better unfortunately this camera wants to do the auto correction of the lighting so let's hook up the controller so we'll see this in a second want to take this apart but what I was mentioning earlier about piezo driver that's in here is we'll hear this beep when it starts up it's actually a double beep and that's to tell me that we're about to do a targeting offset a little quick targeting offset procedure and what that does is it calculates the difference between the calibrated values on the nine-off sensor that are based on a previous little calibration routine we ran which basically involves pointing the thing at true north so you use your your phone or a compass to tell you true north pointed at that collect some values do a little dance the gyro and accelerometer seem to auto-calibrate really nicely on this sensor and see Grover has a great write-up on this process that I'm gonna be including in the bn0055 guide and linking to in the power wash simulator guide but you just need those values one time unless you move to a different location on the earth but as long as you're kind of in the same basic location you won't need to do that every time but what we do need to do is say okay if I was playing pointed this way and now want to play pointed this way I want to create a relative offset a targeting offset so that center is center again so I've got a nice long USB cable here plug this in so you're gonna listen for a double beep and that's gonna say okay we want you to point it where you want to play the game so point it at the center and then we'll hear a confirmation beep about two or three seconds later when it's finished be okay so you see oh I have to turn on I have I have a debug mode where it's actually not moving the camera that's okay you know what I want to demo some of the other stuff while while we're not worried about where I'm aiming this okay so you can see here I've got a lot of beeps happening and that's because of what I'm doing with the the nunchuck I've got my nunchuck cord as well as my USB cord coming out of the bottom of the handle here so the nunchuck is gonna do all of my see that yeah all of my strafing movement right so I don't have camera control right now so it's just strafing forward backward right left so that's just sending HID commands of WASD and then when I tilt this up it beeps to say okay you're in this up modifier position if you press C you're gonna re set your offsets there it goes it actually accidentally did it's normal C button function which is switching the angle of that nozzle but if we're up here I gotta check my code why it's doing both so that's sending a HID R to do that change I think it is of the nozzle angle but that's the sound of okay you've just recalibrated so tilt it forward again this is should only be doing the nozzle stuff and if I tilt down you'll see it's highlighting the dirt and then did I tell it to do something when I'm no I don't think I don't think I have it doing anything yet on down tilt and see then I mentioned roll so if I roll the cursor or the the weemote we chuck it will crouch if I do it again it'll go to prone position which is really helpful for getting up under those fenders and then if I do it a third time we go back to standing so those are the three positions and then if I tilt left we'll jump boink and that'll help you if you want to spray and get all that gunk up there so let me plug this back in to my computer here where I can edit the code and this is super dangerous because I've got HID commands that could be spewing out and doing who knows what to my broadcast but I'm gonna go over and open up code that's running on here are you it no oh I gotta unplug this high badge or turn it off second there you go okay let me show you this so cursor false and that's just helpful during coding if you have this plugged in and you're testing other stuff you don't want it moving your cursor around unless you had a way to like set the gun in the little holster and Reese recenter the the offsets then it won't then it won't move on you but I'm gonna change this to true and then before that reeks too much havoc I'm gonna unplug it now we'll plug that back in okay so again it's gonna start up wants me to point at center okay it's now got those offsets so now you can see as I move the actual gun around now let's say I want to I want to adjust this I want to be pointing straight straight ahead instead of a little tilted up switch the camera view again so this one so here I want to read I want to adjust my offsets so this is this is the angle I want go up be and you see it stopped spinning around and now I can hold it still instead of pointed up I can hold it kind of level with the ground okay now on my controller I can press Z to turn on the water I can use the thumbstick especially when you're just standing still you can kind of put both hands on there you don't really need to use other than the trigger on here the trigger can be a toggle even just in the game it has a mode where you get down a little low look at that there's a mode where it will just toggle the trigger doesn't have to be held constantly so that's a that's a choice there I can move around while I'm down here we can even change our oh yeah so here you can see look at the color of the tip in the game on the pressure washer nozzle it's yellow right now I can switch that to green which has a wider tip white even wider and then go to red there we go red is like hey I wouldn't do that to my stuff because it probably just scratch the heck out of it but in the game that's great we get this like needle like performance so that's pretty cool this is the tap detection again the cedar Grove maker created for the bn-o-o five five it does not have gonna hit escape on this so our camera doesn't spin as I'm talking stop there's not a built-in tap detection routine on that sensor and so the so cedar Grove wrote a little routine to determine some accelerometer values that were very different from each other between samples and and so that's in the code and we'll talk about that so let me let me see it was there any other I think that's all the features that we have again if I come over here and one let's say Todd just mentioned highlighting the dirt so I'm just gonna tilt down oh my god it's filthy on this side okay that's fine but you know what I want a wider spray to start with so the white one whoop oh okay so something I don't know what's happened I want to fix my my offset something went crazy okay shoo I've calmed it down I don't know what that was about but you can see it's really nice to to be able to even if you're not moving the game machine around to be able to re set the offsets so let's say I want to point over that way and have that be center now I can now I don't have to point at the screen for whatever weird reason now I can clean this off and let's say I want to get some of those little pieces of dirt I'm gonna go to a more targeted like that yeah yeah oh you know what I think the mode I was gonna switch to let me see does this switch it there we go so I did have a mode for this so down well let me stay mostly centered down on the Wiimote and the C button switches to this gun aim but no head look so you can see the camera is fixed until I reach the edges so this sometimes is let me tap two different whoa sometimes this is helpful in the game to sort of keep the camera if you put it's actually a little nicer if you get nauseous and first-person shooters so it's kind of nice to be able to aim the gun but not change the camera so that's what that mode is and that's by tilting down with the we chuck and then pressing the C button and back up let's change that nozzle and let's jump we can jump onto that that's hard to do I made it okay now we're on top now we can clean the top of this thing and again I want to re-center it so I'm gonna do my offset dance and now we're cleaning the top I want to hold the camera still the top of this thing all right that's the demo of how it's working let's take a look at code here let me know if you have any questions up to this point then we'll take it apart but we'll talk about how it's working and then show you the guts of it which will actually give me an opportunity after the show to take some final pictures of it for the guide so that's part of my reasoning okay so right now it's gonna mess with my cursor if I touch it if you lay it down and then start it up it's basically it thinks it's pointed at zero it's not doesn't detect any movement so you're good but if I bump it my cursor on this computer will go wild so I'm gonna set the cursor variable to false and now it won't care if I move this around I can do fun stuff however if you look at my code sorry I wasn't showing that a second ago if you look at the code here if I tap this the tap detect actually sends a mouse wheel click a roll like one one increment of a mouse wheel because that's how you switch between the nozzles in the game so let's give me I'm gonna put focus in my code window here oh I got scroll down a bit though oh it's angry at me I have some USB HID thing that's mad there we go so let me scroll down so if you look at my code very slowly it has a kind of a slow scroll on this machine it might just because the resolution of the monitor is high but you can see that's that's the command that gets sent there if you look in my code window if I press the C button that types are if I tilt it down it's type typing C there I'm also getting autocomplete so that's weird and we can also tab one of these is tab I forget which one who among you is tab is it down yeah so each time I tilt that we get a little little tab so those are the joys of developing HID stuff is sometimes you're fighting yourself so you kind of have to set things carefully down okay so this code is getting pretty close to finish you can see here I've got a little list of a little list of the functions there up at the top in the comments you can change these some of these are especially the HID key codes I've just listed in these constants here so you can see we have a bunch of libraries for bringing in the constants here for debug and cursor which is kind of a debug thing there are some variables here that you can set to adjust things in the sensor so this sensor ratio thing this was a really huge idea that impacted the the quality of the the cursor movement a lot the cursor movement on its own is great but once I added the we stuff the BNO was fighting with the we messages and so it just was sort of stuttering the the camera quite a bit in fact if you saw last night on the show the the version I had had a kind of a steppy camera now it's really buttery smooth and that's because the sensor packet factor is set 10 to 1 so you get 10 BNO 05 5 messages for every one we moat message which is great the horizontal rate and the vertical rate are what you can tune to essentially impact how fast the camera tracks with the the motion and since we have a wider screen than it is tall I have you could probably tune these to be the 16 by 9 ratio which I don't have in here I've kind of a 1 to 2 then here are some of these keys that you could change out so rotate nozzle happens to be the R key on the keyboard so that's what I'm using when I press the C key in normal mode and you can see I have a secondary this is kind of the modified version of that C key or the C button and that's only when I'm pointed up and that's what or rather when I'm pointed down sorry when I'm pointed down then we're calling the letter C so confusing which is what switches the aim modes of the camera is locked these are some values for accelerometer of the we so I've got at what value do we consider the thing pointed straight up and at what value do we consider it pointed straight down for those modifiers same with roll left and roll right and then these are the thresholds and the debounce times for tapping on just a single tap on the the BNO 05 5 here and I found that with this this pretty low threshold of 6 that allows me to just kind of flick the gun to make it switch the nozzle which is nice it means you don't have to bring both hands together to tap it then we're setting up I square C we're setting up mouse and keyboard stuff I have a little list of the WASD keys just because those aren't going to change you're using the joystick for movement those are going to be WASD set up the nunchuck on I square C then we're creating the instantiation of the BNO 5 also over I square C here's a little beep function and this is just a convenience function for using tone which is part of simple IO and you just feed it that function a frequency and a duration and it has some defaults which is what we hear sometimes and here is that if you're if you remember just not too long ago the circuit python parsec where I showed the print D function there it is in action and in fact let's let's do a quick demo of that I will connect to the so you can see I'm doing stuff here but we're we're not seeing any any feedback so if I if I come up and change my debug to true and we save we should see a bunch of feedback happening here as so there's some joystick info and some where's the mouse pointing and so on so that you you can go through and selectively sometimes it's too much to have it all at once but that's the idea behind debug I don't want to see that stuff now so I'm gonna set debug to false save and then all those print statements stop harassing us you can also see there what just happened so this is like like you saw me do I think I have it do the offset dance or offset math on startup after the double beep and I just point the thing at the center of the screen and this is okay we've got some offsets off of zero so zero would be pointed over here you're now pointed here and the way we do that is these XYZ values so those are what printed out there and those print out even when you have debug off right now I might change that okay then here is a sea grover function for calculating the distance between reference and measured points in a universe the point position tuples can be colors compass accelerometer absolute position we used a version of this I think for the color comparison in the Lego project if I'm remembering correctly so it's finding the using list comprehension it's finding the difference between some values to be able to compare them and find out their Delta then these are offsets that I created and I've made a link here in the B&O 5 library there is now an example script example code called B&O 055 calibrator dot pi and I'll put instructions or link in the guide if you run this you you want to run this this is going to give you your kind of your truth your true north your calibration offsets off off of the true north and the accelerometer and gyro so that you just kind of need to do once unless you moved across the country and then you might need to do it again but those are my starting point and then where I'm pointing it in the game to be center is that offset that you saw it generate at the beginning it's also the offset that happens when we point the we chuck up and press C then I have some states that I'm keeping track of so that I can do this this stuff and press buttons without it constantly spamming things for example the roll state it's at one when it's in the center it's at two when I roll it or two when I roll it to the right and zero and roll to the left then sensor packet count is part of this packet counter that's being used to calm down the amount of data coming from the we and just deal with more B&O data because we want to prioritize that and then this previous acceleration is used as a baseline for tap detection then I'm doing a little beep to say hey we've started print out a little message give you three seconds to point and hold still and then it checks for this angle so this is target angle offset variable which is angle for angle in sensor Euler that is what's used to adjust where you're pointing from your your sensors zero reference point then main loop here okay so you can see just in the concert says get Euler angle values from the sensor Euler angle limits are plus 180 minus 20 on pitch 360 360 on heading and 90 to 90 on roll and we're not using roll you don't need it it's too much we're not tilting the gun sideways like John we were anything like that so that's actually never never used but it is one of the pieces of sensor data that we get so now we're creating a sensor Euler variable which is based on sensor Euler sensor packet count again incremented to to deal with the if we get through enough of those we can then ask the we what it's doing we're now casting the sensors data that it's sending the sort of sensor fusion data of heading pitch and roll and we're we're calling those with with the offset taken off of them we're calling those the heading roll and pitch so that's that's actually what we're working with and that's what can then be turned into mouse data here's how they're turned into mouse data this horizontal move is an integer based on using map range inside a simple IO so it's the heading it's a 0 to 360 thing based on the the magnetometer heading negative 20 to 20 is the band that we're reading and then that is being cast as either a negative or a positive 127 which is kind of the maximum amount you can send a mouse x movement same sort of thing happens with the y so up and down except it's a smaller band that we're looking at 10 to negative 10 and that gets cast to this 63 to negative 63 that I showed you earlier and then if cursor is true so that was that little switch that I flipped we can tell the mouse to move so mouse move x a horizontal amount and move y a horizontal amount and so that can be anywhere from 1 to 127 going to the right on the screen or negative 1 to negative 127 going left on the screen then we have all the we check stuff so if the sensor packet count is bigger than the sensor packet factor then we can finally ask the we what it's up to because we've we've read the sensor the BNO sensor enough times to go interrupt it for a moment and ask the we check what it's doing and I think there are some blocking things in the we check driver which is one of the reasons this is important so we check joy x and joy y are variables that I'm setting based on asking we check joystick and it returns I think a 0 to 65,583 or whatever it is the negative for less than 25 oh does that give us sorry I'm wrong joystick gives like a 0 to 255 0 to 254 I think that's what it returns so anything less than 25 we're going to the left so we hit the keyboard a when we're not we release anything greater than 255 we're to the right we send a D and so on with the other two directions by the way this code I may try to spruce this up oh let's take a moment to appreciate Janisku found a oh it disappeared there was a gift up there for a second of a clean van so I may clean this up so that it isn't it doesn't think it should be sending release messages more than once but I don't think it does I think even though the code looks like oh it must be sending keyboard release the the driver the library for keyboard usph id and circuit python just ignores that if it's already been released so it's not like it's constantly spanning it then we go on to our accelerate accelerometer stuff so again we roll we pitch and we acceleration on z which we're not using that's the gravity you could drop the thing are getting picked up from this we check acceleration then same sort of thing except now you can see I'm using states to see okay if we're rolled to the left rolled to the right if we're pitched up pitched down do different things some of those include beeping so if we pitch it up we'll get a little beep and then if we're pitched up based on that state getting flipped and we press see then that means it's time to run the little recalibration offset you can see that one most of these are just pressing keys but you can see that one see pitch state up so when pitch state is zero that means I've I've tipped this up if I press the C button and it wasn't already pressed then we are updating the target angle offset just like at the beginning to be angle for angular and sensor Euler then we do give a little couple confirmation beeps and then I'm flipping the state to true so that we don't get spurious multiple hits and then last thing we have here after some more straightforward press the Z and release the Z stuff to send the mouse left button which is what actually sends the water spraying you can change that to mouse right button and that's a toggle so you don't have to hold the Z key all the time you could change that to be a toggle and the last thing here is the tap detection so you can see the accelerometer sample is red and then another one is immediately red as fast as it can no delay there and then again we use this Euclidean distance function to compare those two if that difference between those or the delta is greater than or equal to the tap threshold then we are going to register a tap and we'll send this mouse move wheel one and that's what cycles between the different nozzles on there and we give a little beep it's fun okay well so there we are about 263 lines of code to do all that but I am really happy with how how well that's that's working now I just wanted to let me set the cursor active again and I'm gonna plug that back in and just show you an outdoor scene because you can see some of the nice camera movement out there so true on cursor see it beeped and now I know I can unplug it because that means we we restarted I love that big fan of the beeping so before I hook this up actually I will exit to the menu career free play locations how about the playground I'll restart this job confirm so there's the usual this is kind of a nice nice chart of the typical controls which you can see here use washer that's the left mouse button there switch nozzles that's the wheel WASD for movement stand crouch prone that's control jump that's spacebar and I think that's it those are the ones I'm using oh and tab for show dirt and one other which is rotate the nozzle R oh yeah and aim mode C so we're picking up a lot of those on there there's some things that we're not doing that maybe you'd want to add there's a pickup you can pick up ladders and place them so that that could be another we mode thing like maybe with your roll and a button there's a lot a lot you could add all right so we'll continue okay oh gosh we're spinning because I didn't I wasn't pointed at the screen oh it's okay I'm gonna there we go now we're now we're in business so you can see this is a filthy filthy playground just start cleaning that and you may ask if you haven't played this game why would you not just go with the biggest nozzle all the time and you want to try it but sometimes the dirt doesn't come off with the big nozzle because it's lower pressure so that that can vary a lot oh you can of course write your name or draw pictures in there but there we are there we have it our wash simulator in the house let's move that soccer ball they have some physics going on in here want to see where the dirt is oh it's everywhere everything's filthy all right stop there okay so that's the state of that project I'll be putting the guide together right quick so keep an eye out for that again a reminder if you want to get 10% off in the store today yeah Dexter that is a gross playground is so gross disgusting takes a long time to clean that I've played through the whole level filthy that is your coupon code that's gonna get you 10% off in the store today so head on over to Adafruit.com go look for some cool stuff let's let's go back to Adafruit there we go oh that's the learning system there's Adafruit come to the shop throw some stuff in your cart there's some fun banners and things to click on there to get some ideas when you get to check out be sure to type in filthy as your coupon code you get 10% off and that's good until midnight tonight any other questions or things let me just scan through questions and comments in the chats David Esso yes a bit of a deep dive in the workshop for sure well I'm gonna have to write up the how this works section of the code and now finally the code is just about done so it's helpful for me to run through it say it out loud one time it'll be better for it I think all right that's gonna do it thanks everyone for stopping by today thanks everyone over in the YouTube chat thank you my electronic trip Gary T. Botzerker Dave Odesta and then over in our YouTube or discord we've got DJ Dev and Todd Bot Dexter Janiskew 7 C Grover Jeff thank you thank you I hope I didn't miss anyone we I believe had deep dive with Scott tomorrow check the blog check the live broadcast chat channel and if anyone knows for sure if he announced that or not I think he said he was going to and then we got a whole slew of live streams coming back around starting next Tuesday with the next product pick of the week and on Wednesday we'll have 3D Hangouts show and tell ask an engineer this again and on and on and repeat okay thanks everyone see you next time bye bye