mirror of
https://github.com/wled/WLED.git
synced 2025-07-19 00:36:36 +00:00
handle dmx rdm identify
This commit is contained in:
parent
a3bcf92ea5
commit
5a5661f136
@ -1,13 +1,14 @@
|
|||||||
#include "wled.h"
|
#include "wled.h"
|
||||||
|
|
||||||
#ifdef WLED_ENABLE_DMX_INPUT
|
#ifdef WLED_ENABLE_DMX_INPUT
|
||||||
#include "dmx_input.h"
|
|
||||||
#include <esp_dmx.h>
|
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#error DMX input is only supported on ESP32
|
#error DMX input is only supported on ESP32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "dmx_input.h"
|
||||||
|
#include <rdm/responder.h>
|
||||||
|
|
||||||
void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPortNum)
|
void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPortNum)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -102,8 +103,21 @@ void DMXInput::update()
|
|||||||
connected = true;
|
connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t identify = 0;
|
||||||
|
const bool gotIdentify = rdm_get_identify_device(inputPortNum, &identify);
|
||||||
|
// gotIdentify should never be false because it is a default parameter in rdm but just in case we check for it anyway
|
||||||
|
if (identify && gotIdentify)
|
||||||
|
{
|
||||||
|
turnOnAllLeds();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!packet.is_rdm)
|
||||||
|
{
|
||||||
dmx_read(inputPortNum, dmxdata, packet.size);
|
dmx_read(inputPortNum, dmxdata, packet.size);
|
||||||
handleDMXData(1, 512, dmxdata, REALTIME_MODE_DMX, 0);
|
handleDMXData(1, 512, dmxdata, REALTIME_MODE_DMX, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
lastUpdate = now;
|
lastUpdate = now;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -121,7 +135,16 @@ void DMXInput::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
void DMXInput::turnOnAllLeds()
|
||||||
void DMXInput::init(uint8_t, uint8_t, uint8_t, uint8_t) {}
|
{
|
||||||
void DMXInput::update() {}
|
// TODO not sure if this is the correct way?
|
||||||
|
const uint16_t numPixels = strip.getLengthTotal();
|
||||||
|
for (uint16_t i = 0; i < numPixels; ++i)
|
||||||
|
{
|
||||||
|
strip.setPixelColor(i, 255, 255, 255, 255);
|
||||||
|
}
|
||||||
|
strip.setBrightness(255, true);
|
||||||
|
strip.show();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <esp_dmx.h>
|
||||||
/*
|
/*
|
||||||
* Support for DMX/RDM input via serial (e.g. max485) on ESP32
|
* Support for DMX/RDM input via serial (e.g. max485) on ESP32
|
||||||
* ESP32 Library from:
|
* ESP32 Library from:
|
||||||
@ -13,6 +13,10 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// overrides everything and turns on all leds
|
||||||
|
void turnOnAllLeds();
|
||||||
|
|
||||||
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