| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |   WS2812FX.h - Library for WS2812 LED effects. | 
					
						
							|  |  |  |   Harm Aldick - 2016 | 
					
						
							|  |  |  |   www.aldick.org | 
					
						
							|  |  |  |   LICENSE | 
					
						
							|  |  |  |   The MIT License (MIT) | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |   Copyright (c) 2016  Harm Aldick | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |   Permission is hereby granted, free of charge, to any person obtaining a copy | 
					
						
							|  |  |  |   of this software and associated documentation files (the "Software"), to deal | 
					
						
							|  |  |  |   in the Software without restriction, including without limitation the rights | 
					
						
							|  |  |  |   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
					
						
							|  |  |  |   copies of the Software, and to permit persons to whom the Software is | 
					
						
							|  |  |  |   furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  |   The above copyright notice and this permission notice shall be included in | 
					
						
							|  |  |  |   all copies or substantial portions of the Software. | 
					
						
							|  |  |  |   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  |   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  |   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
					
						
							|  |  |  |   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
					
						
							|  |  |  |   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
					
						
							|  |  |  |   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
					
						
							|  |  |  |   THE SOFTWARE. | 
					
						
							| 
									
										
										
										
											2019-02-09 15:37:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |   Modified for WLED | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef WS2812FX_h
 | 
					
						
							|  |  |  | #define WS2812FX_h
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-19 23:45:09 +00:00
										 |  |  | #include "const.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-09 16:00:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define FASTLED_INTERNAL //remove annoying pragma messages
 | 
					
						
							| 
									
										
										
										
											2020-08-25 15:23:17 +00:00
										 |  |  | #define USE_GET_MILLISECOND_TIMER
 | 
					
						
							| 
									
										
										
										
											2018-11-04 19:14:23 +00:00
										 |  |  | #include "FastLED.h"
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-16 18:59:00 +00:00
										 |  |  | #define DEFAULT_BRIGHTNESS (uint8_t)127
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | #define DEFAULT_MODE       (uint8_t)0
 | 
					
						
							| 
									
										
										
										
											2018-11-16 18:59:00 +00:00
										 |  |  | #define DEFAULT_SPEED      (uint8_t)128
 | 
					
						
							| 
									
										
										
										
											2020-09-07 19:01:10 +00:00
										 |  |  | #define DEFAULT_INTENSITY  (uint8_t)128
 | 
					
						
							| 
									
										
										
										
											2019-03-05 09:59:15 +00:00
										 |  |  | #define DEFAULT_COLOR      (uint32_t)0xFFAA00
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-17 21:46:17 +00:00
										 |  |  | #ifndef MIN
 | 
					
						
							| 
									
										
										
										
											2020-03-26 09:18:19 +00:00
										 |  |  | #define MIN(a,b) ((a)<(b)?(a):(b))
 | 
					
						
							| 
									
										
										
										
											2020-11-17 21:46:17 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | #ifndef MAX
 | 
					
						
							| 
									
										
										
										
											2020-03-26 09:18:19 +00:00
										 |  |  | #define MAX(a,b) ((a)>(b)?(a):(b))
 | 
					
						
							| 
									
										
										
										
											2020-11-17 21:46:17 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-03 14:33:37 +00:00
										 |  |  | /* Not used in all effects yet */ | 
					
						
							| 
									
										
										
										
											2019-10-03 23:21:18 +00:00
										 |  |  | #define WLED_FPS         42
 | 
					
						
							| 
									
										
										
										
											2019-12-06 00:44:45 +00:00
										 |  |  | #define FRAMETIME        (1000/WLED_FPS)
 | 
					
						
							| 
									
										
										
										
											2019-10-03 14:33:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  | /* each segment uses 52 bytes of SRAM memory, so if you're application fails because of
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |   insufficient memory, decreasing MAX_NUM_SEGMENTS may help */ | 
					
						
							| 
									
										
										
										
											2020-09-19 23:18:31 +00:00
										 |  |  | #ifdef ESP8266
 | 
					
						
							| 
									
										
										
										
											2021-07-14 21:10:19 +00:00
										 |  |  |   #define MAX_NUM_SEGMENTS    18
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |   /* How many color transitions can run at once */ | 
					
						
							|  |  |  |   #define MAX_NUM_TRANSITIONS  8
 | 
					
						
							|  |  |  |   /* How much data bytes all segments combined may allocate */ | 
					
						
							| 
									
										
										
										
											2021-03-24 22:55:39 +00:00
										 |  |  |   #define MAX_SEGMENT_DATA  4096
 | 
					
						
							| 
									
										
										
										
											2020-09-19 23:18:31 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2021-07-01 11:24:48 +00:00
										 |  |  |   #ifndef MAX_NUM_SEGMENTS
 | 
					
						
							|  |  |  |     #define MAX_NUM_SEGMENTS  32
 | 
					
						
							|  |  |  |   #endif
 | 
					
						
							| 
									
										
										
										
											2021-03-24 22:55:39 +00:00
										 |  |  |   #define MAX_NUM_TRANSITIONS 24
 | 
					
						
							| 
									
										
										
										
											2021-03-18 22:19:17 +00:00
										 |  |  |   #define MAX_SEGMENT_DATA  20480
 | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-24 18:36:25 +00:00
										 |  |  | #define LED_SKIP_AMOUNT  1
 | 
					
						
							|  |  |  | #define MIN_SHOW_DELAY  15
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-21 22:23:09 +00:00
										 |  |  | #define NUM_COLORS       3 /* number of colors per segment */
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | #define SEGMENT          _segments[_segment_index]
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  | #define SEGCOLOR(x)      _colors_t[x]
 | 
					
						
							| 
									
										
										
										
											2019-05-21 22:23:09 +00:00
										 |  |  | #define SEGENV           _segment_runtimes[_segment_index]
 | 
					
						
							| 
									
										
										
										
											2020-01-14 09:57:23 +00:00
										 |  |  | #define SEGLEN           _virtualSegmentLength
 | 
					
						
							| 
									
										
										
										
											2019-06-20 12:40:12 +00:00
										 |  |  | #define SEGACT           SEGMENT.stop
 | 
					
						
							| 
									
										
										
										
											2021-05-29 22:08:24 +00:00
										 |  |  | #define SPEED_FORMULA_L  5U + (50U*(255U - SEGMENT.speed))/SEGLEN
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | #define RESET_RUNTIME    memset(_segment_runtimes, 0, sizeof(_segment_runtimes))
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | // some common colors
 | 
					
						
							|  |  |  | #define RED        (uint32_t)0xFF0000
 | 
					
						
							|  |  |  | #define GREEN      (uint32_t)0x00FF00
 | 
					
						
							|  |  |  | #define BLUE       (uint32_t)0x0000FF
 | 
					
						
							|  |  |  | #define WHITE      (uint32_t)0xFFFFFF
 | 
					
						
							|  |  |  | #define BLACK      (uint32_t)0x000000
 | 
					
						
							|  |  |  | #define YELLOW     (uint32_t)0xFFFF00
 | 
					
						
							|  |  |  | #define CYAN       (uint32_t)0x00FFFF
 | 
					
						
							|  |  |  | #define MAGENTA    (uint32_t)0xFF00FF
 | 
					
						
							|  |  |  | #define PURPLE     (uint32_t)0x400080
 | 
					
						
							|  |  |  | #define ORANGE     (uint32_t)0xFF3000
 | 
					
						
							|  |  |  | #define PINK       (uint32_t)0xFF1493
 | 
					
						
							|  |  |  | #define ULTRAWHITE (uint32_t)0xFFFFFFFF
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | // options
 | 
					
						
							| 
									
										
										
										
											2019-03-05 09:59:15 +00:00
										 |  |  | // bit    7: segment is in transition mode
 | 
					
						
							| 
									
										
										
										
											2020-08-04 16:50:16 +00:00
										 |  |  | // bits 4-6: TBD
 | 
					
						
							|  |  |  | // bit    3: mirror effect within segment
 | 
					
						
							| 
									
										
										
										
											2020-04-23 21:52:33 +00:00
										 |  |  | // bit    2: segment is on
 | 
					
						
							| 
									
										
										
										
											2019-03-05 09:59:15 +00:00
										 |  |  | // bit    1: reverse segment
 | 
					
						
							|  |  |  | // bit    0: segment is selected
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | #define NO_OPTIONS   (uint8_t)0x00
 | 
					
						
							| 
									
										
										
										
											2019-03-05 09:59:15 +00:00
										 |  |  | #define TRANSITIONAL (uint8_t)0x80
 | 
					
						
							| 
									
										
										
										
											2020-08-04 16:50:16 +00:00
										 |  |  | #define MIRROR       (uint8_t)0x08
 | 
					
						
							| 
									
										
										
										
											2020-04-23 21:52:33 +00:00
										 |  |  | #define SEGMENT_ON   (uint8_t)0x04
 | 
					
						
							| 
									
										
										
										
											2019-03-05 09:59:15 +00:00
										 |  |  | #define REVERSE      (uint8_t)0x02
 | 
					
						
							|  |  |  | #define SELECTED     (uint8_t)0x01
 | 
					
						
							|  |  |  | #define IS_TRANSITIONAL ((SEGMENT.options & TRANSITIONAL) == TRANSITIONAL)
 | 
					
						
							| 
									
										
										
										
											2020-08-04 16:50:16 +00:00
										 |  |  | #define IS_MIRROR       ((SEGMENT.options & MIRROR      ) == MIRROR      )
 | 
					
						
							| 
									
										
										
										
											2020-04-23 21:52:33 +00:00
										 |  |  | #define IS_SEGMENT_ON   ((SEGMENT.options & SEGMENT_ON  ) == SEGMENT_ON  )
 | 
					
						
							|  |  |  | #define IS_REVERSE      ((SEGMENT.options & REVERSE     ) == REVERSE     )
 | 
					
						
							|  |  |  | #define IS_SELECTED     ((SEGMENT.options & SELECTED    ) == SELECTED    )
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-22 15:26:19 +00:00
										 |  |  | #define MODE_COUNT  118
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define FX_MODE_STATIC                   0
 | 
					
						
							|  |  |  | #define FX_MODE_BLINK                    1
 | 
					
						
							|  |  |  | #define FX_MODE_BREATH                   2
 | 
					
						
							|  |  |  | #define FX_MODE_COLOR_WIPE               3
 | 
					
						
							|  |  |  | #define FX_MODE_COLOR_WIPE_RANDOM        4
 | 
					
						
							|  |  |  | #define FX_MODE_RANDOM_COLOR             5
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | #define FX_MODE_COLOR_SWEEP              6
 | 
					
						
							| 
									
										
										
										
											2018-03-31 22:08:50 +00:00
										 |  |  | #define FX_MODE_DYNAMIC                  7
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | #define FX_MODE_RAINBOW                  8
 | 
					
						
							|  |  |  | #define FX_MODE_RAINBOW_CYCLE            9
 | 
					
						
							|  |  |  | #define FX_MODE_SCAN                    10
 | 
					
						
							|  |  |  | #define FX_MODE_DUAL_SCAN               11
 | 
					
						
							|  |  |  | #define FX_MODE_FADE                    12
 | 
					
						
							|  |  |  | #define FX_MODE_THEATER_CHASE           13
 | 
					
						
							|  |  |  | #define FX_MODE_THEATER_CHASE_RAINBOW   14
 | 
					
						
							|  |  |  | #define FX_MODE_RUNNING_LIGHTS          15
 | 
					
						
							| 
									
										
										
										
											2019-02-05 20:53:39 +00:00
										 |  |  | #define FX_MODE_SAW                     16
 | 
					
						
							|  |  |  | #define FX_MODE_TWINKLE                 17
 | 
					
						
							| 
									
										
										
										
											2019-01-31 22:42:48 +00:00
										 |  |  | #define FX_MODE_DISSOLVE                18
 | 
					
						
							|  |  |  | #define FX_MODE_DISSOLVE_RANDOM         19
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | #define FX_MODE_SPARKLE                 20
 | 
					
						
							|  |  |  | #define FX_MODE_FLASH_SPARKLE           21
 | 
					
						
							|  |  |  | #define FX_MODE_HYPER_SPARKLE           22
 | 
					
						
							|  |  |  | #define FX_MODE_STROBE                  23
 | 
					
						
							|  |  |  | #define FX_MODE_STROBE_RAINBOW          24
 | 
					
						
							|  |  |  | #define FX_MODE_MULTI_STROBE            25
 | 
					
						
							|  |  |  | #define FX_MODE_BLINK_RAINBOW           26
 | 
					
						
							| 
									
										
										
										
											2018-03-18 22:16:53 +00:00
										 |  |  | #define FX_MODE_ANDROID                 27
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | #define FX_MODE_CHASE_COLOR             28
 | 
					
						
							|  |  |  | #define FX_MODE_CHASE_RANDOM            29
 | 
					
						
							|  |  |  | #define FX_MODE_CHASE_RAINBOW           30
 | 
					
						
							|  |  |  | #define FX_MODE_CHASE_FLASH             31
 | 
					
						
							|  |  |  | #define FX_MODE_CHASE_FLASH_RANDOM      32
 | 
					
						
							|  |  |  | #define FX_MODE_CHASE_RAINBOW_WHITE     33
 | 
					
						
							| 
									
										
										
										
											2018-01-10 22:57:58 +00:00
										 |  |  | #define FX_MODE_COLORFUL                34
 | 
					
						
							| 
									
										
										
										
											2017-12-13 23:12:02 +00:00
										 |  |  | #define FX_MODE_TRAFFIC_LIGHT           35
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | #define FX_MODE_COLOR_SWEEP_RANDOM      36
 | 
					
						
							|  |  |  | #define FX_MODE_RUNNING_COLOR           37
 | 
					
						
							| 
									
										
										
										
											2021-01-04 10:11:36 +00:00
										 |  |  | #define FX_MODE_AURORA                  38
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | #define FX_MODE_RUNNING_RANDOM          39
 | 
					
						
							|  |  |  | #define FX_MODE_LARSON_SCANNER          40
 | 
					
						
							|  |  |  | #define FX_MODE_COMET                   41
 | 
					
						
							|  |  |  | #define FX_MODE_FIREWORKS               42
 | 
					
						
							| 
									
										
										
										
											2019-02-11 22:49:04 +00:00
										 |  |  | #define FX_MODE_RAIN                    43
 | 
					
						
							| 
									
										
										
										
											2021-02-09 23:37:05 +00:00
										 |  |  | #define FX_MODE_TETRIX                  44
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | #define FX_MODE_FIRE_FLICKER            45
 | 
					
						
							| 
									
										
										
										
											2018-03-18 22:16:53 +00:00
										 |  |  | #define FX_MODE_GRADIENT                46
 | 
					
						
							|  |  |  | #define FX_MODE_LOADING                 47
 | 
					
						
							| 
									
										
										
										
											2019-12-04 11:15:12 +00:00
										 |  |  | #define FX_MODE_POLICE                  48
 | 
					
						
							|  |  |  | #define FX_MODE_POLICE_ALL              49
 | 
					
						
							|  |  |  | #define FX_MODE_TWO_DOTS                50
 | 
					
						
							|  |  |  | #define FX_MODE_TWO_AREAS               51
 | 
					
						
							| 
									
										
										
										
											2021-04-10 22:50:14 +00:00
										 |  |  | #define FX_MODE_RUNNING_DUAL            52
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | #define FX_MODE_HALLOWEEN               53
 | 
					
						
							|  |  |  | #define FX_MODE_TRICOLOR_CHASE          54
 | 
					
						
							|  |  |  | #define FX_MODE_TRICOLOR_WIPE           55
 | 
					
						
							|  |  |  | #define FX_MODE_TRICOLOR_FADE           56
 | 
					
						
							|  |  |  | #define FX_MODE_LIGHTNING               57
 | 
					
						
							|  |  |  | #define FX_MODE_ICU                     58
 | 
					
						
							|  |  |  | #define FX_MODE_MULTI_COMET             59
 | 
					
						
							|  |  |  | #define FX_MODE_DUAL_LARSON_SCANNER     60
 | 
					
						
							|  |  |  | #define FX_MODE_RANDOM_CHASE            61
 | 
					
						
							|  |  |  | #define FX_MODE_OSCILLATE               62
 | 
					
						
							| 
									
										
										
										
											2018-09-10 22:20:12 +00:00
										 |  |  | #define FX_MODE_PRIDE_2015              63
 | 
					
						
							|  |  |  | #define FX_MODE_JUGGLE                  64
 | 
					
						
							|  |  |  | #define FX_MODE_PALETTE                 65
 | 
					
						
							|  |  |  | #define FX_MODE_FIRE_2012               66
 | 
					
						
							| 
									
										
										
										
											2018-09-08 14:21:44 +00:00
										 |  |  | #define FX_MODE_COLORWAVES              67
 | 
					
						
							|  |  |  | #define FX_MODE_BPM                     68
 | 
					
						
							|  |  |  | #define FX_MODE_FILLNOISE8              69
 | 
					
						
							|  |  |  | #define FX_MODE_NOISE16_1               70
 | 
					
						
							|  |  |  | #define FX_MODE_NOISE16_2               71
 | 
					
						
							|  |  |  | #define FX_MODE_NOISE16_3               72
 | 
					
						
							|  |  |  | #define FX_MODE_NOISE16_4               73
 | 
					
						
							| 
									
										
										
										
											2018-11-04 19:14:23 +00:00
										 |  |  | #define FX_MODE_COLORTWINKLE            74
 | 
					
						
							| 
									
										
										
										
											2018-11-07 19:22:05 +00:00
										 |  |  | #define FX_MODE_LAKE                    75
 | 
					
						
							| 
									
										
										
										
											2018-11-20 20:31:07 +00:00
										 |  |  | #define FX_MODE_METEOR                  76
 | 
					
						
							| 
									
										
										
										
											2018-12-02 01:49:05 +00:00
										 |  |  | #define FX_MODE_METEOR_SMOOTH           77
 | 
					
						
							|  |  |  | #define FX_MODE_RAILWAY                 78
 | 
					
						
							| 
									
										
										
										
											2019-01-31 22:42:48 +00:00
										 |  |  | #define FX_MODE_RIPPLE                  79
 | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  | #define FX_MODE_TWINKLEFOX              80
 | 
					
						
							| 
									
										
										
										
											2019-10-01 23:17:26 +00:00
										 |  |  | #define FX_MODE_TWINKLECAT              81
 | 
					
						
							|  |  |  | #define FX_MODE_HALLOWEEN_EYES          82
 | 
					
						
							| 
									
										
										
										
											2019-11-18 11:29:36 +00:00
										 |  |  | #define FX_MODE_STATIC_PATTERN          83
 | 
					
						
							| 
									
										
										
										
											2019-11-29 17:53:01 +00:00
										 |  |  | #define FX_MODE_TRI_STATIC_PATTERN      84
 | 
					
						
							| 
									
										
										
										
											2019-12-04 11:15:12 +00:00
										 |  |  | #define FX_MODE_SPOTS                   85
 | 
					
						
							|  |  |  | #define FX_MODE_SPOTS_FADE              86
 | 
					
						
							| 
									
										
										
										
											2019-12-06 00:44:45 +00:00
										 |  |  | #define FX_MODE_GLITTER                 87
 | 
					
						
							|  |  |  | #define FX_MODE_CANDLE                  88
 | 
					
						
							| 
									
										
										
										
											2019-12-28 14:43:55 +00:00
										 |  |  | #define FX_MODE_STARBURST               89
 | 
					
						
							| 
									
										
										
										
											2020-01-03 11:58:31 +00:00
										 |  |  | #define FX_MODE_EXPLODING_FIREWORKS     90
 | 
					
						
							| 
									
										
										
										
											2020-01-03 22:19:40 +00:00
										 |  |  | #define FX_MODE_BOUNCINGBALLS           91
 | 
					
						
							|  |  |  | #define FX_MODE_SINELON                 92
 | 
					
						
							|  |  |  | #define FX_MODE_SINELON_DUAL            93
 | 
					
						
							|  |  |  | #define FX_MODE_SINELON_RAINBOW         94
 | 
					
						
							|  |  |  | #define FX_MODE_POPCORN                 95
 | 
					
						
							| 
									
										
										
										
											2020-01-12 14:04:49 +00:00
										 |  |  | #define FX_MODE_DRIP                    96
 | 
					
						
							| 
									
										
										
										
											2020-01-18 23:06:17 +00:00
										 |  |  | #define FX_MODE_PLASMA                  97
 | 
					
						
							| 
									
										
										
										
											2020-01-19 12:51:49 +00:00
										 |  |  | #define FX_MODE_PERCENT                 98
 | 
					
						
							| 
									
										
										
										
											2020-02-15 19:07:15 +00:00
										 |  |  | #define FX_MODE_RIPPLE_RAINBOW          99
 | 
					
						
							| 
									
										
										
										
											2020-02-17 10:01:05 +00:00
										 |  |  | #define FX_MODE_HEARTBEAT              100
 | 
					
						
							| 
									
										
										
										
											2020-03-25 10:17:45 +00:00
										 |  |  | #define FX_MODE_PACIFICA               101
 | 
					
						
							| 
									
										
										
										
											2020-04-21 22:51:00 +00:00
										 |  |  | #define FX_MODE_CANDLE_MULTI           102
 | 
					
						
							| 
									
										
										
										
											2020-05-06 13:28:16 +00:00
										 |  |  | #define FX_MODE_SOLID_GLITTER          103
 | 
					
						
							| 
									
										
										
										
											2020-06-05 22:57:34 +00:00
										 |  |  | #define FX_MODE_SUNRISE                104
 | 
					
						
							|  |  |  | #define FX_MODE_PHASED                 105
 | 
					
						
							|  |  |  | #define FX_MODE_TWINKLEUP              106
 | 
					
						
							|  |  |  | #define FX_MODE_NOISEPAL               107
 | 
					
						
							|  |  |  | #define FX_MODE_SINEWAVE               108
 | 
					
						
							|  |  |  | #define FX_MODE_PHASEDNOISE            109
 | 
					
						
							|  |  |  | #define FX_MODE_FLOW                   110
 | 
					
						
							| 
									
										
										
										
											2020-06-22 10:30:31 +00:00
										 |  |  | #define FX_MODE_CHUNCHUN               111
 | 
					
						
							| 
									
										
										
										
											2020-08-22 18:54:59 +00:00
										 |  |  | #define FX_MODE_DANCING_SHADOWS        112
 | 
					
						
							| 
									
										
										
										
											2020-09-26 23:58:21 +00:00
										 |  |  | #define FX_MODE_WASHING_MACHINE        113
 | 
					
						
							| 
									
										
										
										
											2020-12-07 07:33:08 +00:00
										 |  |  | #define FX_MODE_CANDY_CANE             114
 | 
					
						
							| 
									
										
										
										
											2020-12-15 12:35:50 +00:00
										 |  |  | #define FX_MODE_BLENDS                 115
 | 
					
						
							| 
									
										
										
										
											2020-12-22 12:15:57 +00:00
										 |  |  | #define FX_MODE_TV_SIMULATOR           116
 | 
					
						
							| 
									
										
										
										
											2020-12-22 15:26:19 +00:00
										 |  |  | #define FX_MODE_DYNAMIC_SMOOTH         117
 | 
					
						
							| 
									
										
										
										
											2018-01-09 22:13:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-12 22:28:29 +00:00
										 |  |  | class WS2812FX { | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |   typedef uint16_t (WS2812FX::*mode_ptr)(void); | 
					
						
							| 
									
										
										
										
											2020-01-02 21:10:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // pre show callback
 | 
					
						
							|  |  |  |   typedef void (*show_callback) (void); | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   static WS2812FX* instance; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |    | 
					
						
							|  |  |  |   // segment parameters
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |   public: | 
					
						
							| 
									
										
										
										
											2021-06-29 22:45:36 +00:00
										 |  |  |     typedef struct Segment { // 25 (28 in memory?) bytes
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       uint16_t start; | 
					
						
							| 
									
										
										
										
											2019-03-05 09:59:15 +00:00
										 |  |  |       uint16_t stop; //segment invalid if stop == 0
 | 
					
						
							| 
									
										
										
										
											2021-06-29 22:45:36 +00:00
										 |  |  |       uint16_t offset; | 
					
						
							| 
									
										
										
										
											2018-11-16 18:59:00 +00:00
										 |  |  |       uint8_t speed; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       uint8_t intensity; | 
					
						
							| 
									
										
										
										
											2018-09-06 00:05:56 +00:00
										 |  |  |       uint8_t palette; | 
					
						
							| 
									
										
										
										
											2019-03-01 16:10:42 +00:00
										 |  |  |       uint8_t mode; | 
					
						
							| 
									
										
										
										
											2020-05-10 21:58:50 +00:00
										 |  |  |       uint8_t options; //bit pattern: msb first: transitional needspixelstate tbd tbd (paused) on reverse selected
 | 
					
						
							| 
									
										
										
										
											2020-01-14 09:57:23 +00:00
										 |  |  |       uint8_t grouping, spacing; | 
					
						
							| 
									
										
										
										
											2019-12-02 11:41:35 +00:00
										 |  |  |       uint8_t opacity; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       uint32_t colors[NUM_COLORS]; | 
					
						
							| 
									
										
										
										
											2021-04-04 19:10:44 +00:00
										 |  |  |       char *name; | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |       bool setColor(uint8_t slot, uint32_t c, uint8_t segn) { //returns true if changed
 | 
					
						
							|  |  |  |         if (slot >= NUM_COLORS || segn >= MAX_NUM_SEGMENTS) return false; | 
					
						
							|  |  |  |         if (c == colors[slot]) return false; | 
					
						
							|  |  |  |         ColorTransition::startTransition(opacity, colors[slot], instance->_transitionDur, segn, slot); | 
					
						
							|  |  |  |         colors[slot] = c; return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       void setOpacity(uint8_t o, uint8_t segn) { | 
					
						
							|  |  |  |         if (segn >= MAX_NUM_SEGMENTS) return; | 
					
						
							|  |  |  |         if (opacity == o) return; | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |         ColorTransition::startTransition(opacity, colors[0], instance->_transitionDur, segn, 0); | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |         opacity = o; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |       /*uint8_t actualOpacity() { //respects On/Off state
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |         if (!getOption(SEG_OPTION_ON)) return 0; | 
					
						
							|  |  |  |         return opacity; | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |       }*/ | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |       void setOption(uint8_t n, bool val, uint8_t segn = 255) | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |         //bool prevOn = false;
 | 
					
						
							|  |  |  |         //if (n == SEG_OPTION_ON) prevOn = getOption(SEG_OPTION_ON);
 | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  |         if (val) { | 
					
						
							|  |  |  |           options |= 0x01 << n; | 
					
						
							|  |  |  |         } else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           options &= ~(0x01 << n); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |         //transitions on segment on/off don't work correctly at this point
 | 
					
						
							|  |  |  |         /*if (n == SEG_OPTION_ON && segn < MAX_NUM_SEGMENTS && getOption(SEG_OPTION_ON) != prevOn) {
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |           if (getOption(SEG_OPTION_ON)) { | 
					
						
							|  |  |  |             ColorTransition::startTransition(0, colors[0], instance->_transitionDur, segn, 0); | 
					
						
							|  |  |  |           } else { | 
					
						
							|  |  |  |             ColorTransition::startTransition(opacity, colors[0], instance->_transitionDur, segn, 0); | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |         }*/ | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  |       } | 
					
						
							|  |  |  |       bool getOption(uint8_t n) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         return ((options >> n) & 0x01); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-02-28 21:54:30 +00:00
										 |  |  |       inline bool isSelected() | 
					
						
							| 
									
										
										
										
											2019-06-20 12:40:12 +00:00
										 |  |  |       { | 
					
						
							|  |  |  |         return getOption(0); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-02-28 21:54:30 +00:00
										 |  |  |       inline bool isActive() | 
					
						
							| 
									
										
										
										
											2019-06-20 12:40:12 +00:00
										 |  |  |       { | 
					
						
							|  |  |  |         return stop > start; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-02-28 21:54:30 +00:00
										 |  |  |       inline uint16_t length() | 
					
						
							| 
									
										
										
										
											2019-05-21 22:23:09 +00:00
										 |  |  |       { | 
					
						
							|  |  |  |         return stop - start; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-02-28 21:54:30 +00:00
										 |  |  |       inline uint16_t groupLength() | 
					
						
							| 
									
										
										
										
											2020-01-14 09:57:23 +00:00
										 |  |  |       { | 
					
						
							|  |  |  |         return grouping + spacing; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       uint16_t virtualLength() | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         uint16_t groupLen = groupLength(); | 
					
						
							| 
									
										
										
										
											2020-08-06 22:50:19 +00:00
										 |  |  |         uint16_t vLength = (length() + groupLen - 1) / groupLen; | 
					
						
							| 
									
										
										
										
											2020-08-04 16:50:16 +00:00
										 |  |  |         if (options & MIRROR) | 
					
						
							| 
									
										
										
										
											2020-08-19 22:04:02 +00:00
										 |  |  |           vLength = (vLength + 1) /2;  // divide by 2 if mirror, leave at least a single LED
 | 
					
						
							| 
									
										
										
										
											2020-08-04 16:50:16 +00:00
										 |  |  |         return vLength; | 
					
						
							| 
									
										
										
										
											2019-12-05 06:59:05 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-07-01 22:24:14 +00:00
										 |  |  |       uint8_t differs(Segment& b) { | 
					
						
							|  |  |  |         uint8_t d = 0; | 
					
						
							|  |  |  |         if (start != b.start)         d |= SEG_DIFFERS_BOUNDS; | 
					
						
							|  |  |  |         if (stop != b.stop)           d |= SEG_DIFFERS_BOUNDS; | 
					
						
							|  |  |  |         if (offset != b.offset)       d |= SEG_DIFFERS_GSO; | 
					
						
							|  |  |  |         if (grouping != b.grouping)   d |= SEG_DIFFERS_GSO; | 
					
						
							|  |  |  |         if (spacing != b.spacing)     d |= SEG_DIFFERS_GSO; | 
					
						
							|  |  |  |         if (opacity != b.opacity)     d |= SEG_DIFFERS_BRI; | 
					
						
							|  |  |  |         if (mode != b.mode)           d |= SEG_DIFFERS_FX; | 
					
						
							|  |  |  |         if (speed != b.speed)         d |= SEG_DIFFERS_FX; | 
					
						
							|  |  |  |         if (intensity != b.intensity) d |= SEG_DIFFERS_FX; | 
					
						
							|  |  |  |         if (palette != b.palette)     d |= SEG_DIFFERS_FX; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ((options & 0b00101111) != (b.options & 0b00101111)) d |= SEG_DIFFERS_OPT; | 
					
						
							|  |  |  |         for (uint8_t i = 0; i < NUM_COLORS; i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if (colors[i] != b.colors[i]) d |= SEG_DIFFERS_COL; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return d; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     } segment; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // segment runtime parameters
 | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  |     typedef struct Segment_runtime { // 28 bytes
 | 
					
						
							| 
									
										
										
										
											2021-03-01 18:50:14 +00:00
										 |  |  |       unsigned long next_time;  // millis() of next update
 | 
					
						
							|  |  |  |       uint32_t step;  // custom "step" var
 | 
					
						
							|  |  |  |       uint32_t call;  // call counter
 | 
					
						
							|  |  |  |       uint16_t aux0;  // custom var
 | 
					
						
							|  |  |  |       uint16_t aux1;  // custom var
 | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  |       byte* data = nullptr; | 
					
						
							|  |  |  |       bool allocateData(uint16_t len){ | 
					
						
							|  |  |  |         if (data && _dataLen == len) return true; //already allocated
 | 
					
						
							|  |  |  |         deallocateData(); | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |         if (WS2812FX::instance->_usedSegmentData + len > MAX_SEGMENT_DATA) return false; //not enough memory
 | 
					
						
							| 
									
										
										
										
											2021-05-13 15:35:20 +00:00
										 |  |  |         // if possible use SPI RAM on ESP32
 | 
					
						
							| 
									
										
										
										
											2021-06-18 10:16:04 +00:00
										 |  |  |         #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
 | 
					
						
							| 
									
										
										
										
											2021-05-13 15:35:20 +00:00
										 |  |  |         if (psramFound()) | 
					
						
							|  |  |  |           data = (byte*) ps_malloc(len); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         #endif
 | 
					
						
							|  |  |  |           data = (byte*) malloc(len); | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  |         if (!data) return false; //allocation failed
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |         WS2812FX::instance->_usedSegmentData += len; | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  |         _dataLen = len; | 
					
						
							|  |  |  |         memset(data, 0, len); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       void deallocateData(){ | 
					
						
							| 
									
										
										
										
											2021-05-13 15:35:20 +00:00
										 |  |  |         free(data); | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  |         data = nullptr; | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |         WS2812FX::instance->_usedSegmentData -= _dataLen; | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  |         _dataLen = 0; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-12-10 01:55:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /** 
 | 
					
						
							|  |  |  |        * If reset of this segment was request, clears runtime | 
					
						
							|  |  |  |        * settings of this segment. | 
					
						
							|  |  |  |        * Must not be called while an effect mode function is running | 
					
						
							|  |  |  |        * because it could access the data buffer and this method  | 
					
						
							|  |  |  |        * may free that data buffer. | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       void resetIfRequired() { | 
					
						
							|  |  |  |         if (_requiresReset) { | 
					
						
							|  |  |  |           next_time = 0; step = 0; call = 0; aux0 = 0; aux1 = 0;  | 
					
						
							|  |  |  |           deallocateData(); | 
					
						
							|  |  |  |           _requiresReset = false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /** 
 | 
					
						
							|  |  |  |        * Flags that before the next effect is calculated, | 
					
						
							|  |  |  |        * the internal segment state should be reset.  | 
					
						
							|  |  |  |        * Call resetIfRequired before calling the next effect function. | 
					
						
							|  |  |  |        */ | 
					
						
							| 
									
										
										
										
											2021-02-28 21:54:30 +00:00
										 |  |  |       inline void reset() { _requiresReset = true; } | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  |       private: | 
					
						
							|  |  |  |         uint16_t _dataLen = 0; | 
					
						
							| 
									
										
										
										
											2020-12-10 01:55:14 +00:00
										 |  |  |         bool _requiresReset = false; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     } segment_runtime; | 
					
						
							| 
									
										
										
										
											2018-01-10 22:57:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |     typedef struct ColorTransition { // 12 bytes
 | 
					
						
							|  |  |  |       uint32_t colorOld = 0; | 
					
						
							|  |  |  |       uint32_t transitionStart; | 
					
						
							|  |  |  |       uint16_t transitionDur; | 
					
						
							|  |  |  |       uint8_t segment = 0xFF; //lower 6 bits: the segment this transition is for (255 indicates transition not in use/available) upper 2 bits: color channel
 | 
					
						
							|  |  |  |       uint8_t briOld = 0; | 
					
						
							|  |  |  |       static void startTransition(uint8_t oldBri, uint32_t oldCol, uint16_t dur, uint8_t segn, uint8_t slot) { | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |         if (segn >= MAX_NUM_SEGMENTS || slot >= NUM_COLORS || dur == 0) return; | 
					
						
							|  |  |  |         if (instance->_brightness == 0) return; //do not need transitions if master bri is off
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |         uint8_t tIndex = 0xFF; //none found
 | 
					
						
							|  |  |  |         uint16_t tProgression = 0; | 
					
						
							|  |  |  |         uint8_t s = segn + (slot << 6); //merge slot and segment into one byte
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (uint8_t i = 0; i < MAX_NUM_TRANSITIONS; i++) { | 
					
						
							|  |  |  |           uint8_t tSeg = instance->transitions[i].segment; | 
					
						
							|  |  |  |           //see if this segment + color already has a running transition
 | 
					
						
							|  |  |  |           if (tSeg == s) { | 
					
						
							|  |  |  |             tIndex = i; break; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           if (tSeg == 0xFF) { //free transition
 | 
					
						
							|  |  |  |             tIndex = i; tProgression = 0xFFFF; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (tIndex == 0xFF) { //no slot found yet
 | 
					
						
							|  |  |  |           for (uint8_t i = 0; i < MAX_NUM_TRANSITIONS; i++) { | 
					
						
							|  |  |  |             //find most progressed transition to overwrite
 | 
					
						
							|  |  |  |             uint16_t prog = instance->transitions[i].progress(); | 
					
						
							|  |  |  |             if (prog > tProgression) { | 
					
						
							|  |  |  |               tIndex = i; tProgression = prog; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ColorTransition& t = instance->transitions[tIndex]; | 
					
						
							|  |  |  |         if (t.segment == s) //this is an active transition on the same segment+color
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           t.briOld = t.currentBri(); | 
					
						
							|  |  |  |           t.colorOld = t.currentColor(oldCol); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           t.briOld = oldBri; | 
					
						
							|  |  |  |           t.colorOld = oldCol; | 
					
						
							|  |  |  |           uint8_t prevSeg = t.segment & 0x3F; | 
					
						
							|  |  |  |           if (prevSeg < MAX_NUM_SEGMENTS) instance->_segments[prevSeg].setOption(SEG_OPTION_TRANSITIONAL, false); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         t.transitionDur = dur; | 
					
						
							|  |  |  |         t.transitionStart = millis(); | 
					
						
							|  |  |  |         t.segment = s; | 
					
						
							|  |  |  |         instance->_segments[segn].setOption(SEG_OPTION_TRANSITIONAL, true); | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |         //refresh immediately, required for Solid mode
 | 
					
						
							|  |  |  |         if (instance->_segment_runtimes[segn].next_time > t.transitionStart + 22) instance->_segment_runtimes[segn].next_time = t.transitionStart; | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |       } | 
					
						
							|  |  |  |       uint16_t progress(bool allowEnd = false) { //transition progression between 0-65535
 | 
					
						
							|  |  |  |         uint32_t timeNow = millis(); | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |         if (timeNow - transitionStart > transitionDur) { | 
					
						
							|  |  |  |           if (allowEnd) { | 
					
						
							|  |  |  |             uint8_t segn = segment & 0x3F; | 
					
						
							|  |  |  |             if (segn < MAX_NUM_SEGMENTS) instance->_segments[segn].setOption(SEG_OPTION_TRANSITIONAL, false); | 
					
						
							|  |  |  |             segment = 0xFF; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           return 0xFFFF; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |         uint32_t elapsed = timeNow - transitionStart; | 
					
						
							|  |  |  |         uint32_t prog = elapsed * 0xFFFF / transitionDur; | 
					
						
							|  |  |  |         return (prog > 0xFFFF) ? 0xFFFF : prog; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       uint32_t currentColor(uint32_t colorNew) { | 
					
						
							|  |  |  |         return instance->color_blend(colorOld, colorNew, progress(true), true); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       uint8_t currentBri() { | 
					
						
							|  |  |  |         uint8_t segn = segment & 0x3F; | 
					
						
							|  |  |  |         if (segn >= MAX_NUM_SEGMENTS) return 0; | 
					
						
							| 
									
										
										
										
											2021-01-13 10:24:27 +00:00
										 |  |  |         uint8_t briNew = instance->_segments[segn].opacity; | 
					
						
							|  |  |  |         uint32_t prog = progress() + 1; | 
					
						
							|  |  |  |         return ((briNew * prog) + (briOld * (0x10000 - prog))) >> 16; | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |       } | 
					
						
							|  |  |  |     } color_transition; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     WS2812FX() { | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |       WS2812FX::instance = this; | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  |       //assign each member of the _mode[] array to its respective function reference 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _mode[FX_MODE_STATIC]                  = &WS2812FX::mode_static; | 
					
						
							|  |  |  |       _mode[FX_MODE_BLINK]                   = &WS2812FX::mode_blink; | 
					
						
							|  |  |  |       _mode[FX_MODE_COLOR_WIPE]              = &WS2812FX::mode_color_wipe; | 
					
						
							|  |  |  |       _mode[FX_MODE_COLOR_WIPE_RANDOM]       = &WS2812FX::mode_color_wipe_random; | 
					
						
							|  |  |  |       _mode[FX_MODE_RANDOM_COLOR]            = &WS2812FX::mode_random_color; | 
					
						
							|  |  |  |       _mode[FX_MODE_COLOR_SWEEP]             = &WS2812FX::mode_color_sweep; | 
					
						
							|  |  |  |       _mode[FX_MODE_DYNAMIC]                 = &WS2812FX::mode_dynamic; | 
					
						
							|  |  |  |       _mode[FX_MODE_RAINBOW]                 = &WS2812FX::mode_rainbow; | 
					
						
							|  |  |  |       _mode[FX_MODE_RAINBOW_CYCLE]           = &WS2812FX::mode_rainbow_cycle; | 
					
						
							|  |  |  |       _mode[FX_MODE_SCAN]                    = &WS2812FX::mode_scan; | 
					
						
							|  |  |  |       _mode[FX_MODE_DUAL_SCAN]               = &WS2812FX::mode_dual_scan; | 
					
						
							|  |  |  |       _mode[FX_MODE_FADE]                    = &WS2812FX::mode_fade; | 
					
						
							|  |  |  |       _mode[FX_MODE_THEATER_CHASE]           = &WS2812FX::mode_theater_chase; | 
					
						
							|  |  |  |       _mode[FX_MODE_THEATER_CHASE_RAINBOW]   = &WS2812FX::mode_theater_chase_rainbow; | 
					
						
							| 
									
										
										
										
											2019-02-05 20:53:39 +00:00
										 |  |  |       _mode[FX_MODE_SAW]                     = &WS2812FX::mode_saw; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _mode[FX_MODE_TWINKLE]                 = &WS2812FX::mode_twinkle; | 
					
						
							| 
									
										
										
										
											2019-01-31 22:42:48 +00:00
										 |  |  |       _mode[FX_MODE_DISSOLVE]                = &WS2812FX::mode_dissolve; | 
					
						
							|  |  |  |       _mode[FX_MODE_DISSOLVE_RANDOM]         = &WS2812FX::mode_dissolve_random; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _mode[FX_MODE_SPARKLE]                 = &WS2812FX::mode_sparkle; | 
					
						
							|  |  |  |       _mode[FX_MODE_FLASH_SPARKLE]           = &WS2812FX::mode_flash_sparkle; | 
					
						
							|  |  |  |       _mode[FX_MODE_HYPER_SPARKLE]           = &WS2812FX::mode_hyper_sparkle; | 
					
						
							|  |  |  |       _mode[FX_MODE_STROBE]                  = &WS2812FX::mode_strobe; | 
					
						
							|  |  |  |       _mode[FX_MODE_STROBE_RAINBOW]          = &WS2812FX::mode_strobe_rainbow; | 
					
						
							|  |  |  |       _mode[FX_MODE_MULTI_STROBE]            = &WS2812FX::mode_multi_strobe; | 
					
						
							|  |  |  |       _mode[FX_MODE_BLINK_RAINBOW]           = &WS2812FX::mode_blink_rainbow; | 
					
						
							|  |  |  |       _mode[FX_MODE_ANDROID]                 = &WS2812FX::mode_android; | 
					
						
							|  |  |  |       _mode[FX_MODE_CHASE_COLOR]             = &WS2812FX::mode_chase_color; | 
					
						
							|  |  |  |       _mode[FX_MODE_CHASE_RANDOM]            = &WS2812FX::mode_chase_random; | 
					
						
							|  |  |  |       _mode[FX_MODE_CHASE_RAINBOW]           = &WS2812FX::mode_chase_rainbow; | 
					
						
							|  |  |  |       _mode[FX_MODE_CHASE_FLASH]             = &WS2812FX::mode_chase_flash; | 
					
						
							|  |  |  |       _mode[FX_MODE_CHASE_FLASH_RANDOM]      = &WS2812FX::mode_chase_flash_random; | 
					
						
							|  |  |  |       _mode[FX_MODE_CHASE_RAINBOW_WHITE]     = &WS2812FX::mode_chase_rainbow_white; | 
					
						
							|  |  |  |       _mode[FX_MODE_COLORFUL]                = &WS2812FX::mode_colorful; | 
					
						
							|  |  |  |       _mode[FX_MODE_TRAFFIC_LIGHT]           = &WS2812FX::mode_traffic_light; | 
					
						
							|  |  |  |       _mode[FX_MODE_COLOR_SWEEP_RANDOM]      = &WS2812FX::mode_color_sweep_random; | 
					
						
							|  |  |  |       _mode[FX_MODE_RUNNING_COLOR]           = &WS2812FX::mode_running_color; | 
					
						
							| 
									
										
										
										
											2021-01-04 10:11:36 +00:00
										 |  |  |       _mode[FX_MODE_AURORA]                  = &WS2812FX::mode_aurora; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _mode[FX_MODE_RUNNING_RANDOM]          = &WS2812FX::mode_running_random; | 
					
						
							|  |  |  |       _mode[FX_MODE_LARSON_SCANNER]          = &WS2812FX::mode_larson_scanner; | 
					
						
							|  |  |  |       _mode[FX_MODE_COMET]                   = &WS2812FX::mode_comet; | 
					
						
							|  |  |  |       _mode[FX_MODE_FIREWORKS]               = &WS2812FX::mode_fireworks; | 
					
						
							| 
									
										
										
										
											2019-02-11 22:49:04 +00:00
										 |  |  |       _mode[FX_MODE_RAIN]                    = &WS2812FX::mode_rain; | 
					
						
							| 
									
										
										
										
											2021-02-09 23:37:05 +00:00
										 |  |  |       _mode[FX_MODE_TETRIX]                  = &WS2812FX::mode_tetrix; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _mode[FX_MODE_FIRE_FLICKER]            = &WS2812FX::mode_fire_flicker; | 
					
						
							|  |  |  |       _mode[FX_MODE_GRADIENT]                = &WS2812FX::mode_gradient; | 
					
						
							|  |  |  |       _mode[FX_MODE_LOADING]                 = &WS2812FX::mode_loading; | 
					
						
							| 
									
										
										
										
											2019-12-04 11:15:12 +00:00
										 |  |  |       _mode[FX_MODE_POLICE]                  = &WS2812FX::mode_police; | 
					
						
							|  |  |  |       _mode[FX_MODE_POLICE_ALL]              = &WS2812FX::mode_police_all; | 
					
						
							|  |  |  |       _mode[FX_MODE_TWO_DOTS]                = &WS2812FX::mode_two_dots; | 
					
						
							|  |  |  |       _mode[FX_MODE_TWO_AREAS]               = &WS2812FX::mode_two_areas; | 
					
						
							| 
									
										
										
										
											2021-04-10 22:50:14 +00:00
										 |  |  |       _mode[FX_MODE_RUNNING_DUAL]            = &WS2812FX::mode_running_dual; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _mode[FX_MODE_HALLOWEEN]               = &WS2812FX::mode_halloween; | 
					
						
							|  |  |  |       _mode[FX_MODE_TRICOLOR_CHASE]          = &WS2812FX::mode_tricolor_chase; | 
					
						
							|  |  |  |       _mode[FX_MODE_TRICOLOR_WIPE]           = &WS2812FX::mode_tricolor_wipe; | 
					
						
							|  |  |  |       _mode[FX_MODE_TRICOLOR_FADE]           = &WS2812FX::mode_tricolor_fade; | 
					
						
							|  |  |  |       _mode[FX_MODE_BREATH]                  = &WS2812FX::mode_breath; | 
					
						
							|  |  |  |       _mode[FX_MODE_RUNNING_LIGHTS]          = &WS2812FX::mode_running_lights; | 
					
						
							|  |  |  |       _mode[FX_MODE_LIGHTNING]               = &WS2812FX::mode_lightning; | 
					
						
							|  |  |  |       _mode[FX_MODE_ICU]                     = &WS2812FX::mode_icu; | 
					
						
							|  |  |  |       _mode[FX_MODE_MULTI_COMET]             = &WS2812FX::mode_multi_comet; | 
					
						
							|  |  |  |       _mode[FX_MODE_DUAL_LARSON_SCANNER]     = &WS2812FX::mode_dual_larson_scanner; | 
					
						
							|  |  |  |       _mode[FX_MODE_RANDOM_CHASE]            = &WS2812FX::mode_random_chase; | 
					
						
							|  |  |  |       _mode[FX_MODE_OSCILLATE]               = &WS2812FX::mode_oscillate; | 
					
						
							|  |  |  |       _mode[FX_MODE_FIRE_2012]               = &WS2812FX::mode_fire_2012; | 
					
						
							| 
									
										
										
										
											2018-09-08 14:21:44 +00:00
										 |  |  |       _mode[FX_MODE_PRIDE_2015]              = &WS2812FX::mode_pride_2015; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _mode[FX_MODE_BPM]                     = &WS2812FX::mode_bpm; | 
					
						
							|  |  |  |       _mode[FX_MODE_JUGGLE]                  = &WS2812FX::mode_juggle; | 
					
						
							|  |  |  |       _mode[FX_MODE_PALETTE]                 = &WS2812FX::mode_palette; | 
					
						
							| 
									
										
										
										
											2018-09-08 14:21:44 +00:00
										 |  |  |       _mode[FX_MODE_COLORWAVES]              = &WS2812FX::mode_colorwaves; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _mode[FX_MODE_FILLNOISE8]              = &WS2812FX::mode_fillnoise8; | 
					
						
							|  |  |  |       _mode[FX_MODE_NOISE16_1]               = &WS2812FX::mode_noise16_1; | 
					
						
							|  |  |  |       _mode[FX_MODE_NOISE16_2]               = &WS2812FX::mode_noise16_2; | 
					
						
							|  |  |  |       _mode[FX_MODE_NOISE16_3]               = &WS2812FX::mode_noise16_3; | 
					
						
							|  |  |  |       _mode[FX_MODE_NOISE16_4]               = &WS2812FX::mode_noise16_4; | 
					
						
							| 
									
										
										
										
											2018-11-04 19:14:23 +00:00
										 |  |  |       _mode[FX_MODE_COLORTWINKLE]            = &WS2812FX::mode_colortwinkle; | 
					
						
							| 
									
										
										
										
											2018-11-07 19:22:05 +00:00
										 |  |  |       _mode[FX_MODE_LAKE]                    = &WS2812FX::mode_lake; | 
					
						
							| 
									
										
										
										
											2018-11-20 20:31:07 +00:00
										 |  |  |       _mode[FX_MODE_METEOR]                  = &WS2812FX::mode_meteor; | 
					
						
							| 
									
										
										
										
											2018-12-02 01:49:05 +00:00
										 |  |  |       _mode[FX_MODE_METEOR_SMOOTH]           = &WS2812FX::mode_meteor_smooth; | 
					
						
							|  |  |  |       _mode[FX_MODE_RAILWAY]                 = &WS2812FX::mode_railway; | 
					
						
							| 
									
										
										
										
											2019-01-31 22:42:48 +00:00
										 |  |  |       _mode[FX_MODE_RIPPLE]                  = &WS2812FX::mode_ripple; | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  |       _mode[FX_MODE_TWINKLEFOX]              = &WS2812FX::mode_twinklefox; | 
					
						
							| 
									
										
										
										
											2019-10-01 23:17:26 +00:00
										 |  |  |       _mode[FX_MODE_TWINKLECAT]              = &WS2812FX::mode_twinklecat; | 
					
						
							|  |  |  |       _mode[FX_MODE_HALLOWEEN_EYES]          = &WS2812FX::mode_halloween_eyes; | 
					
						
							| 
									
										
										
										
											2019-11-18 11:29:36 +00:00
										 |  |  |       _mode[FX_MODE_STATIC_PATTERN]          = &WS2812FX::mode_static_pattern; | 
					
						
							| 
									
										
										
										
											2019-11-29 19:25:30 +00:00
										 |  |  |       _mode[FX_MODE_TRI_STATIC_PATTERN]      = &WS2812FX::mode_tri_static_pattern; | 
					
						
							| 
									
										
										
										
											2019-12-04 11:15:12 +00:00
										 |  |  |       _mode[FX_MODE_SPOTS]                   = &WS2812FX::mode_spots; | 
					
						
							|  |  |  |       _mode[FX_MODE_SPOTS_FADE]              = &WS2812FX::mode_spots_fade; | 
					
						
							| 
									
										
										
										
											2019-12-06 00:44:45 +00:00
										 |  |  |       _mode[FX_MODE_GLITTER]                 = &WS2812FX::mode_glitter; | 
					
						
							|  |  |  |       _mode[FX_MODE_CANDLE]                  = &WS2812FX::mode_candle; | 
					
						
							| 
									
										
										
										
											2019-12-28 14:43:55 +00:00
										 |  |  |       _mode[FX_MODE_STARBURST]               = &WS2812FX::mode_starburst; | 
					
						
							| 
									
										
										
										
											2019-12-27 19:58:06 +00:00
										 |  |  |       _mode[FX_MODE_EXPLODING_FIREWORKS]     = &WS2812FX::mode_exploding_fireworks; | 
					
						
							| 
									
										
										
										
											2020-01-05 20:26:14 +00:00
										 |  |  |       _mode[FX_MODE_BOUNCINGBALLS]           = &WS2812FX::mode_bouncing_balls; | 
					
						
							| 
									
										
										
										
											2019-12-10 19:26:02 +00:00
										 |  |  |       _mode[FX_MODE_SINELON]                 = &WS2812FX::mode_sinelon; | 
					
						
							| 
									
										
										
										
											2019-12-24 19:41:03 +00:00
										 |  |  |       _mode[FX_MODE_SINELON_DUAL]            = &WS2812FX::mode_sinelon_dual; | 
					
						
							|  |  |  |       _mode[FX_MODE_SINELON_RAINBOW]         = &WS2812FX::mode_sinelon_rainbow; | 
					
						
							| 
									
										
										
										
											2019-12-10 19:34:59 +00:00
										 |  |  |       _mode[FX_MODE_POPCORN]                 = &WS2812FX::mode_popcorn; | 
					
						
							| 
									
										
										
										
											2020-01-12 14:04:49 +00:00
										 |  |  |       _mode[FX_MODE_DRIP]                    = &WS2812FX::mode_drip; | 
					
						
							| 
									
										
										
										
											2020-01-18 23:06:17 +00:00
										 |  |  |       _mode[FX_MODE_PLASMA]                  = &WS2812FX::mode_plasma; | 
					
						
							| 
									
										
										
										
											2020-01-19 12:51:49 +00:00
										 |  |  |       _mode[FX_MODE_PERCENT]                 = &WS2812FX::mode_percent; | 
					
						
							| 
									
										
										
										
											2020-02-15 19:07:15 +00:00
										 |  |  |       _mode[FX_MODE_RIPPLE_RAINBOW]          = &WS2812FX::mode_ripple_rainbow; | 
					
						
							| 
									
										
										
										
											2020-02-18 17:52:47 +00:00
										 |  |  |       _mode[FX_MODE_HEARTBEAT]               = &WS2812FX::mode_heartbeat; | 
					
						
							| 
									
										
										
										
											2020-03-25 10:17:45 +00:00
										 |  |  |       _mode[FX_MODE_PACIFICA]                = &WS2812FX::mode_pacifica; | 
					
						
							| 
									
										
										
										
											2020-04-21 22:51:00 +00:00
										 |  |  |       _mode[FX_MODE_CANDLE_MULTI]            = &WS2812FX::mode_candle_multi; | 
					
						
							| 
									
										
										
										
											2020-05-06 13:28:16 +00:00
										 |  |  |       _mode[FX_MODE_SOLID_GLITTER]           = &WS2812FX::mode_solid_glitter; | 
					
						
							| 
									
										
										
										
											2020-06-05 22:57:34 +00:00
										 |  |  |       _mode[FX_MODE_SUNRISE]                 = &WS2812FX::mode_sunrise; | 
					
						
							|  |  |  |       _mode[FX_MODE_PHASED]                  = &WS2812FX::mode_phased; | 
					
						
							|  |  |  |       _mode[FX_MODE_TWINKLEUP]               = &WS2812FX::mode_twinkleup; | 
					
						
							|  |  |  |       _mode[FX_MODE_NOISEPAL]                = &WS2812FX::mode_noisepal; | 
					
						
							|  |  |  |       _mode[FX_MODE_SINEWAVE]                = &WS2812FX::mode_sinewave; | 
					
						
							|  |  |  |       _mode[FX_MODE_PHASEDNOISE]             = &WS2812FX::mode_phased_noise; | 
					
						
							|  |  |  |       _mode[FX_MODE_FLOW]                    = &WS2812FX::mode_flow; | 
					
						
							| 
									
										
										
										
											2020-06-22 10:30:31 +00:00
										 |  |  |       _mode[FX_MODE_CHUNCHUN]                = &WS2812FX::mode_chunchun; | 
					
						
							| 
									
										
										
										
											2020-08-22 18:54:59 +00:00
										 |  |  |       _mode[FX_MODE_DANCING_SHADOWS]         = &WS2812FX::mode_dancing_shadows; | 
					
						
							| 
									
										
										
										
											2020-09-26 23:58:21 +00:00
										 |  |  |       _mode[FX_MODE_WASHING_MACHINE]         = &WS2812FX::mode_washing_machine; | 
					
						
							| 
									
										
										
										
											2020-12-07 07:33:08 +00:00
										 |  |  |       _mode[FX_MODE_CANDY_CANE]              = &WS2812FX::mode_candy_cane; | 
					
						
							| 
									
										
										
										
											2020-12-15 12:35:50 +00:00
										 |  |  |       _mode[FX_MODE_BLENDS]                  = &WS2812FX::mode_blends; | 
					
						
							| 
									
										
										
										
											2020-12-22 12:15:57 +00:00
										 |  |  |       _mode[FX_MODE_TV_SIMULATOR]            = &WS2812FX::mode_tv_simulator; | 
					
						
							| 
									
										
										
										
											2020-12-22 15:26:19 +00:00
										 |  |  |       _mode[FX_MODE_DYNAMIC_SMOOTH]          = &WS2812FX::mode_dynamic_smooth; | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       _brightness = DEFAULT_BRIGHTNESS; | 
					
						
							| 
									
										
										
										
											2019-02-09 15:37:20 +00:00
										 |  |  |       currentPalette = CRGBPalette16(CRGB::Black); | 
					
						
							|  |  |  |       targetPalette = CloudColors_p; | 
					
						
							| 
									
										
										
										
											2019-03-09 20:41:23 +00:00
										 |  |  |       ablMilliampsMax = 850; | 
					
						
							| 
									
										
										
										
											2018-12-03 23:58:06 +00:00
										 |  |  |       currentMilliamps = 0; | 
					
						
							| 
									
										
										
										
											2019-10-18 10:19:52 +00:00
										 |  |  |       timebase = 0; | 
					
						
							| 
									
										
										
										
											2019-06-20 12:40:12 +00:00
										 |  |  |       resetSegments(); | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void | 
					
						
							| 
									
										
										
										
											2021-02-24 19:23:32 +00:00
										 |  |  |       finalizeInit(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       service(void), | 
					
						
							| 
									
										
										
										
											2019-02-11 22:49:04 +00:00
										 |  |  |       blur(uint8_t), | 
					
						
							| 
									
										
										
										
											2020-08-29 20:26:39 +00:00
										 |  |  |       fill(uint32_t), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       fade_out(uint8_t r), | 
					
						
							| 
									
										
										
										
											2019-06-20 12:40:12 +00:00
										 |  |  |       setMode(uint8_t segid, uint8_t m), | 
					
						
							|  |  |  |       setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0), | 
					
						
							|  |  |  |       setColor(uint8_t slot, uint32_t c), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       setBrightness(uint8_t b), | 
					
						
							|  |  |  |       setRange(uint16_t i, uint16_t i2, uint32_t col), | 
					
						
							| 
									
										
										
										
											2020-01-02 21:10:59 +00:00
										 |  |  |       setShowCallback(show_callback cb), | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |       setTransition(uint16_t t), | 
					
						
							| 
									
										
										
										
											2018-09-06 00:05:56 +00:00
										 |  |  |       setTransitionMode(bool t), | 
					
						
							| 
									
										
										
										
											2020-11-04 10:04:40 +00:00
										 |  |  |       calcGammaTable(float), | 
					
						
							| 
									
										
										
										
											2017-02-04 21:17:28 +00:00
										 |  |  |       trigger(void), | 
					
						
							| 
									
										
										
										
											2020-01-14 09:57:23 +00:00
										 |  |  |       setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       resetSegments(), | 
					
						
							| 
									
										
										
										
											2021-02-27 11:06:14 +00:00
										 |  |  |       populateDefaultSegments(), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       setPixelColor(uint16_t n, uint32_t c), | 
					
						
							|  |  |  |       setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0), | 
					
						
							| 
									
										
										
										
											2020-02-22 16:20:34 +00:00
										 |  |  |       show(void), | 
					
						
							| 
									
										
										
										
											2021-04-04 11:54:34 +00:00
										 |  |  |       setPixelSegment(uint8_t n), | 
					
						
							|  |  |  |       deserializeMap(uint8_t n=0); | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-24 10:52:23 +00:00
										 |  |  |     bool | 
					
						
							| 
									
										
										
										
											2021-03-29 00:28:34 +00:00
										 |  |  |       isRgbw = false, | 
					
						
							| 
									
										
										
										
											2021-04-24 04:45:50 +00:00
										 |  |  |       isOffRefreshRequred = false, //periodic refresh is required for the strip to remain off.
 | 
					
						
							| 
									
										
										
										
											2019-05-21 22:23:09 +00:00
										 |  |  |       gammaCorrectBri = false, | 
					
						
							|  |  |  |       gammaCorrectCol = true, | 
					
						
							| 
									
										
										
										
											2019-12-02 11:41:35 +00:00
										 |  |  |       applyToAllSelected = true, | 
					
						
							| 
									
										
										
										
											2020-12-10 04:29:53 +00:00
										 |  |  |       setEffectConfig(uint8_t m, uint8_t s, uint8_t i, uint8_t p), | 
					
						
							|  |  |  |       // return true if the strip is being sent pixel updates
 | 
					
						
							|  |  |  |       isUpdating(void); | 
					
						
							| 
									
										
										
										
											2018-11-24 10:52:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     uint8_t | 
					
						
							| 
									
										
										
										
											2019-11-30 18:17:25 +00:00
										 |  |  |       mainSegment = 0, | 
					
						
							| 
									
										
										
										
											2020-02-19 23:45:09 +00:00
										 |  |  |       rgbwMode = RGBW_MODE_DUAL, | 
					
						
							| 
									
										
										
										
											2019-05-21 22:23:09 +00:00
										 |  |  |       paletteFade = 0, | 
					
						
							|  |  |  |       paletteBlend = 0, | 
					
						
							| 
									
										
										
										
											2019-11-12 18:33:34 +00:00
										 |  |  |       milliampsPerLed = 55, | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       getBrightness(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       getMode(void), | 
					
						
							|  |  |  |       getSpeed(void), | 
					
						
							| 
									
										
										
										
											2019-02-22 21:53:33 +00:00
										 |  |  |       getModeCount(void), | 
					
						
							|  |  |  |       getPaletteCount(void), | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  |       getMaxSegments(void), | 
					
						
							| 
									
										
										
										
											2019-12-01 00:42:52 +00:00
										 |  |  |       //getFirstSelectedSegment(void),
 | 
					
						
							| 
									
										
										
										
											2019-11-30 18:17:25 +00:00
										 |  |  |       getMainSegmentId(void), | 
					
						
							| 
									
										
										
										
											2019-05-21 22:23:09 +00:00
										 |  |  |       gamma8(uint8_t), | 
					
						
							| 
									
										
										
										
											2020-11-04 10:04:40 +00:00
										 |  |  |       gamma8_cal(uint8_t, float), | 
					
						
							| 
									
										
										
										
											2021-04-10 22:50:14 +00:00
										 |  |  |       sin_gap(uint16_t), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       get_random_wheel_index(uint8_t); | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-27 12:42:14 +00:00
										 |  |  |     int8_t | 
					
						
							|  |  |  |       tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  |     uint16_t | 
					
						
							|  |  |  |       ablMilliampsMax, | 
					
						
							| 
									
										
										
										
											2019-12-01 00:42:52 +00:00
										 |  |  |       currentMilliamps, | 
					
						
							| 
									
										
										
										
											2021-02-05 00:33:26 +00:00
										 |  |  |       triwave16(uint16_t), | 
					
						
							|  |  |  |       getFps(); | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |     uint32_t | 
					
						
							| 
									
										
										
										
											2020-08-25 15:23:17 +00:00
										 |  |  |       now, | 
					
						
							| 
									
										
										
										
											2019-10-18 10:19:52 +00:00
										 |  |  |       timebase, | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       color_wheel(uint8_t), | 
					
						
							| 
									
										
										
										
											2020-06-05 22:57:34 +00:00
										 |  |  |       color_from_palette(uint16_t, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri = 255), | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |       color_blend(uint32_t,uint32_t,uint16_t,bool b16=false), | 
					
						
							|  |  |  |       currentColor(uint32_t colorNew, uint8_t tNr), | 
					
						
							| 
									
										
										
										
											2019-05-21 22:23:09 +00:00
										 |  |  |       gamma32(uint32_t), | 
					
						
							| 
									
										
										
										
											2019-11-18 19:43:27 +00:00
										 |  |  |       getLastShow(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       getPixelColor(uint16_t), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       getColor(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  |     WS2812FX::Segment& | 
					
						
							|  |  |  |       getSegment(uint8_t n); | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     WS2812FX::Segment_runtime | 
					
						
							|  |  |  |       getSegmentRuntime(void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     WS2812FX::Segment* | 
					
						
							|  |  |  |       getSegments(void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // builtin modes
 | 
					
						
							|  |  |  |     uint16_t | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_static(void), | 
					
						
							|  |  |  |       mode_blink(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       mode_blink_rainbow(void), | 
					
						
							|  |  |  |       mode_strobe(void), | 
					
						
							|  |  |  |       mode_strobe_rainbow(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_color_wipe(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       mode_color_sweep(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_color_wipe_random(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       mode_color_sweep_random(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_random_color(void), | 
					
						
							| 
									
										
										
										
											2018-03-31 22:08:50 +00:00
										 |  |  |       mode_dynamic(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_breath(void), | 
					
						
							|  |  |  |       mode_fade(void), | 
					
						
							|  |  |  |       mode_scan(void), | 
					
						
							|  |  |  |       mode_dual_scan(void), | 
					
						
							|  |  |  |       mode_theater_chase(void), | 
					
						
							|  |  |  |       mode_theater_chase_rainbow(void), | 
					
						
							|  |  |  |       mode_rainbow(void), | 
					
						
							|  |  |  |       mode_rainbow_cycle(void), | 
					
						
							|  |  |  |       mode_running_lights(void), | 
					
						
							| 
									
										
										
										
											2019-02-05 20:53:39 +00:00
										 |  |  |       mode_saw(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_twinkle(void), | 
					
						
							| 
									
										
										
										
											2019-01-31 22:42:48 +00:00
										 |  |  |       mode_dissolve(void), | 
					
						
							|  |  |  |       mode_dissolve_random(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_sparkle(void), | 
					
						
							|  |  |  |       mode_flash_sparkle(void), | 
					
						
							|  |  |  |       mode_hyper_sparkle(void), | 
					
						
							|  |  |  |       mode_multi_strobe(void), | 
					
						
							| 
									
										
										
										
											2018-03-18 22:16:53 +00:00
										 |  |  |       mode_android(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_chase_color(void), | 
					
						
							|  |  |  |       mode_chase_random(void), | 
					
						
							|  |  |  |       mode_chase_rainbow(void), | 
					
						
							|  |  |  |       mode_chase_flash(void), | 
					
						
							|  |  |  |       mode_chase_flash_random(void), | 
					
						
							|  |  |  |       mode_chase_rainbow_white(void), | 
					
						
							| 
									
										
										
										
											2018-01-10 22:57:58 +00:00
										 |  |  |       mode_colorful(void), | 
					
						
							| 
									
										
										
										
											2017-12-13 23:12:02 +00:00
										 |  |  |       mode_traffic_light(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_running_color(void), | 
					
						
							| 
									
										
										
										
											2021-01-04 10:11:36 +00:00
										 |  |  |       mode_aurora(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_running_random(void), | 
					
						
							|  |  |  |       mode_larson_scanner(void), | 
					
						
							|  |  |  |       mode_comet(void), | 
					
						
							|  |  |  |       mode_fireworks(void), | 
					
						
							| 
									
										
										
										
											2019-02-11 22:49:04 +00:00
										 |  |  |       mode_rain(void), | 
					
						
							| 
									
										
										
										
											2021-02-09 23:37:05 +00:00
										 |  |  |       mode_tetrix(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       mode_halloween(void), | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  |       mode_fire_flicker(void), | 
					
						
							| 
									
										
										
										
											2018-03-18 22:16:53 +00:00
										 |  |  |       mode_gradient(void), | 
					
						
							|  |  |  |       mode_loading(void), | 
					
						
							| 
									
										
										
										
											2019-12-04 11:15:12 +00:00
										 |  |  |       mode_police(void), | 
					
						
							|  |  |  |       mode_police_all(void), | 
					
						
							|  |  |  |       mode_two_dots(void), | 
					
						
							|  |  |  |       mode_two_areas(void), | 
					
						
							| 
									
										
										
										
											2021-04-10 22:50:14 +00:00
										 |  |  |       mode_running_dual(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       mode_bicolor_chase(void), | 
					
						
							|  |  |  |       mode_tricolor_chase(void), | 
					
						
							|  |  |  |       mode_tricolor_wipe(void), | 
					
						
							|  |  |  |       mode_tricolor_fade(void), | 
					
						
							| 
									
										
										
										
											2019-01-31 22:42:48 +00:00
										 |  |  |       mode_lightning(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       mode_icu(void), | 
					
						
							|  |  |  |       mode_multi_comet(void), | 
					
						
							|  |  |  |       mode_dual_larson_scanner(void), | 
					
						
							|  |  |  |       mode_random_chase(void), | 
					
						
							|  |  |  |       mode_oscillate(void), | 
					
						
							|  |  |  |       mode_fire_2012(void), | 
					
						
							| 
									
										
										
										
											2018-09-08 14:21:44 +00:00
										 |  |  |       mode_pride_2015(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       mode_bpm(void), | 
					
						
							|  |  |  |       mode_juggle(void), | 
					
						
							|  |  |  |       mode_palette(void), | 
					
						
							| 
									
										
										
										
											2018-09-08 14:21:44 +00:00
										 |  |  |       mode_colorwaves(void), | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       mode_fillnoise8(void), | 
					
						
							|  |  |  |       mode_noise16_1(void), | 
					
						
							|  |  |  |       mode_noise16_2(void), | 
					
						
							|  |  |  |       mode_noise16_3(void), | 
					
						
							|  |  |  |       mode_noise16_4(void), | 
					
						
							| 
									
										
										
										
											2018-11-04 19:14:23 +00:00
										 |  |  |       mode_colortwinkle(void), | 
					
						
							| 
									
										
										
										
											2018-11-07 19:22:05 +00:00
										 |  |  |       mode_lake(void), | 
					
						
							| 
									
										
										
										
											2018-11-20 20:31:07 +00:00
										 |  |  |       mode_meteor(void), | 
					
						
							| 
									
										
										
										
											2018-12-02 01:49:05 +00:00
										 |  |  |       mode_meteor_smooth(void), | 
					
						
							|  |  |  |       mode_railway(void), | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  |       mode_ripple(void), | 
					
						
							| 
									
										
										
										
											2019-10-01 23:17:26 +00:00
										 |  |  |       mode_twinklefox(void), | 
					
						
							|  |  |  |       mode_twinklecat(void), | 
					
						
							| 
									
										
										
										
											2019-11-18 11:29:36 +00:00
										 |  |  |       mode_halloween_eyes(void), | 
					
						
							| 
									
										
										
										
											2019-11-22 18:19:48 +00:00
										 |  |  |       mode_static_pattern(void), | 
					
						
							| 
									
										
										
										
											2020-05-06 13:28:16 +00:00
										 |  |  |       mode_tri_static_pattern(void), | 
					
						
							| 
									
										
										
										
											2019-12-04 11:15:12 +00:00
										 |  |  |       mode_spots(void), | 
					
						
							| 
									
										
										
										
											2019-12-10 19:06:00 +00:00
										 |  |  |       mode_spots_fade(void), | 
					
						
							| 
									
										
										
										
											2019-12-06 00:44:45 +00:00
										 |  |  |       mode_glitter(void), | 
					
						
							| 
									
										
										
										
											2019-12-27 19:58:06 +00:00
										 |  |  |       mode_candle(void), | 
					
						
							| 
									
										
										
										
											2020-01-03 11:58:31 +00:00
										 |  |  |       mode_starburst(void), | 
					
						
							| 
									
										
										
										
											2020-01-03 22:19:40 +00:00
										 |  |  |       mode_exploding_fireworks(void), | 
					
						
							| 
									
										
										
										
											2020-01-05 20:26:14 +00:00
										 |  |  |       mode_bouncing_balls(void), | 
					
						
							| 
									
										
										
										
											2019-12-10 19:34:59 +00:00
										 |  |  |       mode_sinelon(void), | 
					
						
							| 
									
										
										
										
											2019-12-24 19:41:03 +00:00
										 |  |  |       mode_sinelon_dual(void), | 
					
						
							|  |  |  |       mode_sinelon_rainbow(void), | 
					
						
							| 
									
										
										
										
											2020-01-12 14:04:49 +00:00
										 |  |  |       mode_popcorn(void), | 
					
						
							| 
									
										
										
										
											2020-01-18 23:06:17 +00:00
										 |  |  |       mode_drip(void), | 
					
						
							| 
									
										
										
										
											2020-01-19 12:51:49 +00:00
										 |  |  |       mode_plasma(void), | 
					
						
							| 
									
										
										
										
											2020-02-15 19:07:15 +00:00
										 |  |  |       mode_percent(void), | 
					
						
							| 
									
										
										
										
											2020-02-17 10:12:39 +00:00
										 |  |  |       mode_ripple_rainbow(void), | 
					
						
							| 
									
										
										
										
											2020-03-25 10:17:45 +00:00
										 |  |  |       mode_heartbeat(void), | 
					
						
							| 
									
										
										
										
											2020-04-21 22:51:00 +00:00
										 |  |  |       mode_pacifica(void), | 
					
						
							| 
									
										
										
										
											2020-05-06 13:28:16 +00:00
										 |  |  |       mode_candle_multi(void), | 
					
						
							| 
									
										
										
										
											2020-06-05 22:57:34 +00:00
										 |  |  |       mode_solid_glitter(void), | 
					
						
							|  |  |  |       mode_sunrise(void), | 
					
						
							|  |  |  |       mode_phased(void), | 
					
						
							|  |  |  |       mode_twinkleup(void), | 
					
						
							|  |  |  |       mode_noisepal(void), | 
					
						
							|  |  |  |       mode_sinewave(void), | 
					
						
							|  |  |  |       mode_phased_noise(void), | 
					
						
							| 
									
										
										
										
											2020-06-22 10:30:31 +00:00
										 |  |  |       mode_flow(void), | 
					
						
							| 
									
										
										
										
											2020-08-22 18:54:59 +00:00
										 |  |  |       mode_chunchun(void), | 
					
						
							| 
									
										
										
										
											2020-09-26 23:58:21 +00:00
										 |  |  |       mode_dancing_shadows(void), | 
					
						
							| 
									
										
										
										
											2020-12-07 07:33:08 +00:00
										 |  |  |       mode_washing_machine(void), | 
					
						
							| 
									
										
										
										
											2020-12-15 12:35:50 +00:00
										 |  |  |       mode_candy_cane(void), | 
					
						
							| 
									
										
										
										
											2020-12-22 12:15:57 +00:00
										 |  |  |       mode_blends(void), | 
					
						
							| 
									
										
										
										
											2020-12-22 15:26:19 +00:00
										 |  |  |       mode_tv_simulator(void), | 
					
						
							|  |  |  |       mode_dynamic_smooth(void); | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   private: | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  |     uint32_t crgb_to_col(CRGB fastled); | 
					
						
							|  |  |  |     CRGB col_to_crgb(uint32_t); | 
					
						
							| 
									
										
										
										
											2019-02-09 15:37:20 +00:00
										 |  |  |     CRGBPalette16 currentPalette; | 
					
						
							|  |  |  |     CRGBPalette16 targetPalette; | 
					
						
							| 
									
										
										
										
											2019-10-01 23:17:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-24 19:23:32 +00:00
										 |  |  |     uint16_t _length, _virtualSegmentLength; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     uint16_t _rand16seed; | 
					
						
							|  |  |  |     uint8_t _brightness; | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |     uint16_t _usedSegmentData = 0; | 
					
						
							|  |  |  |     uint16_t _transitionDur = 750; | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-05 00:33:26 +00:00
										 |  |  |     uint16_t _cumulativeFps = 2; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-25 01:19:12 +00:00
										 |  |  |     void load_gradient_palette(uint8_t); | 
					
						
							| 
									
										
										
										
											2018-09-06 00:05:56 +00:00
										 |  |  |     void handle_palette(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-11 22:49:04 +00:00
										 |  |  |     bool | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |       _triggered; | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-02 21:10:59 +00:00
										 |  |  |     show_callback _callback = nullptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  |     // mode helper functions
 | 
					
						
							|  |  |  |     uint16_t | 
					
						
							|  |  |  |       blink(uint32_t, uint32_t, bool strobe, bool), | 
					
						
							| 
									
										
										
										
											2020-04-21 22:51:00 +00:00
										 |  |  |       candle(bool), | 
					
						
							| 
									
										
										
										
											2019-10-03 18:57:22 +00:00
										 |  |  |       color_wipe(bool, bool), | 
					
						
							| 
									
										
										
										
											2020-12-22 15:26:19 +00:00
										 |  |  |       dynamic(bool), | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  |       scan(bool), | 
					
						
							| 
									
										
										
										
											2020-02-18 20:28:46 +00:00
										 |  |  |       running_base(bool,bool), | 
					
						
							| 
									
										
										
										
											2019-12-23 17:38:54 +00:00
										 |  |  |       larson_scanner(bool), | 
					
						
							| 
									
										
										
										
											2019-12-24 19:41:03 +00:00
										 |  |  |       sinelon_base(bool,bool), | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  |       dissolve(uint32_t), | 
					
						
							|  |  |  |       chase(uint32_t, uint32_t, uint32_t, bool), | 
					
						
							|  |  |  |       gradient_base(bool), | 
					
						
							| 
									
										
										
										
											2020-02-15 19:07:15 +00:00
										 |  |  |       ripple_base(bool), | 
					
						
							| 
									
										
										
										
											2020-02-18 17:52:47 +00:00
										 |  |  |       police_base(uint32_t, uint32_t, bool), | 
					
						
							| 
									
										
										
										
											2021-02-24 19:23:32 +00:00
										 |  |  |       running(uint32_t, uint32_t, bool theatre=false), | 
					
						
							| 
									
										
										
										
											2019-12-04 11:15:12 +00:00
										 |  |  |       tricolor_chase(uint32_t, uint32_t), | 
					
						
							|  |  |  |       twinklefox_base(bool), | 
					
						
							| 
									
										
										
										
											2020-06-05 22:57:34 +00:00
										 |  |  |       spots_base(uint16_t), | 
					
						
							|  |  |  |       phased_base(uint8_t); | 
					
						
							| 
									
										
										
										
											2019-08-30 13:39:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-01 23:17:26 +00:00
										 |  |  |     CRGB twinklefox_one_twinkle(uint32_t ms, uint8_t salt, bool cat); | 
					
						
							| 
									
										
										
										
											2020-03-25 10:17:45 +00:00
										 |  |  |     CRGB pacifica_one_layer(uint16_t i, CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff); | 
					
						
							| 
									
										
										
										
											2020-08-22 18:54:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |     void | 
					
						
							|  |  |  |       blendPixelColor(uint16_t n, uint32_t color, uint8_t blend), | 
					
						
							| 
									
										
										
										
											2021-04-04 11:54:34 +00:00
										 |  |  |       startTransition(uint8_t oldBri, uint32_t oldCol, uint16_t dur, uint8_t segn, uint8_t slot); | 
					
						
							| 
									
										
										
										
											2021-02-13 00:02:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     uint16_t* customMappingTable = nullptr; | 
					
						
							|  |  |  |     uint16_t  customMappingSize  = 0; | 
					
						
							| 
									
										
										
										
											2018-09-06 00:05:56 +00:00
										 |  |  |      | 
					
						
							|  |  |  |     uint32_t _lastPaletteChange = 0; | 
					
						
							| 
									
										
										
										
											2019-03-05 09:59:15 +00:00
										 |  |  |     uint32_t _lastShow = 0; | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     uint32_t _colors_t[3]; | 
					
						
							|  |  |  |     uint8_t _bri_t; | 
					
						
							| 
									
										
										
										
											2018-09-06 00:05:56 +00:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     uint8_t _segment_index = 0; | 
					
						
							| 
									
										
										
										
											2018-09-06 00:05:56 +00:00
										 |  |  |     uint8_t _segment_index_palette_last = 99; | 
					
						
							| 
									
										
										
										
											2020-01-14 09:57:23 +00:00
										 |  |  |     segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 24 bytes per element
 | 
					
						
							| 
									
										
										
										
											2021-06-29 22:45:36 +00:00
										 |  |  |       // start, stop, offset, speed, intensity, palette, mode, options, grouping, spacing, opacity (unused), color[]
 | 
					
						
							|  |  |  |       {0, 7, 0, DEFAULT_SPEED, 128, 0, DEFAULT_MODE, NO_OPTIONS, 1, 0, 255, {DEFAULT_COLOR}} | 
					
						
							| 
									
										
										
										
											2018-09-04 13:51:38 +00:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2019-12-31 10:11:05 +00:00
										 |  |  |     segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 28 bytes per element
 | 
					
						
							|  |  |  |     friend class Segment_runtime; | 
					
						
							| 
									
										
										
										
											2020-01-14 09:57:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-08 23:35:48 +00:00
										 |  |  |     ColorTransition transitions[MAX_NUM_TRANSITIONS]; //12 bytes per element
 | 
					
						
							|  |  |  |     friend class ColorTransition; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     uint16_t | 
					
						
							|  |  |  |       realPixelIndex(uint16_t i), | 
					
						
							|  |  |  |       transitionProgress(uint8_t tNr); | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  | //10 names per line
 | 
					
						
							|  |  |  | const char JSON_mode_names[] PROGMEM = R"=====([ | 
					
						
							|  |  |  | "Solid","Blink","Breathe","Wipe","Wipe Random","Random Colors","Sweep","Dynamic","Colorloop","Rainbow", | 
					
						
							| 
									
										
										
										
											2019-12-23 12:06:14 +00:00
										 |  |  | "Scan","Scan Dual","Fade","Theater","Theater Rainbow","Running","Saw","Twinkle","Dissolve","Dissolve Rnd", | 
					
						
							| 
									
										
										
										
											2019-12-10 23:59:15 +00:00
										 |  |  | "Sparkle","Sparkle Dark","Sparkle+","Strobe","Strobe Rainbow","Strobe Mega","Blink Rainbow","Android","Chase","Chase Random", | 
					
						
							| 
									
										
										
										
											2021-01-04 10:11:36 +00:00
										 |  |  | "Chase Rainbow","Chase Flash","Chase Flash Rnd","Rainbow Runner","Colorful","Traffic Light","Sweep Random","Running 2","Aurora","Stream", | 
					
						
							| 
									
										
										
										
											2021-02-09 23:37:05 +00:00
										 |  |  | "Scanner","Lighthouse","Fireworks","Rain","Tetrix","Fire Flicker","Gradient","Loading","Police","Police All", | 
					
						
							| 
									
										
										
										
											2021-04-10 22:50:14 +00:00
										 |  |  | "Two Dots","Two Areas","Running Dual","Halloween","Tri Chase","Tri Wipe","Tri Fade","Lightning","ICU","Multi Comet", | 
					
						
							| 
									
										
										
										
											2019-12-31 10:13:40 +00:00
										 |  |  | "Scanner Dual","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise", | 
					
						
							| 
									
										
										
										
											2019-12-10 23:59:15 +00:00
										 |  |  | "Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple", | 
					
						
							| 
									
										
										
										
											2020-01-03 11:58:31 +00:00
										 |  |  | "Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle","Fireworks Starburst", | 
					
						
							| 
									
										
										
										
											2020-02-17 10:01:05 +00:00
										 |  |  | "Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent","Ripple Rainbow", | 
					
						
							| 
									
										
										
										
											2020-06-22 10:30:31 +00:00
										 |  |  | "Heartbeat","Pacifica","Candle Multi", "Solid Glitter","Sunrise","Phased","Twinkleup","Noise Pal", "Sine","Phased Noise", | 
					
						
							| 
									
										
										
										
											2020-12-22 15:26:19 +00:00
										 |  |  | "Flow","Chunchun","Dancing Shadows","Washing Machine","Candy Cane","Blends","TV Simulator","Dynamic Smooth" | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  | ])====="; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const char JSON_palette_names[] PROGMEM = R"=====([ | 
					
						
							| 
									
										
										
										
											2020-05-03 18:57:53 +00:00
										 |  |  | "Default","* Random Cycle","* Color 1","* Colors 1&2","* Color Gradient","* Colors Only","Party","Cloud","Lava","Ocean", | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  | "Forest","Rainbow","Rainbow Bands","Sunset","Rivendell","Breeze","Red & Blue","Yellowout","Analogous","Splash", | 
					
						
							|  |  |  | "Pastel","Sunset 2","Beech","Vintage","Departure","Landscape","Beach","Sherbet","Hult","Hult 64", | 
					
						
							|  |  |  | "Drywet","Jul","Grintage","Rewhi","Tertiary","Fire","Icefire","Cyane","Light Pink","Autumn", | 
					
						
							| 
									
										
										
										
											2019-12-13 00:23:07 +00:00
										 |  |  | "Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura", | 
					
						
							| 
									
										
										
										
											2021-08-12 19:58:51 +00:00
										 |  |  | "Aurora","Atlantica","C9 2","C9 New","Temperature","Aurora 2","Retro Clown","Candy","Toxy Reaf","Fairy Reaf", | 
					
						
							| 
									
										
										
										
											2021-08-25 16:17:03 +00:00
										 |  |  | "Semi Blue","Pink Candy","Red Reaf","Aqua Flash","Yelblu Hot","Lite Light","Red Flash","Blink Red","Red Shift","Red Tide", | 
					
						
							| 
									
										
										
										
											2021-08-12 19:58:51 +00:00
										 |  |  | "Candy2" | 
					
						
							| 
									
										
										
										
											2019-03-06 00:20:38 +00:00
										 |  |  | ])====="; | 
					
						
							| 
									
										
										
										
											2019-02-10 22:05:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-17 22:43:07 +00:00
										 |  |  | #endif
 |