update readme

master
Hideaki Tai 4 years ago
parent 3fa4db5846
commit d42ecf5529

@ -18,6 +18,11 @@ Please use them depending on the situation.
- ArtnetReveiver - ArtnetReveiver
- Artnet (Integrated Sender/Receiver) - Artnet (Integrated Sender/Receiver)
#### Warning
**From v0.1.11, arguments of callbacks must be `const` for safety. Previous sketches can not be compiled as is, so please add `const` to the arguments of callbacks.**
### ArtnetSender ### ArtnetSender
```C++ ```C++
@ -143,24 +148,29 @@ void setup()
FastLED.addLeds<NEOPIXEL, PIN_LED>(&leds, NUM_LEDS); FastLED.addLeds<NEOPIXEL, PIN_LED>(&leds, NUM_LEDS);
artnet.begin(); artnet.begin();
artnet.subscribe(universe, [](uint8_t* data, uint16_t size)
{ // if Artnet packet comes to this universe, forward them to fastled directly
// artnet data size per packet is 512 max artnet.forward(universe, leds, NUM_LEDS);
// so there is max 170 pixel per packet (per universe)
for (size_t pixel = 0; pixel < NUM_LEDS; ++pixel) // this can be achieved manually as follows
{ // artnet.subscribe(universe, [](uint8_t* data, uint16_t size)
size_t idx = pixel * 3; // {
leds[pixel].r = data[idx + 0]; // // artnet data size per packet is 512 max
leds[pixel].g = data[idx + 1]; // // so there is max 170 pixel per packet (per universe)
leds[pixel].b = data[idx + 2]; // for (size_t pixel = 0; pixel < NUM_LEDS; ++pixel)
} // {
FastLED.show(); // size_t idx = pixel * 3;
}); // leds[pixel].r = data[idx + 0];
// leds[pixel].g = data[idx + 1];
// leds[pixel].b = data[idx + 2];
// }
// });
} }
void loop() void loop()
{ {
artnet.parse(); // check if artnet packet has come and execute callback artnet.parse(); // check if artnet packet has come and execute callback
FastLED.show();
} }
``` ```
@ -269,6 +279,8 @@ void unsubscribe(const uint32_t universe);
void unsubscribe(const uint8_t net, const uint8_t subnet, const uint8_t universe); void unsubscribe(const uint8_t net, const uint8_t subnet, const uint8_t universe);
void unsubscribe(); // for all packet of all universe void unsubscribe(); // for all packet of all universe
void clear_subscribers(); // clear all callbacks void clear_subscribers(); // clear all callbacks
inline void forward(const uint32_t universe, CRGB* leds, const uint16_t num);
inline void forward(const uint8_t net, const uint8_t subnet, const uint8_t universe, CRGB* leds, const uint16_t num);
``` ```
## Supported Platform ## Supported Platform

Loading…
Cancel
Save