Creating a UI on a microcontroller: Part 7

It's been a while since my last update on this library, but I have been working on things slowly. I got buried deep in the hole of optimising memory until you could again use my library on an AVR Arduino board, but perhaps more importantly it massively reduces the memory footprint on other things.

I got bogged down in the messy detail of handling the AVR program space functions, especially when trying to make it also compile and run for ESP8266. The Arduino core for ESP8266 provides similar looking functions but they don't behave exactly the same. Also I encountered some messiness when trying to use them inside a C++ class, in ways I should have realised was verboten.

Regardless, now if you pass the library a string type argument stored in program space it marks it as such and accesses it differently, depending on the processor. This includes using different methods to find the length of strings for centring and so on.

Time consuming fiddly stuff but it had to be done and finally you can run the example code on an Arduino Nano again, only consuming 1124 of 2048 bytes dynamic memory. The sketch does use most of the program storage, which is down to the large amount of text stored there. It runs stably, something you can easily compromise when throwing lots of string data around with a small margins on the stack.

I've enjoyed this learning exercise, but I now need to test my library with other architectures supported by the Arduino IDE, such as a Teensy with an ARM Cortex-M4. In these cases it shouldn't be so necessary to store small chunks of text in program storage but it is something I would like to be sure of working. I believe I have a Teensy 3.2 somewhere.

Recycling an old laptop into a Command Centre: Part 1

I have, for some time had a plan to build a portable 'command centre' prop which has a generic PC inside but has that industrial look often seen in action movies. A friend asked me to dispose of an old dead laptop so I stripped it down and made it work.

This laptop was a good candidate for this as it was one of those bulky OEMed machines that use a generic motherboard with various components on little daughterboards. It was dead because the PSU socket had been smashed but as this was a discrete socket clipped into the case, fixing it up was easy.

It's too old to be much use with modern software but a stripped down Linux install works just fine.

Over a lazy afternoon I carefully stripped out all the modules, including taking the webcam and microphone out of the screen surround and it's now ready for when I get the time to build the physical enclosure. I'm particularly pleased with how bright and clear the screen is after a careful clean, initially it looked dismal.

My plan is to use this ridiculous stainless steel waterproof keyboard/trackball combo I bought some years back as part of the prop.

I'd also like to use this set of rackmount monitors, but they take a composite input.

It seems reasonable that a USB to composite out peripheral might exist but if it doesn't I can run them with some microcontrollers and maybe do a Serial to composite display that shows text you send it, a bit like a dumb terminal. throw in support for some basic ANSI control characters and I'm creating the other half of my terminal UI library.

I've seen products on Tindie that turn a VGA monitor into a proper VT100 compatible terminal but nothing for composite and I'd need it to connect over USB anyway. I have a small stash of composite displays I've picked up over the years and creating something to drive them would be good. It could be easily argued that a Raspberry Pi Zero is a better way to do this but then you've got three computers to look after and I'm a fan of using microcontrollers instead.

The laptop can also drive a VGA screen for yet another display but I think that would make the prop physically too big.

Rookie SMD mistake

 

I received the new boards from JLCPCB and they look great, but I've made a real rookie mistake when ordering.

Working in EasyEDA, component selection defaults to 0201 packages for things like the resistors.

These are tiny. Really really tiny.

This is something I already knew and just missed it when laying out the board.

I realised my mistake when ordering the components but thought, let's give it a go. I have made an attempt to solder these but with my ageing eyesight I can barely see and handle them, let alone apply paste and hot air to successfully solder them.

Now with the ongoing pandemic I don't have any immediate application for these boards, so I'll pause a little while before coming back to them and producing a new version. Either I'll choose larger components or have JLCPCB do PCB assembly for me, which is increasingly affordable.

Creating a UI on a microcontroller: Part 6

There was some chat on Brian Lough's Discord channel about Bitbank's animated GIF player library.

It's optimised for use on microcontrollers, not classic AVR but anything with ~32KB or RAM or more, and can do much better frame rates than more generic libraries. On real screens it's excellent.

As I've been fiddling around with displaying stuff on the Serial/Stream terminal I quickly hacked around one of the example sketches and made this.

Running on an ESP8266, the terminal baud rate is 230400, any higher generates garbage, playing the GIF back from a PROGMEM array. Terminal client is PuTTY.

It's obviously not high def video but it's oddly satisfying to make this ridiculous thing happen. The GIF is already optimised to mostly send changes, which helps a lot. A static GIF would display quite easily.

So displaying very basic blocky images in the terminal isn't impossible, I might look at integrating it. You'd have to 'curate' what images you displayed.



I also had a go at the badger meme GIF and because it's not optimised and sends just every line the result is far less satisfying.




Creating a UI on a microcontroller: Part 5

In this update I've added 'list boxes' and the ability to style text inputs as password fields. So the list of widgets is now...

  • Buttons
  • Checkboxes
  • Radio buttons
  • Text boxes with scrollable content
  • List boxes
  • Single line text input fields
  • Single line password input fields


Creating a UI on a microcontroller: Part 4

In this update I show the work I've done on styling widgets with colours, different box drawing characters and different positions for labels/shortcuts.



Creating a UI on a microcontroller: Part 3

Another update on my terminal interface UI library and after lots of code cleanup it now handles multiple editable text input fields. I started using OBS to capture the output with so this video is cleaner than the first ones.

To recap I've now got the following working as simple to create 'widgets', any of which you can have multiples of on the screen at the same time and swap between them with keyboard shortcuts or the mouse.

  • Buttons
  • Checkboxes
  • Radio buttons
  • Text boxes with scrollable content
  • Single line text input fields
At this point it's using more memory than is practical on classic AVR Arduino boards but I know I'll be able to reduce the footprint a lot later.



Part ordering gamble

I have for a very long time wanted to build in the sort of 'scanning' you see in sci-fi movies to our LARP events as an actual working piece of tech. As the majority of our events occur outdoors the obvious answer is GPS. So I've made a gamble and bought forty GPS modules that came up just cheap enough to justify it to myself.

More so than other modules, cheap GPS modules seem to appear, disappear, then a few months later something similar but different appears on the market. I had identified some I wanted for this project a while back but then they disappeared and as I want to make a compact wearable with a 3D printed case, changing modules is non-trivial.

These super-compact modules look just the ticket and ordering them is an attempt to force my hand into making progress on this. The plan is that most things I build which are connected to the mesh network will have a GPS module. I did this a long time ago with the 'magic compass' but doing it at scale opens up the possibility of making something like the 'motion tracker' seen in Aliens etc.