PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

50 rindas
1.1KB

  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. }