Python ?

Wow. I have to say I never thought I was going to end up writing Python programs for fun and (no) profit. That is until I got a Raspberry Pi Sense Hat, at least.

The specific project I’m working on is a remote temperature monitor for an unoccupied site that I’m responsible for, to allow us to react if the furnace goes out there before the pipes burst.

Given the Python library for the Sense Hat, it was basically trivial to build a program that would watch for the temperature to go outside a given range, and send email to me if it did. It took a couple of hours longer than I expected it would to write, but my excuse is that it really was my first Python program. 🙂 (Also, it seems there are quirks around getting accurate temperature readings from the SH, so I’m still tweaking the program, but it’s basically working.)

Given the 8×8 display on the Hat, I even managed to provide a continuous temperature display. 8×8 is not enough pixels to make something look good, so you end up with something like this (as drawn by the Sense Hat Emulator developer tool):

Ugly but readable. For the inquisitive, here’s the “McQ’s First Python Program” version of a function to display the digits:

###########################################################
# Display two digits on the sense hat.
 

# Digit patterns
digits0_9 = [
    [2, 9, 11, 17, 19, 25, 27, 33, 35, 42],  # 0
    [2, 9, 10, 18, 26, 34, 41, 42, 43],      # 1
    [2, 9, 11, 19, 26, 33, 41, 42, 43],      # 2
    [1, 2, 11, 18, 27, 35, 41, 42],          # 3
    [3, 10, 11, 17, 19, 25, 26, 27, 35, 43], # 4
    [1, 2, 3, 9, 17, 18, 27, 35, 41, 42],    # 5
    [2, 3, 9, 17, 18, 25, 27, 33, 35, 42],   # 6
    [1, 2, 3, 9, 11, 19, 26, 34, 42],        # 7
    [2, 9, 11, 18, 25, 27, 33, 35, 42],      # 8
    [2, 9, 11, 17, 19, 26, 27, 35, 43]       # 9
]
     
def display_two_digits (a_number, color): 

    global digits0_9
    black = (0, 0, 0)
     
    if a_number < 0:
        negative = True
        a_number = abs(a_number)
    else:
        negative = False
         
    first_digit = int(int(a_number / 10) % 10)
    second_digit = int(a_number % 10)
 
    # set pixels for the two digits
    pixels = [black for i in range(64)]
    digit_glyph = digits0_9[first_digit]
    for i in range(0, len(digit_glyph)):
        pixels[digit_glyph[i]] = color
    digit_glyph = digits0_9[second_digit]
    for i in range(0, len(digit_glyph)):
        pixels[digit_glyph[i]+4] = color
     
    # set pixels for a minus sign for negatives
    if negative:
        pixels[56] = color
        pixels[57] = color
        pixels[58] = color
     
    # set bottom right pixel if number is more than 2 digits
    if a_number > 99:
        pixels[63] = color
     
    # display the result
    sense.set_pixels(pixels)
 

Of course, you pass in a color for the digits to show, so when the temperature is outside the range, you can show it in red. 😉

Anyway, feel free to point out all the noob Python programming mistakes. I’m always happy to improve.

Site news (again)

So, I realized my last post was probably a bit confusing. The reason I was seeing issues with my older posts was that I had moved them to a new WordPress install because, as it happens, I have once again moved GCW to a new machine. This time, it’s another Raspberry Pi, but this new install has a few nice things going for it:

  1. It’s an 8Gig model. I don’t actually believe I need that much space to run a web server most of the time, but I am running quite a few web apps on it now, and depending on what was going on, I was seeing some peaks on the 4Gig one that were pushing into swap.
  2. It’s a brand new, fresh install on SSD. The old one was still running off a MicroSD card, with the website content stored on a separate SSD. Although this gave me lots of storage for the website, it meant that the install was just that tiny bit more complex than a standard one, so I was forever fiddling with it when updating, etc.
  3. It’s even smaller! I love the size of the finished result. Here’s a picture to give you the idea. Note the size of the ethernet jack on the side for scale.

This time around, I’ve only got 500Gig of storage for the whole install including the website, but I’m no where near hitting that limit yet, so I’m very happy.

