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. Peripherals
  3. Digital outputs

SimHub control

PreviousSetupNextFirmware control

Last updated 9 months ago

We can use the feature rich RGB LED editor in SimHub to control our output hubs. We'll make a virtual LED strip and trick SimHub into sending us data for RGB LEDs, which we will use to feed the output hubs instead.

Naturally, SimHub cant change the color or brightness of our analog LEDs. So the way you use the RGB editor is by making the virtual LED black or brightness 0 will turn the output off, and any other color or brightness setting will turn it on.

It doesn't have to be analog LEDs we're controlling with out output pins, the SimHub connection will just give us a very convenient way to control individual outputs, make profiles and use game telemetry to turns things on and off.

We'll start off in 14_LEDSetup.ino:

//----------------------------------------------------------------------------
// ---------------------------- STRIP #1 SETUP -------------------------------
//----------------------------------------------------------------------------

#define LED1COUNT 0
#define LED1PIN 2  
#define LED1TYPE NEO_GRB + NEO_KHZ800
#define LED1REVERSE 0
#define LED1PRIVATE 0

If we're sending LED data to output hubs, STRIP #1 is reserved for that. If you're using real RGB LEDs as well, put those on strip 2, 3 and/or 4.

Nothing else needs to be filled out, we don't have a LED pin.

For the sake of education, lets say we also have a real RGB LED strip with 40 LEDs wired to pin 25. We'll put those on STRIP #2 then, and the results is like this:

//----------------------------------------------------------------------------
// ---------------------------- STRIP #1 SETUP -------------------------------
//----------------------------------------------------------------------------

#define LED1COUNT 54
#define LED1PIN 2
#define LED1TYPE NEO_GRB + NEO_KHZ800
#define LED1REVERSE 0
#define LED1PRIVATE 0

//----------------------------------------------------------------------------
// ---------------------------- STRIP #2 SETUP -------------------------------
//----------------------------------------------------------------------------

#define LED2COUNT 40
#define LED2PIN 25
#define LED2TYPE NEO_GRB + NEO_KHZ800
#define LED2REVERSE 0
#define LED2PRIVATE 0

Next, we'll have to feed the LED data stream to our output hubs. We'll move on to 45_OutputHubs.ino:

void outputHubRun()
{
//--------------------------------------
//---------CONTROLLING OUTPUT HUBS------
//---------------START HERE-------------
//--------------------------------------





//--------------------------------------
//---------------END HERE---------------
//--------------------------------------
}

We'll use the function outputLEDImport(hub number, start LED) to link our hubs to the SimHub LED data stream. One function call for each hub, each continuing on the chain where the other stopped. Keep in mind that when working with LEDs in DDC, we're refering to the first LED in the chain as 0, while in SimHub the first is 1. So the first 16 LEDs in DDC are 0 to 15, while in SimHub 1 to 16.

void outputHubRun()
{
//--------------------------------------
//---------CONTROLLING OUTPUT HUBS------
//---------------START HERE-------------
//--------------------------------------

outputLEDImport(1,0);
outputLEDImport(2,16);
outputLEDImport(3,32);
outputLEDImport(4,48);


//--------------------------------------
//---------------END HERE---------------
//--------------------------------------
}

In SimHub, you'll now have a chain of 94 LEDs, ordered like this:

Set LED1COUNT to the total amout of output slots we're using on all of our hubs combined. If we're taking the examples from the chapter, we've got 4 hubs; the first three with 16 active slots and the 4th with 6 slots used. In total 54 outputs.

on making connection between SimHub and your controller.

setup
Read this