// Initialize or reinitialize the DMX RDM mode. // The other values are stored for later use with the specific commands. void DMXSerialClass2::init(struct RDMINIT *initData, RDMCallbackFunction func, uint8_t modePin, uint8_t modeIn, uint8_t modeOut) { // This structure is defined for mapping the values in the EEPROM struct EEPROMVALUES eeprom; // save the given initData for later use. _initData = initData; _rdmFunc = func; _dmxModePin = modePin; _dmxModeIn = modeIn; _dmxModeOut = modeOut; _baseInit(); // now initialize RDM specific elements _isMute = false; _rdmAvailable = false; _identifyMode = false; _softwareLabel = "Arduino RDM 1.0"; DeviceIDCpy(_devID, initData->deviceID); // read from EEPROM or set defaults for (unsigned int i = 0; i < sizeof(eeprom); i++) ((byte *)(&eeprom))[i] = EEPROM.read(i); // check if the EEEPROM values are from the RDM library if ((eeprom.sig1 == 0x6D) && (eeprom.sig2 == 0x68)) { _startAddress = eeprom.startAddress; strcpy (deviceLabel, eeprom.deviceLabel); DeviceIDCpy(_devID, eeprom.deviceID); } else { // set default values _startAddress = 1; strcpy (deviceLabel, "new"); _devID[4] = random255(); // random(255); _devID[5] = random255(); // random(255); } // if // setup the manufacturer adressing device-ID _devIDGroup[0] = _devID[0]; _devIDGroup[1] = _devID[1]; _saveEEPRom(); // now start digitalWrite(_dmxModePin, _dmxModeIn); // data in direction _dmxSendBuffer = _rdm.buffer; // _dmxSendLen = ... will be set individually // Setup Hardware // Enable receiver and transmitter and interrupts UCSRnB = (1<<RXENn) | (1<<RXCIEn); _DMXSerialBaud(Calcprescale(DMXSPEED), DMXFORMAT); // Enable serial reception with a 250k rate } // initRDM()
// get the deviceID void DMXSerialClass2::getDeviceID (DEVICEID id) { DeviceIDCpy(id, _devID); } // getDeviceID()