DDC
  • Welcome
    • Introduction
    • Supported hardware
  • 1: Project planning
    • Switch inputs
      • Switch table
      • Direct
      • Shift register
      • Port expander
    • Analog inputs
      • External ADC
    • RGB LED
    • Digital outputs
    • PWM / Circuit control
    • EEPROM
    • Processing and memory
  • 2. Wiring
    • Switch inputs
      • Matrix
      • Direct
      • Shift register
      • Port expander
    • Analog
      • Analog switches
      • External ADC
    • RGB LED
    • Digital outputs
    • PWM / Circuit control
    • EEPROM
  • 3. Coding
    • Essentials
      • 02_Board.ino
      • 08_Joystick
      • 10_TableAndAnalog.ino
        • Switch table
        • Analog channels
      • 30_Switches.ino
    • Peripherals
      • RGB LED
        • Firmware control
          • LED functions
          • Color
          • Brightness
          • Presets
        • SimHub control
      • Digital outputs
        • Setup
        • SimHub control
        • Firmware control
      • PWM / Circuit control
        • Setup
        • Calibrate
        • Switch control
        • Trigger control
      • Shift register
      • I2C devices
        • ADS1115
        • PCA9555
        • CAT24C512
    • Advanced
      • Analog inject
      • Conditional coding
        • Triggers
        • Editors
      • Field placement
      • Presets
        • 31_RunningPresets.ino
        • 32_Presets.ino
        • Example
    • Upload
    • Naming the controller
  • 4. Connect to SimHub
    • LED control
    • Controller settings and properties
      • How to connect?
      • How does it work?
      • How to control it?
      • Property list
  • Switch library
    • Pushbutton
    • Function switches
    • Toggle switches
    • Hat switches
    • Car control functions
      • QuickSwitch
      • BrakeMagic
      • ThrottleHold
      • Handbrake
    • Pedals & paddles
      • Brake/throttle
      • Clutch
      • Bite point & launch
      • Filtered curves
      • Shifter
    • Funky switch
      • Directional
      • Center push
    • Encoders
      • rotary2Bit
      • rotary4Bit
      • funkyRotary
      • wildEncoder
      • E18
      • rotaryPulse
      • PEC11
    • Rotary switches
      • rotaryAnalog
      • quickRotary
      • SW1
      • Editing functions
    • Multiswitch complexes
      • Hybrid rotary
      • Multifunction rotary
      • Modded encoder
      • Stacked encoder
    • Preset
    • DDS
    • RGB LED control
    • PWM / Circuit control
    • Utility
  • Fast DDC
    • Buttons and LED
    • 4 encoders, buttons and LED
    • Dual clutches, 4 encoders, buttons and LED
    • Dual clutches, 6 encoders, button matrix and LED
  • CB1
    • Ordering
      • Order together
      • Order yourself
        • 1. Open in EasyEDA
        • 2. Export files
        • 3. Edit Pick&Place
        • 4. Pin headers and jumper
        • 5. Order from JLCPCB
    • Wiring
    • Code
      • Essentials
      • Complete project
      • Settings
    • Circuit
    • Shields
      • Robin
  • Collaboration
Powered by GitBook
On this page
  1. Switch library
  2. Rotary switches

rotaryAnalog

PreviousRotary switchesNextquickRotary

Last updated 9 months ago

All rotaryAnalog functions are for 12-position switches. The most common are 8, 10, 12 and 16 positions - with 12 being the most common. These functions can be without too much hassle to match larger numbers of positions.

For fewer than 12 positions, simply use a dummy value for the unused positions, a value the switch will never be close to reaching. For instance:

rotaryAnalogSimple(2, 58, 209, 342, 462, 565, 680, 848, 1023, 10000, 10000, 10000, 10000, false); Here, a 8 position switch is used, and the last 4 positions are given the value "10 000".

All rotary switch functions require you to the voltage comming from the switch in all its positions. The one exception is rotaryAnalog2ModeShort(), which is a version of rotaryAnalog2Mode (the most used rotary switch function) that will assume the voltages in the 12 positions of the swich. This makes the function a lot easier to use.

rotaryAnalog()

Setup with several switch modes, including a You can set the amount of positions of the hybrid switch to any number.

Modes:

  • 0: 12-position switch. Absolute.

  • 1: Incremental

  • 2: Open hybrid, X positions

  • 3: Closed hybrid

