Drilling comedy holes

I put up our Christmas lights last week, what with it being close to Christmas. I’ve not seen the neighbours getting out chairs and drinks to watch me work, but they should do. I’m quite entertaining when I try to do this kind of DIY.

First thing I had to do was make a hole in the garage wall. In previous years I’ve just threaded the power cable for the lights through the edge of the garage door. However my shiny new garage door fits a bit more closely, so the lazy way is no longer an option.

I carefully planned where the hole should be and got out my special long drill bit. I’m very proud of it. It can go through one or more than walls at once. I started drilling and the wall seemed to go on for a very long time. So long in fact that the drill got stuck. So I was forced to leave the drill hanging off the wall with the wire still connected as I pondered what to do next. It looked as if I’d hired the invisible man to do some DIY for me.

Eventually after a bit of fun and games with a mole wrench I managed to wrest the drill out of the bricks. I discovered that I’d drilled into the side of the garage. In other words there was no inside to this hole, it just went on for the length of the building and out of the back.

The second hole was much more successful, and shortly after that I had my lights up and working. I told number one son that I’d drilled two holes that day, one in the wrong place and one in the right place. “Oh” he said. “Which one did you drill first?”

Developer Developer Developer 2020 online

cat Viewer.png

Giving a session online is a very strange thing to do. You sit in a room in front of a camera giving it your all and hoping that there is someone on the other end watching. I was first on one of the tracks, so I was able to kid myself that I was actually doing the keynote presentation….

I did a talk abut Bluetooth and Furbies. It seemed to go OK, except for the bit at the end where I lost my way around Teams and couldn’t find the Q&A window. As you can see above, the I was also doing well with the feline audience. Thanks to @developerday for the picture. All the sessions are going to appear on YouTube in due course. Keep an eye on here.

Compile early and compile often

yet more leaves.png

I’ve been writing a big and complicated program for a while. I’m not sure if it is supposed to be big and complicated, it just seems to be turning out that way. And one of the things I’ve remembered from my days of doing this kind of thing is “compile early and compile often”. If you wait a while before hitting the compile button you can sometimes get so many errors that it can take you a while to figure out. Modern editors are quite good at spotting coding mistakes as you write, but there is nothing like letting the compiler take a proper look at your code.

I’ve been hitting compile every time I’ve written a few lines. That way, if I get an error I don’t have to look through much text. I do this even though I’ve no intention of running the program at that stage. It’s just that when I’ve done a bit that I think should compile it is worth getting the proper opinion on the matter.

When I was teaching programming we used to get people come in with 500 line programs that didn’t compile and they weren’t sure why. They’d written all the code down and then hit compile and were surprised by the number of errors they got. I used to tell them that a good way to start would be with an empty program that compiles and then add the statements a small amount at a time, compiling at each stage.

Conducting currents

The toaster failed yesterday. It did this at exactly the same time as the lights went out and the radio stopped working. Coincidence? I think not.

It turned out that one of the currents had fallen out of a teacake and landed between the element wire and ground. The resulting current flow (I like the way that sounds) had triggered the earth trip on that power circuit. So all I had to do was figure this out, and then go into the garage and flip the switch into the on position.

Current through currents is not always a win.

Solder pranking

When I was younger than I am now and much less responsible one of the standard workshop tricks we used to play on each other was to replace someone’s solder with a piece of solid core wire. They look very similar, it’s just that one of them doesn’t melt when you apply it to the soldering iron.

I did this to myself today. I’ve been wiring up some connected little boxes with solid core wire and I started to try and melt it. It took me a while to figure out what I’d done. If I’d done it to anyone else I’d be quite impressed with myself. As it was, all I did was burn my fingers a little bit…

Fixing Windows 10 USB problems

mouse power.png

Ever since I got my desktop (four years ago) I’ve had a problem with my mouse and Bluetooth connections randomly disconnecting. This was very irritating, particularly if it happened as I was coming into land or under heavy fire. Or both.

Number one son reckoned that my machine was possessed in some way, but it turns out that the truth is much simpler. I was allowing Windows 10 to turn off these devices to save power. I’ve no idea why a desktop machine should turn off your mouse and keyboard connections in this way, but it does. You have to explicitly tell it not to by using the USB Input Device Properties dialog above that you can find in the Device Manager. I made the change (for all my USB devices) a while back and it has worked for me so far.

Alarms are complicated

