How does it work?
Last updated
Last updated
The controller settings are sent over USB as two bit fields.
To explain what a bit field is, I'll have to explain a few other things first.
Bits are the building blocks, the currency and the language in computing. A single bit is essentially an on/off-switch. The bit is a logical state 0 or 1. On or off. Often, it represents a physical component, such as the charge of a capacitor or the conduction properties of a transistor. A flash memory drive has millions of transistors, each representing a bit, each possible to change between two states.
In programming, a single bit is usually too small to work with. If you want to express a number of a certain size, you'll need a bunch of bits. So we're working with several bits at the time.
When programming microcontrollers, typically the smallest package of bits is 8 (such as a byte). When programming applications it is usually 16. Everything is built around using these different sized packages of bits. Think of it like buying a pack of cigarettes. Buying single sigarettes is not possible (at least not where I'm from), you'll have to adhere to the system and buy 20 at the time.
This means that if I have eight different settings in my firmware that is either on or off, and I want to express this in code, I'll have to pop an 8-pack of bits (byte) for each one. Since I'm only trying to express on/off (1 or 0), I'll only be using the first bit in each byte. The remaining 7 bits are never used. The equivalent in cigarettes is that if you need 8 cigarettes, you'll buy 8 packets of cigarettes and only take a single cigarette from each. Sounds crazy? Well this is how it works. It is more convenient this way, and trying to make use of every bit in every byte will require more processing power.
However, if we're going to send information somewhere, it is not necessarily convenient anymore. We'd like the information to be as condensed as possible, since sending stuff both takes time and processing power. In that case it might be worth trying to make use of every bit. Instead of using 8 bytes for my 8 on/off-settings, I'll try to use every bit of a single byte.
Before I had 8 bytes that had a value of either 1 or 0. Now I have a single byte who's value doesn't make much sense anymore. Lets say that setting number 1, 4 and 8 are on, and the others are off. The bits in the byte would spell out like 10001001. In decimal number this is 137. But in this context, the number 137 doesn't mean anything. This byte is only useful if it comes with an explaination:
And now we have a bit field; a package of bits with more information that just the total value of the package. Bit fields have to come with an explaination, or else you wont know which bit means what.
DDC sends controller settings in two 16-bit packages. 32 bits total, 32 settings on/off. These two fields are named rotaryField and buttonField. Don't mind the names, they don't mean anything. You can have a look at 19_Bitfields to see how they are structured:
The top one is rotaryField, the bottom one is buttonField. As you can see, many of the bits in each field is already in use. Only 4 bits available in buttonField and 7 in rotaryField. This is because many of the DDC functions will automatically send info to these fields. Such as magic button activation, dual clutches modes and current preset selected. However, if you're not using any of these functions, you can overwrite their place in the fields. Feel free to edit these comments in 19_Bitfields and set up the fields the way you like.
In the plugin, the fields are displayed at the bottom:
The colored boxes are the ones that are reserved for specific functions.