Darktable USB Controller with Arduino

Hi! I am new to this forum and this is my first post.
I was thinking about having a hardware control unit to control a number of core functions in my darktable workflow. A search in these forums shows three previous related discussions:

The first two are using existing Midi controllers, while the third one is using an Arduino to build one. They all have in common that they send Midi signals to the computer, which then requires some software to convert these to key/mouse signals.
The solution that I would like to propose seems much simpler to me. The Arduino (pro micro) can directly send key/mouse signals via USB to the computer, so there would not be any need to use Midi plus the midi-to-key conversion software.

My plan is to use the following electronics:

  • an Arduino pro micro
  • a 20(character) x 4(row) LCD display (with I2C adapter)
  • some push button switches (maybe ten)
  • a number of rotary encoders (three to five)
    and put these into a relatively small enclosure.

With the push buttons, you activate different darktable modules - and the LCD display shows in the top row the name of the selected module. In the other three rows, it lists what the different rotary encoders do for this module. Then, turning a rotary encoder sends the key-shortcut to activate the corresponding slider, plus the mouse-wheel information to change its value.
I think this could be very helpful for my workflow as there are a few modules that could be used this way like the white balance (temperature slider), exposure module (exposure slider), sharpen module (three rotary encoders for radius, amount, threshold), shadows&highlights (shadows, highlights, and radius sliders), local contrast.
Other modules, like tone curve and color zones require 2-dimensional control. One could possibly add a little joystick for this purpose, but I doubt that this will be precise enough. Probably it’s better to continue using the mouse for this.

If one runs out of push buttons, one could implement short, long, and (possible) double click functionality. The rotary encoders also have push button switches built in - these could be used to switch between coarse and fine tuning.

These are my initial ideas.
I would appreciate your opinions, comments, suggestions, and possibly experience on whether this makes technically sense and if it would really be helpful for the everyday usage of darktable.

Thanks!

2 Likes

You do realise that the last post you quote is six years old? And that, as I point out at the end of that thread, a lot has changed since then and all (well I guess most; some of it is quite specific and I wonder how much the display day really adds) the functionality you are imagining is already implemented within dt so that many midi devices are fully supported out of the box?

If you are still considering building your own hardware and communicating rotary encoder turns with something else than midi, first, you might want to reconsider because midi is specifically meant for this kind of thing and I believe there are several arduino libraries that can send it. Second, you might still be able to fit it smoothly within the dt input framework by writing a small module similar to the existing libs/tools/midi.c Currently there is only one other such module, supporting gamepads.

2 Likes

As the existing solutions work, is it financially worthwhile to build your own controller?

With the existing supported controllers, you can do all the configuration from within dt, whereas, if I understand your proposal, you would have to set up dt for the shortcuts you want to use, and then set those up on the Arduino. Meaning you have to make any changes in two places.

Of course, you may want to do it as a fun project…

As an aside, several of the dt modules you propose to control are more or less outdated or not recommended (mostly because of a risk of artifacts avoided by newer modules).

1 Like

Thank you so much for your quick reply! This is great news and it will be very helpful. If the midi functionality is implemented in dt, this really seems to be the simpler solution.
I have already installed and played with an Arduino midi library, so this should be straightforward. And I have read multiple times through the section “midi-device-support” in the dt 4.2 docs. But somehow, I do not see how/where I can create the shortcuts that relate a note-on/-off or a continuous controller on the midi side to a dt function. Can this also be done in the settings/shortcuts menu? Or is there another way to define these?
Thanks again!

Thank you for your response! Please see my reply to dterrahe regarding midi. Yes, that’s what I will use.
But I think, I will also benefit from your reply in some other way: You mention that some of my modules are outdated (or not recommended anymore). I was not aware of that. I mostly do black and white conversions, and the color_zones module seems to be perfect for that, as it lets me simulate color filters for b/w photography (in the lightness curve). On top of that, I use the tone_curve module to adjust the contrast and tonality of the pictures. And I am (so far) very happy with the results.
Could you please let me know if/why these are not recommended anymore, and which other modules would be preferred for these purposes? I would appreciate your help!

Yes, or using the mapping mode. In the latter case, you press the shortcuts button (next to the settings button) and hover the mouse over a slider you want to connect to a rotator. Then you simply turn it (or you press a note button). The connection will immediately be made.

If there is no response, you may need to configure the alsa driver (if you are using linux) to make sure the device is opened in the first place. If you haven’t made any mappings yet, then pressing or turning should display a warning message.

BTW have you seen this GitHub - AndreaLunaro/LightDeck ? That should work too, but I’ve had no confirmation from anybody who actually built it and used it with dt.

1 Like

The most important ones are probably the “sharpen” module and “shadows & highlights”. Iirc, the problem was that those do gaussian blurs in Lab space, i.e. display-referred. That means that they are likely to cause halos when pushed a bit. Of course, they aren’t unusable (we’ve lived with such modules for years, after all), but the alternatives are better in that respect. For sharpening, I usually use “diffuse or sharpen” (can be slow, though) or contrast equaliser. “Shadows & highlights” can be replaced by tone equaliser (more precise, but imho not suited for use of a midi controller).

1 Like

The “mapping mode” is another piece of great information (which I have not found before). This makes the assignments much easier! Thanks also for the link to the “LightDeck” - I can probably get some good information from that. However, while LightDeck uses a large number of rotators (one for each function), I plan is to have a small number of rotators (maybe just 3) which, after pushing different buttons, have different functions, as indicated in this sketch.


This sketch just shows the concept - it’s not meant to represent the layout. The push buttons all sit in a block (like a 3x4 matrix), and the selected module plus the current functions of the rotators are displayed in the LCD.

1 Like

