Using Multiple Processor Cores on the ESP32

Most computers, particularly tiny embedded ones, have a single processor core. This means that they can do just one thing at a time. If you want a computer like this to appear to perform multiple actions at the same time it must execute a tiny “slice” of each action in turn to give the illusion of parallel activity.

However, the ESP32 has two processor cores, which means that it can run two “threads” of execution in the same program code. This has suddenly become very interesting to me, as I don’t want the LEDS to flicker when the computer controlling them has to go off and talk to the network.

It turns out that running tasks on different processors in the ESP32 is actually pretty easy. I used this guide here to get started. Then I slightly changed my program so that the code that drives the leds runs on one thread and the code that talks to the network runs on another.

It just worked. I was amazed. And there was no flicker on the display. One core in ESP32 is continuously running a function that redraws the display and the other core is waiting for network messages.

If you’re wondering how it all works, and whether you can get your hands on the code, I’m going to write a howto and put the whole thing on GitHub really soon.

Scrunching Text

I’ve actually got my display showing text now. This turned out to be a bit more difficult than I expected. Drawing text was easy, there’s a built in 6x9 font. But of course I wanted a bigger one, so I scaled the text to double size. Then I discovered that, because there are now two pixels between each character, the text wouldn’t fit on the screen. So I rewrote the display code to place each character individually and draw them only one pixel apart. Then I noticed that the redraw was a bit slow and made the display flicker. So I improved the driver to only draw changed characters rather than the entire text. And then I found that characters redrawn in the middle of a line overwrote a part of the characters next to them because they were now one pixel closer than they should have been. So I modified my draw function to redraw all the characters “downstream” of an updated character and put back the missing bits.

And now it works.

And I have another problem. The display is not “fire and forget”. It works because the computer controlling it is continuously clocking the red, green and blue data to turn on each pixel in turn. This means that when the ESP 32 goes off to read the WiFi and get the message to be displayed the whole display falls apart and, if I’m really unlucky, the whole thing crashes.

Oh well. I’ll leave that for tomorrow.

Led Panel Pax Indicator

This morning I was seized with a desire to make an indicator for the PAX counter device that I’ve been playing with. The counter sends the number of WiFi and Bluetooth devices that it has seen in the last minute up to The Things Network via Lora and I fancied making something that displayed that number.

A while back I had a play with a LED panel that looks rather nice. In fact I’ve got one stuck on my wall and I bought a few more at the time. So I got one out of the garage and set about getting it to work.

Last time I used a Teensy device but this time I thought I’d use one of the dirt cheap ESP32 devices that I’ve bought a few of. The hardware of the panels is actually quite simple. There are connections for red, green and blue (RGB) pixels and you just shift the pattern for row of pixels into these connections. There are four address bits you can use to select which of 16 rows you wish to control, and there are two RGB inputs, so you can drive two rows at the same time.

I used the library here to drive the panels from my ESP32. The panels are designed to be daisy chained so that you can send a row of pixels that spans a number of them. The library uses this to good effect by linking the outputs back to inputs so that all the colours can be regarded as one great big shift register. This reduces the number of pins that you need to allocate to drive the display, at the expense of a bit more wiring.

I’ve used what I call a “spatchcock” assembly method. Because the ESP32 is supplied with soldered pins I’ve had to solder onto these pins and then flatten them so that the device will fit inside the picture frame.

I’ve got it displaying pictures. Tomorrow I’ll try drawing some text.

The fault is never where you think it is. Never.

We’ve been having problems with my Air Quality sensor code not recognising a sensor properly. It’s the worst kind of problem; where mine works but the other one doesn’t.

Today we found out that the problem was that the supplier had sent a different model of sensor device. The good news is that I’ve not got a lot of extra diagnostic code in my driver that can probably notice this next time, or at least make it easier to discover. It all goes back to one of the irrefutable truths of debugging:

If what is happening is impossible it is either not impossible, or not happening.

Connected Humber Logo

This might surprise you, but I’m now a director of a company. We’ve set up Connected Humber CIC as a way of formalising things that we have previously been doing just for fun. Expect to hear more about this going forwards.

Of course a company needs a logo. So I’ve been playing with Inkscape,. The word on the street is that the word on the street needs to be in vector format so that you can draw it on the side of a building if required (although I think this will probably not ever be needed). If you use pixels for a design you can only make the image bigger by making the pixels bigger and that just ends up looking poor.

