Ctrldev

From ZynthianWiki
Jump to navigation Jump to search

1 How Do I start writing a ctrldev driver?

Well you first have to do a lot of the process that's described here, so a quick scan of the questions and have a look at any you don't understand. We assume you have vsc all set up and ready to rock and you have a debug-able zynthian attached and it runs...

1.1 Where do I put what files to make it work?

The ctrldev files are located in the directory /zynthian/zynthian-ui/zyngine/ctrldev in the zynthian repository zynthian-ui which is what you should have forked to get to this point. It is a simple task to copy one of the existing files rename it to something that suits what you are doing and away you go....

Well there is one other thing that needs doing to ensure the file you have added is included in the scan the zynthian makes to detect device drivers it knows about and that is to add the details of your file into the rather peculiarly named __init__.py file . . This is a default file that python likes to see in a directory to tell it what is and is not required elsewhere.... As of (2024-09-09) it looks like this...

# -*- coding: utf-8 -*-
__all__ = [
   "zynthian_ctrldev_akai_apc_key25_mk2",
   "zynthian_ctrldev_akai_midimix",
   "zynthian_ctrldev_akai_mpk_mini_mk3",
   "zynthian_ctrldev_duopiano",
   "zynthian_ctrldev_korg_nanokontrol2",
   "zynthian_ctrldev_launchkey_mini_mk3",
   "zynthian_ctrldev_launchpad_mini",
   "zynthian_ctrldev_launchpad_mini_mk3",
   "zynthian_ctrldev_launchpad_pro_mk2",
   "zynthian_ctrldev_launchpad_pro_mk3",
   "zynthian_ctrldev_launchpad_x",
   "zynthian_ctrldev_riband",
   "zynthian_ctrldev_behringer_motor61"
]

__all__ is a python directive to publish these modules and it means they can be seen as fully fledged members of the zynthian namespace.

This needs to match the naming of your script, which is the file zyngine/ctrldev/zynthian_ctrldev_behringer_motor61.py, which in my case I copied from the Duo_piano File...

1.2 How do we know we are actively running our code....?

We set a breakpoint in the VSC source code listing.