Bokeh

Making sense of the mess in my head

  • Exploring Uncut - March 10th, 2025

    A bit of a social life

    Not much happened this week in terms of exploration.
    Being an introvert, I try to space out social events so I have time to recharge in between. This week was a bit of a failure on that front, with one concert, two family dinners, lunch with a friend, and a GeekClub meeting.
    You might be wondering—what exactly is GeekClub?

    I’ve been a CoderDojo coach for several years now. We meet about once a month to help kids between 7 and 17 years discover programming.
    Watching kids tackle exciting programming projects at CoderDojo is always inspiring. But as coaches, we started to feel like spectators and were longing for more.
    Some of the coachs and I invited a few friends and started meeting once a month to discuss tech (and more) over drinks. This month’s topics included full stack development in Swift or Python, Software Defined Radios and antenna shapes, Home Assistant and Modus, 3D printing filaments and more.

    Read more…
  • Exploring Uncut - March 3rd, 2025

    Introduction

    I would like to publish more often on this blog. I really do.

    In fact, I have a long list of topics to write about. I even have several draft posts that I should just finalize and publish.

    One main issue is that, as I reread a post to put the finishing touches on it, I ask myself more questions. Is it totally exact ? Does it need more background information ? Why can I write this and can I prove it somehow ?

    Read more…
  • Addressing previous oversights

    Introduction

    Back in November 2024, as I closed my Blink them to death using Embedded Swift presentation at Pragma Conf, I promised to release the source code of the 3 projects I presented before the end of the year. I thought this would be an easy goal to achieve and that I’d finish way sooner.

    Of course the projects had been prototypes so far, so I wanted to cleanup the code and recheck everything was working as expected. This ended up taking much longer than expected (plus, daily life got in the way—but that’s another story).

    Read more…
  • Rolling back a brew formula

    Introduction

    I find Homebrew super convenient to install and keep up to date the large collection of tools I rely on. But sometimes, things do not work out the way you plan.

    Warning

    Read more…
  • Timers in Swift on nRF52

    Introduction

    In this post, we’ll continue exploring Embedded Swift on an nRF 52840 dk, using the nRF Connect SDK. Our goal this time is to execute code after a certain delay, with optional periodic repetition.
    In Swift, one would typically use a Timer class to implement such a feature. Can we use that with Embedded Swift?

    Foundation

    Embedded Swift is really about the Swift language, and the language only includes the Swift runtime and the standard library, both having some limitations in Embedded Swift.
    Timer is not part of those, it is included in Foundation. In the Apple ecosystem, we take Foundation for granted, but really it is a separate library, that’s not part of the language.

    Read more…
  • Randomness on nRF52 using Embedded Swift

    Update 2025-07-12: Added import statement for getentropy() implementation in stubs.c

    Introduction

    Randomness comes in handy in many different places. It’s useful in the logic of many games to make enemies behave in an unpredictable fashion, it can distribute the timing of events when used within a retry mechanism and random data is sometimes integral to AI algorithms.
    In this post, we’ll see how to generate random numbers in Embedded Swift on an nRF52840 DK using the nRF Connect SDK.

    Read more…
  • Creating a Swift type for button input on nRF52 - Part 2

    Introduction

    In the last post, Creating a Swift type for button input on nRF52 - Part 1, we worked on code to abstract interacting with a button in Swift code. We had a working prototype, but things fell apart as soon as we cleaned up the code and encapsulated it in a struct.

    Investigating the issue

    Let’s see if there’s valuable information in the documentation.

    /**
     * @brief GPIO callback structure
     *
     * Used to register a callback in the driver instance callback list.
     * As many callbacks as needed can be added as long as each of them
     * are unique pointers of struct gpio_callback.
     * Beware such structure should not be allocated on stack.
     *
     * Note: To help setting it, see gpio_init_callback() below
     */
    struct gpio_callback {
    	/** This is meant to be used in the driver and the user should not
    	 * mess with it (see drivers/gpio/gpio_utils.h)
    	 */
    	sys_snode_t node;
    
    	/** Actual callback function being called when relevant. */
    	gpio_callback_handler_t handler;
    
    	/** A mask of pins the callback is interested in, if 0 the callback
    	 * will never be called. Such pin_mask can be modified whenever
    	 * necessary by the owner, and thus will affect the handler being
    	 * called or not. The selected pins must be configured to trigger
    	 * an interrupt.
    	 */
    	gpio_port_pins_t pin_mask;
    };
    

    The documentation for the definition of the gpio_callback gives an interesting piece of information.
    Can you spot it?

    Read more…
  • Creating a Swift type for button input on nRF52 - Part 1

    Introduction

    In my previous post, Controlling an LED using Embedded Swift on nRF52, we created a Swift struct to encapsulate the C code required to control an LED. In this post, we’ll do the same for a button.

    If you want to follow along, the code is available on GitHub with each step having its own commit.

    Starting from working code

    As a starting point, we will write the whole code in C. This code is based on the Lesson 2 - Exercise 2 sample code from the nRF Connect SDK Fundamentals course from the Nordic Developer Academy.

    Read more…
  • Controlling an LED using Embedded Swift on nRF52

    Introduction

    In my previous post, nrfx-blink Step by Step, I took you through the steps required to configure your development environment to build and flash the “Blinky” Embedded Swift example from Apple on an nRF52840 DK. In this post, we’ll explore that example more deeply, grow from there, and adapt it to be more natural for Swift developers.

    If you want to follow along, the code is available on GitHub with each step having its own commit.

    Read more…
  • nrfx-blink Step by Step

    Introduction

    When getting started with Embedded Swift, the examples published by Apple are really an incredible resource. However they’re just that — examples, right to the point and sometimes with minimal information. If you’re new to embedded development, you’ll need to do some additional digging (which isn’t too bad, that’s how you learn).

    Embedded Swift development is very specific to the chipset that you’re targeting. As you can see, there are several examples in the repository, targeted at different boards and using different options (bare metal vs SDK/RTOS).

    Read more…