This is HBR episode 2951 for a Monday, the 25th of November 2019. Today's show is entitled, I walk through my Pyface CAD Python code part 2, and as part of the series a little bit of Python. It's hosted by Mr. X. It's about 15 minutes long and carries an explicit flag. The summary is, in this episode I cover some generic functions as the top of the code. This episode of HBR is brought to you by an honest host.com. Get 15% discount on all shared hosting with the offer code HBR 15. That's HBR 15. Bit your web hosting that's honest and fair at an honesthost.com. Hello and welcome hacker public audience. My name is Mr. X and welcome to this spotcast. I'd like to start as usual by thanking a people at HBR for making this series available to all such an invaluable service. HBR is a community-led podcast provided by the community for the community. That means you can contribute to why you record something and send a turn I'm sure with often interesting. Okay so this is part 2 of my run through my Python code for the Pyface CAD and display. I don't board which I have from Raspberry Pi. In this episode I covered some of the generic functions at the top of the code basically. I forgot to mention the last time that I included a copy of my Python code CAD-menu.py. So it was called, think it was. I'll include a copy of that script on each of the episodes. I recorded this, the actual main part on a one-r and a listening back to it. I noticed that I started off at a nice piece, nice gentle piece and gradually it gets faster on faster to the point where I'm just a jibbling rick. Just desperately get to the end of it. So I must apologize for that and I don't worry if you can't comprehend it. It's a fault at my end not yours. So never mind. Anyway on with this show, so this is part 2. So back in enjoy. What's my theme? How long has this been going for? 15 minutes. Oh, this is a disaster. This is going to be far too long. Right, okay, global variables. So yeah, rubbish. Got too many global variables. So I just mentioned that the various functions. So I've got the first function come to get HPRQ. So I've got a description here. Go to Hacker Publicer, just a stats page and extract the number of days to next free slot. Turns on Blinkstick, LED with colored dependent on the number of days to next free slot in HPRQ. Prince number of days to next free slot to the display. Yeah, so I think that's quite self-explanatory. The next one is a series of functions set up and the control of the Blinkstick. So I was probably next from the Blinkstick documentation or whatever. So Blinkstick underscore off, that turns all the Blinksticks you've got attached off. Blinkstick on open parenthesis color, close parenthesis. So if you give it a few pass a value to it, the way you should do it, you can pass a color and it will change color. So if you is called B-stick underscore on open parenthesis and you put the color in, I don't know, I think blue, it's a blue and that's if there's a blue. Red, then I must be red. Green is a green. Close parenthesis. Then I'll switch on a Blinkstick color green. So Valla colors was a say black, silver gray, white, maroon, red, purple, fuchsia, red, green, lime, all of yellow, navy, blue, teal, and aqua. How accurate these colors are going to be, well, I don't think totally accurate, but there you go. So that's Blink B-stick on, B-stick on random, that just turns it on with a random color. A B-stick Blink, turn Blinkstick on with a applied color. A B-stick underscore Blink open parenthesis color, close parenthesis, so you can give a color in it a Blink off and on basically. Right, so that's the end of the Blinkstick stuff. So death run C-M-D, run command. I used to run external Linux commands, so you can, you can run a command with that basically. And I think that made, I may have got that idea from a project that somebody did to turn their Raspberry Pi into our internet radio thingy. I think I may have got that from that. I'm going to be even going to find the reference, get my IP. Well, that just returns IP address. That's what that does. Get my ESSID, get your Wi-Fi, SSID basically. Get my Wi-Fi strength, well, get it's the Wi-Fi strength as a percentage. Next one, wait for IP. Right, that tries 10 times to get an IP of all the IP address. So, for a length of their Wi-Fi is less than zero and the count is greater than zero. Then go through the look basically. And if it can't get it within 10 turns it'll say I don't know Wi-P. So it's a very, very basic thing. I'm going to show you what's popular to tell you the truth. I haven't thought I tested that. Death show Wi-Fi info shows Wi information on display shows ESSID on first line and both the Wi-Fi signal strength as a percentage and the IP address on the second line. Obviously, in these ideas, you can pinch for your own use. So in these ideas, you can obviously pinch for your own use. Custom bit maps, selection of custom bit maps to use on LCD display. So I've got a speaker, a play, a stop, a play list, a pause, a back and a forward. I think some of these I had to draw myself. As it paused, I had to draw myself, I can't remember. One of these ones I had to draw myself anywhere. I couldn't find an example on line and I was a web site you can go to to work out. I think it's a chip that uses on the LCD display board and the company that provides a chip has got a web site, a handy website where you can put a numbers and it'll give you an approach. It'll show you what it's going to look like basically. Because time to, it's quite tricky to do with numbers yourself without this website, you can do it, I think. So that's that. Right long string open parentheses, long string, close parentheses. So this is one of these rare examples where I pass a value to one of my functions. It's a string that you passed it. So it writes a long string to the pie face control and display LCD and scrolls it to the left until the last character appears on the right hand side of the screen. This, this is my, I had multiple attempts at doing this. My first attempt was it was just a hack really and it sent things good at wrong and also stuff like this. This one seems to work. This seems to work reliably and I add a character at the end because it's otherwise it would be very, I can special character at an exact kind of arrow thing that came across. It's like a pointy arrow so that you can clearly see where the end of the string appears at the beginning starts because otherwise it's not tricky to see, it's a bit tricky to see where the string stops sort of thing. So there's a, there's a few variables, look, local access, you've got global variables and local variables. So local variables are only visible from within that function. So there's a number of local variables in the right long string function. One is called display size and it got set to 15. So that's a number of characters that can be displayed on one line of display. Another one step size and that's come to set to four. Step size screen scrolling message on display. So as it's scrolling across how many characters on each scroll does it do you want to to move it? You know if it's going to, it's going to ripple through. Is it moving the screen one character or two characters or four kind of whatever? Now this was of something that I did there's a finement later though and because I just, well I'll carry on in that I'll explain a minute. But good after that I've got scroll speed and that's set to 0.55. I think that's a second, 0.55 second. I just scroll speed delay in seconds between scrolls. Oh the last one is, oh the last one is scrolly scroll equals zero. Default value for scroll used when string is smaller than display size. So if the, if the string is smaller than the full width of the screen then there's no need to to scroll it so it scrolls zero. So that's what that's for. So what I wanted to discover was that you know obviously LCD is quite a basic LCD screen and at different temperatures the refresh rate differs so sometimes it can be very bloody particularly when it temperature drops and but then it could be okay in the summer so then you put it make it really slow and then you find it well it's at slow it's taking forever to scroll and it's unnecessarily slow in the summer. So whether it was thought well it doesn't actually need to move just one character at a time they could pick and it could move more and I found four characters it was quite a good compromise you could still clearly see it's scrolling across the screen look quite natural and 0.55 second between each scroll was fast enough it didn't blur too much and you could still read it obviously you can tweak these settings yourself but that's a whole point of having these variables rather than digging around in the code trying to work out what he's going on you can just tweak these numbers and to suit yourself and you could go crazy I mean you could say that okay between this month and that month then it's summer so therefore set the scroll speed to this speed if it's between this month and that month and it's obviously winter so say that to that speed she could do all sorts of clever things it's um you're limited only by your own imagination I mean that's that's the beauty of um of doing this I think yourself um probably nobody else on the planet would be slightly interested in this it's um but there he go remember a um glad to be talking about project that he did they see you you know a good project you know it was it say something along the lines of something that the person himself is fasteted by and things it think things it wonderful and but nobody else can see any point to you know it's or something to that effect and I think that's true um these are just I just tend to use this thing I don't tend to look at it at all and I'm going to the code for a while other than that tiny wee change I was telling you about earlier were they variable um and it display uh sets up they'll see display for selected menu uh zero for podcast one for audiobooks and two for system so yeah you just call and it display and it sets the display back up again for reset some the the the screen basically uh quite handy display main menu to what's the first initiate display oh yes display main menu so this is the the when you're changing between the menus you get a brief message telling you what menu you're in so clear LCD and display the appropriate main menu message um so for example if you're in menu zero it'll print zero it's zero open square bracket podcast close square bracket wait for 0.7 of a second and then go to init this init display to initiate the display for the screen for menu zero and if it's not zero it does the one for audiobooks which is one if it's not that it's two which is system and so on if it's not that it's an invalid menu right so finally we get on to the buttons except we don't because I think that's a good place there to stop um I think that's long enough so um thank you very much for listening to this hopefully you got something out of it um if you want to contact me I can be contact that at mrx at hpr at googlemail.com that's mrx at hpr the at symbol googlemail.com so tune in next time for exciting episode part three of my series on my python program bye for new you've been listening to hecker public radio and hecker public radio dot org we are a community podcast network that released the shows every week day Monday through Friday today showed like all our shows was contributed by an hpr listener like yourself if you ever thought of recording a podcast and click on our contribute in to find out how easy it really is hecker public radio was found by the digital.com and the informomicon computer club and it's part of the binary revolution at bmf.com if you have comments on today's show please email the host directly leave a comment on the website or record a follow up episode yourself unless otherwise status today's show is released on the creative comments attribution share a like the dot org license