           case OpDmx: {
             ArtDmx* dmx = (ArtDmx*)buffer;
             int port = node.getPort(dmx->SubUni, dmx->Net);
-            switch (port) {
-              case 0:
-               //mergeRGBWtoLED(dmx->Data, (byte*)leds1, NUM_RGBW);
-                //FastLED[0].show(leds1, NUM_RGB, 255);            
-                memcpy(leds1, dmx->Data, NUM_RGBW*4);
-                FastLED[0].show(leds1, NUM_RGB, 255);
-                
-                break;
-              case 1:
-                mergeWtoRGBW(dmx->Data, (byte*)leds1, NUM_RGBW);
-                FastLED[0].show(leds1, NUM_RGB, 255);
-                break;
-              case 2:
-                mergeRGBtoRGBW(dmx->Data, (byte*)leds2, NUM_RGBW);
-                FastLED[1].show(leds2, NUM_RGB, 255);
-                break;
-              case 3:
-                mergeWtoRGBW(dmx->Data, (byte*)leds2, NUM_RGBW);
-                FastLED[1].show(leds2, NUM_RGB, 255);
-                break;
+            if(!locateMode){
+              // Bit swap length
+              int l = ((dmx->Length & 0xF) << 8) + ((dmx->Length & 0xF0) >> 8);
+              
+              switch (port) {
+                case 0:
+                  memcpy(leds1, dmx->Data, l);
+                  FastLED[0].show(leds1, NUM_RGB, 255);                
+                  break;
+                case 1:
+                  memcpy(leds2, dmx->Data, l);
+                  FastLED[1].show(leds2, NUM_RGB, 255);                
+                  break;
+                case 2:
+                  memcpy(leds3, dmx->Data, l);
+                  FastLED[2].show(leds3, NUM_RGB, 255);                
+
+//                  memcpy(leds1+256, dmx->Data, l);
+  //                FastLED[0].show(leds1, NUM_RGB, 255);                
+                  break;
+                case 3:
+                  memcpy(leds4, dmx->Data, l);
+                  FastLED[3].show(leds4, NUM_RGB, 255);           
+                  break;
+              }
             }
           }
           break;
 
+          case OpAddress: {
+            T_ArtAddress * address = (T_ArtAddress*)buffer;
+
+            if(address->LongName[0] != 0)
+              memcpy(config.longName, address->LongName, 64);
+            if(address->ShortName[0] != 0)
+              memcpy(config.shortName, address->ShortName, 18);
+
+            if(address->NetSwitch != 0x7f)
+              config.net = address->NetSwitch;
+
+            if(address->SubSwitch != 0x7f)              
+              config.subnet = address->SubSwitch;
+
+            
+            for(int i=0;i<4;i++){
+              if(address->SwIn[i] != 0x7f)
+                config.portAddrIn[i] = address->SwIn[i];
+              if(address->SwOut[i] != 0x7f){
+                config.portAddrOut[i] = address->SwOut[i];                
+              }              
+            }            
+
+            if(address->Command == 0x04){
+              locateMode = true;
+            } else {
+              locateMode = false;
+            }
+            
+            
+            node = ArtNode(config, sizeof(buffer), buffer);
+
+            saveConfig();
+            loadConfig();
+            node.createPollReply();
+            artnetSend(buffer, sizeof(ArtPollReply));
+
+            
+            break;
+          }
           // IpProg packet
-          case OpIpProg:
+          /*case OpIpProg:
             node.createIpProgReply();
             artnetSend(buffer, sizeof(ArtIpProgReply));
             break;
-
+*/
           // Unhandled packet
           default:
             break;
         }
       }
     }
+  }
+
+  if(locateMode){  
+    byte* d = (byte*)leds1;    
+    for(int i=0;i<NUM_RGBW;i++){
+      d[i*4] = 0;
+      d[i*4+1] = (sin(10+i + millis()/100.0)+1)*128.0;
+      d[i*4+2] = 0;
+      d[i*4+3] = (sin(i + millis()/100.0)+1)*128.0;
+      
+      
+    }
+    FastLED[0].show(leds1, NUM_RGB, 255);
+    FastLED[1].show(leds1, NUM_RGB, 255);
+    FastLED[2].show(leds1, NUM_RGB, 255);
+    FastLED[3].show(leds1, NUM_RGB, 255);
+  }
+}
+
+void blink(){
+  byte* d = (byte*)leds1;
+  
+  for(int i=0;i<NUM_RGBW*4;i++){
+    d[i] = 30;
+  }
+  FastLED[0].show(leds1, NUM_RGB, 255);
+
+  delay(300);
+
+  for(int i=0;i<NUM_RGBW*4;i++){
+    d[i] = 0;
+  }
+  FastLED[0].show(leds1, NUM_RGB, 255);
+  delay(100);
+}
+
+
+////////////////////////////////////////////////////////////
+void loadConfig() {
+  // To make sure there are settings, and they are YOURS!
+  // If nothing is found it will use the default settings.
+  if (EEPROM.read(CONFIG_MEM_START + 0) == CONFIG_VERSION[0] &&
+      EEPROM.read(CONFIG_MEM_START + 1) == CONFIG_VERSION[1] &&
+      EEPROM.read(CONFIG_MEM_START + 2) == CONFIG_VERSION[2]){
+    for (unsigned int t=CONFIG_START; t<sizeof(config)-CONFIG_END; t++){
+      *((char*)&config + t ) = EEPROM.read(CONFIG_MEM_START + t + 3 - CONFIG_START);
+    }
+  }
+}
+
+////////////////////////////////////////////////////////////
+void saveConfig() {
+  EEPROM.write(CONFIG_MEM_START + 0, CONFIG_VERSION[0]);
+  EEPROM.write(CONFIG_MEM_START + 1, CONFIG_VERSION[1]);
+  EEPROM.write(CONFIG_MEM_START + 2, CONFIG_VERSION[2]);
+  for (unsigned int t=CONFIG_START; t<sizeof(config)-CONFIG_END; t++){
+    EEPROM.write(CONFIG_MEM_START + t - CONFIG_START + 3, *((char*)&config + t));
   }
 }
 

  node = ArtNode(config, sizeof(buffer), buffer);

  FastLED.addLeds<WS2812, 5, RGB>(leds1, NUM_RGB);
  FastLED.addLeds<WS2812, 21, RGB>(leds2, NUM_RGB);
}

////////////////////////////////////////////////////////////

#include <SPI.h>
#include <Ethernet.h>
#include <ArtNode.h>

#include "TeensyMAC.h"
#include <EEPROM.h>

#define VERSION_HI 0
#define VERSION_LO 2

#define NUM_RGBW  128*2
#define NUM_RGB   (NUM_RGBW/4*3)
#define PIN_RESET 9

// ID of the settings block
#define CONFIG_VERSION "ls1"

// Tell it where to store your config data in EEPROM
#define CONFIG_MEM_START 16
#define CONFIG_START 17
#define CONFIG_END 2

EthernetUDP udp;
byte buffer[600];

CRGB leds1[NUM_RGB];
CRGB leds2[NUM_RGB];
CRGB leds3[NUM_RGB];
CRGB leds4[NUM_RGB];

bool locateMode = false;

int oemCode = 0x0000; // OemUnkown

