Lab_interaccio/2020/Audio-Ethernet (iguzzini)/send_receive-JP/send_receive-JP.ino

57 lines
1.3 KiB
Arduino
Raw Permalink Normal View History

2025-02-25 21:29:42 +01:00
#include "Artnet.h"
#include <SPI.h> // needed for Arduino versions later than 0018
// Ethernet stuff
//const IPAddress ip(192, 168, 1, 201);
const IPAddress ip( 10, 0, 0, 10 );
uint8_t mac[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB};
Artnet artnet;
//ArtnetSender artnetSend;
const uint16_t size = 40;
uint8_t data[size];
uint8_t value = 0;
uint32_t universe = 1;
void setup()
{
Serial.begin(115200);
delay(4000);
Ethernet.begin(mac, ip);
//artnetSend.begin("10.0.0.11"); // send to localhost
artnet.begin("10.0.0.11"); // send to localhost
Serial.println("set subscriber");
// if Artnet packet comes to this universe, this function is called
artnet.subscribe(universe, [](uint8_t* data, uint16_t size)
{
Serial.print("artnet data (universe : ");
Serial.print(universe);
Serial.println(") = ");
for (size_t i = 0; i < size; ++i)
{
Serial.print(data[i]); Serial.print(",");
}
Serial.println();
});
Serial.println("start");
}
void loop()
{
artnet.parse(); // check if artnet packet has come and execute callback
value = millis() % 256;
memset(data, value, size);
artnet.set(universe, data, size);
artnet.streaming(); // automatically send set data in 40fps
delay(100);
//Serial.println("loop");
}