Uses the rotary field for Since is has 4 modes it uses 2 slots in the field.

void rotaryAnalog(int analogChannel, int fieldPlacement, int hybridPositions, int pos1, int pos2, int pos3, int pos4, int pos5, int pos6, int pos7, int pos8, int pos9, int pos10, int pos11, int pos12, bool reverse)

Switch setup with explainations:

rotaryAnalog(

2, <- analog channel

1, <- placement in rotary field

7, <- Switch positions in hybrid mode

16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, <- Switch position values

false); <- Direction is not reversed, so CW rotation increasese button number.

  • Field placement to 1. Uses two slots in the bit field (1 and 2). So [DahlDesign.DDCR1] and [DahlDesign.DDCR2] and will show the modes.

  • Hybrid switch has 7 positions. The starting number of the hybrid switch and 12-position mode is determined by the number set in the block for analogButtonNumber[]. The number for incremental mode is determined by the number set in the block for analogButtonNumberIncMode[].

  • This switch has "reverse" set to true, which can be a good idea if it is placed horizontally on the right side. Turning it CCW will now increase the count instead of reducing.

So typed out in 30_Switches.ino:

rotaryAnalog(2, 1, 7, 16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, false);

  • modButton() if you want to change modes freely. modButton() not needed to change modes across presets.

  • hybridButton() to lock position and use rotary as incremental switch.

  • X button numbers, minimum 12, determined by the largest number of positions in any mode.

  • Two slots in the rotary field.

rotaryAnalogSimple()

12 - position switch. Absolute.

void rotaryAnalogSimple(int analogChannel, int pos1, int pos2, int pos3, int pos4, int pos5, int pos6, int pos7, int pos8, int pos9, int pos10, int pos11, int pos12, bool reverse)

Switch setup with explainations:

rotaryAnalogSimple(

2, <- analog channel

16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, <- Switch position values

false); <- Direction is not reversed, so CW rotation increasese button number.

  • The starting number of the 12-positions is determined by the number set in the block for analogButtonNumber[].

  • This switch has "reverse" set to true, which can be a good idea if it is placed horizontally on the right side. Turning it CCW will now increase the count instead of reducing.

So typed out in 30_Switches.ino:

rotaryAnalogSimple(2, 16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, false);

  • 12 button numbers

rotaryAnalogMute()

12 - position switch. Absolute.

Produces no button presses, but the position of the switch is still detected by the firmware and can be used for or .

void rotaryAnalogMute(int analogChannel, int pos1, int pos2, int pos3, int pos4, int pos5, int pos6, int pos7, int pos8, int pos9, int pos10, int pos11, int pos12, bool reverse)

Switch setup with explainations:

rotaryAnalogMute(

2, <- analog channel

16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, <- Switch position values

false); <- Direction is not reversed, so CW rotation increasese button number.

  • This switch has "reverse" set to true, which can be a good idea if it is placed horizontally on the right side. Turning it CCW will now increase the count instead of reducing. So typed out in 30_Switches.ino:

rotaryAnalogMute(2, 16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, false);

  • None

rotaryAnalogPartial()

12 - position switch. Absolute.

void rotaryAnalogPartial(int analogChannel, int muteStart, int muteEnd, int pos1, int pos2, int pos3, int pos4, int pos5, int pos6, int pos7, int pos8, int pos9, int pos10, int pos11, int pos12, bool reverse)

Switch setup with explainations:

rotaryAnalogPartial(

2, <- analog channel

5, <- The first position in the muted range

9, <- The last position in the muted range

16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, <- Switch position values

false); <- Direction is not reversed, so CW rotation increasese button number.

  • The starting number of the 12-positios is determined by the number set in the block for analogButtonNumber[]. In the example above, positions 5, 6, 7, 8 and 9 are muted. The button numbers used will not automatically compress, there will be unused button numbers in the middle of the switch range.

  • This switch has "reverse" set to true, which can be a good idea if it is placed horizontally on the right side. Turning it CCW will now increase the count instead of reducing. So typed out in 30_Switches.ino:

rotaryAnalogPartial(2, 5, 9, 16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, false);

  • 12 button numbers

rotaryAnalog2Mode()

Setup with 2 switch modes.

Modes:

  • 0: 12 - position switch. Absolute.

  • 1: Incremental

