If you read the previous logs, you might have gotten the message that I love 1-bit guis. I loved Atari TOS and the early version of MacOS. To create 1 bit graphics, you can draw lines or pixels using code like this for instance (this is not real code!):
To draw fonts, there are several different solutions out there. Having followed David Welch's bare metal programming tutorials, I was using the psf font format, which is very simple. It contains a 32byte header with a few important parameters such as the width and height of the characters. You can create these fonts by hand if you want. Just create a C header filer with a byte array, and start entering bytes manually according to the spec.
Even though the format is quite simple, it's a very tedious job. I looked around, and there seemed to be no simple (free) app to create 1 bit pixel graphics. I also have a Samsung Note 9, and it seemed like a romantic idea to be able to use the included pen for drawing. I have to travel to work a lot this month, so I had some train time to waste. That's when I created bixl. It's a very simple pixel drawing program.
It's a web app that is available here: https://synthology.gitlab.io/bixl/
I had some experimentation code lying around for creating a pwa, so this web app is also a pwa that you can install directly from the browser onto your computer/phone/...
You can start from scratch, or load an existing psf font. Only psf version 2 is supported at this time, but I'm not planning to add support for more file formats. If you want to add it yourself, dig in, it's open source! :-)
Fighting the lifelong enemy called perfection
Now is a great time to talk to you about the worst enemy I have to face all the time: perfection. If you don't want a lecture about that, just skip the rest of the log as there will be no new technical information.
When working on stuff like this, it's easy to lose yourself in details. I constantly think like: 'oh it would be nice to add x feature', or: 'people will probably need feature y'. This process keeps on going and if you give in to it, you will never deliver or it will take you a very long time to do so. And even then, it will never feel complete. there's always something more you can add.
So it was then that I realised that I have to fight the ocd and perfectionism when it strikes. With bixl, I had the original idea to also integrate a reverse engineering tool for inspecting binary files for 1-bit graphics. There is a tool that I created a while ago, and recently cleaned up a bit for public use. it's available here: https://synthology.gitlab.io/ceebit/. My plan was to add that to bixl as well. While I still very much like the idea, I have to restrain myself Both products exist, and are working. There would be no other benefit except to have both tools in 1, and to satisfy my inner demon. Here is a screenshot of a wip version that had an extra top bar with a drawing tab, and an inspect tab.
If you look at the source code of bixl, you will see that every line of code is inside the index.html file. Ask any serious web developer and this would be frowned upon. The way I work is usually like this: I have an idea, I start messing around and suddenly I have something that works. Then I'm supposed to rewrite it the way it should be done, or to say it with proper terms: refactor. Nicely separate the ui code from the logic and stuff like that. instead, this time I decided to skip that step and leave it like this. In my mind this is a complete mess. But you know what? it works. It does what I want, it's reasonably featured, it works on desktop and smartphones, it looks nice and it can load and save psf files. Why on earth would I want to start refactoring it just to satisfy parts of my brain that like things clean. I'm giving this away for free. Not that this is a ground breaking piece of software, but I spent time on it. Hours of my life that I could have spent otherwise, and I'm giving them away to you for free. Are you really going to tell me I should have cleaned it up before 'donating' it to the community?
If you ever have the chance and access to look at some commercial closed-source code, you might be surprised at what you would find. When having a beer with a good friend that works for a company that delivers software for the military, this subject came up. He told me something that stuck around. His philosophy was that If it works and it's stable, it works. The time you usually spend to clean things up afterwards and make it 'just perfect' is not worthed. Because even if you reach perfection, something is going to mess that up anyway. A new feature, some system changes, ... Try to spent as little time as possible rewriting or refactoring.
Even now, when working on openSampler, it frequently comes to mind: should I just start over and do everything in C? Because if I would use C, then I can reuse a lot of code for other projects that only have C compilers. That would mean I have to rewrite or even reimplement certain features of Circle, and that would be an immense time hog. No. I need to fight the idea. Just stick to what you have created already. If the problem comes up that I want to reuse some code on a microcontroller, then I'll just have to cross that bridge when I come to it. Why start rewriting stuff when you don't even know you're going to use them. And why would I even think I could do a better job than what already exists in the Circle library? I probably don't, and most likely make a mess out of something beautiful!