Test post

Most of my older posts seem to have extended entries for the titles. I’m not sure what’s going on, but I suspect it’s a side-effect of one too many export/imports. Something to figure out eventually.

Update: I managed to turn it off by hiding post abstracts. I’m not sure why this suddenly started happening however. Hm…

That’s better.

So take a look at this…

I apparently have joined the big leagues, although it’s a bit too early to say for sure. The ping time isn’t great, but I guess it will be good enough. For comparison, here’s what I had before the upgrade:

Ping: 4ms
Down 47.5
Up: 10.4

I’ve tried GeForce Now and it’s like night and day. The game looks basically like it’s running locally now.

As you can see from this post, GCW transferred over seamlessly too.

Now, let’s try some MMOs… 🙂

Fun with Pi

There have been a number of interesting things happening in the Raspberry Pi community lately.

One new hotness is the RPi 4 with 8Gig of RAM, which in addition to having more RAM than you will likely ever need on a machine like this, also has a slightly updated power module that improves the behavior with some USB-C power supplies. It does mean that you can now open too many Chromium tabs to keep track of on this platform too. 😛

Another interesting update is the support for booting off of USB drives, instead of the MicroSD card. This lets you use an SSD over USB3 as your main drive, which is both much faster than the built-in MicroSD, and will have a significantly longer lifespan.

Finally, there is the 64-bit version of Raspian (now renamed as Raspberry Pi OS), which actually matters given you can get a Pi with more than 32bits of address space, but it will likely also improve performance for many tasks once the beta kinks are ironed out.

Anyway, being the RPi geek that I am, here is my latest desktop…

An 8Gig RPi4 with a 500Gig Samsung SSD, in the awesome Argon ONE Pi 4 case, which has both a temperature controlled fan (that is almost always off under normal workloads) and, believe it or not, a working power button that does a safe shutdown! This is definitely the slickest Pi case I’ve used, even if moving all the ports to the back meant making it nearly 50% larger than the Flirc case, which was my previous favorite.

Anyway, even with an SSD that cost more than the Pi and the Argon ONE case together, and the Pi overclocked to 2GHz, it’s still too slow to be a great desktop experience, but it works well enough that I was able to write this post, while watching youtube videos, with several other apps open, including LibreOffice and Gimp, so it’s definitely real.

Sony WF-1000XM3

I have been a wireless headphone geek for a long time. To give you some idea how bad it is, I have all of:

  • Beats Solo3
  • Marley Smile Jamaica
  • Trekz Titanium (bone conduction)
  • Plantronix Backbeat Fit
  • Soundcore Liberty Air
  • Corsair Void Pro (times 2)
  • Steelseries Arctis 7

… and that’s only the ones that I still currently use.

When the Apple AirPods Pro and Sony WF-1000XM3 came out, I tried them both and decided to pick up the Sony’s based on a perceived slightly better sound quality. Since then, I’ve seen several reviews of them both, with some level of agreement on the sound, and indications that the noise cancelling is also better.

However, my overall experience with the Sony’s has been quite poor, to the point that in retrospect I’m confident the AirPods would have been the better answer. Honestly, the UX on the WF-1000XM3 is so bad that I can’t help but think Steve Jobs would have fired any team that came forward with something in the same state.

The first issue is the companion app which, despite several updates since I first ran it, is still frequently unable to connect to the headphones, or drops the connection at some point after it gets connected, or simply crashes completely. It also includes something called “Adaptive Sound Control”, which has the following Engrish description:

The app detects your actions and [Ambient Sound Control] is switched.

Whatever this is supposed to do, the behavior manages to be simultaneously be both intrusive and not useful. I turned it off almost immediately.

The headphones themselves are also unreliable. Sometimes when you take them out of the charge case, they don’t BT connect at all. Sometimes they connect (i.e. show up as connected in the BT device list) but don’t become available as headphones (doh!). If they do get connected, the connection will later sometimes drop for one or both of them.