So I’ve been learning about SVG (Scaleable Vector Graphics) and getting my head around yet another user interface. Inkscape isn’t too bad to use, and after a bit of fiddling I’ve come up with the above. I could give you lots of artistic rationale for the design, you could say it represents the sun of technology rising above a seascape. However, I just did it this way because I think it looks nice.

Dyrham Park is a great place to visit

..as seen on TV

Dyrham Park (pronounced “Durham Park”) is presently on the TV screen as one of the locations for the ITV production of Sanditon, a fairly speculative visualisation of an unfinished Jane Austen story. Apparently the "original” story ran out about half way through the first episode. There are 7 more episodes after that and so I think they should have probably added “from an idea by…” to the author credits.

Nevertheless, to my untrained eyes the plot and characters look pretty similar to “proper” versions of Jane Austen texts and we are happily trying to work out which characters are good and which bad and which chap the heroine will end up with. It seems to be boiling down to the “worthy” one or the “smouldering” one at the moment. My bet is on the bloke with the smoke coming out of his ears. Bad news for worthy folk everywhere.

Anyhoo, we didn’t really go to Dyrham Park purely on the strength of a TV tie in, we just fancied a day out in a nice place. In this respect it delivered really well. The location is lovely, the house fascinating, the views awesome, the food in the cafe tasty and we had a thoroughly nice time.

Fun with a fish eye….

If you’re in the area you should go and take a look. Whether or not you’ve seen in on the TV.

Astral Chain for Nintendo Switch

Astral Chain for the Nintendo Switch looks like a very good game. I can say this with confidence because today I spent a good chunk of time watching number one son play it.

There’s a nice mix of fighting, exploring, problem solving and interacting with people. Along with a nicely mind-bending premise. Amazing that such a rich environment can fit into a tiny card that then goes into handheld that you can carry around and play on the bus.

Dead Dot Matrix

Dot matrix printers eh? You leave them standing for a year and then when you go to use them again they don’t work.

In retrospect this was a bit silly. And my joy in finding that I could get complete set of inkjet cartridges for a fiver may have been misplaced as they might have gummed everything up. I’ve narrowed the fault down to the print head or something else. A replacement print head (which may or may not fix the problem) can be obtained for around twenty five quid. So the question is: do I spend the money on a new print head or do I throw the printer away?

Windows Subsystem for Linux on Surface Go

I blogged a while back about how easy it is to install and use the Windows Subsystem for Linux (WSL) on your PC. Today I thought I’d install it on my little Surface Go. I had a spare 15 minutes and I figured that was all the time it would take. I was right.I was very quickly installing the standard applications. I was worried that enabling the WSL and installing the Ubunto operating system would use up a lot of precious hard drive space but this turns out not to be the case. I’ve got the system running and I only seem to have lost a few hundred megabytes of storage.

Just one more reason why the Surface Go is an awesome machine.

Wreckfest Review

One of my favourite Playstation 1 games was Destruction Derby. It was one of the first games I bought for my brand new console and it was really groundbreaking in gameplay and vehicle damage. I really liked the mode when you just had to survive as long as possible with every other car trying to smash your car into pieces.

I reckon Wreckfest is a good spiritual successor to my PS1 favourite. It has car damage, plenty of devious opponents and some seriously wacky races. I’m running it on an Xbox One X and it looks lovely. My favourite level so far (although I can’t do it) is one where you are placed in a Reliant Regal three wheeler and asked to take on 24 school busses in a battle for first place. I’ve only managed to get as far as 11th so far, but I’m enjoying working on it. Apparently I’ve got combine harvesters and lots of other things to look forward to in the future. I’m not a fan of the racing couches though. Very hard to control.

There’s lots of customisation available. The cars in the game are not licensed but it’s pretty obvious what each is modelled on. The only criticism I have is that the loading times are a bit on the long side. I actually started to worry that the word “LOADING” would be burnt into the screen I spent so much time staring at it.

However, the good news is that if you want to restart a race (usually because someone sneakily sent you into a spin or off the track) the restart time (the one you really care about) is pretty much zero.

I’ve not actually gone into a shop and bought a physical copy of a game for a while. In this case I’m glad that I did.

Vinyl Memories

My turntable belt arrived today, so I can now play my records again. I grabbed a few from the loft and fired them up. A few things sprang to mind:

  • you seem to have to do quite a bit just to play a record. There’s a lot of faffing around for 20 minutes of music. This is of course the inspiration behind my difficultifier of days gone by.

  • the sound is surprisingly good for a what a really primitive way of storing and retrieving sound

  • I really need to get myself a record cleaner

Having said all this, it was rather nice to hear all these sounds from the past.