From 54bc46b7fcf7cd3d91d1341d2730c2f07e043a93 Mon Sep 17 00:00:00 2001 From: Hideaki Tai Date: Sun, 8 Nov 2020 12:37:49 +0900 Subject: [PATCH] add how to use ArtNet with FastLED --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/README.md b/README.md index f88b230..971f927 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,52 @@ void loop() } ``` + +### Artnet Receiver + FastLED + + +``` C++ +#include + +// declarations for Ethernet/WiFi + +ArtnetReceiver artnet; + +// FastLED +#define NUM_LEDS 1 +CRGB leds[NUM_LEDS]; +const uint8_t PIN_LED_DATA = 3; + +void setup() +{ + // setup Ethernet/WiFi... + + // setup FastLED + FastLED.addLeds(&leds, NUM_LEDS); + + artnet.begin(); + artnet.subscribe(universe, [](uint8_t* data, uint16_t size) + { + // artnet data size per packet is 512 max + // so there is max 170 pixel per packet (per universe) + for (size_t pixel = 0; pixel < NUM_LEDS; ++pixel) + { + size_t idx = pixel * 3; + leds[pixel].r = data[idx + 0]; + leds[pixel].g = data[idx + 1]; + leds[pixel].b = data[idx + 2]; + } + FastLED.show(); + }); +} + +void loop() +{ + artnet.parse(); // check if artnet packet has come and execute callback +} +``` + + ## Other Settings ### Net, Sub-Net, Universe, and Universe(15bit)