 All right, good afternoon to everybody to get Our windows streamed out so I don't this right now You want this just behind And we turn review we could probably Part is it to see the text. It looks pretty hard. Maybe it's just because a small Well, there's really no text in there. And it's partially the way back So Good afternoon to everybody my name is Tim This is the deep dive live stream, which is weekly live stream where we are working on circuit Python related stuff If you are brand new to this or you're catching this in the future and you don't know what I am talking about Circuit Python is an implementation of Python that runs on tiny computers called microcontrollers Such as for instance this one right here This device is a pi portal has a nice relatively large touch screen there on the front Or a screen with a touch overlay, I guess But the core idea here is this tiny computer is able to run circuit Python Which means when you plug it into your computer, it's going to show up like a thumb drive There will be a Python code file on there. You can edit that file in order to Interact with whatever hardware is connected to the tiny computer So in the case of the pi portal, it's sort of main feature is the screen and the touch overlay Which means your Python code can draw stuff on the screen But there are many many different shapes and sizes of these devices with different capabilities built in Some of them have more some of them have less some of them are tiny some of them are huge Pretty much any kind of different form factor. You could imagine The thing that ties these all together is Running circuit Python on them. So they all kind of behave the same way with regards to being able to be Coded with this Python code If you are interested in learning more you can go to circuit python org That's the main website for the project. You can also join us on the discord Which is linked below EDA fru.it slash discord and if you happen to join us during a live stream There's a live broadcast chat channel on the discord, which you can join Which is the chat that is on the stream right below me There's also some circuit Python related channels that are active all the time whether or not there is a stream going on Circuit Python is an open source project. Anybody is allowed to use it. Anybody's allowed to port support for it to their own hardware So third parties can make their own devices and add circuit Python support to them like this Raspberry Pi device Or Cduino or wave share or Arduino or Individuals they can all create their own devices and add circuit Python support for them You don't have to pay in order to do that The company that makes that possible is a to fruit and this is their website a to fruit calm They are providing the financial backing for a circuit Python by paying the folks who work on the project There's a team of folks who work on it full-time And there are some folks like me who work on the project part-time who they also pay in order to work on it So thank you to Adafruit and if you want to help support the project One of the ways you can do that is just by heading over to Adafruit calm and buying hardware from there So thanks to everybody who does that how's it going some nice over in the discord Quinn man What you doing that? Yep? I will what you covering I will I will say just a minute what we're gonna be working on although Spoiler alert it has to do with what's on the screen now. So you can kind of get a sense maybe Differences between circuit Python and micro Python. I am not necessarily the best suited to answer it specifically But I think in the documentation There is a section about this differences from micro Python. I would suggest start with this I'll link that and then if you have any other questions or interests beyond that Feel free to come join us on the discord and ask Any more specific questions if you can happen to track it down? Well, it's probably really hard right now There was a an AMA on the Python subreddit Which also had a decent answer from both Scott the lead of a circuit Python developer as well as I think either Jimmo or one of the other micro Python developers But I think this is not something you can see right now unless it's archived somewhere Or do we know just released the uno r4 Wi-Fi no r4 Wi-Fi that sounds pretty sweet, you know Wi-Fi oh Wow with a whole little grid of Let's see the picture of it, please The whole little grid of LEDs that's pretty sweet Who's that thing run off of r4? Is that the name of the CPU? I guess our for a R a 4 in one huh, oh Okay, okay ESP 32 s3 nice There's if this you said they just released this there's probably no support for this here yet, but I do think I Do you think that? ESP 32 s3 there are some devices already Based on this chip that circuit Python does support so presumably it should be pretty straightforward to add There's Python support for this device as well. That's pretty sweet Available for pre-order it looks like right now Yeah, thanks for that. I didn't know about that. It's pretty cool All right, so what are we working on today? We are working on this outlined text and to be more specific We are working on taking What is currently just hard-coded? stuff inside of a code file and Refactoring it to make a new class that is a special type of label that will allow us to set the Outline color and the outline Size and then it will draw the outline according to those values What I have in this one here that's driving this thing is I have this function add outline Which is taking a bitmap and a target color and a outline color and a size and Then processing the bitmap In order to add the outline to it whoop something saved the code So it's gonna restart here on us, but We want to pack this into a label object so that we can have like You know, maybe it would say like outlined label or something here, right? Like You know you would make it like this and you would include a bunch of these same properties But you would also include the outline color and the outline size Don't dive too deep. We're gonna be diving pretty deep into the code though No water here. I have a question regarding pie portal on the website. It says it has 256 K of RAM while the ESP 32 S2 feather has 2 mega PS RAM is it really an 8x different seems a bit strange Well, I mean the pipe portal is very very old at this point, right? Like when was the when was the pie portal released? So it's a samd 21 whereas the ESP 32 s2 is a much newer chip, so You know a light like with a lot of computers. They tend to multiply Pretty quickly. I don't know off the top of my head if those if that's like a hundred percent That's a hundred percent correct, but I mean it sounds sounds right to me not Not super big on the stats of everything so I don't I don't typically know the exact like CPU or RAM or Any of that stuff the the one stat that I'm more up on for most of the devices is the amount of space that you get to save your files I know that for more devices than I do processor speed or anything else Ram Yeah, I don't know for sure hundred megs eight megs of flash this one doesn't seem to say RAM I you know that sounds reasonable to me Sounds like it could very well be the case to me that it's eight times But I don't know for a fact, but I do think it's just a lot about the newer chip Last week you mentioned libraries that were frozen in and Not needed or used in the lib folder. How would you determine which libraries are frozen in? Yeah, good question. So the best way that I know if to do that is inside the core project If you know what device you're looking for you would go and find the Folder for that device which is going to be inside ports Then you need to choose what port it is. So like let's just take the pie portal for instance Since that's the device I have here. We would go inside at Mel samd. We would find The Boards folder right here. We would go inside boards We would find pie portal which might be ater for a pie portal, but might be just pie portal Yeah, okay pie portal right there we go in that and then I'm not sure which file it is I think maybe this one. Yeah, this one right here. So mpconfigboard.mk inside the device folder that's gonna have this list down here, which is gonna List out all of the libraries that are frozen in or any particular device Ram is mentioned in the primary guide rewrite makes sense considering the age The other thing that I do have also is I have a I should We make a PR for the new version of display text before I jump all the way into the add outline Let's do that So as part of this effort to make the outlined text I Ended up with Three can side the core to two things one new feature one new functionality with the originally bitmap dot blit function to add the Skip self index. So I modified the core to add this in order to use it for the outline text But also it ultimately got refactored into bitmap tools Which means that the actual bitmap label the regular one the existing one not the new outlined one I want to create it also does need to be changed in order to Be able to use that new version of circuit Python when that core PR would get merged, which it's not merged yet So it's not need to be right now, but it will need to go along with that. So we'll check out What remotes do we have get remote? Okay, let's rename that get remote rename origin Probably want to be adding foamy guy Yeah, for sure. You're welcome foamy guy make a new branch get check out dash B. Let's see. This would be the lit refactor It's from your fruit main track and It's really not that much to change Have it in this just copy that and then paste it and it shows the difference Need more of a difference. Okay, so importing bitmap tools There was a lot more of them. Let's go By get back. Let's say rollback We'll just change the one thing. I think it's the import and then Later on down there. It will need to use the new version Sure why the invention is different. I must have run control alt L on boards I have micro SD card like the pipe portal does the drive That it uses use the SD card as root. Yeah, another good question. It does not the SD card is a separate thing You have to explicitly Initialize and mount the SD card in your code and then you are able to access files that are on the SD card You can I believe I'm not a hundred percent sure But I think you can save Python files on the SD card and then like import or execute them So like you can run code off of it, but it's not treated as the root You have to explicitly initialize it and mount it and the default code that you'll find for mounting it will mount it at Slash SD rather than like slash as the root by itself. This is gonna be Yeah, so the part that I changed was add this which says if bitmap tools has blit then use that Though this used to exist on the bitmap object itself. I refactored it to here In order to save room on some devices that did not fit anymore So now this code will handle and so and then since we have the if statement here it means No matter which version of circuit Python you run it under it's gonna work So if you run it under like current one, it would be this The new one after it gets merged to be this you're not under a super duper ancient old one That doesn't have this then it would actually fall back and do the Python code here So I was curious about that. Yeah, for sure. That's all we Import and then the if statements like the change. I think right. Yeah, okay Let's make sure that's all we need by grabbing this copy and paste it back on the device. I'm gonna close this He's gonna assume the left is the one I want to go So I'm gonna click to that a million times if it's not It's this in here That get overridden and make sure it still works Which it does Then we can go back to our display text. We can run pre-commit pre-commit run a It will format. Please tell me it did not just changed all the same indentions that I got done I did not it did only just a little but it Expanded that one. That's it Okay bitmap tools stop blit Factors support this we will go from a guy remote display text. Let's say So that so that devices that aren't the same versions can still both work library And it created as a draft is it really should not isn't need to be in Arguably probably shouldn't be merged until after this which is set for nine point no point no Because it breaks the changes the API But we'll do this we can get this in now and get the actions worked through if there's anything it needs. Okay Now we can make a new branch and start our outlined label. So let's go get Check out new branch outlined label From so do I want to I mean ordinarily we would go from main I think I actually want to start it from I think I want to start it from blit refactor though Because we're gonna want the version of this that's modified because it's using the new code which is on my device And we want to use the new code because it has the new functionality that allowed this to work so Yeah, let's I Guess it will just go from the branch. We're on but I don't know how that I'm not sure if that's how it works Let me just go new branch from here Branch name will be outlines label Now do we need to copy paste bitmap label or could we extend it? So inside bitmap label. It's extending label base I think if we if we if we I Mean we could basically at the end of this function You could Pretty much kind of like call our ad outline thing here and that should give us the outlined text Can I over? Can I override this and then? Call the parent version, but then add something else to it. It did fail talks me I Run pre-commit, I guess I don't think I read um that's gonna be it is the docs and because that's a core module that needs That needs to use the lock See is this This one. I don't think needs to be here though. This is a library. It shouldn't still that that's either here or there He dogs, but now I'm on a new branch extra space back to outline label I'll merge emerge from this just so we get the latest stuff Python Let's rerun Python override method And call No, these call super dot show Okay, so I think we want to override bitmap label override place text Call super dot place text and then add our outline And then return the result that we got from super place text And I think like everything else pretty much should be basically the same as bitmap label We'll add like properties for the color and the size of the outline But I think everything else should not need to be different. So Let's Copy how does this one work? This extends label. I'm just gonna I'm just gonna make a new one back to outline the label outlined label fix this Just try to tab to the next field in the text file Uh, this is outlined label Why that slowed down? Let me displays Oh This is a subclass of bitmap label that adds outline color and stroke size Version I don't really need time. I don't think We do want bitmap label and we're gonna make our class label extend that We want init def init we want to I guess we're gonna have like We need to do args also So we we would eventually we'd be at well, I'd say eventually we could add it now. So let's go outlined no outline color Um, should we default it to a color or should we default it to none Let's see much sense in defaulting it to none. What color does the label default to label base default to gray That way whether they have white text or black text, it'll still be visible. I don't know if that's That's logic in the world, but go with it for now Uh, so maybe like Nines Uh outline Size equals we'll just say one is the default We're gonna call super Knit we are gonna also get quarks past quarks up Okay, we're gonna override underscore place text. Whoa Dang, okay, put all that stuff in that's cool. We are gonna first call super super dot place Text and we're gonna just pass through all the same stuff Are they Only this one has a default. So I think they're not they're just uh Quarter-based or whatever, right? We can just say bitmap and then text and then font and then x pause y pause skip index and Yeah, we could I guess pass outline stuff here, but I mean I don't know that we need to necessarily because We're gonna have self and we can just look it up off of self inside of Well inside of this function, which is here. So Yeah, yeah, yeah, actually no, yeah, we would never be passing it up to the parent function. Actually that makes no sense So what I'm talking about there Let's get our Imports working here. What's wrong with this? So I think Protocol I guess I don't know is that font I oh Turn is it terminal? What that's from Did that come from? Only for types the font protocol Contact and then I guess we'll say I mean bitmap, but I mean let's try like I don't know we might need we might need it like actually need it for something other than types But I'm not sure you already know what the outline label looks like uh What it looks like will look like as you're developing it I mean if you if you mean visually what it looks like on the display I do like it will look like this effectively. I mean you'll be able to change the color and the size of the outline um But it will look like that visually if you mean the code, um I don't have necessarily a clear picture of how that works. I'm just kind of Flying by the seat of my pants so to speak just kind of trying to Work it out as we go. I mean ultimately I would say what I'm aiming for on the code side is as little code as possible in the outlined label Class and instead hopefully we're relying The majority on our parent class the bitmap label and just adding a little tiny bit of extra functionality At the end at the end of when it renders its bitmap Uh, and then if you meant something else then Feel free to clarify if neither of those was what you were talking about I don't know why Skipindex, why is this unexpected argument? Did it why why do we have? Not sure enough. I don't know Oh, no, it's there. Oh that one. That's the one that is by name. Okay. Okay, so we need skipindex equals Yeah, it still doesn't like it. I guess probably I have a different version of display text installed in my python Environment that's not this version and I guess maybe that didn't exist yet or something. I'm not Why it's not uh It's not recognizing that but that's fine. We'll just go on it's mad because we haven't returned this. Let's get uh parent results And at the end of this we're gonna return that return parent To make it work on images or bitmaps. So Yeah, I think The way that I'm gonna implement it right now is on the label class, but the next level of this Is going to be to try to add it to bitmap tools inside the core make a new function on bitmap tools Called, uh, maybe dilate because I think that's what this process is called And that one that's in the core it will work on Any arbitrary bitmap, um Like a single colored shape inside of any arbitrary bitmap. It won't have to be text. So My immediate Like first goal is the the outlined label to make it specific for that, but I definitely do have in mind Trying to generalize it one step further and also move it into the core which should speed it up some as well um And when that second step happens it would then be able to be used arbitrarily on any kind of bitmap essentially I was referring to the visual aspect, but I appreciate learning a bit more about the development process too. Thanks. Yeah, for sure Thanks for the question Yeah, and and that's the thing too visually like it's very, um It's it's very much up to the font like whatever font is there will have a huge impact on how it ends up looking We we could change a few other things about the visual like right now I am doing I don't know if there's a technical name for it, but I'm doing I guess a square dilation um, you you could do a rounded like a circle dilation instead and it would make Some of the corners look more rounded. So like the top of the h here for instance Right now it's like a square cut 90 for both the foreground, which is the white and the background the outline Which is the black it's a square 90 if you use a circle For your dilation instead of a square then you could end up with a rounded corner For the black up there Which might be a nice effect So like that that may be something we do eventually as a way to kind of give it a little bit of a different twist visually um But that's definitely a relatively minor thing grand scheme of things is it will only really affect those Corners those hard cut corners Everything else would end up kind of looking the same Okay, so we want to here. I think we're gonna just call a function that's called add self dot add outline I we could make it and um Yeah, I don't I mean it's kind of the same deal We don't really need to pass anything to it because everything is going to be on self anyway, so I mean like we could pass arguments, but it's not going to change anything You know one thing we will need to do is probably set up more colors. Where does our palette get created? Is this reset text? Where does it come from the first time that background color? No, but that's only that's just setting items Who creates this? Maybe it's the parent Oh, that's gonna be gonna make it a little tougher, isn't it? Self-taught uh, there it is. Yeah. Yeah. Yeah, okay Um Yeah, we're gonna need a new palette as well because we need to add a third color for our outline because you're gonna be allowed to have Foreground background and outlines so technically you'll be able to have the foreground like the white text The background like the black rectangle here But then you'll also be able to have the outline so you could say have like a red outline for instance And you could have the black rectangle with the red outline around the text too You can take the background out if you want like you'll have your choice of how to do it But we need three colors if we want to be able to support all of those which means we need to change this palette You have three colors, but you can't I don't think like change Palette to have more so what we'll do is we'll say uh foreground color Is equal to self dot palette Z I think zero goes to the foreground That was over here where we set that Set background Okay, zero is actually the background color But that makes it seem like at least so we'll say foreground is one Duplicate background That'll be zero So we'll save those two into their own variables and then we're gonna go self dot palette Is equal to a new palette But we'll have three colors instead of two And we'll technically also be throwing away the old palette here And So then we're gonna turn around and go zero equals background one equals uh foreground Two Will be the outline color Okay, so now we have three colors in our palette and we have the outline color too Got our parent result we add the outline to it return the parent result So Yeah, aside from the fact that this doesn't exist and therefore obviously this won't do anything And this looks good. I'm gonna make sure by just creating this Add the outline And I'm just gonna put pass inside of it and then I'm pretty sure we should be able to create one of these objects and put it on the display It won't have the actual outline in it yet. It will just be a copy effectively of bitmap label at this point But this will tell us if uh I have completely broken the location at all So bitmap labels are fine. We want to make sure that outlined label. So is working So what I'm gonna do is I'm gonna change this bottom one here From being a bitmap label to being a outlined label and I just said it's not actually gonna have an outline yet, but It's gonna tell me if I've already broken something or not other. No, what is it? It's um Rectangle text area this one. So The change our import Outlines label I mean to put this. Oh, did I not call it label? I called it outlines label What are you for scrolling label? I think we will call it out. I think I'll keep it as called outlines label since it does a different thing So bitmap label and label Both contain a class that is simply called label But that is because they are essentially meant to have the same api. They're kind of meant to be like drop in replaceable Outlined label and scrolling label have different functionality. So I think it stands to reason It would have a different name, which means we'll need to do this too But other than that, it should just work. Everything else should kind of follow through from being a bitmap label. Hopefully Attribute error dict has no Get glyph Definitely broken something outline label 41 Which is just where we call super Oh I'm pretty sure I need to do More like this, right? Oh, uh, maybe font actually as well Probably, right? I'm a font though. Can we get that from parent? It's because it's not a quark though. It's a uh A um position based one, so I guess maybe we can't uh Maybe that should work Skip index we change the error at least add outline. Okay at 51. Oh, no, no, it's still Oh, no codepie 51 It's a creep Still 41 here still director Basically get all the way into reset text Reset text is going to call place text, which is going to call Outlined label place text, which is then going to call super and back into Bitmap label place text, but it's failing 66 Got multiple Values for skip index So like here it just doesn't pass it So it's a none to write all pixels. Otherwise skip this palette index when copying glyph bitmaps imported for slanted text where rectangular glyph boxes overlap How would we have multiple values? I don't really get why we would have multiple values When in doubt turn it out You know what they say I don't know if they say that but they should Zero real looks like one value to me Um, let's look at 209 reset text It's here. That's where we're calling place text We call place text. We pass bitmap We pass text or possibly reversed Pass font Padding left padding right Well minus some stuff Plus some stuff two three four five out of one two three four five six Does it get used in here? This is actually used It's passed a blit But yes How does it think there are multiples? Okay, here's what we're gonna do go back to 209 Right before we call place text I mean I can't print out skip index though because I don't have skip index here But it would default to zero here but We would call inside place I'm glad I I did this before we had any of our actual outline functionality because if I was trying to troubleshoot this while also trying to troubleshoot like Radiuses and bitmap manipulations and blitting and all that stuff like we just have so many things Wires crossed. Okay. I wasn't scrolled down. It was like that's a surprising output Okay, so inside bitmap label place text Actually, I'm a little surprised by the order of that, right? Didn't those Be in the other order. Oh nine is here out to call place Yeah, here we're inside reset text inside How to call place text The way I thought this worked is When this calls place text, I would be expecting it to call Outlined label place text since that's what our object actually is In the case of our code over there This does get tricky because I have the other labels actually still on display Let me turn those off. So we're only looking at pronounced from the one new one A bunch of stuff for that problem or back to the same thing. We only should have only pronounced from our one We're inside label resists replace reset text. We're about to call place text Okay. Yeah. Yeah. Now we're inside outlined label place text We had skip index of zero Because it was not passed and the default value is zero Just got printed from here Then we try to call parent Place text Is it not supposed to be this? I don't It's still orange like that to Seven positional arguments, but eight were given so Not supposed to be positional. Yeah, I'm a little Stumped on that why Be a lullo That is that is bizarre. I don't like that I don't think this Doesn't tell you what's wrong. Like I don't I don't understand how I mean it Obviously it does tell you what's wrong. So there's just it works in a way that I don't understand but It would be nice if that error message was like somehow related more so to self and First argument rather than the last argument I guess like everything shifted so Okay, okay. So everything shifted which means that It was treating y position as skip index and then it was treating skip index as skip index But it It would also be nice if maybe that could like check for self right if that's the common way that that happens Maybe just check for that and make the error message say something about it. That'd be pretty helpful Okay, we made it though. Thank you stack over flow hug report for sure. I didn't see the username, but thanks to that person Um, we do have our box now, so we should be good add outline. Let's just make sure one more thing real quick Let's make sure our add outline is actually like doing something Doesn't matter what it's doing Just yet, but let's make sure it's doing something for now. Let's just um draw a line inside of the bitmap so bitmap tools dot Draw a line bitmap is self dot Map and then x1 y1. Let's go zero zero Not tall it is for sure. I guess, uh, maybe let's just say like 50 and Value, uh, so let's do two because that That should be our red Oh, you know what I just realized we're gonna have the same problem That we had with our palette, but with our Bitmap it's probably gonna be the case because score bitmap is Going to get created from the length of palette It's gonna be two when that happens Oh, but this is inside reset text actually so I kind of had assumed that would happen inside of a knit But I was wrong. Okay, it gets set to none here. It might it might actually just work actually Okay, red line. Nope out of range. Um It's 10 too much 10 is too much 50 I guess You should make the outline. Oh, I would try and see I would try and see sure what you mean Range of targets still Do we not have don't have the bitmap out of range of it's the size With the 289 At the 37 Yeah value Well out of range Yeah, I think it's telling me this one Yeah Okay, and there's our line right there as well. So we can't paint our outline color so Reset text gets called from init of bitmap label And at that time When that happens There is only two colors in the palette Because this happens inside of here Both of those things happen. It creates the palette with two. It calls reset text Therefore our bitmap gets created with two. We then create a palette with three out here But our bitmap still has two and reset text does not get called from Reset text, I guess Okay, what if we just do Inside outline label? What if we go here and do it again? So let's just say self dot Copy whatever it says Okay, so no change, but can we use red now? I think hopefully we should be able to from here well Oh, you know what I'm saying red, but like is it actually red? I ever even set it up Create a new bitmap unless it can be reused So probably it probably thinks it can be reused since the it's only checking the size here Well, it's checking none, but It'll be none And the size will be the same so it thinks it's reusable. Therefore it just does this So calling reset text at the end of here does not actually help us Box this is all like so much stuff up here Uh bitmap is none. So what if we go What if we do this? Can make it none in our case Out of range of target It would not be red. It would be this color because we didn't Add anything I'm sure right here. Um, okay, we're gonna I mean it has to be the colors So What if we go self dot bitmap? We just set one pixel. Did we get the exact same error? Oh, but yeah pretty So it's like our bitmap still has the wrong number Colors print Creating bitmap with this many colors Length of self okay, how many do we get? Getting bitmap with two colors Never did it again. So that did not work By bitmap label reset about to call place text Wait, we never got the new one Outline label 41 Calling a knit of bitmap label. So bitmap label a knit 113 is gonna be Set text Set text to 11 place text This text goes inside outlined label Outline 61 Okay, we have not really a race condition, but kind of because This whole chain of events is Happening because of or inside of this A knit call here. This is causing everything to happen Including reset text place text and all that Which is causing us to add outline which is causing us to try to do this but all this is happening from Inside of here all this is happening because of that call at the end of a knit Which means we haven't even finished A knit of bitmap label yet, which means we haven't made our new palette Set our bitmap to none. We just haven't done any of that stuff yet. We're basically still in here Hmm That is tricky I don't Like it It's probably not The actual ultimate solution But if we just ignore that will the rest of this work If we fail to add the outline then don't bother Okay, okay, uh Yeah, I guess I I do have it. Let me actually do make it red Okay, I think the red pixel is there I'm gonna switch it back to the line because that'll be much easier to see Than the single pixel I don't know if we have a different way to do that though honestly because I mean I should say I can think of a different way to do it, but it involves essentially copy pasting a lot more of bitmap label Because like we could copy paste a lot more of bitmap label and then we could change a knit And then like the rest of it can follow suit and we can tweak anything we need But it would be ideal if we can avoid copying like the entire bitmap label class essentially if we can override it instead That's so much nicer And if we override it We need to hook into place text. I'm pretty sure And if we need to hook into place text and we need to call our add outline This is always gonna want to fail the first time it gets called because It's actually gonna be from the init of the parent class rather than Our class so we haven't set up any of our special stuff yet and we can't do it this way because All these things rely on stuff that got done inside of here. So we have to do this first We kind of have this chicken egg thing where this is gonna call This which is gonna call this Which is gonna try to do stuff with the special outlined color Index But that's gonna fail if it's all the way here I mean, I guess we could Instead of try catch. I guess we could like literally like Flip a boolean for first call or something like that, but that doesn't seem great either Well, we'll keep kicking it around the whole brain. We'll see if uh See if anything Better than that comes to mind at any point, but the good news is we have our label showing We are calling our add outline. It's actually being able to add some red pixels. So we're like Most of the way there. We pretty much just need to grab This code Put it inside of here. Hopefully we need Yeah, let me keep all that stuff for now. So add outline Okay, so Yeah, no, we don't need to pass any of that stuff. I don't think We need to pass any of that stuff. I don't know. We don't need the Okay, so stamp source that is our uh, that is our square I was explaining that square and circle dilation This is effectively choosing whether we're going to get those rounded corners or not And in our case, it's a square. So we're not changed to be Here because we need to create one Although we should not really be creating it every time we call add outline because that's going to be every time We change the text truthfully we should create our stamp source Inside of a knit I'm going to put it on self It's going to be a bitmap the size is going to be the outline size How did I do that outline color index? Plus one where because it just it needs to be Big enough it needs to have enough indexes for us to set the index we want So in our case, I think we So outline color index is always two so this could just always be three And that should work as long as this doesn't change then this should work outline color index But it would be two not three there because it's not plus one like that one was okay So now we have our stamp source. We create it inside of a knit so we can use it later on without Having to create it again. So now that's gone, which is nice. We won't be creating that bitmap every single time we change the text Bitmap that height so that's going to be self bitmap and self bitmap And you guessed it Self bitmap target color index now that's going to be That's going to be the foreground color But it's going to be the index of the foreground color Which is One bitmap tools blitz self Self size that is outline size. We should save that on self. I don't think we did that yet We'll make a Property later as well with a setter so this can be set and get We should save the outline color as well. We might as well We're already setting it on to here. I guess but Yeah, actually we're already setting it on to here. We don't need to save it We're going to be using the index anyway. Okay, but size this would be Yeah, that's would be outline size. Yeah, yeah target color index Uh, so that is our foreground color, which is one I'm gonna skip anything else. No, I don't think so stamp source. Oh self dot Wait, who tried to use stamp source? outline label has no stamp source 85 Oh, I did it underscore. I think I did it underscore It has no stamp source either What did I call it? Okay, we have the same chicken and egg problem again because We're inside of this one, which means we haven't set that up yet And so maybe that's what we key off of That's what we key off of If self dot stamp source Then we And we do all this stuff should filter out Not only the first one, but any one that happens to ever happen before We have this I do like this a bit better than the try catch Works Which it does not so I'll add to check if we have it It's like has adder at that point. I thought it would be none if if we didn't have it doesn't get to be none All right. Well in that case, we are just going to go back to try catching and we're going to catch the value error which will come from Not being able to use the correct color yet And we are also going to catch the attribute error We now know comes from Having a stamp source yet attribute error Why is this whole red? Oh our convention Outline still black instead of red Line might be black instead of red. Let's take off the background color First set it to none So is this code adding the Backbox I'm missing something No, that's not adding. So what is adding the black box? Color color background color kinds of trouble So does background default to black or none? What's to none? Color is none It's because we made a new palette Is there a get transparent? I don't think there is Is transparent or is nice. Okay, so we will say Back into outline label Before we throw away our old palette. We also want to say Background is transparent equals palette is transparent index of zero. How's it going DJ Devin? Good evening So if that is will be true or false that's going to get stored in here and then after that we'll say if Background is transparent then self that palette It's parent zero I have no more black box You get no bed either so Oh, that's turned back on actually Yes, we're always getting these exceptions. I have to assume we're always getting these exceptions Just back So it's not a list Isn't isn't there a better way to do that? Did it will just print correctly? Did it print? Print trace print exception. So we got one That we did not have a stamp source And then we got another one that we did not have a stamp source Uh, no see because now we call reset text here So let's put these before that Nice Okay Now we get red and we can change the color now here inside of our constructor Green let's say although green is going to blend in with the Raspberry Pi so that wasn't a great choice You can still see it pretty well. Oh, yeah, okay um Let's make sure if we change the text that it Like works nice Now one thing that might break it is Changing the text color That was fine. Okay. Uh, what about changing the background color? So what if we did bring back our background color? And let's also change the background color here But I do that before the sleep. No, it's interesting how it's interesting that it refreshes Before it changes the text like we get to see these two things happen Before this one pretty fairly significantly timed One thing we may still need to be doing is the patty I think he did not offer all this padding. We might actually Not have a Outline that works correctly It's like a real outline or stroke or customizable. This is like a real outline or stroke and customizable. Awesome. Yes. Yeah actually not Parable So one thing is down here. We don't have a green it looks like And I guess maybe like one pixel on the left. I'm not sure about the left, but maybe one pixel on the left is cut off Definitely the bottom of the p though I think we need to like intentionally make the padding bigger A little bit like we need our padding to be our default padding should be based on outline size Should be like some Feel like the outline size plus something plus some static constant And padding bottom of one is actually not quite big enough yet because we still Either have one or zero pixels of green down there. I'm not sure but it's definitely not two, which is what our outline should be Maybe that could be There you go You find out we could definitely be counting pixels if we do that If it I will say like if it was quicker to get it from the sd card into the computer I hope that one day we will have passed through sd card to where the pie portal can be plugged into the computer and then On the computer we can see The files on the sd card blue pixel down I guess we don't need to have one. Do we want to have one extra? It's arguable. I don't know the Super strong preference I guess There we go now there's actually so random though one on the top four on the bottom Two on the left two on the right and we could probably get away with one on the right Can we or to put it another way? I'm pretty sure the right had Two pixels of space and the left had one But we could have also put the left on two instead of putting the right on one but Get down from the top And yeah I it hit some kind of snag of some sort I don't recall or I don't think I ever really knew what the details were I do remember when Dan was working on it and I think I recall a an update on the uh Maybe an update one week on the meeting or something that was about whatever problem that ultimately came up Something with usb. Maybe tiny tiny usb something It's updated in there or something to support it. I'm not sure But yeah, that would be super duper sweet if we could do that Or uh screenshots Okay, let's make a color so that we can change Rather, I mean, let's make a property so that we can change the outline color Uh, we do need to oh We do need uh, no, we don't need to save it actually we could get it from pallet No, for sure if that's actually gonna work. Let's change it to red nice Uh, so really the only thing left is I think the size Actually Let's change it to one here. I guess So we can't really go bigger just yet because the paddings don't get adjusted Actually, I don't know the paddings Is padding a They're individual pat properties for the paddings or those only set from the constructor Those are only set from the constructor right now. I'd actually need to be able to get those because I think we need to check the current padding and see if it's big enough and then if it's not make it bigger Um, I will be right back though Or anything about usb host device Do we're working on lately possibly something like that instead of hosting externally? Uh, yeah, that's a good question. I do not know I know the only thing I know about the host device stuff is um It would allow you to plug in a keyboard. I'm pretty sure But I that's really the only thing I know about it. I have not actually caught show and tell Uh, I watched yesterday's show and tell but I have not caught the last couple before that I think it's been shown off a couple of times, but I'm not sure the details So we're gonna have a problem if we try to make the outline size too big because We're gonna need to increase the size of the padding as a result of making the outline size too big quote-unquote Uh, which is actually ultimately it's gonna kind of have a cascade. It's gonna have to end up making a new bitmap as well Which is not super efficient. So Yeah, the recommendation would be probably don't necessarily change the outline size dynamically unless you really have to but I suppose we could just not provide the property for it It looks like it worked anyway, though That still looks like two to me Oh, but you know what? It's not gonna call reset text or whatever, right? You know, I think we need to call reset text After we change the outline size so that it will get re-rendered Don't have font Um, is that get stored somewhere? Elf dot font probably I'll score On board so I have an sd card the only thing I use before is music and screenshots What does padding do is that for within the rect? Yep. Yep extra size inside of the Inside of the background of the label That looks like we went down to one on the left and the top but not The right and the bottom Well, you know why that would be because Whenever we change the outline size we actually need to also recreate the stamp source And that is now now our red is actually one and we could theoretically I think set it to anything But if we go bigger than two We're gonna start cutting off the Outline by the edge of the rectangle on the right edge. It feels cramped a little bit The bottom it no longer has its blue line, but I think the outline is all there, which is nice The left looks like it doesn't have its blue line either Pop is now down to one Well, we've made it pretty darn far. I think what I'm gonna do For now is copy this stuff back Into display text repo, right? And now a bunch of this is gonna have new print statements, which I have added a A lot of Is it in here if they're identical Sense is that very much, but okay We can get rid of all these prints now now contents are identical if I So again, it should well, that's probably why You can treat it as a difference though This is a whole this does have a lot of print statements in it as well There used to be a thing called compare with current Or something to that effect and it's not here anymore I don't know how to do it like I think there used to be one called compare with current revision And it would compare the code that you have in the file against the code that is Currently committed in the branch so it would effectively give you your diff of whatever you've changed Since your last commit It's also what this is, but I'm Kind of weirded out by this contents are identical like why is it treating it as a change if the contents are identical? I guess we're just gonna have to live with it though I'm gonna turn off the prints. I think let's get rid of this You can also delete this now. Yeah, I mean I guess we could go back to passing on those Okay, only two that are left are commented out Eventually we could also get rid of some of this code as well, but I'm gonna keep it for now because it's kind of In the mix with the core pr so outline label That's the lines too long valid names Unused variables does not like my commented out print statements That's it, right? I'm gonna go ahead and push it for now. Even though it's gonna fail the uh pre-commit check All right, so that'll fail, but that's fine. Okay. I think I'm gonna wrap it up there for the evening So we created I don't know if I ever did look back on this one again. Yeah, there we go. Okay. We did pass the second time so it's nice Um, and then we don't I don't think we want to create this one yet Uh, especially since it's not gonna pass Actions I think it will definitely fail all that same stuff we just saw So it's nice to have it pushed and up into github I'm just like saved somewhere other than my computer, but it's not quite ready for the pr just yet Um So I think I'll cut it off there. Thanks for hanging out. Uh, everybody. Thanks for all the good questions We have a lot of great questions tonight. I'm always happy to answer your questions about I mean pretty much anything circuit python related whether it's what I'm working on or not. So Um, yeah, feel free to come back on Friday afternoons if you have questions And I will certainly attempt to answer them to the best of my ability Um, thank you to everybody for hanging out. Um, I will be back in the morning tomorrow morning at 10 a.m Central time over on my own channels I will post the links in the live broadcast chat just like I do every week. So if you want to watch more uh circuit python programming content like this you can find that tomorrow morning and If you would like to do so then I will see you then I hope that everybody has a good rest of your evening and a good weekend and all that kind of stuff And otherwise I'll catch you next time whenever it may be Let me see the chat here. Nice feature to have. I've been shooting using the four. Yep. I saw Yours with the the kind of offset four Would have such a huge performance hit on the s2 or s3 stopped using it. So hopefully be more efficient It should be. Yeah, I think it should be for sure because it will at the very least it's it's no longer using uh multiple copies of the whole bitmap so Yeah, it should it should take up less ram for sure. I would think So yep, uh, thanks again everybody and I will see you later