diff --git a/examples/Ethernet/receiver/receiver.ino b/examples/Ethernet/receiver/receiver.ino index 1c7a2d7..192a1c3 100644 --- a/examples/Ethernet/receiver/receiver.ino +++ b/examples/Ethernet/receiver/receiver.ino @@ -8,29 +8,26 @@ ArtnetReceiver artnet; uint32_t universe1 = 1; uint32_t universe2 = 2; -void callback(uint8_t* data, uint16_t size) -{ +void callback(const uint8_t* data, const uint16_t size) { // you can also use pre-defined callbacks } -void setup() -{ +void setup() { Serial.begin(115200); Ethernet.begin(mac, ip); artnet.begin(); // if Artnet packet comes to this universe, this function is called - artnet.subscribe(universe1, [&](uint8_t* data, uint16_t size) - { + artnet.subscribe(universe1, [&](const uint8_t* data, const uint16_t size) { Serial.print("artnet data (universe : "); Serial.print(universe1); Serial.print(", size = "); Serial.print(size); Serial.print(") :"); - for (size_t i = 0; i < size; ++i) - { - Serial.print(data[i]); Serial.print(","); + for (size_t i = 0; i < size; ++i) { + Serial.print(data[i]); + Serial.print(","); } Serial.println(); }); @@ -39,7 +36,6 @@ void setup() artnet.subscribe(universe2, callback); } -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 } diff --git a/examples/Ethernet/send_receive/send_receive.ino b/examples/Ethernet/send_receive/send_receive.ino index eaa2888..91324c8 100644 --- a/examples/Ethernet/send_receive/send_receive.ino +++ b/examples/Ethernet/send_receive/send_receive.ino @@ -16,8 +16,7 @@ const uint16_t size = 512; uint8_t data[size]; uint8_t value = 0; -void setup() -{ +void setup() { Serial.begin(115200); delay(2000); @@ -27,24 +26,21 @@ void setup() Serial.println("set subscriber"); // if Artnet packet comes to this universe, this function is called - artnet.subscribe(universe, [](uint8_t* data, uint16_t size) - { + artnet.subscribe(universe, [](const uint8_t* data, const uint16_t size) { Serial.print("artnet data (universe : "); Serial.print(universe); Serial.print(", size = "); Serial.print(size); Serial.print(") :"); - for (size_t i = 0; i < size; ++i) - { - Serial.print(data[i]); Serial.print(","); + for (size_t i = 0; i < size; ++i) { + Serial.print(data[i]); + Serial.print(","); } Serial.println(); }); - // if Artnet packet comes, this function is called to every universe - artnet.subscribe([&](uint32_t univ, uint8_t* data, uint16_t size) - { + artnet.subscribe([&](const uint32_t univ, const uint8_t* data, const uint16_t size) { Serial.print("ArtNet data has come to universe: "); Serial.println(univ); }); @@ -52,13 +48,12 @@ void setup() Serial.println("start"); } -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); artnet.set(universe, data, size); - artnet.streaming(); // automatically send set data in 40fps + artnet.streaming(); // automatically send set data in 40fps } diff --git a/examples/Ethernet/sender/sender.ino b/examples/Ethernet/sender/sender.ino index e64df2d..e7433ee 100644 --- a/examples/Ethernet/sender/sender.ino +++ b/examples/Ethernet/sender/sender.ino @@ -12,26 +12,23 @@ const uint16_t size = 512; uint8_t data[size]; uint8_t value = 0; -void setup() -{ +void setup() { Serial.begin(115200); delay(2000); Ethernet.begin(mac, ip); artnet.begin(target_ip); - Serial.println("start"); Serial.println(UDP_TX_PACKET_MAX_SIZE); } -void loop() -{ +void loop() { value = (millis() / 4) % 256; memset(data, value, size); artnet.set(universe, data, size); - artnet.streaming(); // automatically send set data in 40fps + artnet.streaming(); // automatically send set data in 40fps // Serial.println("loop"); } diff --git a/examples/WiFi/receiver/receiver.ino b/examples/WiFi/receiver/receiver.ino index 2c51957..265543c 100644 --- a/examples/WiFi/receiver/receiver.ino +++ b/examples/WiFi/receiver/receiver.ino @@ -11,34 +11,35 @@ ArtnetWiFiReceiver artnet; uint32_t universe1 = 1; uint32_t universe2 = 2; -void callback(uint8_t* data, uint16_t size) -{ +void callback(const uint8_t* data, const uint16_t size) { // you can also use pre-defined callbacks } -void setup() -{ +void setup() { Serial.begin(115200); // WiFi stuff WiFi.begin(ssid, pwd); WiFi.config(ip, gateway, subnet); - while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } - Serial.print("WiFi connected, IP = "); Serial.println(WiFi.localIP()); + while (WiFi.status() != WL_CONNECTED) { + Serial.print("."); + delay(500); + } + Serial.print("WiFi connected, IP = "); + Serial.println(WiFi.localIP()); artnet.begin(); // if Artnet packet comes to this universe, this function (lambda) is called - artnet.subscribe(universe1, [&](uint8_t* data, uint16_t size) - { + artnet.subscribe(universe1, [&](const uint8_t* data, const uint16_t size) { Serial.print("lambda : artnet data (universe : "); Serial.print(universe1); Serial.print(", size = "); Serial.print(size); Serial.print(") :"); - for (size_t i = 0; i < size; ++i) - { - Serial.print(data[i]); Serial.print(","); + for (size_t i = 0; i < size; ++i) { + Serial.print(data[i]); + Serial.print(","); } Serial.println(); }); @@ -47,7 +48,6 @@ void setup() artnet.subscribe(universe2, callback); } -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 } diff --git a/examples/WiFi/send_receive/send_receive.ino b/examples/WiFi/send_receive/send_receive.ino index e51e258..3db4183 100644 --- a/examples/WiFi/send_receive/send_receive.ino +++ b/examples/WiFi/send_receive/send_receive.ino @@ -15,48 +15,48 @@ const uint16_t size = 512; uint8_t data[size]; uint8_t value = 0; -void setup() -{ +void setup() { Serial.begin(115200); // WiFi stuff WiFi.begin(ssid, pwd); WiFi.config(ip, gateway, subnet); - while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } - Serial.print("WiFi connected, IP = "); Serial.println(WiFi.localIP()); + while (WiFi.status() != WL_CONNECTED) { + Serial.print("."); + delay(500); + } + Serial.print("WiFi connected, IP = "); + Serial.println(WiFi.localIP()); artnet.begin(target_ip); // if Artnet packet comes to this universe, this function is called - artnet.subscribe(universe, [&](uint8_t* data, uint16_t size) - { + artnet.subscribe(universe, [&](const uint8_t* data, const uint16_t size) { Serial.print("artnet data (universe : "); Serial.print(universe); Serial.print(", size = "); Serial.print(size); Serial.print(") :"); - for (size_t i = 0; i < size; ++i) - { - Serial.print(data[i]); Serial.print(","); + for (size_t i = 0; i < size; ++i) { + Serial.print(data[i]); + Serial.print(","); } Serial.println(); }); // if Artnet packet comes, this function is called to every universe - artnet.subscribe([&](uint32_t univ, uint8_t* data, uint16_t size) - { + artnet.subscribe([&](const uint32_t univ, const uint8_t* data, const uint16_t size) { Serial.print("ArtNet data has come to universe: "); Serial.println(univ); }); } -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); artnet.set(universe, data, size); - artnet.streaming(); // automatically send set data in 40fps + artnet.streaming(); // automatically send set data in 40fps } diff --git a/examples/WiFi/sender/sender.ino b/examples/WiFi/sender/sender.ino index 32d9d40..9e67261 100644 --- a/examples/WiFi/sender/sender.ino +++ b/examples/WiFi/sender/sender.ino @@ -15,24 +15,26 @@ const uint16_t size = 512; uint8_t data[size]; uint8_t value = 0; -void setup() -{ +void setup() { Serial.begin(115200); // WiFi stuff WiFi.begin(ssid, pwd); WiFi.config(ip, gateway, subnet); - while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } - Serial.print("WiFi connected, IP = "); Serial.println(WiFi.localIP()); + while (WiFi.status() != WL_CONNECTED) { + Serial.print("."); + delay(500); + } + Serial.print("WiFi connected, IP = "); + Serial.println(WiFi.localIP()); artnet.begin(target_ip); } -void loop() -{ +void loop() { value = (millis() / 4) % 256; memset(data, value, size); artnet.set(universe, data, size); - artnet.streaming(); // automatically send set data in 40fps + artnet.streaming(); // automatically send set data in 40fps }