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. 3. Coding
  2. Advanced
  3. Conditional coding

Triggers

These are simple functions that can be used with conditional coding, or the LEDtrigger() function. These functions will return true or false.

buttonFieldBit(int bit)

Type in a field placement to check if this bit is 1. Use this to check for switch modes. If you've got a toggleM() switch using field placement 3, you can write buttonFieldBit(3). It will return TRUE for switch mode 1 and FALSE for switch mode 0.

rotaryFieldBit(int bit);

Type in a field placement to check if this bit is 1. Use this to check for switch modes. If you've got a rotaryAnalog2Mode switch using field placement 6, you can write rotaryFieldBit(6). It will return TRUE for switch mode 1 and FALSE for switch mode 0.

buttonPressed(int row, int column)

Check if a button or toggle on a given row and column number is pressed. Example: buttonPressed(3,4) to check a switch on row3 column4. This data is generated after debouncing algorithms, so this button needs to have a pushButton(3,4) or similar called in 30_Switches.ino.

switchPressed(int row, int column)

Check of a button or toggle on a given row and column number is pressed. Example: switchPressed(3,4) to check a switch on row3 column4. This differs from buttonPressed() is that this function looks at the raw data input from the switch, not the processed and debounced button press. The advantage of this is that you can check for the state of a switch that isn't using any switch funtion, and thus not generating any button press in windows.

togglePressed(int row, int column)

Check of a momentary button using a latching mode on a given row and column number is pressed. Example:togglePressed(3,4) to check a switch on row3 column4.

presetSearch (int presetNumber)

Returns true if you're in the preset in question. Example: presetSearch(4) will return TRUE of you're in preset 4, otherwise it returns FALSE.

modButtonPressed ()

Returns TRUE if modbutton is pressed, otherwise FALSE. Doesnt require any input, simply write modButtonPressed().

biteSettingMode (int biteSettingMode)

Returns TRUE if the current bite setting mode (0 -3) is the same as you typed in the function. Otherwise FALSE.

rotaryPosition(int analogChannelNumber, int switchPosition)

This function will check a rotary switch for a given position. Give it the channel number your switch is set up on, well as a switch position. Will return TRUE if this switch is in that position, otherwise FALSE. Example: rotaryPosition(3,9) will check if the switch on analog channel 3 is in position 9 or not.

analogTravel(int analogChannel, int threshold)

Check if an analog switch has travled at least to the set threshold of its total travel. For instance, if you want something to happen when a clutch paddle is pressed completely, use its channel number and set threshold to 100(%).

encoderStack(int row, int column, int layer)

This function will check a stacked encoder for which layer it is currently in. Type in the row and column number for the stack button and which layer you want to check for. Stack layers start on 0.

PreviousConditional codingNextEditors

Last updated 6 months ago