ProDevelopTeam#MasterRace / Mbed 2 deprecated ArtnetDMX

Dependencies:   mbed DMX TextLCD mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
Ayrton_L
Date:
Fri Mar 18 00:44:33 2016 +0000
Parent:
27:1bd34c90e0a9
Child:
29:4a11f841dae1
Commit message:
DMX Update;

Changed in this revision

ArtNet.h Show annotated file Show diff for this revision Revisions of this file
DMX.lib Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
Settings.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
--- a/ArtNet.h	Thu Mar 17 17:11:18 2016 +0000
+++ b/ArtNet.h	Fri Mar 18 00:44:33 2016 +0000
@@ -34,6 +34,7 @@
     uint16_t I16_OPCode = 0x5000;
     uint16_t I16_ProtocolVersie = 14;
     uint16_t I16_Universe = 0;
+    uint32_t I32_Universes[2] = {0};
     uint8_t I8_Values[2][511];
 }
 
@@ -48,17 +49,31 @@
         int size = eth.receive();   
         if(size > 0) {
             eth.read(C_Buf, size);
-             if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36)
+             if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36)    //Poort checken (6465 = 0x1936 // deel van udp protocol
             {
                 char C_ID[7];
                 memcpy(C_ID, &C_Buf[42], 7);
-                if(ArtNet::I32_CheckHeader(C_ID) == 0)
+                if(ArtNet::I32_CheckHeader(C_ID) == 0)                                                  //Art-Net Header checken
                 {
-                    if(C_Buf[50] == 0x00 and C_Buf[51]== 0x50)
+                    if(C_Buf[50] == 0x00 and C_Buf[51]== 0x50)                                          //OPcode checken
                     {
-                        if(C_Buf[52] == 0x00 and C_Buf[53]== 0x0E)
+                        if(C_Buf[52] == 0x00 and C_Buf[53]== 0x0E)                                      //Protocol Versie (14) checken
                         {
+                            // 56/57 = universe
+                            I16_Universe = C_Buf[56];
+                            I16_Universe = I16_Universe << 8;
+                            I16_Universe = I16_Universe & 0xFF00;
+                            I16_Universe = I16_Universe + C_Buf[57];
                             
+                            if(I16_Universe == I32_Universes[0])
+                            {
+                            }
+                            else if(I16_Universe == I32_Universes[1])
+                            {
+                            }
+                            else if(I16_Universe == I32_Universes[2])
+                            {
+                            }
                         } 
                     }   
                 }
--- a/DMX.lib	Thu Mar 17 17:11:18 2016 +0000
+++ b/DMX.lib	Fri Mar 18 00:44:33 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/Ayrton_L/code/DMX/#54754f9736f1
+https://developer.mbed.org/users/Ayrton_L/code/DMX/#256845339155
--- a/README.md	Thu Mar 17 17:11:18 2016 +0000
+++ b/README.md	Fri Mar 18 00:44:33 2016 +0000
@@ -5,17 +5,17 @@
     
     Programma geschreven door Ayrton Leyssens en Tim Swannet
     
-    Laatst aangepast op:        14/03/2016
+    Laatst aangepast op:        18/03/2016
                                 
     changes     :               - Banner geschreven
                                 - Begin van display
                                 - DMX verder uitgewerkt
                                 - Startbeginselen der Art-NET geschreven
+                                - DMX implementeren
+                                - ArtNet implementeren
                                 
     TO-DO       :               - ArtNet settings via display
                                 - DMX optimaliseren 
-                                - DMX implementeren
-                                - ArtNet implementeren
                                 - Display menu schrijven
                                 - Buttons inlezen
                                 - CRT_SECURE_NO_WARNINGS verwijderen uit main.h
@@ -29,7 +29,7 @@
                                 Deze 2x 16Kb is ook beschikbaar voor de gebruiker, maar dan indirect.
                                 
                                 
-    SoftwareVersie:             B-00-08
+    SoftwareVersie:             B-00-12
     
     
     B :     Beta
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Settings.h	Fri Mar 18 00:44:33 2016 +0000
@@ -0,0 +1,36 @@
+#ifndef SETTINGS_H
+#define SETTINGs_H
+#include "mbed.h"
+class Settings
+{
+    public:
+        Settings();
+        ~Settings();
+        
+        uint32_t I32_GetUniverse(uint32_t I32_UniKeuze);
+        
+    private:
+        uint32_t I32_Universe[3];
+};
+#endif
+Settings::Settings()
+{
+}
+Settings::~Settings()
+{
+}
+
+uint32_t Settings::I32_GetUniverse(uint32_t I32_UniKeuze)
+{
+    switch (I32_UniKeuze)
+    {
+        case 1:
+            return I32_Universe[0];
+        case 2:
+            return I32_Universe[1];
+        case 3:
+            return I32_Universe[2];
+        default:
+            return 0;
+    }
+}
\ No newline at end of file
--- a/main.cpp	Thu Mar 17 17:11:18 2016 +0000
+++ b/main.cpp	Fri Mar 18 00:44:33 2016 +0000
@@ -1,34 +1,178 @@
 #include "main.h"
 
+
 DMX XLR1(p9);
-ArtNet X;
+DMX XLR2(p13);
+DMX XLR3(p28);
+//ArtNet X;
 
-DigitalOut DMXled(LED1);
-DigitalOut Mainled(LED2);
+DigitalOut DMXled1(LED1);
+DigitalOut DMXled2(LED2);
+DigitalOut DMXled3(LED3);
+DigitalOut MAINled(LED4);
+Ethernet eth;
+uint32_t I32_CheckHeader(char C_Header[7]);
 
 
-void V_DMXThread(void const *args)
+ 
+typedef struct {
+    uint32_t Universe[2];   
+    uint8_t I8_Values[511];       
+}DMX_Data;
+
+void V_DMXThread1(void const *args)
 {
+    wait_ms(10);
     while(1)
     {
-        DMXled = 1;
-        wait_ms(500);
         XLR1.V_SendDMX();
-        DMXled = 0;
-        wait_ms(500);
+    }
+}
+
+void V_DMXThread2(void const *args)
+{
+    wait_ms(15);
+    while(1)
+    {
+        XLR2.V_SendDMX();
+    }
+}
+
+void V_DMXThread3(void const *args)
+{
+    
+    wait_ms(15);
+    while(1)
+    {
+        XLR3.V_SendDMX();
     }
 }
 
 int main() 
 {
-    Thread T_DMX(V_DMXThread);
-    X.V_ArtNet();
-    while (1)
+    DMXled1 = 0;
+    DMXled2 = 0;
+    DMXled3 = 0;
+    Thread T_DMX1(V_DMXThread1);
+    Thread T_DMX2(V_DMXThread2);
+    Thread T_DMX3(V_DMXThread3);
+    
+    char C_Buf[572];
+    uint16_t I16_Universe;
+    while(1) 
     {
-        Mainled = 0;
-        wait_ms(500);
-        Mainled = 1;
-        wait_ms(500);
+        int size = eth.receive();   
+        if(size > 0) {
+            eth.read(C_Buf, size);
+             if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36)    //Poort checken (6465 = 0x1936 // deel van udp protocol
+            {
+                char C_ID[7];
+                memcpy(C_ID, &C_Buf[42], 7);
+                if(I32_CheckHeader(C_ID) == 0)                                                  //Art-Net Header checken
+                {
+                    if(C_Buf[50] == 0x00 and C_Buf[51]== 0x50)                                          //OPcode checken
+                    {
+                        if(C_Buf[52] == 0x00 and C_Buf[53]== 0x0E)                                      //Protocol Versie (14) checken
+                        {
+                            // 56/57 = universe
+                            I16_Universe = C_Buf[56];
+                            I16_Universe = I16_Universe << 8;
+                            I16_Universe = I16_Universe & 0xFF00;
+                            I16_Universe = I16_Universe + C_Buf[57];
+                            
+                            Settings S;
+                            uint8_t I8_Values[512];
+                            
+                            if(I16_Universe == S.I32_GetUniverse(1))
+                            {
+                                MAINled = 1;
+                                if(C_Buf[60] == 255)
+                                {
+                                    if(DMXled2 == 1)
+                                    {
+                                        DMXled2 = 0;
+                                        DMXled1 = 1;
+                                    }
+                                    else
+                                    {
+                                        DMXled1 = 0;
+                                        DMXled2 = 1;
+                                    }
+                                }
+                                memcpy(I8_Values, &C_Buf[60], 512);
+                                XLR1.V_SetData(I8_Values);
+                            }
+                            else if(I16_Universe == S.I32_GetUniverse(2))
+                            {
+                                memcpy(I8_Values, &C_Buf[60], 512);
+                                XLR2.V_SetData(I8_Values);
+                            }
+                            else if(I16_Universe == S.I32_GetUniverse(3))
+                            {
+                                memcpy(I8_Values, &C_Buf[60], 512);
+                                XLR3.V_SetData(I8_Values);
+                            }
+                        } 
+                    }   
+                }
+            }
+        }
+        wait_ms(1);
     }
 }
 
