mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-07-12 00:15:44 +00:00
formatted init commit
This commit is contained in:
parent
b1454a5c5f
commit
45019c6e4c
8 changed files with 130 additions and 119 deletions
80
src/main.cpp
80
src/main.cpp
|
@ -2,21 +2,21 @@
|
|||
// 2024-10-17 Patrick Schwarz
|
||||
|
||||
#include <ArtnetWiFi.h>
|
||||
//#include <ArtnetEther.h>
|
||||
// #include <ArtnetEther.h>
|
||||
|
||||
#include "ESPDMX.h"
|
||||
|
||||
// WiFi stuff
|
||||
const char* ssid = "artnet";
|
||||
const char* pwd = "mbgmbgmbg";
|
||||
const char *ssid = "artnet";
|
||||
const char *pwd = "mbgmbgmbg";
|
||||
const IPAddress ip(192, 168, 1, 201);
|
||||
const IPAddress gateway(192, 168, 1, 1);
|
||||
const IPAddress subnet(255, 255, 255, 0);
|
||||
|
||||
// Art-Net stuff
|
||||
ArtnetWiFi artnet;
|
||||
//const String target_ip = "192.168.1.200";
|
||||
uint8_t universe = 1; // 0 - 15
|
||||
// const String target_ip = "192.168.1.200";
|
||||
uint8_t universe = 1; // 0 - 15
|
||||
const uint16_t size = 512;
|
||||
uint8_t data[size];
|
||||
uint8_t value = 0;
|
||||
|
@ -24,23 +24,23 @@ uint8_t value = 0;
|
|||
// DMX stuff
|
||||
DMXESPSerial dmx;
|
||||
|
||||
|
||||
void setup() {
|
||||
void setup()
|
||||
{
|
||||
|
||||
// Serial console
|
||||
//Serial.begin(115200);
|
||||
// Serial.begin(115200);
|
||||
|
||||
// WiFi stuff
|
||||
//WiFi.begin(ssid, pwd);
|
||||
// WiFi.begin(ssid, pwd);
|
||||
WiFi.softAP(ssid, pwd);
|
||||
WiFi.softAPConfig(ip, gateway, subnet);
|
||||
//WiFi.config(ip, gateway, subnet);
|
||||
//while (WiFi.status() != WL_CONNECTED) {
|
||||
// Serial.print(".");
|
||||
delay(500);
|
||||
// WiFi.config(ip, gateway, subnet);
|
||||
// while (WiFi.status() != WL_CONNECTED) {
|
||||
// Serial.print(".");
|
||||
delay(500);
|
||||
//}
|
||||
//Serial.print("WiFi connected, IP = ");
|
||||
//Serial.println(WiFi.localIP());
|
||||
// Serial.print("WiFi connected, IP = ");
|
||||
// Serial.println(WiFi.localIP());
|
||||
|
||||
// Initialize Art-Net
|
||||
artnet.begin();
|
||||
|
@ -49,30 +49,31 @@ void setup() {
|
|||
dmx.init();
|
||||
|
||||
// if Artnet packet comes to this universe, this function is called
|
||||
artnet.subscribeArtDmxUniverse(universe, [&](const uint8_t *data, uint16_t size, const ArtDmxMetadata& metadata, const ArtNetRemoteInfo& remote) {
|
||||
/*Serial.print("lambda : artnet data from ");
|
||||
Serial.print(remote.ip);
|
||||
Serial.print(":");
|
||||
Serial.print(remote.port);
|
||||
Serial.print(", universe = ");
|
||||
Serial.print(universe);
|
||||
Serial.print(", size = ");
|
||||
Serial.print(size);
|
||||
Serial.print(") :");*/
|
||||
artnet.subscribeArtDmxUniverse(universe, [&](const uint8_t *data, uint16_t size, const ArtDmxMetadata &metadata, const ArtNetRemoteInfo &remote)
|
||||
{
|
||||
/*Serial.print("lambda : artnet data from ");
|
||||
Serial.print(remote.ip);
|
||||
Serial.print(":");
|
||||
Serial.print(remote.port);
|
||||
Serial.print(", universe = ");
|
||||
Serial.print(universe);
|
||||
Serial.print(", size = ");
|
||||
Serial.print(size);
|
||||
Serial.print(") :");*/
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
dmx.write((i+1), data[i]);
|
||||
// Serial.print(data[i]);
|
||||
// Serial.print(",");
|
||||
}
|
||||
//Serial.println();
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
dmx.write((i + 1), data[i]);
|
||||
// Serial.print(data[i]);
|
||||
// Serial.print(",");
|
||||
}
|
||||
// Serial.println();
|
||||
|
||||
dmx.update();
|
||||
|
||||
});
|
||||
dmx.update(); });
|
||||
|
||||
// if Artnet packet comes, this function is called to every universe
|
||||
artnet.subscribeArtDmx([&](const uint8_t *data, uint16_t size, const ArtDmxMetadata& metadata, const ArtNetRemoteInfo& remote) {
|
||||
artnet.subscribeArtDmx([&](const uint8_t *data, uint16_t size, const ArtDmxMetadata &metadata, const ArtNetRemoteInfo &remote)
|
||||
{
|
||||
/*Serial.print("received ArtNet data from ");
|
||||
Serial.print(remote.ip);
|
||||
Serial.print(":");
|
||||
|
@ -87,12 +88,12 @@ void setup() {
|
|||
Serial.print(metadata.sequence);
|
||||
Serial.print(", size = ");
|
||||
Serial.print(size);
|
||||
Serial.println(")");*/
|
||||
});
|
||||
Serial.println(")");*/ });
|
||||
}
|
||||
|
||||
void loop() {
|
||||
artnet.parse(); // check if artnet packet has come and execute callback
|
||||
void loop()
|
||||
{
|
||||
artnet.parse(); // check if artnet packet has come and execute callback
|
||||
|
||||
/*value = (millis() / 4) % 256;
|
||||
memset(data, value, size);
|
||||
|
@ -100,5 +101,4 @@ void loop() {
|
|||
artnet.setArtDmxData(data, size);
|
||||
artnet.streamArtDmxTo(target_ip, universe); // automatically send set data in 40fps
|
||||
// artnet.streamArtDmxTo(target_ip, net, subnet, univ); // or you can set net, subnet, and universe */
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue