-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtpm_artnet.cpp
139 lines (67 loc) · 2.67 KB
/
tpm_artnet.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// artnet
#include "config_TPM.h"
#include "tpm_artnet.h"
#include "config_fs.h"
#include "tools.h"
#include "leds.h"
#include <ArtnetWifi.h>
// Artnet
ArtnetWifi artnet; // make the Artnet server
artnet_struct artnet_cfg = { DEF_ARTNET_STAT_UNIVERSE, DEF_ARTNET_NUMBER_OF_UNIVERSES };
artnet_node_struct artnetNode[ARTNET_NR_NODES_TPM] = {{DEF_ARTNET_STAT_UNIVERSE,DEF_ARTNET_NUMBER_OF_UNIVERSES,{172,16,222,20},36},
{DEF_ARTNET_STAT_UNIVERSE,DEF_ARTNET_NUMBER_OF_UNIVERSES,{172,16,222,22},36},
{DEF_ARTNET_STAT_UNIVERSE,DEF_ARTNET_NUMBER_OF_UNIVERSES,{172,16,222,23},36},
{DEF_ARTNET_STAT_UNIVERSE,DEF_ARTNET_NUMBER_OF_UNIVERSES,{172,16,222,21},36}
};
void ARTNET_set_node(uint8_t node_Nr, uint8_t universe )
{
artnet.setUniverse(universe);
artnet.setLength(510); // 510 max
}
void ARTNET_send_node(uint8_t node_Nr)
{
artnet.write(artnetNode[node_Nr].IP);
}
void ARNET_set_pixel(uint16_t pixel, uint8_t redColor, uint8_t greenColor, uint8_t blueColor)
{
uint16_t startChannel = 0; //
startChannel = constrain(pixel * 3, 0, 510);
artnet.setByte(startChannel, redColor);
artnet.setByte(startChannel +1, greenColor);
artnet.setByte(startChannel +2, blueColor);
}
void ARTNET_set_channel(uint16_t channel, uint8_t value)
{
artnet.setByte(channel, value);
}
void WiFi_artnet_recive_loop()
{
// the main artnet loop calback set to leds function with show
artnet.read();
}
void WiFi_artnet_Load_Vars()
{
// configure the Artnet vaiables
// from disk or load the defaults.
if (!FS_artnet_read())
{
write_bool(ARTNET_SEND, DEF_ARTNET_SEND_ENABLE);
write_bool(ARTNET_RECIVE, DEF_ARTNET_RECIVE_ENABLE);
artnet_cfg.startU = DEF_ARTNET_STAT_UNIVERSE;
artnet_cfg.numU = DEF_ARTNET_NUMBER_OF_UNIVERSES;
}
}
void WiFi_artnet_rc_enable()
{
if(get_bool(ARTNET_RECIVE))
//artnet.begin(artnet_mac, 0); // mac and ip setting useless since were setting ip for the esp8266
artnet.setArtDmxCallback(LEDS_artnet_in); // function in leds with show
}
void WiFi_artnet_enable()
{
// enable artnet, This is a exclusice mode other settings dont apply
WiFi_artnet_Load_Vars();
artnet.begin( );
if(get_bool(ARTNET_RECIVE))
artnet.setArtDmxCallback(LEDS_artnet_in); // function in leds with show
}