mirror of
https://github.com/wled/WLED.git
synced 2025-04-19 12:27:17 +00:00
Port over remaining WLEDMM part of DMX Input and adapt for AC
This commit is contained in:
parent
953e994c88
commit
a582786655
@ -249,6 +249,7 @@
|
||||
#define REALTIME_MODE_ARTNET 6
|
||||
#define REALTIME_MODE_TPM2NET 7
|
||||
#define REALTIME_MODE_DDP 8
|
||||
#define REALTIME_MODE_DMX 9
|
||||
|
||||
//realtime override modes
|
||||
#define REALTIME_OVERRIDE_NONE 0
|
||||
|
@ -151,17 +151,17 @@ Timeout: <input name="ET" type="number" min="1" max="65000" required> ms<br>
|
||||
Force max brightness: <input type="checkbox" name="FB"><br>
|
||||
Disable realtime gamma correction: <input type="checkbox" name="RG"><br>
|
||||
Realtime LED offset: <input name="WO" type="number" min="-255" max="255" required>
|
||||
<div id="dmxInput"> <!--WLEDMM-->
|
||||
<div id="dmxInput">
|
||||
<h4>Wired DMX Input Pins</h4>
|
||||
DMX RX: <input name="IDMR" type="number" min="-1" max="99">RO<br/>
|
||||
DMX TX: <input name="IDMT" type="number" min="-1" max="99">DI<br/>
|
||||
DMX Enable: <input name="IDME" type="number" min="-1" max="99">RE+DE<br/>
|
||||
DMX Port: <input name="IDMP" type="number" min="1" max="2"><br/>
|
||||
</div>
|
||||
<div id="dmxInputOff"> <!--WLEDMM-->
|
||||
<div id="dmxInputOff">
|
||||
<br><em style="color:darkorange">This firmware build does not include DMX Input support. <br></em>
|
||||
</div>
|
||||
<div id="dmxOnOff2"> <!--WLEDMM-->
|
||||
<div id="dmxOnOff2">
|
||||
<br><em style="color:darkorange">This firmware build does not include DMX output support. <br></em>
|
||||
</div>
|
||||
<hr class="sml">
|
||||
|
@ -15,7 +15,7 @@ void rdmPersonalityChangedCb(dmx_port_t dmxPort, const rdm_header_t *header,
|
||||
DMXInput *dmx = static_cast<DMXInput *>(context);
|
||||
|
||||
if (!dmx) {
|
||||
USER_PRINTLN("DMX: Error: no context in rdmPersonalityChangedCb");
|
||||
DEBUG_PRINTLN("DMX: Error: no context in rdmPersonalityChangedCb");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ void rdmPersonalityChangedCb(dmx_port_t dmxPort, const rdm_header_t *header,
|
||||
const uint8_t personality = dmx_get_current_personality(dmx->inputPortNum);
|
||||
DMXMode = std::min(DMX_MODE_PRESET, std::max(DMX_MODE_SINGLE_RGB, int(personality)));
|
||||
doSerializeConfig = true;
|
||||
USER_PRINTF("DMX personality changed to to: %d\n", DMXMode);
|
||||
DEBUG_PRINTF("DMX personality changed to to: %d\n", DMXMode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ void rdmAddressChangedCb(dmx_port_t dmxPort, const rdm_header_t *header,
|
||||
DMXInput *dmx = static_cast<DMXInput *>(context);
|
||||
|
||||
if (!dmx) {
|
||||
USER_PRINTLN("DMX: Error: no context in rdmAddressChangedCb");
|
||||
DEBUG_PRINTLN("DMX: Error: no context in rdmAddressChangedCb");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ void rdmAddressChangedCb(dmx_port_t dmxPort, const rdm_header_t *header,
|
||||
const uint16_t addr = dmx_get_start_address(dmx->inputPortNum);
|
||||
DMXAddress = std::min(512, int(addr));
|
||||
doSerializeConfig = true;
|
||||
USER_PRINTF("DMX start addr changed to: %d\n", DMXAddress);
|
||||
DEBUG_PRINTF("DMX start addr changed to: %d\n", DMXAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,15 +105,15 @@ bool DMXInput::installDriver()
|
||||
{
|
||||
|
||||
const auto config = createConfig();
|
||||
USER_PRINTF("DMX port: %u\n", inputPortNum);
|
||||
DEBUG_PRINTF("DMX port: %u\n", inputPortNum);
|
||||
if (!dmx_driver_install(inputPortNum, &config, DMX_INTR_FLAGS_DEFAULT)) {
|
||||
USER_PRINTF("Error: Failed to install dmx driver\n");
|
||||
DEBUG_PRINTF("Error: Failed to install dmx driver\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
USER_PRINTF("Listening for DMX on pin %u\n", rxPin);
|
||||
USER_PRINTF("Sending DMX on pin %u\n", txPin);
|
||||
USER_PRINTF("DMX enable pin is: %u\n", enPin);
|
||||
DEBUG_PRINTF("Listening for DMX on pin %u\n", rxPin);
|
||||
DEBUG_PRINTF("Sending DMX on pin %u\n", txPin);
|
||||
DEBUG_PRINTF("DMX enable pin is: %u\n", enPin);
|
||||
dmx_set_pin(inputPortNum, txPin, rxPin, enPin);
|
||||
|
||||
rdm_register_dmx_start_address(inputPortNum, rdmAddressChangedCb, this);
|
||||
@ -129,7 +129,7 @@ void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPo
|
||||
//TODO add again once dmx output has been merged
|
||||
// if(inputPortNum == dmxOutputPort)
|
||||
// {
|
||||
// USER_PRINTF("DMXInput: Error: Input port == output port");
|
||||
// DEBUG_PRINTF("DMXInput: Error: Input port == output port");
|
||||
// return;
|
||||
// }
|
||||
#endif
|
||||
@ -138,7 +138,7 @@ void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPo
|
||||
this->inputPortNum = inputPortNum;
|
||||
}
|
||||
else {
|
||||
USER_PRINTF("DMXInput: Error: invalid inputPortNum: %d\n", inputPortNum);
|
||||
DEBUG_PRINTF("DMXInput: Error: invalid inputPortNum: %d\n", inputPortNum);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,12 +148,12 @@ void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPo
|
||||
{(int8_t)txPin, false}, // these are not used as gpio pins, thus isOutput is always false.
|
||||
{(int8_t)rxPin, false},
|
||||
{(int8_t)enPin, false}};
|
||||
const bool pinsAllocated = pinManager.allocateMultiplePins(pins, 3, PinOwner::DMX_INPUT);
|
||||
const bool pinsAllocated = PinManager::allocateMultiplePins(pins, 3, PinOwner::DMX_INPUT);
|
||||
if (!pinsAllocated) {
|
||||
USER_PRINTF("DMXInput: Error: Failed to allocate pins for DMX_INPUT. Pins already in use:\n");
|
||||
USER_PRINTF("rx in use by: %s\n", pinManager.getPinOwnerText(rxPin).c_str());
|
||||
USER_PRINTF("tx in use by: %s\n", pinManager.getPinOwnerText(txPin).c_str());
|
||||
USER_PRINTF("en in use by: %s\n", pinManager.getPinOwnerText(enPin).c_str());
|
||||
DEBUG_PRINTF("DMXInput: Error: Failed to allocate pins for DMX_INPUT. Pins already in use:\n");
|
||||
DEBUG_PRINTF("rx in use by: %s\n", pinManager.getPinOwnerText(rxPin).c_str());
|
||||
DEBUG_PRINTF("tx in use by: %s\n", pinManager.getPinOwnerText(txPin).c_str());
|
||||
DEBUG_PRINTF("en in use by: %s\n", pinManager.getPinOwnerText(enPin).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -165,11 +165,11 @@ void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPo
|
||||
// pin to core 0 because wled is running on core 1
|
||||
xTaskCreatePinnedToCore(dmxReceiverTask, "DMX_RCV_TASK", 10240, this, 2, &task, 0);
|
||||
if (!task) {
|
||||
USER_PRINTF("Error: Failed to create dmx rcv task");
|
||||
DEBUG_PRINTF("Error: Failed to create dmx rcv task");
|
||||
}
|
||||
}
|
||||
else {
|
||||
USER_PRINTLN("DMX input disabled due to rxPin, enPin or txPin not set");
|
||||
DEBUG_PRINTLN("DMX input disabled due to rxPin, enPin or txPin not set");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -187,7 +187,7 @@ void DMXInput::updateInternal()
|
||||
if (dmx_receive(inputPortNum, &packet, DMX_TIMEOUT_TICK)) {
|
||||
if (!packet.err) {
|
||||
if(!connected) {
|
||||
USER_PRINTLN("DMX Input - connected");
|
||||
DEBUG_PRINTLN("DMX Input - connected");
|
||||
}
|
||||
connected = true;
|
||||
identify = isIdentifyOn();
|
||||
@ -202,7 +202,7 @@ void DMXInput::updateInternal()
|
||||
}
|
||||
else {
|
||||
if(connected) {
|
||||
USER_PRINTLN("DMX Input - disconnected");
|
||||
DEBUG_PRINTLN("DMX Input - disconnected");
|
||||
}
|
||||
connected = false;
|
||||
}
|
||||
|
@ -116,6 +116,11 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
|
||||
// update status info
|
||||
realtimeIP = clientIP;
|
||||
|
||||
handleDMXData(uni, dmxChannels, e131_data, mde, previousUniverses);
|
||||
}
|
||||
|
||||
void handleDMXData(uint16_t uni, uint16_t dmxChannels, uint8_t* e131_data, uint8_t mde, uint8_t previousUniverses) {
|
||||
byte wChannel = 0;
|
||||
unsigned totalLen = strip.getLengthTotal();
|
||||
unsigned availDMXLen = 0;
|
||||
@ -130,7 +135,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
}
|
||||
|
||||
// DMX data in Art-Net packet starts at index 0, for E1.31 at index 1
|
||||
if (protocol == P_ARTNET && dataOffset > 0) {
|
||||
if (mde == REALTIME_MODE_ARTNET && dataOffset > 0) {
|
||||
dataOffset--;
|
||||
}
|
||||
|
||||
@ -211,7 +216,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
else
|
||||
dataOffset = DMXAddress;
|
||||
// Modify address for Art-Net data
|
||||
if (protocol == P_ARTNET && dataOffset > 0)
|
||||
if (mde == REALTIME_MODE_ARTNET && dataOffset > 0)
|
||||
dataOffset--;
|
||||
// Skip out of universe addresses
|
||||
if (dataOffset > dmxChannels - dmxEffectChannels + 1)
|
||||
@ -285,7 +290,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
}
|
||||
} else {
|
||||
// All subsequent universes start at the first channel.
|
||||
dmxOffset = (protocol == P_ARTNET) ? 0 : 1;
|
||||
dmxOffset = (mde == REALTIME_MODE_ARTNET) ? 0 : 1;
|
||||
const unsigned dimmerOffset = (DMXMode == DMX_MODE_MULTIPLE_DRGB) ? 1 : 0;
|
||||
unsigned ledsInFirstUniverse = (((MAX_CHANNELS_PER_UNIVERSE - DMXAddress) + dmxLenOffset) - dimmerOffset) / dmxChannelsPerLed;
|
||||
previousLeds = ledsInFirstUniverse + (previousUniverses - 1) * ledsPerUniverse;
|
||||
|
@ -193,6 +193,7 @@ void handleDMXInput();
|
||||
|
||||
//e131.cpp
|
||||
void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol);
|
||||
void handleDMXData(uint16_t uni, uint16_t dmxChannels, uint8_t* e131_data, uint8_t mde, uint8_t previousUniverses);
|
||||
void handleArtnetPollReply(IPAddress ipAddress);
|
||||
void prepareArtnetPollReply(ArtPollReply* reply);
|
||||
void sendArtnetPollReply(ArtPollReply* reply, IPAddress ipAddress, uint16_t portAddress);
|
||||
|
@ -442,11 +442,11 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
||||
#ifndef WLED_ENABLE_DMX_INPUT
|
||||
settingsScript.print(SET_F("hideDMXInput();")); // hide "dmx input" settings
|
||||
#else
|
||||
settingsScript.print(SET_F("hideNoDMXInput();")); //hide "not comp iled in" message
|
||||
sappend('v',SET_F("IDMT"),dmxInputTransmitPin);
|
||||
sappend('v',SET_F("IDMR"),dmxInputReceivePin);
|
||||
sappend('v',SET_F("IDME"),dmxInputEnablePin);
|
||||
sappend('v',SET_F("IDMP"),dmxInputPort);
|
||||
settingsScript.print(SET_F("hideNoDMXInput();")); //hide "not compiled in" message
|
||||
printSetFormValue(settingsScript,SET_F("IDMT"),dmxInputTransmitPin);
|
||||
printSetFormValue(settingsScript,SET_F("IDMR"),dmxInputReceivePin);
|
||||
printSetFormValue(settingsScript,SET_F("IDME"),dmxInputEnablePin);
|
||||
printSetFormValue(settingsScript,SET_F("IDMP"),dmxInputPort);
|
||||
#endif
|
||||
printSetFormValue(settingsScript,PSTR("DA"),DMXAddress);
|
||||
printSetFormValue(settingsScript,PSTR("XX"),DMXSegmentSpacing);
|
||||
|
Loading…
x
Reference in New Issue
Block a user