From 2f7be3475d47d8f8c67aa60e92a0610a6b38303e Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 13 Feb 2021 01:02:14 +0100 Subject: [PATCH] Updated mapping comment --- wled00/FX.h | 8 ++++- wled00/FX_fcn.cpp | 74 +++++++++++++++++++++++------------------------ 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index 44c57d074..589a7005c 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -24,6 +24,8 @@ Modified for WLED */ +#include "wled.h" + #ifndef WS2812FX_h #define WS2812FX_h @@ -847,7 +849,11 @@ class WS2812FX { void blendPixelColor(uint16_t n, uint32_t color, uint8_t blend), - startTransition(uint8_t oldBri, uint32_t oldCol, uint16_t dur, uint8_t segn, uint8_t slot); + startTransition(uint8_t oldBri, uint32_t oldCol, uint16_t dur, uint8_t segn, uint8_t slot), + deserializeMap(void); + + uint16_t* customMappingTable = nullptr; + uint16_t customMappingSize = 0; uint32_t _lastPaletteChange = 0; uint32_t _lastShow = 0; diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 41b01016e..aef500ce1 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -27,50 +27,25 @@ #include "FX.h" #include "palettes.h" -//enable custom per-LED mapping. This can allow for better effects on matrices or special displays -/* -//this is just an example (30 LEDs). It will first set all even, then all uneven LEDs. -const uint16_t customMappingTable[] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, - 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29}; - -//another example. Switches direction every 5 LEDs. -const uint16_t customMappingTable[] = { - 0, 1, 2, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14, - 19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 29, 28, 27, 26, 25}; - -const uint16_t customMappingSize = sizeof(customMappingTable)/sizeof(uint16_t); //30 in example -*/ -uint16_t* customMappingTable = nullptr; -uint16_t customMappingSize = 0; - #ifndef PWM_INDEX #define PWM_INDEX 0 #endif -void WS2812FX::deserializeMap(void) { - DynamicJsonDocument doc(JSON_BUFFER_SIZE); // full sized buffer for larger maps +/* + Custom per-LED mapping has moved! - DEBUG_PRINTLN(F("Reading LED map from /ledmap.json...")); + Create a file "ledmap.json" using the edit page. - if (!readObjectFromFile("/ledmap.json", nullptr, &doc)) return; //if file does not exist just exit - - if (customMappingTable != nullptr) { - delete[] customMappingTable; - customMappingTable = nullptr; - customMappingSize = 0; - } - - JsonArray map = doc[F("map")]; - if (!map.isNull() && map.size()) { // not an empty map - customMappingSize = map.size(); - customMappingTable = new uint16_t[customMappingSize]; - for (uint16_t i=0; i