I’ve always found it surprising how simple things end up being complicated. Take adding alarms to my Connected Little Boxes…. I want to have alarms that I can set in the device. When an alarm time is reached I want the device to perform an assigned action, perhaps make a sound, drive a servo or change the colour of a light. This is simple I say to myself. And I write a function to celebrate:

bool atAlarmTime(struct ClockAlarm *alarm, struct clockReading *reading)
{
    if (alarm->hour != reading->hour)
    {
        return false;
    }

    if (alarm->minute != reading->minute)
    {
        return false;
    }

    return true;
}

The function will return true when the clock reaches the alarm time. I can use this to trigger whatever action is bound to the alarm. Simple.

Well, not really. My program will be repeatedly checking the alarm to see if it has triggered. So if I just use the above function I will find that an alarm will trigger continuously for the entire alarm minute when it due. And what about when I turn the device on or change the time? Do I want it to ignore “past” alarms or not? If my device was controlling a heating system I’d want it to respond to an alarm even to turn the heating on even if that event was in the past. Otherwise I’d turn the system on at 12:00 and freeze because the event that turned on the boiler was set to 7:00am.

I’ve ended up setting up options and flags and writing code that spins through the set alarms looking for ones that should have been triggered and triggering them if that is what the user wants. Yep. Alarms are complicated.

"Don't Buy" PIR Sensors

dontbuy pir.png

More PIR advice from Rob….

The UK consumer magazine Which? has a “don’t buy” advisory that it slaps on really poor products. I think I’ll have a go at that. I rate these HC-SR505 PIR sensors as a don’t buy. I got them thinking they would work as well as the HC-SR501 sensors that I’m using for my “Connected Little Boxes”. It turns out that they are a bad bet for two reasons.

  1. When they detect a person they hold that signal for around 13 seconds before releasing it. The timeout of the HC-SR501 can be adjusted and it has two different detection modes which are much more flexible.

  2. They stop working after a few hours.

Definite don’t buy.

Things not to do with PIR sensors

pir lense.png

“Hi. I’m Rob. I do stupid things with hardware so you don’t have to”

Today I thought it might be a good idea to see what happens if you try to use a PIR sensor without the plastic dome lens on top. I figured that I’d be happy to sacrifice a bit of sensitivity for a cooler aesthetic. In other words I wanted to get rid of the ugly dome and put the sensor behind a 3d printed panel.

Preliminary tests suggested that this might work, so I designed and printed a case lid and put the sensor behind it. Then it didn’t work at all. I think that 3D printed PLA is probably a bit too opaque to the infra-red signal that the sensor uses. Oh well.

Cascadia Code Looks Lovely

cascadia.png

I’m a very old programmer. I can remember when “Courier New” was the monospaced font that everyone was using. Then came “Consolas” which I still really like.

And now we have “Cascadia Code”. I’ve decided that this typeface is one of the reasons that I like Microsoft Terminal so much. It is the default font used by that program. I think it looks really good. There’s a whole family of Cascadia fonts including some very nice “light” monospaced fonts. Well worth a look if you want to spruce up your documentation a bit.

Microsoft Terminal is Awesome

microsoft terminal.png

Of late I’ve been spending quite a lot of my time in Windows PowerShell. One of the things that drives me a bit nuts about it is the horrible choice of colours for errors and whatnot. I’ve quite often found myself having to cut the text out of the window and paste it into Notepad just so I can read it with proper contrast. Colour combinations such as dark red on dark blue don’t work well for me. Perhaps its my age.

Anyhoo, I’ve found a way round this which works really well. It’s called Windows Terminal and you can download it from the Windows App store. It has tabs so you can have multiple shells open in the same window - which is great if you’re talking to several remote systems using ssh. It uses the same colour scheme but for some reason the text looks a lot better. It has awesome profile support that you can fiddle with and customize to your heart’s content. It also lets you use images as the backdrops to your terminal sessions.

Well worth a look.

Horrid little emails

horridemail.png

I’ve been getting these horrid little emails for a while. The one above is from a “quantum astrologer” called Roxanne. According to the message in the email the man in my life has “has done things in his past that are resurging today making him cold and distant...”. Blimey. Maybe what she really wants me to do is click the link at the bottom to “make sure that I don’t receive any emails from us”. Ugh.

Some things can be more fixed than they need to be...

Waking up in a toasty warm house is all very well, but perhaps not at 2:00 am in the morning.

It got so cold last night that the heating decided it needed to heat things up. So it did. In the middle of the night. I’ve now adjusted the night-time trigger levels so that the heating only comes on when it gets properly artic code at night.

Hopefully the next post here won’t be heating related.