+uint32_t I32_CheckHeader(char C_Header[6])
+{
+    if(C_Header[0] == 'A')
+    {
+        if(C_Header[1] == 'r')
+        {
+            if(C_Header[2] == 't')
+            {
+                if(C_Header[3] == '-')
+                {
+                    if(C_Header[4] == 'N')
+                    {
+                        if(C_Header[5] == 'e')
+                        {
+                            if(C_Header[6] == 't')
+                            {
+                                return 0;
+                            }
+                            else
+                            {
+                                return 1;
+                            }  
+                        }
+                        else
+                        {
+                            return 1;
+                        }  
+                    }
+                    else
+                    {
+                        return 1;
+                    }  
+                }
+                else
+                {
+                    return 1;
+                }     
+            }
+            else
+            {
+                return 1;
+            }  
+        }
+        else
+        {
+            return 1;
+        }    
+    }
+    else
+    {
+        return 1;
+    }
+}
+
+
--- a/main.h	Thu Mar 17 17:11:18 2016 +0000
+++ b/main.h	Fri Mar 18 00:44:33 2016 +0000
@@ -4,12 +4,11 @@
 #define _CRT_SECURE_NO_WARNINGS
 
 #include "mbed.h"
+#include "rtos.h"
 #include "stdint.h"
-
-#define DMX_CHANNELS 512
  
 #include "DMX.h"
-#include "ArtNet.h"
+#include "Settings.h"
 #include "Screen.h"