And speaking of “one or both”, the strangest thing about them is the way they start up. They behave a bit like they are two different bluetooth devices that notice while they are connecting that they can work together. The start up sequence has three voice prompts:

  1. Indicate they are powered on (“Power on.”)
  2. Indicate the current battery level (“Battery fully charged.”)
  3. Indicate they are connected (“Bluetooth connected.”)

However, because they sync up part way through the start up, you will hear somewhere between zero and three of those messages in each ear, and by that I mean a *different* number of messages in each ear. It’s a terrible experience.

[Aside: Hey Sony, there is absolutely no reason to ever say “Power on.”. If you say any of the other prompts, we know the power is on. 😉 ]

One final comment: the WF-1000XM3 — btw, who thought that was a good name for *anything*? — are quite a bit heavier on the ear than, for example, the SoundCore Liberty Airs. I didn’t realize how much of a difference this was until I used the Airs again recently. I now find myself going back to the Airs often, even though the WF-1000XM3 have clearly better sound.

Rebuilding an old MBP

I had an old, broken 2009 MacBook Pro sitting on a shelf because I had never gotten around to trying to fix it. It had three significant issues:

  1. It randomly kernel panicked every once in a while
  2. It had an SSD drive in it that no longer worked
  3. Three of the keys on the keyboard didn’t work.

Last weekend, I finally decided to see if I could get it into working shape again. To start, I took the back off and removed the failed SSD drive. The MBP is too old to run a current version of MacOS, but it still has a working HD drive, so I decided to install Linux there.

To fix the keys, I tried removing the key caps and cleaning the switches, but after putting them back together they still failed. By chance however, I noticed that if I *smashed* the key beside one of the failed ones (in frustration? 🙂 ) then the original keys would start working for a bit. This led me to pulling that other key cap off and cleaning it, and after putting it back together all the keys worked.

This only left me with the random kernel panics, so I booted the Mac into hardware test mode and let it do a full test. Even after 10 minutes of hammering RAM and CPU (with the fans screaming), there were no failures, so I chalked the problem up to either a Mac driver issue, or something to do with the now removed SSD.

For linux, I just went with Ubuntu, mostly because there was a tutorial about installing on Macs that seemed pretty reasonable. The only wrinkle was the lack of a driver for the MBP’s discrete graphics card. I went for the easy option of doing nomodeset in grub, and ended up with…

I don’t think it’s worth putting a new battery in it, but if I needed a home computer for email and web browsing this would be perfectly useful. Nice!

I had a camera.

When the Micro Four Thirds mirrorless digital cameras first came out, I decided I was going to take the plunge and get myself a “good” camera. The one I ended up buying was an Olympus E-PL1. I guess camera geeks recognize that model as not being great, but at the time, it took what I thought were pretty amazing photos.

Over the years though, I didn’t really spend as much time as I thought I would taking pictures, and once cell phones started to have decent cameras, the E-PL1 got relegated to a shelf, except when Deb was using it to do product shots for Sheep’s Ahoy.

Today when I was cleaning up my stash of old USB cables — a bigger task than it might seem; I ended throwing out close to 50(!) — I actually found the camera’s custom USB cable, which had been missing for years. This sparked my interest in the old beast enough to recharge it’s battery and take some shots, to see how it compares to my iPhone’s camera.

I won’t keep you in suspense: The iPhone 8P’s photos were better. I thought that the larger sensor in the E-PL1 might let it take better low light photos, but the images were just as noisy as the iPhone’s, if not worse.

As a quick comparison, here’s one representative photo from each:

By just about any measure, the iPhone picture is better: warmer, less noise, sharper. Oh well. And Deb’s XR takes even better pictures than the 8P! I can’t even say that the E-PL1 had better manual shooting features, since at least for my amateur needs Halide does just as much, and I could even get additional lenses if I wanted to.

Don’t get me wrong. I realize there are still digital cameras out there that take much better photos than any cell phone. They’re just not priced to make sense for anyone who isn’t going to make a serious commitment to photography (like my friend John). I’m happy with the pictures I take on my phone, and I’m sure when I upgrade to the iPhone 12 Pro (or whatever it ends up being called) they’ll be even better. 😉