handle rdm dmx address changes

This commit is contained in:
Arne 2023-08-18 15:47:01 +02:00 committed by Will Tatam
parent 50b56c64f5
commit 2989155f05
2 changed files with 24 additions and 0 deletions

View File

@ -9,6 +9,24 @@
#include "dmx_input.h"
#include <rdm/responder.h>
void rdmAddressChangedCb(dmx_port_t dmxPort, const rdm_header_t *header,
void *context)
{
DMXInput *dmx = static_cast<DMXInput *>(context);
if (!dmx)
{
USER_PRINTLN("DMX: Error: no context in rdmAddressChangedCb");
return;
}
if (header->cc == RDM_CC_SET_COMMAND_RESPONSE)
{
const uint16_t addr = dmx_get_start_address(dmx->inputPortNum);
DMXAddress = std::min(512, int(addr));
USER_PRINTF("DMX start addr changed to: %d\n", DMXAddress);
}
}
dmx_config_t DMXInput::createConfig() const
{
@ -104,6 +122,7 @@ void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPo
USER_PRINTF("DMX enable pin is: %u\n", enPin);
dmx_set_pin(inputPortNum, txPin, rxPin, enPin);
rdm_register_dmx_start_address(inputPortNum, rdmAddressChangedCb, this);
initialized = true;
}
else

View File

@ -29,6 +29,11 @@ private:
void turnOnAllLeds();
dmx_config_t createConfig() const;
//is invoked whenver the dmx start address is changed via rdm
friend void rdmAddressChangedCb(dmx_port_t dmxPort, const rdm_header_t *header,
void *context);
uint8_t inputPortNum = 255; // TODO make this configurable
/// True once the dmx input has been initialized successfully
bool initialized = false; // true once init finished successfully