Posts

Three reasons to love guizero

Image
I'm working on a Quiz runner project for my forthcoming book on the micro:bit. The first version worked, but it was much too complicated and very hard to test. After weeks of frustration I decided to go back to the drawing board and try a different approach. The current design is shaping up well. It uses a conventional computer as well as micro-bits, and the program that runs on the big computer needs a Gui. The micro:bit connected to the computer acts as a radio receiver; the micro:bits for each team transmit a signal when the team wants to answer a question. The person running the quiz sees that a team is buzzed and asks them for their answer. Then they tell the program whether the answer is right or wrong so the computer can keep score. The program on the computer needs a Gui. I've played with @codeboom 's guizero before, and liked it, so I decided to use it for the project. It's turned out to be an excellent choice, for several reasons: guizero h...

A concise solution to a fiddly coding problem

Image
I My pomodoro timer is coming on nicely. I'll post about progress in the next day or so. For now, here is a short story about a problem I hit while working on the project, and the happy solution that I came up with. For some time I've kept an online journal for each project I'm working on. Like some blogs, the journals used to have the latest entries at the top. Here's a sample journal file: # Project journal for zero-web ## Thursday 07 February 2019 I added 2 new pages. ## Monday 04 February 2019 I've created a homepage. I'll serve it with websocketd. I found that order confusing. I decided that I'd prefer the posts ordered as they would be in a paper diary, with the latest posts last. That way I could read the  project history like a book. The problem: I have a lot of project journals, and I really didn't want to edit them all by hand. I decided to write a program to do it. The problem was simple to solve using APL. Regul...

Pomodoro timer with ToF sensor in CircuitPython

Image
Yesterday I started working on a fun application using a time of flight sensor. It looks as if it's going to solve a problem I've had for years. Like many of my friends I use P omodoro time management when I'm writing or coding. The Pomodoro technique uses a timer to you to get up and take a five minute break after 25 minutes at the keyboard. This helps you focus during the 25 minutes of work and the break keeps you healthy and fresh. The original Italian creator used a kitchen timer shaped like a tomato - hence the name. I don't have a suitable kitchen timer so I use a web browser to access http://e.ggtimer.com/pomodoro . That works well if I remember to start the timer whenever I sit down to write or code, and to restart it if I am interrupted. Often I forget, and that's annoying. A while ago I came up with the idea of automating the Pomodoro. My first idea used a pressure sensitive cushion on my study chair. I had some fun wit...

Early computing in Britain

Yesterday I spent a fascinating afternoon at a BCS Computer Conservation Society meeting, listening to Professor Simon Lavington's outstanding talk on Early Computing in Britain. Simon described the genesis of  Feranti's Mark I and I* computers and their early history in the late 1940s and early 1950s. This was a seminal period in the history of computing. I was just too young to experience it, but the first two computers I programmed were Ferranti Machines. Back in 1958, as an 11-year old, I wrote a short program in Pegasus Autocode; I finally debugged it a few years ago! Some years later, in 1966, I was lucky enough to get a gap year job working for David Hendry on the BCL compiler for Atlas , then the most powerful computer in the world. I knew very little about the Ferranti Mark I which was the predecessor of the Pegasus. Like all electronic computers of those early days the Mark I used valves (vacuum tubes) which were prone to failure when their filaments broke. ...

A little Raspberry Pi history

Image
a pre-alpha version of the Pi (reproduced with permission) A few days ago someone pointed out that it was eight years since Eben Upton's first blog post on the Raspberry Pi website. The site had actually been live for a while (from 6 May 2011), with just enough information to get me and others excited about the potential of the Pi. The website explained that the goal was to produce a low-cost Linux-capabable ARM-based board for educational purposes. That was interesting, but not world-shaking. There were already a few hobbyist SBCs (Single Board Computers), but they weren't cheap. I think the BeagleBoard was over a hundred pounds, and  you needed some specialised hardware to level-shift the 1.8V GPIO pins to a useful voltage. So how much was the Pi going to cost? According to the website The expected price is $25 for a fully-configured system. Back then, that was almost unbelievable. Indeed, to many, it was unbelievable. The early days of the Pi were dogged...

When mu is not enough...

Image
I'm working on a micro:bit project book at the moment, and the current chapter covers a Quiz runner application. It needs multiple micro:bits. For testing I need at least three, one for the Quiz runner and one for each of two competing teams. Although the micro:bits have different roles, they are all running the same software. The Quiz runner identifies her micro:bit by pressing button A; her micro:bit then sends a radio invitation for the other micro:bits to check in, team by team. From then on each micro:bit knows its role and can behave appropriately.   Mu and PyCharm   I normally use Nicholas Tollervey's excellent mu editor for MicroPython development, but the Quiz runner program is more complex than most. I am using Git to commit versions as the development progresses. Mu's minimalist design makes it very easy to learn. To keep it simple it has no integration with version control applications like Git, so I am using JetBrains' PyCharm . A few wee...

reggie - readable regular expressions in Python

Image
Regular Expressions are powerful but they can be hard to tame. There’s an old programmer’s joke: A programmer has a problem, and she decides to use regular expressions. Now she has two problems. Unless you use regular expressions regularly (sorry for the awful pun!), they can be Hard to read Hard to write Hard to debug reggie makes regular expressions readable and easy to use. I've used regular expressions for a number of projects over the years, but the idea for reggie came about a decade ago. I was working on a project where we had to parse CDRs (Call Detail Records). These are text files that Telecommunication Service Providers use to identify calls and other services billable to their customers. The CDRs we received were CSV files with a complex format and we decided to use regexes (Regular Expressions) to verify and interpret them. We liked regexes, but they were less popular with our business analysts. The BAs were happy with our Java code, but they ...