I bought a Rovyvon A5R flashlight. It’s a great little flashlight that charges by USB C and has many useful modes. While I’m generally quite happy with modes, I spend a lot less time using a flashlight than editing text and was a little confused about how to switch to the one I wanted. The manual for the flashlight is accurate but not clearly written.

So I used graphviz to knock out a state diagram showing the number of clicks to switch between modes:

state diagram

This is missing that the ‘Regular’ mode will start in the mode that it last spent 3 minutes in. I couldn’t think of a way to represent that graphically that would be clear at a glance, so if I had to use words to explain the graphic I might as well just have written out that previous sentence.

While this diagram may be useful in the unlikely case you buy the exact same flashlight, my own familiarity came more from the effortful study of creating the diagram than looking at the diagram. So I’m really sharing this as an example of a useful study technique.

Here’s the source, if you’d like to use it as a starting point for your own diagrams:

digraph FlashlightStateMachine {
    rankdir=TB;
    node [shape=rectangle, style=rounded];

    // Main states
    locked [label="Locked Off\n(blinks twice)" style="rounded,dashed"];
    unlocked [label="Unlocked Off\n(blinks three times)" style="rounded,dashed"];
    momentary [label="Momentary On", style="rounded,bold"];
    regular [label="Regular On", style="rounded,bold"];
    sidelight [label="Sidelight On", style="rounded,bold"];

    // Bidirectional edge between locked and unlocked
    locked -> unlocked [label=" 5", dir="both"];

    // Momentary transitions
    unlocked -> momentary [xlabel="hold", dir=both];

    // Regular on transitions
    unlocked -> regular [label="2"];
    regular -> unlocked [label=" long"];

    // Sidelight transitions
    unlocked -> sidelight [label="3"];
    regular -> sidelight [label="3"];
    sidelight -> unlocked [label=" long"];

    // Subgraph for Regular On brightness levels
    subgraph cluster_regular {
        label="Regular Modes";
        style=dashed;

        low [label="Low"];
        med [label="Medium"];
        high [label="High"];
        moon [label="Moon"];

        low -> med;
        med -> high;
        high -> moon;
        moon -> low;
    }

    // Subgraph for Sidelight modes
    subgraph cluster_sidelight {
        label="Sidelight Modes";
        style=dashed;

        white_low [label="White Low"];
        white_high [label="White High"];
        red [label="Red"];
        red_flash [label="Red Flash"];

        white_low -> white_high;
        white_high -> red;
        red -> red_flash;
        red_flash -> white_low;
    }

    // Connect main states to substates
    regular -> low [style=dotted, arrowhead=none];
    sidelight -> white_low [style=dotted, arrowhead=none];

    // Layout
    {rank = same; locked; unlocked;}
    {rank = same; momentary; regular; sidelight;}
}