mirror of
https://github.com/wled/WLED.git
synced 2025-07-20 17:26:32 +00:00
Move dmx_input pin allocations from wled.cpp to dmx.cpp
This commit is contained in:
parent
9e2268bd74
commit
a0ca243955
@ -88,9 +88,25 @@ bool dmxInputInitialized = false; //true once initDmx finished successfully
|
|||||||
|
|
||||||
void initDMX() {
|
void initDMX() {
|
||||||
|
|
||||||
|
|
||||||
if(dmxInputReceivePin > 0 && dmxInputEnablePin > 0 && dmxInputTransmitPin > 0)
|
if(dmxInputReceivePin > 0 && dmxInputEnablePin > 0 && dmxInputTransmitPin > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const managed_pin_type pins[] = {
|
||||||
|
{dmxInputTransmitPin, false}, //these are not used as gpio pins, this isOutput is always false.
|
||||||
|
{dmxInputReceivePin, false},
|
||||||
|
{dmxInputEnablePin, false}
|
||||||
|
};
|
||||||
|
const bool pinsAllocated = pinManager.allocateMultiplePins(pins, 3, PinOwner::DMX_INPUT);
|
||||||
|
if(!pinsAllocated)
|
||||||
|
{
|
||||||
|
USER_PRINTF("Error: Failed to allocate pins for DMX_INPUT. Pins already in use:\n");
|
||||||
|
USER_PRINTF("rx in use by: %s\n", pinManager.getPinOwnerText(dmxInputReceivePin).c_str());
|
||||||
|
USER_PRINTF("tx in use by: %s\n", pinManager.getPinOwnerText(dmxInputTransmitPin).c_str());
|
||||||
|
USER_PRINTF("en in use by: %s\n", pinManager.getPinOwnerText(dmxInputEnablePin).c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
dmx_config_t config{
|
dmx_config_t config{
|
||||||
255, /*alloc_size*/
|
255, /*alloc_size*/
|
||||||
0, /*model_id*/
|
0, /*model_id*/
|
||||||
|
@ -141,7 +141,9 @@ bool PinManager::allocateMultiplePins(const managed_pin_type * mptArray, byte ar
|
|||||||
bool PinManager::allocatePin(byte gpio, bool output, PinOwner tag)
|
bool PinManager::allocatePin(byte gpio, bool output, PinOwner tag)
|
||||||
{
|
{
|
||||||
// HW I2C & SPI pins have to be allocated using allocateMultiplePins variant since there is always SCL/SDA pair
|
// HW I2C & SPI pins have to be allocated using allocateMultiplePins variant since there is always SCL/SDA pair
|
||||||
if (!isPinOk(gpio, output) || (gpio >= WLED_NUM_PINS) || tag==PinOwner::HW_I2C || tag==PinOwner::HW_SPI) {
|
// DMX_INPUT pins have to be allocated using allocateMultiplePins variant since there is always RX/TX/EN triple
|
||||||
|
if (!isPinOk(gpio, output) || (gpio >= WLED_NUM_PINS) || tag==PinOwner::HW_I2C || tag==PinOwner::HW_SPI
|
||||||
|
|| tag==PinOwner::DMX_INPUT) {
|
||||||
#ifdef WLED_DEBUG
|
#ifdef WLED_DEBUG
|
||||||
if (gpio < 255) { // 255 (-1) is the "not defined GPIO"
|
if (gpio < 255) { // 255 (-1) is the "not defined GPIO"
|
||||||
if (!isPinOk(gpio, output)) {
|
if (!isPinOk(gpio, output)) {
|
||||||
|
@ -44,6 +44,7 @@ enum struct PinOwner : uint8_t {
|
|||||||
DMX = 0x8A, // 'DMX' == hard-coded to IO2
|
DMX = 0x8A, // 'DMX' == hard-coded to IO2
|
||||||
HW_I2C = 0x8B, // 'I2C' == hardware I2C pins (4&5 on ESP8266, 21&22 on ESP32)
|
HW_I2C = 0x8B, // 'I2C' == hardware I2C pins (4&5 on ESP8266, 21&22 on ESP32)
|
||||||
HW_SPI = 0x8C, // 'SPI' == hardware (V)SPI pins (13,14&15 on ESP8266, 5,18&23 on ESP32)
|
HW_SPI = 0x8C, // 'SPI' == hardware (V)SPI pins (13,14&15 on ESP8266, 5,18&23 on ESP32)
|
||||||
|
DMX_INPUT = 0x8D, // 'DMX_INPUT' == DMX input via serial
|
||||||
// Use UserMod IDs from const.h here
|
// Use UserMod IDs from const.h here
|
||||||
UM_Unspecified = USERMOD_ID_UNSPECIFIED, // 0x01
|
UM_Unspecified = USERMOD_ID_UNSPECIFIED, // 0x01
|
||||||
UM_Example = USERMOD_ID_EXAMPLE, // 0x02 // Usermod "usermod_v2_example.h"
|
UM_Example = USERMOD_ID_EXAMPLE, // 0x02 // Usermod "usermod_v2_example.h"
|
||||||
|
@ -423,11 +423,14 @@ void WLED::setup()
|
|||||||
#ifdef WLED_ENABLE_DMX //reserve GPIO2 as hardcoded DMX pin
|
#ifdef WLED_ENABLE_DMX //reserve GPIO2 as hardcoded DMX pin
|
||||||
PinManager::allocatePin(2, true, PinOwner::DMX);
|
PinManager::allocatePin(2, true, PinOwner::DMX);
|
||||||
#endif
|
#endif
|
||||||
|
<<<<<<< HEAD
|
||||||
#ifdef WLED_ENABLE_DMX_INPUT
|
#ifdef WLED_ENABLE_DMX_INPUT
|
||||||
if(dmxInputTransmitPin > 0) PinManager::allocatePin(dmxInputTransmitPin, true, PinOwner::DMX);
|
if(dmxInputTransmitPin > 0) PinManager::allocatePin(dmxInputTransmitPin, true, PinOwner::DMX);
|
||||||
if(dmxInputReceivePin > 0) PinManager::allocatePin(dmxInputReceivePin, true, PinOwner::DMX);
|
if(dmxInputReceivePin > 0) PinManager::allocatePin(dmxInputReceivePin, true, PinOwner::DMX);
|
||||||
if(dmxInputEnablePin > 0) PinManager::allocatePin(dmxInputEnablePin, true, PinOwner::DMX);
|
if(dmxInputEnablePin > 0) PinManager::allocatePin(dmxInputEnablePin, true, PinOwner::DMX);
|
||||||
#endif
|
#endif
|
||||||
|
=======
|
||||||
|
>>>>>>> a516a7b8 (Move dmx_input pin allocations from wled.cpp to dmx.cpp)
|
||||||
|
|
||||||
DEBUG_PRINTLN(F("Registering usermods ..."));
|
DEBUG_PRINTLN(F("Registering usermods ..."));
|
||||||
registerUsermods();
|
registerUsermods();
|
||||||
|
@ -437,12 +437,12 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
|||||||
printSetFormCheckbox(settingsScript,PSTR("EM"),e131Multicast);
|
printSetFormCheckbox(settingsScript,PSTR("EM"),e131Multicast);
|
||||||
printSetFormValue(settingsScript,PSTR("EU"),e131Universe);
|
printSetFormValue(settingsScript,PSTR("EU"),e131Universe);
|
||||||
#ifdef WLED_ENABLE_DMX
|
#ifdef WLED_ENABLE_DMX
|
||||||
oappend(SET_F("hideNoDMX();")); // WLEDMM hide "not compiled in" message
|
settingsScript.print(SET_F("hideNoDMX();")); // hide "not compiled in" message
|
||||||
#endif
|
#endif
|
||||||
#ifndef WLED_ENABLE_DMX_INPUT
|
#ifndef WLED_ENABLE_DMX_INPUT
|
||||||
oappend(SET_F("hideDMXInput();")); // WLEDMM hide "dmx input" settings
|
settingsScript.print(SET_F("hideDMXInput();")); // hide "dmx input" settings
|
||||||
#else
|
#else
|
||||||
oappend(SET_F("hideNoDMXInput();")); // WLEDMM hide "not compiled in" message
|
settingsScript.print(SET_F("hideNoDMXInput();")); //hide "not comp iled in" message
|
||||||
sappend('v',SET_F("IDMT"),dmxInputTransmitPin);
|
sappend('v',SET_F("IDMT"),dmxInputTransmitPin);
|
||||||
sappend('v',SET_F("IDMR"),dmxInputReceivePin);
|
sappend('v',SET_F("IDMR"),dmxInputReceivePin);
|
||||||
sappend('v',SET_F("IDME"),dmxInputEnablePin);
|
sappend('v',SET_F("IDME"),dmxInputEnablePin);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user