瀏覽代碼

added artnet

eLandon 3 年之前
父節點
當前提交
1c5f98ca3a
共有 1 個文件被更改,包括 41 次插入16 次删除
  1. 41 16
      src/main.cpp

+ 41 - 16
src/main.cpp

@@ -1,12 +1,13 @@
 #include <Arduino.h>
-#include <ESPDMX.h>
-
 #include <WiFi.h>
+#include <Artnet.h>
+#include <ESPDMX.h>
 
 // WiFi AP credentials
 const char* ssid     = "AtlasAP";
 const char* password = "feuilles";
 
+Artnet artnet;
 DMXESPSerial dmx;
 
 
@@ -47,6 +48,9 @@ void setup() {
   Serial.print("AP IP address: ");
   Serial.println(IP);
 
+  Serial.println("Opening artnet port");
+  artnet.begin();
+
   Serial.println("Starting DMX and sending blackout");
 
   dmx.init(512, 17);           // initialization for complete bus
@@ -57,6 +61,8 @@ void setup() {
   }
 
   Serial.println("initialized...");
+
+
   delay(200);               // wait a while (not necessary)
 }
 
@@ -66,22 +72,41 @@ void setup() {
 
 void loop() {
 
-  for (int i = 0; i < 512; i++)
+  if (artnet.read() == ART_DMX)
   {
-    dmx.write(i, 255);
+    // print out our data
+    Serial.print("universe number = ");
+    Serial.print(artnet.getUniverse());
+    Serial.print("\tdata length = ");
+    Serial.print(artnet.getLength());
+    Serial.print("\tsequence n0. = ");
+    Serial.println(artnet.getSequence());
+    Serial.print("DMX data: ");
+    for (int i = 0 ; i < artnet.getLength() ; i++)
+    {
+      Serial.print(artnet.getDmxFrame()[i]);
+      Serial.print("  ");
+    }
+    Serial.println();
+    Serial.println();
   }
-  Serial.print("turning on...");
-  dmx.update();           // update the DMX bus
-  Serial.println("updated!");
-  delay(1000);            // wait for 1s
 
-  for (int i = 0; i < 512; i++)
-  {
-    dmx.write(i, 0);
-  }
-  Serial.print("turning off...");
-  dmx.update();           // update the DMX bus
-  Serial.println("updated!");
-  delay(1000);
+  // for (int i = 0; i < 512; i++)
+  // {
+  //   dmx.write(i, 255);
+  // }
+  // Serial.print("turning on...");
+  // dmx.update();           // update the DMX bus
+  // Serial.println("updated!");
+  // delay(1000);            // wait for 1s
+
+  // for (int i = 0; i < 512; i++)
+  // {
+  //   dmx.write(i, 0);
+  // }
+  // Serial.print("turning off...");
+  // dmx.update();           // update the DMX bus
+  // Serial.println("updated!");
+  // delay(1000);
 
 }