I will try that. So far, i used a combination of sharpen and contrast_equalizer, both in rather small amounts (I’m really afraid of the artifacts from overdoing these). The results look (so far!) good to me, since both affect slightly different aspects.
I just opened diffuse_or_sharpen, and I’m panicking in front of all these sliders :slight_smile: I guess, I need to look up some tutorials…

Sounds good! I’d be very interested to hear how you get on. I don’t think I have any useful input, but I’ll keep an eye on this thread. :slightly_smiling_face: :+1:

I feel the same way, so for now I stick to the presets, with perhaps an increase of the number of itrations (careful increase, with some presets increasing the iterations too much gives artifacts).

As for the controller, I have no idea how to set up the system you propose in dt. Of course, you can probably modify what’s sent to dt on the arduino side…

Exactly; since the Arduino needs to be aware what “module” is active anyway (for the display) it may as well send different CC codes depending on it. Standard midi allows for 128 separate encoders.

Alternatively (without the display) midi buttons/notes could be mapped to focus specific modules and then the virtual processing module contains the 1st, 2nd etc slider of each module. It means if you only build 3 encoders, you cannot manipulate the 4th slider in any module (unless you skip the 1st, 2nd or 3rd everywhere, of course), but hopefully in most cases the important ones are at the top anyway (or this could maybe be fixed).

My advice, first get thoroughly acquainted with the functionality of the shortcut system before building anything to tie into it. You can experiment with everything using just keyboard and mouse. Or try a gamepad if you have one lying around.

Except if you use a loupedeck(+).

Nice - thanks!
I have no idea where this is going. Although I have been doing photography for a long time, and I have some experience with editing in Gimp, it’s only been one year since I got my first full-frame DSLR. This was when I started raw editing, and it was my first contact with darktable. I still consider myself a beginner and I still need to improve my basic workflow. Just recently I read someone opinion that if you spend much time on editing (which I do), it would be worth to look into USB controllers, which may increase your efficiency and may save you much time. With my Arduino background, I thought “yes, let me try to come up with a solution, custom-tailored to my purposes.” Now, with the help from the previous responses, I gained some fundamental insights of what’s possible in darktable, and I will try to come up with a design/layout of a controller that might work for me. And if you are an “Arduino guy”, it may inspire you too…

1 Like

That’s good advice - and it’s what I’m currently doing: learn about the shortcut system. I really love the mapping mode which makes everything easy. Currently, I think that it would not really make any difference if I let the Arduino send midi or keyboard/mouse commands. The latter would have the advantage that I can test and set up everything with my keyboard and mouse and, later just plug in the Arduino and let it take over.
I also feel that building my own hardware may have some real advantages: I can program the Arduino such that a single activity (key or mouse wheel) may have multiple actions. E.g. a single push button may at the same time enable a dt module and also bring it in focus. I could also program it such that for some modules, the rotators correspond to sliders (1,2,3) while for others they may correspond to sliders (1,3,5), etc.
A push of the built-in button of a rotary encoder may switch between a coarse mode and a fine mode of a slider.
In everyday life, it may happen that, after bringing one module into focus with the controller, the user may bring another module into focus by using the mouse. For such cases, I could program the rotators such that they first bring the corresponding module into focus, before they send the mouse-wheel code for the rotator movement (to ensure that the original module is visible).
I also try to read articles how people use Loupedeck+ with Lightroom, etc., to get inspiration on other functions to implement. (plus: I’m already thinking of whether the unit could also be used as controller for kdenlive, scribus, and other software, … but that’s a different story)

I’m overthinking this!!
To build a controller that will do everything that I need, I first need to figure out what I need. Now, while studying this, I learn more and more about Darktable (which is great!), but it also seems that I’m not converging. So, I decided to stick to a design, and see how far it takes me. As long as this is not limited by the hardware, I can add features in software - otherwise, I may have to redo it (at some point…). This is my design:

It features:

  • a 20x4 LCD display
  • an array of three push buttons (top left) to select the “main modes” (Lighttable, preview/culling, Darkroom)
  • a mini joystick (this may be used to navigate in Lighttable; in Darkroom it may eventually be used to set/move control points in modules like tone_curve - but it’s not clear to me how well that would work)
  • an array of 3x6 push buttons (to select specific functions; e.g. in Lighttable/preview mode: rating, apply styles ; in Darkroom: select/enable modules)
  • three rotary encoders (in Darkroom: operate module sliders)
  • one rotary encoder (to zoom in/out)

Once the hardware is built, I can start implementing different features in software, see how they work, and add more. Also the decision of keys/mouse vs. midi can be changed at any time.

4 Likes

The rotary encoders and the push buttons just arrived. Here is all the electronics that will be in the controller.

And this is my plan, how to connect everything to the Arduino pro micro.

DarktableController-Arduino-pins

The push buttons (including those in the rotary encoders and the joystick) will be wired in three chains as voltage dividers. This way they can be read via three analog inputs - and I don’t need any additional hardware for their readout (well, except for some resistors).

3 Likes

Wow, reading over your shoulder ;-). Seems a nice project. If I find some time, I will look into this myself. However, an off the shelf solution sourced 2nd hand will probably be more cost-effective, but I understand the joy of building beats off the shelf often. Time is the deciding factor for me. Maybe I’ll join. Thanks for sharing! How did it turn out? Are you sharing more details somewhere?

1 Like

It’s only been 11 months… :slight_smile:
After my last post, I made a little progress, soldering a few pieces.
But then I basically forgot about the project.
So, there is not much to share at the moment.
But one day, I will pick it up and finish it - I hope…
And I agree with you about 2nd hand off-the-shelf vs. building your own.

1 Like

Been there, done that :slight_smile: happens to me as well.