mirror of
https://github.com/wled/WLED.git
synced 2025-07-10 12:26:31 +00:00
handle rdm dmx address changes
This commit is contained in:
parent
50b56c64f5
commit
2989155f05
@ -9,6 +9,24 @@
|
|||||||
#include "dmx_input.h"
|
#include "dmx_input.h"
|
||||||
#include <rdm/responder.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
|
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);
|
USER_PRINTF("DMX enable pin is: %u\n", enPin);
|
||||||
dmx_set_pin(inputPortNum, txPin, rxPin, enPin);
|
dmx_set_pin(inputPortNum, txPin, rxPin, enPin);
|
||||||
|
|
||||||
|
rdm_register_dmx_start_address(inputPortNum, rdmAddressChangedCb, this);
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -29,6 +29,11 @@ private:
|
|||||||
void turnOnAllLeds();
|
void turnOnAllLeds();
|
||||||
|
|
||||||
dmx_config_t createConfig() const;
|
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
|
uint8_t inputPortNum = 255; // TODO make this configurable
|
||||||
/// True once the dmx input has been initialized successfully
|
/// True once the dmx input has been initialized successfully
|
||||||
bool initialized = false; // true once init finished successfully
|
bool initialized = false; // true once init finished successfully
|
||||||
|
Loading…
x
Reference in New Issue
Block a user