Effortless Emacs Multiple Major Modes with Polymode

emacs

I found myself doing something weird recently. Not for the first time, of course, but this was a special kind of weird.

I was editing a file that’s part of my websiteIn Emacs. Of course. Emacs abides.. It’s the implementation of the search form (reachable from the little magnifying glass in the nav bar). This ends up as a normal HTML page, for sure, but it’s written using an unholy mishmash of Pollen syntax, Alpine.js custom attributes and JavaScript. That makes it unenjoyable to edit, since syntax highlighting and language-aware indentation don’t really work.

This mixed language thing is well-known from React and Vue and Svelte and all those JavaScript frameworks that (one way or another) put HTML templates, CSS and JavaScript in the same file. People using React, Vue or Svelte enjoy the economies of scale that come from using popular things, and there are nice editor modes for them.

If you do weird stuff, you’re on your own.

Actually, you’re not on your own. Polymode has your back. You can read about it below the fold.


Full-Text Search with Minisearch and Alpine.js

colophoniaweb-programming

One thing I wanted to add to my new and shiny Pollen website was full-text search. I have about 200 old blog articles on here, and it would be convenient to be able to find things now and then. It seemed like an easy enough thing to do, especially since I only intended to do it at the level of software bricolage, using existing tools.


Server-side Web Analytics with GoAccess

colophonia

Let’s start with a digression.

It will come as no surprise to anyone who knows me even a little bit that I’m just a tad disappointed with the modern internet. You look back at the visions of the early workers in hypertext and networking, and their open-hearted dreams of a world of free information bring a little tear to the eye. Fast forward to 2021, and the web is 90% spam, social media giants and ad-tech. It’s not the shiny future we were promised! It’s a swamp.


A(nother) New Start: Pollen!

colophoniapollen

The alternative title for this article was “The FrankenBlog: It Lives!”. You’ll see why “FrankenBlog” in a minute.

The idea here was to convert my website and blog over to use Pollen, Matthew Butterick’s marvellous Racket-based authoring system. The main reason for wanting to do that is that I have a couple of longer-form writing projects in mind, and Pollen gives much more flexibility than writing in Markdown or something similar.

Starting a new blog with Pollen is easy. Unfortunately, I had some history I wanted to preserve, some new ideas I wanted to try, and a whole row of yaks lined up waiting for a shave.


Unbricking an EFM8UB3 Thunderboard

embeddedelectronics

I’ve been doing some work recently with a little Silicon Labs EFM8UB3 microcontroller. This is a nice 8051 clone with a bunch of peripherals all in a QFN24 package. I’ve been using a minimal development board Silicon Labs calls the Thunderboard. It’s mostly fine, but it has one failure mode that’s pretty annoying. This article is about how to back out of that failure mode if you encounter it.

The Thunderboard has a built-in JLink debugger, and it’s unfortunately possible to put the MCU into a state where the debugger can’t talk to it. That means that you can’t program the board any more, so you might think you’re stuck. You’re not!


Pump Shaft Monitor: Current Sensing #1

embeddedelectronics

One thing I need to do for my pump monitor is to determine when the pump is running. I’m going to do this by measuring the current flowing in the power cable to the pump. That seems like it ought to be an easy thing to do, but doing it safely (it’s a 240V AC mains cable to the pump) and reliably is more complicated than I expected. There might be a simpler way to do things than what I’m trying to do, but this is a good opportunity to do a little bit of analogue electronics and to learn some things. (My analogue electronics skills are negligible, so I’m always on the lookout for small projects or parts of projects that have the right “challenge level” to help me get better!)


Pump Shaft Monitor: Introduction

embeddedelectronics

We live on the side of a hill where rainwater runs down into our garden, gathering at the lowest point to make a “sumpy” patch. The soil has a high clay content, so the runoff is efficient. We also have a cellar. (You can see where this is going already, right?) We have a shaft next to the house that contains a pump to clear out water draining into the sumpy area. A couple of months ago I took the lid off the shaft and found the pump under two metres of water, not running. Opening up the stairs down to the cellar revealed half a metre of water down there... Not good.


Kolyma Books

Kolyma is a region in the far east of Russia. It’s brutally cold, sparsely vegetated, mostly covered in permafrost, and has huge mineral reserves. It was a “favourite” destination of convicts in the Soviet penal system.

I’d not even really heard of the place until a few months ago, but since then I’ve read two books set in Kolyma. Two very different books, one a modern thriller and one something completely other.


STM32 Timer + ADC + DMA: Part 3

embeddedstm32

In this final article of three, we’re going to make our DMA-based ADC example from the second article run off a timer, and we’ll do a small demonstration of how this might be used in a realistic application.

There’s a video demonstrating each of the examples covered in this series of articles. It’s probably most useful to watch it in conjunction with reading the articles.


STM32 Timer + ADC + DMA: Part 2

embeddedstm32

In this second article of three, we’re going to change our polling ADC example from the first article to use DMA.

DMA is a subject that is unavoidably a little complicated. It’s useful to understand what DMA really is to get an idea of where that complexity comes from. That might help to build some enthusiasm to battle your way through the DMA section of the reference manual!

There’s a video demonstrating each of the examples covered in this series of articles. It’s probably most useful to watch it in conjunction with reading the articles.


STM32 Timer + ADC + DMA: Part 1

embeddedstm32

I’ve been doing some STM32 programming recently as part of my Mini-Mapper project (using an STM32F767ZI). I needed to collect samples from several analog inputs at a fixed frequency, for monitoring motor torque. A simple thing to do, right? But the obvious way to do it isn’t necessarily the best.

In this series of three articles, I’m going to try to show a better way. Some of this will be quite boring (it’s just configuring microcontroller peripherals, after all), so I allowed myself a bit of time for a fun “finisher” at the end.

There’s a video demonstrating each of the examples covered in this series of articles. It’s probably most useful to watch it in conjunction with reading the articles.


Datasheet-a-Day W45 2020

electronicsreading

More datasheets and application notes: starting to learn about DACs in the Analog Mini-Tutorials series, another DC/DC converter (in a slightly less silly package), plus a couple of randoms.


Datasheet-a-Day W44 2020

electronicsreading

An interesting application note about crystals (I know very little about them, and need to know more) and a paper about how best to solder QFN packages, plus some jellybeanish analogue ICs and a tiny tiny DC/DC converter.


Datasheet-a-Day W42 2020

electronicsreading

Bit behind on this again, but I have some interesting ones for next week, so maybe that will make me stick with it better.


Datasheet-a-Day W41 2020

electronicsreading

Got a bit distracted with reading microcontroller datasheets and reference manuals for some projects, mostly for the ST Micro STM32F767ZI and for the Silicon Labs “Universal Bee” series (I’m using the EFM8UB3 for a project at the moment). But here’s some “normal” datasheet reading.