This allows an LPC1768 to take Art-Net data and send it to WS2812B LED's

Dependencies:   mbed mbed-rtos EthernetInterface

Committer:
tonydbeck
Date:
Wed Dec 26 21:05:02 2018 +0000
Revision:
15:c730bd607d9a
Full Working Version - December 18

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tonydbeck 15:c730bd607d9a 1 #include "mbed.h"
tonydbeck 15:c730bd607d9a 2 #include "EthernetInterface.h"
tonydbeck 15:c730bd607d9a 3
tonydbeck 15:c730bd607d9a 4 #define ArtMaxUniv 4 // Universe
tonydbeck 15:c730bd607d9a 5 #define SizeRecvBuffer 700
tonydbeck 15:c730bd607d9a 6 #define ArtHeaderID "Art-Net" // packet header
tonydbeck 15:c730bd607d9a 7 #define ArtUDPPort 0x1936 // UDP port 6454 for Art-Net
tonydbeck 15:c730bd607d9a 8 #define ArtVersion 14 // Art-Net version
tonydbeck 15:c730bd607d9a 9 #define OP_Output 0x5000 //Art-Net DMX Packet 'Output'
tonydbeck 15:c730bd607d9a 10 #define OP_Poll 0x2000 // ArtPoll
tonydbeck 15:c730bd607d9a 11 #define OP_PollReply 0x2100 // ArtPoll Reply
tonydbeck 15:c730bd607d9a 12 #define StyleNode 0
tonydbeck 15:c730bd607d9a 13 #define StyleServer 1
tonydbeck 15:c730bd607d9a 14
tonydbeck 15:c730bd607d9a 15 #define STR_LongName "Art-Net to WS2812B - By Tony Beck"
tonydbeck 15:c730bd607d9a 16 #define STR_ShortName "MBED ArtNet LED"
tonydbeck 15:c730bd607d9a 17
tonydbeck 15:c730bd607d9a 18 // host to network short
tonydbeck 15:c730bd607d9a 19 #define htons( x ) ( (( (x) << 8 ) & 0xFF00) | (( (x) >> 8 ) & 0x00FF) )
tonydbeck 15:c730bd607d9a 20 #define ntohs( x ) htons(x)
tonydbeck 15:c730bd607d9a 21 // host to network long
tonydbeck 15:c730bd607d9a 22 #define htonl( x ) ( (( (x) << 24 ) & 0xFF000000) \
tonydbeck 15:c730bd607d9a 23 | (( (x) << 8 ) & 0x00FF0000) \
tonydbeck 15:c730bd607d9a 24 | (( (x) >> 8 ) & 0x0000FF00) \
tonydbeck 15:c730bd607d9a 25 | (( (x) >> 24 ) & 0x000000FF) )
tonydbeck 15:c730bd607d9a 26 #define ntohl( x ) htonl(x)
tonydbeck 15:c730bd607d9a 27
tonydbeck 15:c730bd607d9a 28 struct ArtAddr {
tonydbeck 15:c730bd607d9a 29 unsigned char IP[4]; // ip addess 0.1.2.3
tonydbeck 15:c730bd607d9a 30 unsigned short Port;
tonydbeck 15:c730bd607d9a 31 } __attribute__((packed));
tonydbeck 15:c730bd607d9a 32
tonydbeck 15:c730bd607d9a 33 struct ArtPacketHeader {
tonydbeck 15:c730bd607d9a 34 char ID[8];
tonydbeck 15:c730bd607d9a 35 unsigned short OpCode; // 0x5000
tonydbeck 15:c730bd607d9a 36 } __attribute__((packed));
tonydbeck 15:c730bd607d9a 37
tonydbeck 15:c730bd607d9a 38
tonydbeck 15:c730bd607d9a 39 // dmx transport packet
tonydbeck 15:c730bd607d9a 40 struct ArtDMX_Packet {
tonydbeck 15:c730bd607d9a 41 char ID[8];
tonydbeck 15:c730bd607d9a 42 unsigned short OpCode; // 0x5000
tonydbeck 15:c730bd607d9a 43 unsigned char VersionH; // 0
tonydbeck 15:c730bd607d9a 44 unsigned char Version; // 14
tonydbeck 15:c730bd607d9a 45 unsigned char Sequence; // 0
tonydbeck 15:c730bd607d9a 46 unsigned char Physical; // 0
tonydbeck 15:c730bd607d9a 47 unsigned short Universe;
tonydbeck 15:c730bd607d9a 48 unsigned short Length; // size of data segment
tonydbeck 15:c730bd607d9a 49 unsigned char Data[512]; // data segment
tonydbeck 15:c730bd607d9a 50 } __attribute__((packed));
tonydbeck 15:c730bd607d9a 51
tonydbeck 15:c730bd607d9a 52 struct ArtPoll_Packet {
tonydbeck 15:c730bd607d9a 53 char ID[8];
tonydbeck 15:c730bd607d9a 54 unsigned short OpCode; // 0x5000
tonydbeck 15:c730bd607d9a 55 unsigned char VersionH; // 0
tonydbeck 15:c730bd607d9a 56 unsigned char Version; // 14
tonydbeck 15:c730bd607d9a 57 unsigned char TalkToMe; // 0
tonydbeck 15:c730bd607d9a 58 } __attribute__((packed));
tonydbeck 15:c730bd607d9a 59
tonydbeck 15:c730bd607d9a 60
tonydbeck 15:c730bd607d9a 61 // a responce to a artpoll packet
tonydbeck 15:c730bd607d9a 62 struct ArtPollReply_Packet {
tonydbeck 15:c730bd607d9a 63 char ID[8];
tonydbeck 15:c730bd607d9a 64 unsigned short OpCode; // 0x2000
tonydbeck 15:c730bd607d9a 65 struct ArtAddr Addr; // our ip address and UDP port
tonydbeck 15:c730bd607d9a 66 unsigned char VersionH;
tonydbeck 15:c730bd607d9a 67 unsigned char Version;
tonydbeck 15:c730bd607d9a 68 unsigned char SubSwitchH;
tonydbeck 15:c730bd607d9a 69 unsigned char SubSwitch;
tonydbeck 15:c730bd607d9a 70 unsigned short OEM;
tonydbeck 15:c730bd607d9a 71 char UbeaVersion;
tonydbeck 15:c730bd607d9a 72 char Status;
tonydbeck 15:c730bd607d9a 73 unsigned short EstaMan;
tonydbeck 15:c730bd607d9a 74 char ShortName[18];
tonydbeck 15:c730bd607d9a 75 char LongName[64];
tonydbeck 15:c730bd607d9a 76 char NodeReport[64];
tonydbeck 15:c730bd607d9a 77 unsigned char NumPortsH;
tonydbeck 15:c730bd607d9a 78 unsigned char NumPorts;
tonydbeck 15:c730bd607d9a 79 unsigned char PortType[4];
tonydbeck 15:c730bd607d9a 80 unsigned char GoodInput[4];
tonydbeck 15:c730bd607d9a 81 unsigned char GoodOutput[4];
tonydbeck 15:c730bd607d9a 82 unsigned char Swin[4];
tonydbeck 15:c730bd607d9a 83 unsigned char Swout[4];
tonydbeck 15:c730bd607d9a 84 unsigned char SwVideo;
tonydbeck 15:c730bd607d9a 85 unsigned char SwMacro;
tonydbeck 15:c730bd607d9a 86 unsigned char SwRemote;
tonydbeck 15:c730bd607d9a 87 unsigned char Spare[3]; // three spare bytes
tonydbeck 15:c730bd607d9a 88 unsigned char Style;
tonydbeck 15:c730bd607d9a 89 unsigned char Mac[6];
tonydbeck 15:c730bd607d9a 90 unsigned char Padding[32]; // padding
tonydbeck 15:c730bd607d9a 91 } __attribute__((packed));
tonydbeck 15:c730bd607d9a 92
tonydbeck 15:c730bd607d9a 93
tonydbeck 15:c730bd607d9a 94