void rotaryAnalog2Mode(int analogChannel, int fieldPlacement, int pos1, int pos2, int pos3, int pos4, int pos5, int pos6, int pos7, int pos8, int pos9, int pos10, int pos11, int pos12, bool reverse)

Switch setup with explainations:

rotaryAnalog2Mode(

2, <- analog channel

1, <- placement in rotary field

16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, <- Switch position values

false); <- Direction is not reversed, so CW rotation increasese button number.

  • Field placement to 1 in the rotary field, so [DahlDesign.DDCR1] will show the modes.

  • The starting number of the 12-position mode is determined by the number set in the block for analogButtonNumber[]. The number for incremental mode is determined by the number set in the block for analogButtonNumberIncMode[].

  • This switch has "reverse" set to true, which can be a good idea if it is placed horizontally on the right side. Turning it CCW will now increase the count instead of reducing.

So typed out in 30_Switches.ino:

rotaryAnalog2Mode(2, 1, 16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, false);

  • modButton() if you want to change modes freely. modButton() not needed to change modes across presets.

  • Minimum 12 button numbers.

  • One slot in the rotary field.

rotaryAnalog2ModeShort()

Setup with 2 switch modes. This funtion does not require you to record any values from your switch to set up.

Modes:

  • 0: 12 - position switch. Absolute.

  • 1: Incremental

void rotaryAnalog2ModeShort(int analogChannel, int fieldPlacement, bool reverse)

Switch setup with explainations:

rotaryAnalog2ModeShort(

2, <- analog channel

1, <- placement in rotary field

false); <- Direction is not reversed, so CW rotation increasese button number.

  • Field placement to 1 in the rotary field, so [DahlDesign.DDCR1] will show the modes.

  • The starting number of the 12-position mode is determined by the number set in the block for analogButtonNumber[]. The number for incremental mode is determined by the number set in the block for analogButtonNumberIncMode[].

  • This switch has "reverse" set to true, which can be a good idea if it is placed horizontally on the right side. Turning it CCW will now increase the count instead of reducing.

So typed out in 30_Switches.ino:

rotaryAnalog2ModeShort(2, 1, false);

  • modButton() if you want to change modes freely. modButton() not needed to change modes across presets.

  • Minimum 12 button numbers.

  • One slot in the rotary field.

rotaryAnalogBite()

Setup with 2 switch modes. Identical to rotaryAnalog2Mode(), but with the option to set the bitepoint together with a biteButton().

Modes:

  • 0: 12 - position switch. Absolute.

  • 1: Incremental

void rotaryAnalogBite(int analogChannel, int fieldPlacement, int pos1, int pos2, int pos3, int pos4, int pos5, int pos6, int pos7, int pos8, int pos9, int pos10, int pos11, int pos12, bool reverse)

Switch setup with explainations:

rotaryAnalog2Mode(

2, <- analog channel

1, <- placement in rotary field

16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, <- Switch position values

false); <- Direction is not reversed, so CW rotation increasese button number.

  • Field placement to 1 in the rotary field, so [DahlDesign.DDCR1] will show the modes.

  • The starting number of the 12-position mode is determined by the number set in the block for analogButtonNumber[]. The number for incremental mode is determined by the number set in the block for analogButtonNumberIncMode[].

  • This switch has "reverse" set to true, which can be a good idea if it is placed horizontally on the right side. Turning it CCW will now increase the count instead of reducing.

So typed out in 30_Switches.ino:

rotaryAnalogBite(2, 1, 16, 107, 200, 291, 383, 474, 566, 657, 749, 841, 932, 1023, false);

  • modButton() if you want to change modes freely. modButton() not needed to change modes across presets.

  • Minimum 12 button numbers.

  • One slot in the rotary field.

  • biteButton() to set the bite point

Mix between rotaryAnalogSimle() and rotaryAnalogMute(). You can select a range of positions which will be muted. The remaining positions will produce a button press. The position of the switch is still detected in the muted positions and can be used for or .

Uses the rotary field for Since is has 2 modes it uses 1 slot in the field.

Uses the rotary field for Since is has 2 modes it uses 1 slot in the field.

Uses the rotary field for Since is has 2 modes it uses 1 slot in the field.

field placement.
field placement.
field placement.
edited
field placement.
conditional coding
conditional coding
rotaryInject
rotaryInject
read out
hybrid switch.