Advice on program construction - DMX

image.jpg

It’s probably been 10 years but I should ask for my money back
 
I have multiple .h files now dividing up my code.
If a particular routine that I have sub-divided off into it's own .h file needs the resources of another .h file, then I just declare that at the beginning of the .h file that needs it.

But... I have one .h file that requests to jump to a routine in the main ino file and fails to find it. How do you tell it to go to the main ino?
I thought that would have done so by default.

To clear that up....

In the main INO file, lets say I have:

void test{}

The .h file I have created and included into the main INO file now asks to go to test(); That fails?
It's almost like I need to include the main INO file in the .h file.
 
Last edited:
In the Teensy DMX library, there is an example of setting the DMX output using the set command to send 3 values in the data array to DMX channels 10, 11 and 12.

Code:
/*
 * A basic toy send example.
 *
 * This example is part of the TeensyDMX library.
 * (c) 2019-2020 Shawn Silverman
 */

#include <TeensyDMX.h>

namespace teensydmx = ::qindesign::teensydmx;

// Pin for enabling or disabling the transmitter.
// This may not be needed for your hardware.
constexpr uint8_t kTXPin = 17;

// Create the DMX sender on Serial1.
teensydmx::Sender dmxTx{Serial1};

// Data for 3 channels.
uint8_t data[3]{0x44, 0x88, 0xcc};

void setup() {
  // Turn on the LED, for indicating activity
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWriteFast(LED_BUILTIN, HIGH);

  // Set the pin that enables the transmitter; may not be needed
  pinMode(kTXPin, OUTPUT);
  digitalWriteFast(kTXPin, HIGH);

  // Set some channel values. These are being set in setup() to
  // illustrate that values are 'sticky'. They stay set until changed.
  // There's no special function to call for each iteration of loop().

  // Set channel 1 to 128
  dmxTx.set(1, 128);

  // Set channels 10-12 to the 3 values in 'data'
  dmxTx.set(10, data, 3);

  // Call this after setting up the channel contents if you want to
  // guarantee that the values are used as the initial contents;
  // transmission doesn't start until after begin() is called.
  // If it doesn't matter, begin() can be called before setting the
  // channel contents.
  dmxTx.begin();
}

void loop() {
  // Do something, maybe alter channel values.
}


Is there a way to format that command to send the value 255 to 10 channels (that follow each other E.G 10-19) without needing the array?

E.G dmxTx.set(10, 255, 10);
 
See the fill() function. From the source:

C++:
  // Fills all channels in the specified range to the given value.
  // The behaviour is atomic.
  //
  // This returns `false` if any part of the channel range is not in the range
  // 0-512, or if the length is negative. Otherwise, this returns `true`. The
  // upper limit is equal to `kDMXMaxPacketSize-1`.
  bool fill(int startChannel, int len, uint8_t value);

Link: https://github.com/ssilverman/Teens...92665c0a06b97a27aeca7eef/src/TeensyDMX.h#L938
 
Back
Top