Skip to content

Commit 6f07a5d

Browse files
authored
Merge pull request #33 from Kevitto/master
Example : RDM In to DMX Out
2 parents 93f03a4 + 79ccf4d commit 6f07a5d

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

examples/RDMIntoDMXOut.ino

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// - - - - -
2+
// DmxSerial2 - A hardware supported interface to DMX and RDM.
3+
// RDMSerialRecv.ino: Sample RDM application.
4+
//
5+
// Copyright (c) 2011-2013 by Matthias Hertel, http://www.mathertel.de
6+
// This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx
7+
//
8+
// The following RDM commands are implemented here:
9+
// E120_LAMP_HOURS
10+
// E120_DEVICE_HOURS
11+
//
12+
// More documentation and samples are available at http://www.mathertel.de/Arduino
13+
// - - - - -
14+
15+
#include <DmxSimple.h>
16+
#include <EEPROM.h>
17+
#include <DMXSerial2.h>
18+
19+
// see DMXSerial2.h for the definition of the fields of this structure
20+
//const uint16_t my_pids[] = {E120_DEVICE_HOURS, E120_LAMP_HOURS};
21+
const uint16_t my_pids[] = {};
22+
struct RDMINIT rdmInit = {
23+
"Company Name", // Manufacturer Label
24+
1, // Device Model ID
25+
"RDM Module", // Device Model Label
26+
3, // footprint
27+
(sizeof(my_pids)/sizeof(uint16_t)), my_pids
28+
};
29+
30+
uint16_t startAddress = 0;
31+
int maxSize = 3;
32+
33+
void setup () {
34+
DMXSerial2.init(&rdmInit, processCommand);
35+
36+
pinMode(9, OUTPUT); // defined isIdentifyMode pin for output
37+
digitalWrite(9, LOW);
38+
DmxSimple.usePin(3); // Use Digital pin 3 for DMXSimple output
39+
DmxSimple.maxChannel(maxSize); //set the maxChannel for DMXSimple to the same as the RDM module's max size
40+
41+
} // setup()
42+
43+
44+
void loop() {
45+
if (DMXSerial2.isIdentifyMode()) {
46+
47+
digitalWrite(9, HIGH); // indicator light for the Identify mode
48+
49+
} else {
50+
startAddress = DMXSerial2.getStartAddress(); // retrieve current RDM start address
51+
52+
for (int i = 0; i < maxSize; i++){ // for all DMX packets sent to addresses up to maxSize, forward to DMX out
53+
54+
DmxSimple.write(i + 1, DMXSerial2.readRelative(i)); //Grab all DMX packets sent to RDM address and forward to DMX out
55+
}
56+
57+
digitalWrite(9, LOW);
58+
}
59+
60+
DMXSerial2.tick();
61+
} // loop()
62+
63+
// This function was registered to the DMXSerial2 library in the initRDM call.
64+
// Here device specific RDM Commands are implemented.
65+
bool8 processCommand(struct RDMDATA *rdm, uint16_t *nackReason)
66+
{
67+
byte CmdClass = rdm->CmdClass;
68+
uint16_t Parameter = rdm->Parameter;
69+
bool8 handled = false;
70+
71+
if (CmdClass == E120_SET_COMMAND) {
72+
*nackReason = E120_NR_UNSUPPORTED_COMMAND_CLASS;
73+
}
74+
75+
return handled;
76+
}

0 commit comments

Comments
 (0)