This article is for embedded software developers with a solid working knowledge of C or C++, but who struggle with large and complex projects. If you learn to develop embedded code, e.g. using the Arduino IDE, you find plenty of small example programs. It is helpful to get things started quickly, but as soon as…
Tag: c++
It’s Time to Use #pragma once
In my opinion, preprocessor macros and the outdated #include mechanism are one of the worst parts of the C++ language. It is not just these things are causing a lot of problems, even more, it is very time consuming to find them. This article will focus on #pragma once. In the past, I already wrote…
Write Less Code using the “auto” Keyword
The auto keyword was introduced with C++11. It reduces the amount of code you have to write, reduces repetitive code and the number of required changes. Sadly, many C++ developers are not aware of how useful this keyword is. Especially embedded code can gain a lot by its usage. In this article, I try to…
Units of Measurements for Safe C++ Variables
In your program code, you often deal with unitless values. You can add the units of measurements in the variable or function name, or by adding a comment, but there is still the risk you accidentally make wrong conversions. I will describe how to handle units of measurements for common time values using a custom…
Real Time Counter and Integer Overflow
After writing the article about event-based firmware, I realised there are some misunderstandings about how real-time counters are working and should be used. Especially there is a misconception about an imagined problem if such a counter overflows. In this article, I try to explain this topic in more detail, using an example code for the…
Class or Module for Singletons?
Should you use a class or a module with a namespace for a singleton interface in your firmware? I found there are many misunderstandings which lead beginners to make a wrong decision in this matter. With this article, I try to visualize these misunderstandings with simple example code for the Arduino platform. Before we start,…
Event-Based Firmware (Part 2/2)
In the first part of this series, we explored the general concept of event-based firmware. To read that article, follow this link. The concepts we discussed were directly tailored to one specific firmware. Now, let’s develop those concepts further to build an event system that can be integrated into many different applications. First, we’ll look…
Event-based Firmware (Part 1/2)
You start with small, simple firmware. But with each added feature, the complexity grows and grows. Soon, you need a good design in order to maintain the firmware and ensure the code remains clean and readable. In this article, I explain the event-based approach for writing firmware. I use the term “event-based” because it is…
My Personal Programming Language Recommendation Shift over Time
I am developing software for 20+ years now. In the early days, I developed software in Assembler, Basic, Fortran, Pascal and C. Meanwhile my focus gradually shifted over time. It is a very personal view, with my own language recommendations I gave over time. Languages I never recommend are missing in this article, even I…
Inline AES 256 / CBC Implementation
Today I like to share some encryption code, which can be used in various situations – and is also useful for embedded systems. It is a unique implementation of the AES 256 / CBC crypto algorithm. The goal of this implementation was neither speed nor size. It was written to inline it into existing code….