 All right, hello everyone. Happy Friday We have made it through another week get nice and comfy here Get this dive on the road so to speak get this dive in the ocean We'll go with get this dive in the ocean Let me shuffle a few more of these windows around Did I click the go live? I think I did right? Yes, okay. We're good on There Looks like we're all good Pause this minimize Close this. Let's close Some more of these things that are open. It's not what we needed and get my workspace set up Before hand today, unfortunately Let's close a couple more of these Okay, I think we're already Who gets started so hello to everyone? My name is Tim. I go by foam a guy on github and discord. This is the deep dive Livestream program. This is a weekly program that occurs at this time on Fridays at as it's usually billed at 2 p.m. Pacific Or I guess is that 5 p.m. Eastern? It is 4 p.m. Central as well, which is the time zone that I am in this program was Originally started by Scott the lead developer of circuit Python He has taken some time off because he recently had a child and so his schedule got all changed around I have been holding down the fort so to speak here on the deep dive And yeah, this is the time that we do it. We're looking into all things circuit Python We're getting down into the weeds in the nitty-gritty getting our hands dirty with some code Sometimes we're working in the core. Sometimes we're working on libraries. Sometimes we're working on projects mix of all kinds of different stuff, but the the common theme that ties everything together is circuit Python if You are brand new if you're watching this video in the future If you haven't caught one of these streams before And you don't know what circuit Python is a good place to start to learn more is circuit Python org This is the main website for the project Circuit Python though is a version of Python that is designed to run on these tiny computers called microcontrollers A bunch of pictures of them here on the downloads page at circuit Python org We are running Python on these little computers. We can plug it into the computer. It shows up like a thumb drive We're able to write our Python code on there save it on the device And then it executes inside of the tiny computer There are all different shapes and sizes you can hook up all sorts of different Hardware peripherals like you know lights and buzzers and buttons and levers and beepers and knobs and sensors and You know any kind of little electronic doodad you can think of screens I don't know if I said but all this kind of stuff you can connect up to these Microcontrollers these tiny computers and then you can interact with all of these hardware peripherals from your Python code So that is kind of the 50,000-foot view of what this is all about If you Are interested in contributing to the project it is an open-source project everything all the development occurs out in the open on github We coordinate through the discord, which is linked down below ADA fru.it slash discord That right Yeah, I think I said that right it is down there on the screen either way even if I got it wrong There's a circuit python dev channel all of the sort of collaboration and communication around the development takes place there So if you're looking to get involved in an open-source project We'd love to have you come hang out in the discord with us and get involved in this one If you want to help support the project but not necessarily by getting involved in development another way that you can Do that is just by purchasing hardware from ADA fruit This is their website ADA fruit.com They're hardware and software company based out of New York and Ada fruit is the company that is Primarily funding the circuit python project. So they pay the folks who work on the project full-time They pay some other folks like me who work on the project part-time. They pay us to do the code to You know review changes to write libraries to make projects to make videos guides To live stream to do all these sorts of things Ada fruit is paying the folks who are being paid to do this kind of stuff So certainly thank you to them and then like I said if you want to help support the project You can do so by purchasing hardware from them. So go get yourself some goodies Find some fun toys to play with and in doing so help support make circuit python How's it going see Grover and DJ Devon Happy Friday to both of you been up since last night working on the 3d modeling and printing might fall asleep Fruit microcontrollers You said it great. You're doing a good job. Appreciate it. Thanks my friend over there on YouTube. We have fun So tonight what I am looking at More specifically, we're gonna start out with some ethernet testing and then we're gonna get into some gradients presuming we have some time after that so This will be not brand new to folks who have watched some of my streams before. I don't know if we did ethernet I don't think we did do ethernet on deep dive, but a couple of maybe a week or two back I did some testing and reviewing of the ethernet ethernet PR on Stream and so this is a New PR this time around but we are getting back around to it Cuz I noticed there was another new change in there Sorry, I got to get the camera going here as well cuz we will Have our own little microcontroller that we want to show Something like this for now and I have some extra hardware around which we will potentially get into once we move on to the gradient stuff But this is what we're using right now a little ethernet feather wing with a feather connected to it which not connected to it right now, but About to plug in I can keep it in camera listen This into the computer I've got extra stuff on the desk today because one of the things that I planning on working on next Involve some other hardware that I don't normally Have out or have out on my desk This is running the time puncher thing Right now, but we are going to be switching out to some ethernet code I'm just gonna leave it on this for the moment. We actually need to find our ethernet code So I'm gonna go get the Wiznet library opened up. Oh, I probably should have changed the Batteries my mouse batteries might be dying. We'll see if we make it. I've got some backup ones here anyway, so Um Let's get to Wiznet Had typing that's the branch we're on but we actually want to be going ghpr list and GHPR. Oh, we're behind by two releases now. Goodness gracious Are these still easy to install like skip this thing on it? I have Officially become more difficult to install it doesn't have an update button And I guess I could uninstall and then reinstall but then it might Make me authenticate again. I don't want to mess with it right now so we'll stick with the Slightly out-of-date version for the moment It was I think 80 Pull it up in here as well So I am hopeful. I don't know if it's actually gonna work out this way But I am hopeful that this PR might actually fix some of the weirdness we saw with my network my DHCP I think I was seeing some weirdness where I was getting back different IDs and it was making it fail And this is Talking about fixing a couple off by one, you know an off by one bug here a logic bug here another bug here Um So I'm you know fingers crossed maybe this might even solve some of the issues that I was seeing with my particular network with I assume some kind of configuration or something about the way that my network returns the DHCP Information was causing it not to work in my case except for the first time the first time it joined it was fine, but then if you Started the microcontroller And it tried to rejoin the same network it it didn't succeed the next time Check out 80 if nothing else it has better error handling and outputs because that was the other thing is one of the error Handling things was like just printed a F So that's one of the things I believe is in this as well Take a quick peek through the code while we're here to magic cookie. Oh I don't know about changing that interesting It's look like off by ones. I guess here a couple types changed Sponsor ID mismatch. This is the one I was getting so fingers crossed. Maybe this will be Resolved, but maybe not maybe it'll at least I mean if nothing else it'll be a better error message, which is good If we get lucky, maybe it'll be resolved Like that there is a server. Okay Yeah, yeah, so there's a couple places where this was just returning zero zero rather than raising like a coherent error Know about magic cookie. That sounds pretty yummy. Whoa. Whoa. Whoa. Whoa. Whoa. Whoa. Whoa What's that? This logic actually changed a fair amount. What did he now we have try accept? Oh, I see. Okay. This is actually just try accept on this line. Ah the rare try accept else There is I do think I learned about that isn't that is that a thing? try accept else Executive no exception. Do not see that one very much. I remember learning this and having my mind blown kind of T only so the logic does not actually change too much The print statement is a couple of lines longer, which makes it look more significantly different Honestly, the biggest difference is the try catch on the bit up here. It's like error handling generally And to error if debug transaction ID There's this bit. Oh No, no, this but this is a just yeah. Yeah, this is all just here same stuff Okay, plus one This is eerily similar to what I was getting when it was not working I will freely admit I definitely do not know that much about the intricacies of DHCP I'm probably not the person who could Give a thorough review to this actual code change But I can certainly try it out. I test Wow renamed. I don't necessarily have I mean, I kind of like the underscores, but it does make long names. I don't know sdhcp Interesting we would run this on the PC, maybe we can run this as well to try Let me catch up over here as well Perspective cowbells went out yesterday the arriving either Monday or Tuesday. Nice Getting on distance from What I got them out of Christmas sweet Winston cowbell holiday carols can now happen Tracks up dolls pretty handy occasionally overuse it Yeah, I don't know that I have ever I've ever used one. I've run across them a few times now, but it's about it So we did check out. We're here. We're gonna take this over to our device The lip folder here I Already have some stuff in here This is MPY one you get rid of that Gradients will be coming up Once we get done with this I'll play with gradients or if the question is like, what do you mean by gradients then? Colors like color shifting from one color to another LED colors display some of both hopefully Actually, yeah display I've done some stuff with so far And then LED colors I would like to use The gradients that I've been working on with and LED animations as well actually Which I will if I pull the camera up just a tad One of the things I have here is a LED strip of neopixels To hopefully be putting some gradient colors into Simple test we can go with Yeah, we still I need a PR this I keep saying this every time I've come back through this now This one it won't actually work with our Device I feel like I check this every time, but I'm gonna do it again anyway Believe this is the same as this How's it going kiyoshi? Happy friday, let's save that I don't have a Open before this is actually upside down You could actually just flip it in the camera How's it going biata? Have ants, uh-oh You can guess dance and I Put this Look like it has an actual error truthfully zeta fruit make nail clippers I don't think so You probably could not send me some either really got much better. Do we Did it run? What did it do? Right, right, of course This is exactly what I was just talking about. So this won't actually work on my board Because the spy bus already initialized because It is used for the display Uh board dot spy would be what we want wrong way We're upside down now There we go that one worked We got the light though too far Wait this upside down. I don't know Bit tricky All right, so first time through it did work and in fact I want to say this was the ip that I got before So I guess the real test for my network is going to be whether we can like Just redo it and try it again. Oh, we're also on a older one here I didn't actually succeeded twice. So that's actually good. I don't I do think I maybe got Two successes in a row in the past I don't know that I did ever get three though. So I'm Feeling pretty good Even if we just got this far even if we fail our request honestly Getting connected to the network getting an ip address. We were failing There on my network the way this was used to be working Try accept is almost mandatory for working with requests. Yeah, the the try accept for sure the else bit is the uh The bit that I don't see not quite as much Failed to establish So that's our that's that's okay though. That's the request failing Is actually also just what you're talking about dj But yeah, see that's just like Networks are like that right sometimes it's going to fail to fetch That's just how that goes So I am honestly, I do think this is actually Seems to have fixed the issue with my network. We are on old circuit python 733 We will update that as well Uh, let's see Super handy with requests because every api has their own failure message You can catch each failure do something different useful for hammering away until you start getting Key value pair errors. Yeah So this time we failed we succeeded the first one, but we failed the uh Bitcoin one probably or I mean, it's timed out right now. It'll probably fail, but we'll see either way. It doesn't matter um Let's do update closed out circuit python.org Oh We don't actually need it to be upside down the reason that it was upside down is because the time stamper draws it upside down and Because the display lives Outside of the Circuit python vm It stays rotated So we stayed rotated from like that. We stayed rotated from when the time stamper was running But now that it Will have actually reset And in fact gotten circuit python reinstalled on it It will be back to normal whatever the default orientation is which is now going to be actually upside down to us So we are actually going to need to switch it back around on the upside It actually moves in the way that my brain wants it to now failed to resolve hostname At that time it restarted itself somehow It was about to rerun itself, but I stopped it with control c Let it go again I've got this one Okay, yeah, like I said the code Honestly, it's a bit over my head. I don't know nearly enough about the specifics of the hcp to even really begin to say If anything is good or bad or wrong or right or anything else inside of here, truthfully um Functionally though It's looking good It's looking better than the old one was in my opinion because mine because it wasn't working Reliably on my network Unless if I did a static ip Or if I edited the driver to not care about the Transaction id I think it was called being different catching up on 2x about 15 minutes silly question What's a state machine not a silly question at all state machine is a programming concept there's a Very nice Learn guide in fact that described some of it um The way that I think of it I'll link this learn guide as well and then I'll tell you the way that I think of a state machine the way that I think of it is A while loop And inside the while loop you have basically an if statement that says if the current state is this Then do all of these things else if the current state is this other state then do all these things You know else if the current state is whatever then do all these other things um It's just a style of programming where you have a loop that's going around and around and around infinite loop or whatever really really fast And you have a high level logic condition that says if we're in this state, then this is the stuff we do You know during this frame of execution for in this other state then here's the other stuff we do During that frame of execution And so like as time goes on, you know user interacts with the program things happen And your program will just change the state So, you know, you could go from the loading state into the You know a menu state or something for instance like loading state shows a splash screen Menu state shows, you know a list of options that the user can pick from And then maybe the user chooses a selection from the list and you move on to Some other state, you know the the the sensor screen state or whatever like just depends on Whatever your program is um Yeah, I use state machines a lot with circuit python stuff a couple a couple of my guides are state machines I don't know my friend Doesn't seem particularly relevant I would assume this is what saved us Somehow i'm guessing these being off by one was What was leading to my transaction id kind of being different Ethernet feather wings are nice to have just in case something breaks again in the future Let's oh breaks again in a future beta might be handy as a failover They're faster, but sometimes you can't run ethernet everywhere. Yeah, I know for sure ethernets Honestly kind of a pain to run to a lot of places. Yeah anything outside or further away I could see whipper snapper being a great pair for always online logging Because all wi-fi drops off eventually Yeah, for sure Used finite state machine designs in hardware too great way to organize and manage sequential events Hardware implementations exist in the core of the cpu chips Yeah, I forget was it I don't remember was it anac data? I can't remember if it was anac data or maybe near doc or I might even just be misremembering all together Somebody had one though where they connected like I want to say they had three different internet connections Going on one thing ethernet wi-fi and then uh the cell data one Bank was the three That going there beta five Beta six, uh-oh beta six I don't have a beta six yet I don't remember which I remember which one of these was mine This doesn't get a response by my friend Hope you enjoy your evening Five is mine I would guess some of these I think it mentioned 79 as well I think probably this gets better as well, but I'm not as familiar with this one Yeah Turn zero Does not test for error Yeah Basically, this is where we ran into it Our error was different. It looks like then their error. Maybe Maybe not actually. I think that was the same line. I don't know Well ours was less of an error ours was that this was not being equal Our transaction ID was different. It was one number different one number higher 75 was mine. All right. I won't merge it for right now We'll see if we can have hopefully maybe somebody who knows more about networking um Take a look over it or at least have maybe a couple other people try it Because it does seem good in my environment in fact better than the old driver because it actually works reliably over and over now without doing a static ip Which it didn't used to so that's awesome But maybe we can have some other folks try it I know anecdote is fairly active in network stuff and in this library So maybe they'll give it a try or maybe you can have some other folks if anybody watching Has ethernet device and is interested in trying it out definitely be appreciated if you do go ahead and leave a Leave a comment or leave a review on the You'll pr here number 80 on the wiznet library and then That's really it with ethernet gradients are up next. So gradient I published yesterday This from a guy circuit python gradient helper This will generate a list of colors inside of a gradient I heard a cat getting into something, but I don't know I think anecdata did four cutie pies from one outlet I haven't seen the one you're talking about with three connections Oh, yeah, there's definitely a cat getting into something Use finite state. Oh, yeah, that's the hardware one I'm trying to think if there's a good diagram somewhere for state machines other than the state I mean the state machine learn guide has a diagram. I'm trying to remember If I've seen other learn guides with good ones you don't Feel like I feel like I have but I can't picture what it was Um, okay, so Where do we want to start with this? I think let's start with an easier Neopixel strip. I have this one which has its own fancy printed thing but It needs to be plugged into the device its device is much older We're probably I'm gonna want to update it when I get into it So I think we are actually going to go back down just a hair I'm going to start with this one because this one Is easier to connect. It's just plugged into the fun house here And what I want to do is generate a gradient generate a list of colors and then apply it to this Neopixel strip. I think should be pretty straightforward honestly But I haven't done it yet. I want to do it Where's the twisted up there? And then I think when these lights turn on you'll be able to see it. They're not facing the camera, but I think we'll be able to see it even if they're shining outwards So absolute most basic We're just going to go neopixel library so the most basic way we could use a gradient is just by Setting the gradient, you know one color on each neopixel So that's what I'm going to do first But afterwards I want to try to work it in with led animation because there's like comment There's a couple of them where there's single color that'd be cool. I think If they could be multicolor they could be a gradient and there are some that are rainbows So there are some that are multicolors already But I think it'll be fun to be able to define our own colors Okay, I got a check on this cat. What are we getting into buddy ours is um ours is 30 and I want different stuff anyway, so we'll lift some of the code out of here But I won't take the whole thing This is a Something group Oh, we were okay. This was just testing the the display a oapi change Won't be this it will be um The d0 d1 a0 I think this strip has 30 What is going on with the lighting I'm just gonna not do that I think we'll try the default order and see what happens So we'll do a capital T. I don't know if we need this Like display. Oh, you need to do a while true. Otherwise it won't keep showing First time I've done that though. We're gonna take this I'm just gonna go here for now You'll swap around any there Okay, so yes, we have read on The first pixel in the list Neo pixels basically just behave like a list We have green on the last pixel in the list And we must have 30 pixels. I must have got this right because First one is on one edge Last one is on the other edge Uh, so Nice, uh, let's get a copy of this Don't necessarily need all three of these but Fine as well Try out each one maybe Start with linear. Let's go pink to green That was one of the examples on the page where I got most of this gradient logic I've been redoing that 10. We won't do 10. We'll do 30 because we'll do one per pixel Eventually we'll Make it work with different numbers as well Um Can you do slices on neo pixels? Actually, no You do like pixels Like zero Equals linear colors zero two don't have the library Well, that's not sure I guess if it works it will work without the library too, but That in oops slices. Uh, yeah slices like a slice out of a list So like if you have a list for instance, uh, you know my list or whatever like this and it has one two three Um, we'll just say one two three Uh def Just to show that the types of the things don't matter at all really Uh, if you say like, you know ordinarily when you want to access things from this list, right? You go my list square brackets You know, you'd say like zero. I want to get the first Index or I want to get the last index. Let's say Uh, or you know index number three or whatever a slice is taking multiple parts from the list So you could say my list Like one colon three This will give you what they call a slice out of the list. It will give you the items starting at index one Going to index three, but it's I think exclusive Yeah, it's exclusive on the right side, but inclusive on the left side I don't know why just how it is. So like index one does get included. That's the two Uh index two, which is actually the three somewhat confusingly. Sorry about that does also get included Index three, which is the d does not get included because that's exclusive on that side um, but this allows you to take a section out of a list or If it's hooked up then it may allow us to actually put a section into a list as well however that part I don't know if This will work although It's pretty good to me. Uh, so Is there one of these there is isn't there isn't there a slice for all is that just That just colon I feel like we just came across that Sometime Yes So It's promising right over in repel Okay, nice It gets closer to white over here. I mean, I don't think these colors probably don't probably aren't going to come through Maybe if we do this better. I need to think of slices like ranges with start stops. That's true. Yeah, like range like for eye and range Which also is the same where it's um Exclusive on one side and actually I yeah, I forgot you can I think you can you do steps in slices? Remember actually now that I said for a second. I was gonna say Yeah, you can You can do step as well You're trying to get evens or odds or every fourth or whatever um One thing we could do to get further away from white in the middle here Could we just make these overall darker? I kind of get us farther away from white A little bit dimmer that shows the color a bit better. Okay Okay, so that's pretty cool. I do like that That is a fun that is a fun Utility a fun thing Be able to do Let's do one of the fancier gradients as well We'll pick some new colors. Oh, what do we think for colors here? Um, let's use a blue let's go Blue to yellow doing uppercase and lowercase mixing Let's go all lowercase Purple down with purple. Let's so we go blue to yellow We go purple after that or do we want to try four four might be a bit much for this strip I think the strip that's on this heart shape is a Bigger strip. I think it has more pixels in it. So we could do bigger We could do more colors on that one and have it actually Or not better. I think Mixing is for chaos hours Case mixing is for chaos hours Uh Blue to yellow Well, so purple is tough actually We will need I'll need a Eyedropper or something to get purple. I don't know a purple hex off the top of my head Only pink Purple maybe I don't know. It may look more pink when it's on the actual LEDs honestly, but that's the hashtag kind That looks like We'll go num pixels Go this Purple is on the far end. It's very bright It'd come out more closer to pink. I think I'm not sure about the yellow yellow seems Basically just white I guess that kind of makes sense though. If you gradient blue to yellow You already have max blue and you're approaching max Maybe we don't want blue to yellow. You don't actually really see the yellow Kind of just looks like blue to white and then white to purple Now we can kind of see purple like blue to purple to yellow And I do actually like I will say I like this transition from blue to purple here It doesn't come through the camera quite as well Like through the camera, it looks a little bit closer to white I think but to the naked eye honestly, it looks further into the purples there Whereas like this bit over here looks a lot more white on this side So that is actually super easy because of the way the pixels already behave like a list and we are basically making a list of colors Super easy setting it into there. No problem. I was thinking I was not I don't I hadn't really thought through how it was going to work. I had no idea it was going to be that easy That is actually super easy Uh catching up to two ethernets two wi-fies. There we go. Uh, anecdata linked the gist from the mega internet of doom device You have a definition somewhere for how many pixels should be the color Does look better. Do you have a diffusion plastic? I do not have diffusion plastic, unfortunately I have sheets of white paper which sometimes Make it look better But right now the sheet of white paper that I have that's closest Is actually underneath this and there's a lot of stuff on top of it I don't know that I can shuffle it out of there. I don't know if it's gonna make it too much better even if I can Probably won't be able to get things back Yeah, I think our problem with that Is that our lights are also not pointed straight up into the camera since they're pointed outwards the paper diffuses it almost too much I am also on like low brightness too though. I could probably crank the brightness But all right with this for now. Okay, let's try this bigger one Prepping the overall brightness can help I am on point one I can I could still back off a bit, but I am fairly low already It does actually help it come through the camera quite a bit better Up with cranked brightness. Yeah, that's probably how we'd have to do it He's a paper Cut straight and long. Yeah I think it's if I had them pointed up. I think it would uh The paper would be good, but I am gonna see Oh, did I So there's actually a bit of a mystery on this device as well this one with the heart Maybe we'll get into troubleshooting that some I don't know the first thing I want to do is certainly try out the gradients with it, but If I recall right, this is doing a thing where Some of the LEDs actually are a color that I don't Know why they are the color they are We have a bit of a mystery Let's get this out of here. I will turn the main light back on And so one thing is uh, I noticed this came unplugged And I took it out of its home As it is a very precarious breadboard Wired thing here. I don't even I'm scared to even move it all up in the camera frame Because the wires aren't that long and they come unplugged very easily. So The circuit's not that interesting. Anyway, I promise it's power. It's ground. It's data right now ground is plugged in That is it. I need to figure out which one is power Power is this outside edge right here power. I guess we're probably gonna be wanting the five volt power for neopixels Which on this feather is labeled usb then data I have no idea which pin the program is written for We're gonna plug the device in first and this device is probably going to be on Some kind of ancient circuit python I don't even know Yeah, well, no, that's our okay. That's our data pin. Uh, I don't even know I do not even have any idea. I wonder This is gonna be 700 alpha five Not actually as old as I expected to be honest Still a ways back for This is a feather in four So from 700 alpha five up to 800 beta five We'll make the complete jump Has gone to shippu Uh was on a seven alpha five word. Uh-oh On the same one having trouble, huh? Hopefully we'll be you know if we get lucky honestly, I'll upgrade this and then we just won't have that weirdness with the color Should we let it let's let it run once actually let me let it run once before we update it pin d9 This one has 96 pixels on it pin d9 is where we want to plug this in and is probably just nine Ten nine plugged in Back to light show mode. Maybe Really the light the main thing I needed the light for was to get those Red board wires plugged back in Okay, so I think it's a pretty short little cycle of things here. We'll let it run through its thing This one's rainbow. This one as far as I know everything seems fine so you see this There's a red one down here In the very bottom But this one seems mostly fine red and white red and white It doesn't really come through very well, but this one down here the first One on this side. It's turning red sometimes when it It's not supposed to this is where it's most apparent I believe this is supposed to be all blue But we have that red down there and if you once you see it in that one if you start looking for it You start to notice it in other ones as well where this Basically like this last pixel here Sometimes is just red when it's not Doesn't seem like it's supposed to be how's it going axle? We are working on some gradient fun right now. We're trying to figure out how to apply gradients to neopixel Strips or I should say we did figure it out. It's super easy actually since both behave like lists The slices make it super easy to set our gradients into the neopixel So now I've got this thing out and I'm about to update it to a new version of circuit python And we're going to apply some gradients onto it Ultimately, I'd like to try and hook it up. So some of these led animations can use gradients as well right now I have a couple stock led animations running Um, but I'd love to make them to where they can transition through the gradient of colors like You know, imagine this if it was like blue on this end and it transitioned to green as it made it to the other end or whatever um I think some stuff like that would be cool if we could apply those gradients to the animations Some of them have rainbows already But I think it'd be cool to be able to just pick and choose which colors we actually want beyond Only the rainbow or any of the ones that are built in if there's others. I don't know Um, but first thing we need to do is get this updated. We'd actually I will need the uh I will need this light back on because I cannot see the reset button Uh, and then We might Indulge a slight rabbit hole, you know, if you will go down the rabbit hole a bit We might indulge a rabbit hole of why is this one pixel red? When none of the code tells it to be as far as I can tell We'll see if it's still doing that after I update it if it is And we play with our gradients a little bit Then that'll be the next thing I do is a bit of sleuthing trying to figure out why that pixel is getting painted red sometimes Which is unrelated to the gradients altogether, but I just happen to know that this thing does that and It's been on my list of stuff to look into for a while And I haven't done it because this thing ordinarily is just mounted to a wall Somewhere else in my house and so I don't take it down very often But I have so now is the time to work on it Uh, where am I going? I do not even know let's copy this from here and then go to the boot drive Supposed to be going at least go back to uh Brave mode here Oh, yep, it's fixed Red one's gone So that was easy That will not require any sleuthing That's like a little red here, but that might be intended. This one is kind of like red to pink to blue This one is rainbow-y. So like occasionally it'll be red here, but it was red more often This one is red because it's just resetting This is just the reverse of the last one. So it's also red because it's resetting This one just has red down here. So that's fine The blue one where it sends like one thing around that's the one where it was most obvious This one a little bit and I don't see it there now. So we're looking good Let's get the blue one though Not this one Although I don't see it here. So that one's looking good too I think it's next maybe no after this one There we go. Yeah, this one was the most obvious. There was red down here. Super clearly red Uh, and now we don't have any so Wait It's fixed No more phantom red Uh, let's do some gradients This is the code that's on it. The code that's here is going to be super basic It's just initializing the neopixels setting up led animations on a um What do they call that a sequence? I think sequence of animations. Yeah animation sequence Uh, and then just running them automatically on a on a loop there chase No Which one is The single blue comet it must be well, but that says tail length 20 I don't know. All right, here's what we're gonna do though. We're gonna take this Save that as a backup and then I'm gonna get rid of everything after We set up the neopixel grip all the neopixels Uh, and then our other gradients actually on the other device Could plug back in but I think I'm just gonna put this on the device also I think Oh, it did actually Find it there interesting. Okay. What happens if you do a two color one of these? I don't know if I ever tested that I'm gonna try a two color one So now this is what we just discovered on the other list is because of slices you can super easily just go Set all the pixels to all the colors in the gradient Now you it would be a bit more complicated if you didn't generate What is going on? All right, uh, it'd be a bit more complicated if you did not generate the exact number of colors you needed Maybe we'll do that next Uh, like a map so we have 96 pixels. We're generating 96 colors. We're about to But what if we only generated 30 colors? We could still we could still use map range You actually set it accordingly Oh interesting. Okay wait Did that work? I'm not sure if we're looking at Just where we happen to stop or If this is actually what it looks like is this actually what it looks like That's actually what it looks like Oh, I don't know. No, something's broken. It's not filling the Ah, yeah, there we go. Okay, that's what it looks like that makes more sense. Yeah, no green We shouldn't have the green in there There's our yellow to blue and it does It is white in the middle Uh, and it is also ultra bright. Let me chunk that down I saw that came through quite a bit better. So in this case, it's not that much better. Is it This one has its own diffusion, but it does. Uh, it throws it off a bit In terms of getting picked up by the camera Blue to green Do if we go blue to green through red It's probably gonna get us pretty close to white, isn't it? Kind of but not actually Almost like blue to pink and then pink to orange ish to yellow ish to green That's kind of a cool one Okay, so that's pretty sweet We can set our gradients on here and this I will say like it's not it doesn't look that cool through the camera Honestly, obviously it looks way more impressive to the naked eye than the camera can make it look This one is not great for picking up this like sort of neon Strip or whatever these ones are facing upwards at the camera And I think it's just washing it out. I don't know if we get if we got even dimmer. Is that gonna help or is that gonna hurt? I don't even know if they'll run that low Oh interesting You can kind of see it, but the the colors still are washed out a bit. Honestly It's looking pretty nice straight to the eye though. And this one is This strip is a lot more suited to showing the whole gradient like this because it's got so many more Pixels in it than 30 We have much like really really smooth changes In between all of the colors here Point two looked patchy. Yeah, one of them they didn't uh It did not it turned some of them off like it was almost like not enough power to even light some up or something interesting One day some company will produce cameras that can show LEDs accurately Yeah, they'll make a fortune from youtubers and makers. Yeah, okay can you Can you rotate? Uh a list like So like if I have a list, right? Is there a thing I can do is there like a function or something I can pass this to or call on it or whatever to get this one like starting at here And then like afterwards, you know get the next one like just kind of cycle through it like this and they just each time You advance forward by one and the beginning wraps around to the end Because if we could do that we could like rotate this around the whole strip so that like like right now blue is here and green is here If we could do this like rotation thing here, we could kind of spin it around Is a negative one step can pop from the end and insert at zero. There we go pop from the end insert at zero Yeah, thank you. I was not thinking of it that way, but that is definitely that's exactly what we want but uh Other way around pop from the beginning and add to the end is basically what we want But yeah, okay. How do we uh, how do you do that? Um Is so pop is going to be the end I think All right, right. This is actually still this list here. Yeah pop is the end Is there a can you pop an index? Hey, whoa Index can we do that here? Okay, sweet. So we could go So inside our for loop we go I mean inside our while loop. I was gonna say we make a for loop. We don't even really need a for loop though. Truthfully, we just be just um We could just do it in here. So let's go Bestia colors We're gonna append a new one on the end the one we're gonna append on the end is the one we got from the beginning which is pop Oh pop zero So grab it from the beginning remove it move it all the way back to the end and put it back on So we're gonna do that and then we're gonna update the pixels by just doing this again Probably we're gonna want A little bit of sleep in here. Otherwise it might go crazy on us Maybe something like that. I don't know. Is this better? It's five better Hope when we get a setting if we can land on where the colors will come through a tad better I don't know if we're gonna get that lucky though That's actually quite slow. We might have gotten away without Gotten away without this. I mean that's about the speed the animations. We're running When it's too bright it might this one might benefit this one probably would benefit from the paper unfortunately though my paper is Not actually big enough to go all the way across so Even if that would work, it's not Not gonna help us for now. Okay That's fun. That's a neat kind of animation A uh rotating gradient animation. Maybe so like what would be a fun exercise Maybe is adding a new animation object Is slow because you're copying. I mean, I feel like it's pretty fast. Honestly this one without this is I think about as fast as the uh As the um What you call it The animations I had running in fact, this might be a bit faster I mean, I'm sure it could be I'm sure it could be more efficient than this what we could just always change I mean we could always I mean, I guess we don't even do we need to actually change this I suppose we could Uh Suppose we could just not even update this and only do this one. So this is like Don't care about efficiency Just want the easiest code, but we could actually go pixels So we go, uh, let's go Whoa, let's go temp equals none Let's go temp equals No, we can't do that everything every index needs to change I was gonna say we only need to change the first and last one, but that's not true though We actually would need to change all the rest of them as well I don't know is it gonna get more efficient if we because we still have to change basically we every single pixel has to change To whatever the color its neighbor had last frame So I mean I have no idea if like maybe using a for loop instead of this would be more efficient I don't know that could be But I think I mean I wouldn't suspect by that much. Would it be? There's no way to do it is use a ring buffer I will freely admit I don't I'm not up on that. I'll have to I'd have to read into that a bit Change the color list to start and stop with the same color It's fun to me. I like it. Let's do it And now we always have the same Now it like Both ends are always the same Beginning and the end Of the strip which are down here are always the same now We did get a bit closer to white in some sections as well Okay, I want to look at comet. I think I think that comet was the one we had before that was Just blue I had a tail length of 20 Come on, buddy Little fuzzy dude always getting into things Okay So we would basically instead of these we would go Animate There's only one in all right. There's our comet I am surprised. I think our thing said 20 on the tail length is awfully large What it actually does Speaking awfully long for you my dude Hey, hey, hey, hey Tail length 20 I feel like it's small. It does go way faster Speed one So that's about what it looks like We have bounce false on that one, but Our doesn't matter too much Let's look inside comet and see if we can All right, maybe we can already give it a list. I actually don't know how it works at all What I would like though is if we could give it a list instead of a color and if like Each time it updates it will also advance through the list of colors It does look like so it looks like so far. It's written for a single color Let's have comet colors though Imputed color set color Health comet colors equals black interesting. Thanks comet colors append calculate intensity. So this is I see, okay So one thing it does is it makes a tail for the comet which kind of fades out towards black from Whatever color so in our case blue There it's reversed ring Raw object number pixels is length if ring There's pixels This one has colors here start equals colors Start plus ones Start wraps around here with the if statement else if it's not ring, then it just goes color and colors Break pixels start equals color How would we do that? Set color Imputed color Curious what we have for comet colors here Is that I'm curious what we have for that. Is that a list representing Individual pixels and the color that they have right now or is that a list representing Like this is one color. This is a little bit darker. This is a little bit darker. This is a little bit darker without Without regards to how many actual pixels are colored that color I Could see either but I don't actually know You keep it. Let's see. You could keep the list as is and only increment the index and then do pixels index colon equals SCA colors colon total minus index and swap around You make it a memory view. I haven't used memory views before either. I'll have to look into that them as well It's say it's basically a list of hexes though. If that can make it behave as a memory view that'd be pretty sweet kind of use Like the before slice and the after slice increment the index Is it less operations that just been splitting in half? I'd have to actually try it truthfully I can quite picture what it's doing in terms of how it's going to slice Um The same number of pixel update operations, but you don't have the cost of I see okay The actual pop and append functions Right is your I see I see so you Instead of pop one side and append the other side you're always just keeping track of the current index Doing everything before and doing everything after So the the actual order of the colors in the list doesn't change in that case you only update The neo pixels in fact, yeah, you just update the neo pixels you don't change The list of colors at all. Okay, that does that does make sense. Yeah, because it wouldn't And then yeah, I guess it also would make sense these I have no idea what What the tax is but yeah the tax inside of append and pop Where's the rest of this Oh, they were they were there We might as well, I guess put the new one though I have no idea how old the version I had was Pop is on because it has to remove move all the elements Okay, so I am interested to see inside of here. What is this? List Are we gonna spam really fast? Did spam really fast, but then it stopped so this is only This is basically from black to the color that was chosen 11 We gave it a A length of 10 So will the biggest one be six this time? So, okay. Yeah, so this is generating Although this doesn't go all the way to blue interestingly The last one go all the way to blue It did no actually it didn't okay. I just only went to 230. So this is basically generating A list of tail length plus one colors That go from black to the color we specified So it's basically able to It's kind of already doing a gradient, but it's just always doing a gradient from Black to your color or vice versa if you want to think about it the other way around So what if we had gradient Comet or we forget to do this we make this do This first actually Gradient comment here this will so far should still be the same It hopefully work Not important comment. Do we not be able to work comment? Oh that changed the wrong one It's not even really a gradient. I don't know. We'll change the name of it later And and there's a couple of ways this could work To start with I'm going to try to make it so that instead of this thing generating its own List of colors here I want to try to make it so the user could pass this in How does this actually get set up? We'd look at comment colors and maybe computed. Well computed color is a single one. We should maybe look at comment colors also Left side right side ring ring super initialize Be set who calls this I guess Called after a color has changed So then color to get called the first time right here Triggers set color. Yeah, it's our computed color after we get those all the way blue Which is I guess really just the same thing that got passed into us probably right same thing that got passed is this I don't really know why it's Getting set again back here It's already set there. I don't think this is actually changing it, but I'm not sure So let's go self tail colors is equal to Tail colors and then in here. Let's go if self tail colors Do this stuff else Do this old stuff here then in here. We're just gonna go self comment colors equals self tail colors If we don't update our signature when we call it Nothing changes. Why don't we go back to the gradient every time? Do I still have gradient in here? Ah, right? Yeah, okay enough So far we haven't changed it, but now if we go tail colors your colors I think was Was our tail size plus one. So for now, I'll keep this equal and do this as 11 affected argument And not at it I didn't tail colors affected argument underscore Okay, interesting So we have a comet going around but our comet is red and our Everything else is green We're not getting black I guess we actually still need black So let's say this is oh, whoa, whoa, whoa you 10 near colors near colors insert zero Black Is our comet just had black at the first one? Yeah, that's what I was trying to get Sweet So now we have a comet that follows A gradient you can tell it which colors you want your comet to be And instead of fading to black it fades from one color to another Or if you wanted you could do a triple gradient and one of them could be black In fact instead of inserting black, let's do this differently. Let's go Let's make a new FCA Comet colors Let's go Oh, do we want to go from black? Maybe we want to prepend the black. Maybe that's the better way to do it Let's try it this way though. Let's see what happens. So let's go from black to Green Or should we choose new ones? Let's go from black to blue. Let's try like that. I don't know what that's gonna do It'll do um 10 though Uh 11 actually if black is part of it Interesting, slow it down some If we do it that way, we don't actually have to include The black at the beginning Although if we actually make this into a shareable class, it's probably better To prepend the black at the beginning That way the user doesn't have to pass one that contains black So what would we do if They didn't fit perfectly because I think This now is just basically ignoring the tail length Like I think this actually just looks the same as it did before And now if I change this one to be 21 now, I think it will be longer Yeah So we actually will want Ideally we would want No matter how many colors they pass in We will want to generate that list using map range Comparing to how long the tail is Which means we get a little bit more complex in here. We can't just set this to this Instead we're actually doing something kind of like this. I'll just leave the black here that way we're appending it Uh and then in here we're gonna be Going to be looping this many times Going to do intensity anything Are going to append a color the color we're going to append though That's going to come from tail colors the index we're going to get is Going to come from map range in minimum in maximum so the It's going to come in is This which is the minimum is zero the maximum is Tail length minus one Oh, I did it wrong. It's in min No, I didn't yeah, I did it right in min and then in max Out min out max Oh, and the number is actually first so we should do in over here In min in max then out min out max so this will be zero here and then it will be length of the tail colors So this will basically map The difference between the length of tail colors versus the length of tail length So then I think this one will give us the long tail again if we Set this to 20 but still have this on shorter like 11 No module simple i o our date circuit also text out of range off by one error or do we have like completely Way off the mark not even close error We're index 11 Yeah, which doesn't exist because this is 11 long So out max is too big It should be minus one Are there any use cases where background isn't black Background isn't black Not sure what you mean You mean the comet specifically I will say the black seems important for making it Um Actually turn off the part where the comet is not If you don't use black as one of your colors, then like over here would not be off When the comet is over here for instance Um, I do think this worked. So now we have Only 11 colors our tail length is 20, but we do have the long tail We could even further go like five colors We still get roughly the same gradient So now we can independently change the tail length from the colors So we could get rid of this we already do have black getting added in So one thing is I don't know if the tail length is shorter than the colors Still does work pretty well though got green to yellow Okay, that's pretty cool. I do like that That's cool. I don't think it's ready to share yet I think there's still some work to do on it, but I think the basic idea this is pretty similar to what I was going for I wanted the way to be able to like Make the comet be your own colors rather than Just a single color. So now we have yellow and green You can do any colors you want in here You could do more than two if you want you can have three or four however many um And using this new gradient comet which will probably rename that to Colored comet, maybe we have custom color chase. So maybe custom color comet would make sense Probably would make sense something like that Because you it wouldn't have to be a gradient either, right? You can just give it you can just give it Two colors five colors. You can just make up the colors you want. They don't have to actually be a gradient Um can be any colors obviously just a list of colors Which is exactly what our gradient functions return. So that's what I'm using with it But obviously it could be anything I have 11 of the neo pixel bff What should I do with them? I realized making a five by five pixel game is kind of beyond my scope right now Uh, for example, if you wanted a gradient Blueish comet traveling around a solid red heart. Oh, okay. Yeah in that case you can well So I will say that one In order to make that one work. We will have to You would have to not set black in here. It's probably not the best name for this but D list, okay, so now so right now the behavior doesn't change of course because we didn't change that thing to true Let's go back to 20 here. Let's go you said what now you said blueish Having around a solid red heart Uh, we're gonna have to be making a guess on which one Goes first and which one goes second Because I do not remember But we still have black actually Oh, I didn't pass it still. I didn't pass it still Uh, use black now use black the right also that shouldn't be that should be this use This and then up here Blueish comet traveling around a solid red heart and up we were backwards There we go solid red heart with the blue comet flying around it And then It turns out that you get a tail of kind of pink because it fades from the blue into the red which of course goes through pink Um So in order for that to work you do have to basically you have to instruct it somehow here not to start with black So we would either have to like get rid of this all together and not have it just assume that it's going to put black Or we'd have to do something like I did here with a boolean One of the two if we just got rid of it all together then the user could always use like the user could always put black in their list Uh, but I think it's probably good since comet since the regular comet does it by default I think it's probably good for this one to do it as well Uh, but maybe we keep the boolean like this that way you can switch it into this mode where You don't have a um You don't have like a darkness portion of the thing You have everything is always on and it's just gradients from on To Like from one end to the other of your colors essentially Sweet. All right So that's awesome. I am happy with the progress on that. Like I said, I don't think it's really ready to share yet I do think there's still some tweaks. I want to do to it. I'm sure the name Probably gradient comet is not really what we want to call it. Of course, I'm been using it to test the gradients, but The truth is it could be any list of colors, right? It's really just a custom color comet. So um, I'll probably change the name up and Get the code cleaned up get things fixed up get it actually documented properly And then once all that's done we can actually make a pr from it get it submitted to led animation Um, I think that's going to do it for tonight though That is the main thing that I wanted to play with was gradients and neopixels And I would say we definitely achieved that we figured out how to set A list of colors into our neopixel so that way we can just gradient across the entire strip Uh, we also figured out how we can animate that by popping from one end depending on the other And then here we have now figured out how we can modify some of the led animations to start using our lists of colors um, I think there will probably be a lot of Stuff if we look inside of these rainbow like rainbow chase rainbow combat rainbow Sparkle In fact, I should have probably looked at rainbow comet. I didn't this is the one that's going to be having some different logic inside here Where it's doing color wheel um But I suspect we could pretty easily adapt the rainbow ones to Use gradients instead of rainbows because right now they essentially have a gradient It's just all the way through the whole rainbow. So we could just give them a different gradient That's only through certain colors And I'm pretty sure all three of these will be easily adaptable to do that So that's what we have to look forward to next. Thank you everybody for hanging out this evening I do hope everybody has a good friday evening and a good rest of your weekend I'll be back on my own stream tomorrow morning at 10 a.m. Central time So if you're interested in that you can come out to the same discord. I'll post the links in there when I get started Um beyond that though. Thanks for hanging out everybody. Thanks for the questions the comments everything else Uh, appreciate everybody watching along. I hope everyone has a good evening and I will see you all next time good night