PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ArtnetReceiveCallback.ino 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. This is similar to ArtnetReceive but uses a callback to read the data.
  3. This example may be copied under the terms of the MIT license, see the LICENSE file for details
  4. */
  5. #include <Artnet.h>
  6. #include <Ethernet.h>
  7. #include <EthernetUdp.h>
  8. #include <SPI.h>
  9. Artnet artnet;
  10. // Change ip and mac address for your setup
  11. byte ip[] = {192, 168, 2, 2};
  12. byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};
  13. void setup()
  14. {
  15. Serial.begin(115200);
  16. artnet.begin(mac, ip);
  17. // this will be called for each packet received
  18. artnet.setArtDmxCallback(onDmxFrame);
  19. }
  20. void loop()
  21. {
  22. // we call the read function inside the loop
  23. artnet.read();
  24. }
  25. void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
  26. {
  27. // print out our data
  28. Serial.print("universe number = ");
  29. Serial.print(universe);
  30. Serial.print("\tdata length = ");
  31. Serial.print(length);
  32. Serial.print("\tsequence n0. = ");
  33. Serial.println(sequence);
  34. Serial.print("DMX data: ");
  35. for (int i = 0 ; i < length ; i++)
  36. {
  37. Serial.print(data[i]);
  38. Serial.print(" ");
  39. }
  40. Serial.println();
  41. Serial.println();
  42. }