Writing An OLED Display Driver In MicroZig

Although most people would use C, C++ or MicroPython for programming microcontrollers, there are a few more obscure options out there as well, with MicroZig being one of them. Recently [Andrew Conlin] wrote about how to use MicroZig with the Raspberry Pi RP2040 MCU, showing the process of writing an SSD1306 OLED display driver and running it. Although MicroZig has since published a built-in version, the blog post gives a good impression of what developing with MicroZig is like.

Zig is a programming language which seeks to improve on the C language, adding memory safety, safe pointers (via option types), while keeping as much as possible of what makes C so useful for low-level development intact. The MicroZig project customizes Zig for use in embedded projects,  targeting platforms including the Raspberry Pi MCUs and STM32.  During [Andrew]’s usage of MicroZig it was less the language or supplied tooling that tripped him up, and more just the convoluted initialization of the SSD1306 controller, which is probably a good sign. The resulting project code can be found on his GitHub page.

18 thoughts on “Writing An OLED Display Driver In MicroZig

    1. Its a different kind of mindset I think. I (and I’m guessing you) look at programming languages purely as tool to accomplish a job. But I think just like real life, there are tool enthusiasts, people who get excited over the latest drill or grinder or chainsaw model, I guess its the same with programming languages, people who like and appreciate the tools as well.

      Me, I just care about making the code do what I want, I don’t want it to be clever or simple, efficient or slow. If the job requires me coding in assembly, so be it.

      1. I get you. But sometimes you’ll be working on a project and work out a new tool will help you do it better. Zig is one of those tools. It wasn’t made to be clever or to try fix a general technical problem, someone had a specific project in mind (a DAW) and found that while the current modern tools available could be coerced into doing the job (say C++ or Rust for example) they had overhead that made meeting the realtime requirements hard and while the old school tools (C in this case) could indeed do the job very well it’s been a useful tool for so many years there’s been a lot of footguns bolted onto it to keep it useful. Maybe it’s because in a former life I was a machinist but I really get that train of thought.

        Whether it actually is an improvement I don’t know. I’ve only actually used Zig to build C code so far. But I’ve got to say it has become my favourite C compiler…

    2. I love MicroZig, and for me, it is. It’s way more fun (for me) than rust on embedded, and I’ve done enough C embedded to want Zig’s ergonomics. Developing a HAL port for my board and writing the FOC driver are the point, and I’m having fun doing it.

    1. I really think most of these new languages will naturally start catering to a niche and settle down in it.

      Go is specifically good for writing multithreaded networking applications I hear, Rust is memory safe so safety critical software (their syntax is really intimidating though, it looks like an unterminated string memory leak)

    2. Well I don’t have anything against Rust but I do hate JavaScript. Should I take this oportunity to bash on JavaScript a bit? I know the post is actually about Zig.

    3. Well, LISP may not be popular, but it’s definitely not dead yet. Also, it influenced many modern languages and introduced automated garbage collection to a large audience for the first time. ADA is also still popular in high-reliability embedded systems.
      All these languages find their niche and/or influence other languages that find their niche, it’s one big continuous effort. It seems to me you’re looking at the droplets of water falling down, critisize of their individual volume, and missing the fact that they contiously help fill the ocean.

  1. Could you imagine a day when a subject was presented such that the first paragraph introduced the audience to the core pieces of information required, like what microZig is, and the second paragraph could explain the purpose of this particular usage of it?

    This damn near felt like I was reading a recipe on the internet, although the backstory is at least on point and not a random story about a family vacation.

Leave a Reply to JanCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.