Can't find library mac.h re:artnet implementation

Status
Not open for further replies.
I'm trying to locate the mac.h library referenced in this sketch. Can anyone point me in the right direction?
I'm using a Teensy3.1 via Arduino 1.05 on a macbook air running Mavericks. If I'm in the wrong forum, just let me know.

source
HTML:
https://gist.github.com/natcl/9604245

Code:
//version3 - 8th March 2014 - uses universeSize and requires first_universe_number
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// libraries
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OctoWS2811.h>
#include <mac.h>
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/* uses libs and open licence stufffrom many sources incl. PJRC and ArtisticLicence.*/
//this sketch is a cut down test for receiving Art-net packages via ethernet
/* ****************************************************
* To get this to work for you, YOU NEED TO CHANGE:
* 1) the mac address and IP info to same as your artnet sender
* 2) change leds per strip and universe size (universeSize is size of software output universe selected)
* 3) ensure buff2 size is large enough to take complete led array data set for each frame
* 4) check first_universe_number, can be found using test sketch (usually is 1, sometimes is zero).
*
*for example, in pixelcontroller i have set the array of 60*8 leds, the universe size set to 30
* and the IP set to 192, 168, 1, 10, and port always remains 6454. At the moment, I can only get
* the frame rate max at 15fps, with 480 leds
*
*so for the sketch, I have ledsPerStrip=60, and I need to set universe size to 30
* number of channels and channel buffer go to 90 automatically (as 3*30). buff2 size can be smaller or biggger
* depending on the total array buffer size requied.
******************************************************** */
 
//-------------------- for OctoWS8211--------------------//
const int ledsPerStrip = 60;//CHANGE FOR YOUR SETUP
DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
//----------------end of octows2811 inputs----------------//
 
byte ip[] = {192, 168, 2, 2}; // the IP adress of your device, that should be in same universe of the network you are using
unsigned int localPort = 6454;      // DO NOT CHANGE artnet UDP port is by default 6454
 
//---------------artnet and buffers------------//
const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as zero.
const int numberOfChannels= 180; // Total number of channels you want to receive (1 led = 3 channels)
const int ArtNetHeaderSize = 18; // Do not change
byte channelBuffer[numberOfChannels]; // buffer to store filetered DMX data//SHOULD BE SAME AS numberOfChannels
 
const int MAX_BUFFER_UDP = 530; // leave as is
char packetBuffer[MAX_BUFFER_UDP]; //buffer to store incoming data
 
EthernetUDP Udp;
 
// Art-Net packet parsing
char packetID[8]; // ID of the packet, should be "Art-Net" else ignore
byte sequence;
int incomingUniverse;
int dmxDataLength;
int packetSize;
 
void setup() 
{
  read_mac();
  Serial.begin(115200);
  //setup ethernet and udp socket
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
  delay(250);
  Serial.println("end of setup");
  Serial.println("waiting for incoming Artnet to start");
  //if nothing appears after this, then the loop is not receiving your
  //artnet package
  leds.begin();
  showInit(); //show an led array to confirm    
}
 
void loop() 
{
  packetSize = Udp.parsePacket();
  
  if (packetSize)
  { 
    Udp.read(packetBuffer, MAX_BUFFER_UDP);
       
    //-------read incoming universe and sequence number and check for data series-------------//
    for (int i = 0 ; i < 8 ; i++)
      packetID[i] = packetBuffer[i];
 
    sequence = packetBuffer[12];
    incomingUniverse = packetBuffer[14] | packetBuffer[15] << 8;  
    dmxDataLength = packetBuffer[17] | packetBuffer[16] << 8;  
  
    //-----this section can be commented out if not debugging
    printPacketInfo();   
 
    //------read one universe and put into the right part of the display buffer----//
    for (int i = 0 ; i < dmxDataLength ; i++)
    {
      int bufferIndex = i + ((incomingUniverse - startUniverse) * dmxDataLength);
      if (bufferIndex < numberOfChannels) // to verify
        channelBuffer[bufferIndex] = byte(packetBuffer[ArtNetHeaderSize + i]);
    }       
 
    //------send to leds----//
    for (int i = 0; i < ledsPerStrip * 8; i++)
    {
      leds.setPixel(i, channelBuffer[(i) * 3], channelBuffer[(i * 3) + 1], channelBuffer[(i * 3) + 2]);
    }      
    
    leds.show(); 
  }
}
 
void printPacketInfo()
{
  Serial.print("Received packet of size ");//all print can be removed if not debugging
  Serial.println(packetSize);
  Serial.print("universe number = ");
  Serial.print(incomingUniverse);
  Serial.print("  ");
  Serial.print("data length = ");
  Serial.print(dmxDataLength);
  
  Serial.print("  ");
  Serial.print("sequence n0. = ");
  Serial.println(sequence);
  //for (int i = 0 ; i < numberOfChannels ; i++){
    //Serial.print(channelBuffer[i], DEC);
    //Serial.print("  ");
  //}
}
 
// --------------------------------------------
//---create initial image---//
// --------------------------------------------
void showInit() {
  //-----set all black----//
   for (int i=0; i < 1000; i++) {
    leds.setPixel(i, (0,0,0));}
    leds.show();
    delay(100);
  //-----set display area size to blue-----//  
 for (int i=0; i < ledsPerStrip*8; i++) {
    leds.setPixel(i, (0,0,50));
  }    
  leds.show();
}
 
It is found in #2 at http://forum.pjrc.com/threads/91-teensy-3-MAC-address?highlight=mac+address
it is work done by cmason and THT. THT has placed this in a zip file for download in that thread.

EDIT: But you don't have to use this, if you are having trouble with mac.h you can alternatively comment it out and put a line in for the MAC address, such as:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x4C, 0x8C} ; //the mac adress in HEX of ethernet module/shield
 
Last edited:
Status
Not open for further replies.
Back
Top