-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUDP.pde
More file actions
64 lines (58 loc) · 1.24 KB
/
UDP.pde
File metadata and controls
64 lines (58 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class UDPManager {
//local variables
UDP udp;
String ip = "192.168.137.27";
int port = 6454;
int universes = 1;
byte[] buffer = new byte[530];
//Construction
UDPManager(String cip, int cport){
ip=cip;
port=cport;
udp = new UDP(this);
udp.log(true);
//ID[8]
buffer[0]= 'A';
buffer[1]= 'r';
buffer[2]= 't';
buffer[3]= '-';
buffer[4]= 'N';
buffer[5]= 'e';
buffer[6]= 't';
buffer[7]= 0x00;
//configuration protocol
buffer[8]= 0x00;
buffer[9]= 0x50;
buffer[10]= 0x00;
buffer[11]= 0x0E;
buffer[12]= 0x00;
buffer[13]=0x00;
//universo
buffer[14]=0x00;
buffer[15]= 0x00;
//NUMERO DE LEDS
buffer[16]= 0x01;
buffer[17]= 0x20;
//filling with ceros
for (int i = 18; i< 530; i++){
buffer[i] = 0x00;
}
}
void setArtnet(int LED, byte R, byte G, byte B){
int index=(LED*3)+18;
buffer[index+0]=R;
buffer[index+1]=G;
buffer[index+2]=B;
}
void offArtnet (){
for (int i = 18; i< 530; i++){
buffer[i] = 0x00;
}
}
void displayArtnet (){
println(buffer);
}
void sendArtnet(){
udp.send(buffer, ip, port);
}
}