2016-12-17 23:43:07 +01:00
|
|
|
/*
|
|
|
|
WS2812FX.h - Library for WS2812 LED effects.
|
|
|
|
Harm Aldick - 2016
|
|
|
|
www.aldick.org
|
|
|
|
LICENSE
|
|
|
|
The MIT License (MIT)
|
2018-09-04 15:51:38 +02:00
|
|
|
Copyright (c) 2016 Harm Aldick
|
2016-12-17 23:43:07 +01: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 16:37:20 +01:00
|
|
|
|
2018-09-04 15:51:38 +02:00
|
|
|
Modified for WLED
|
2016-12-17 23:43:07 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WS2812FX_h
|
|
|
|
#define WS2812FX_h
|
|
|
|
|
2020-02-20 00:45:09 +01:00
|
|
|
#include "const.h"
|
2018-11-09 17:00:36 +01:00
|
|
|
|
|
|
|
#define FASTLED_INTERNAL //remove annoying pragma messages
|
2020-08-25 17:23:17 +02:00
|
|
|
#define USE_GET_MILLISECOND_TIMER
|
2018-11-04 20:14:23 +01:00
|
|
|
#include "FastLED.h"
|
2016-12-17 23:43:07 +01:00
|
|
|
|
2018-11-16 19:59:00 +01:00
|
|
|
#define DEFAULT_BRIGHTNESS (uint8_t)127
|
2018-09-04 15:51:38 +02:00
|
|
|
#define DEFAULT_MODE (uint8_t)0
|
2018-11-16 19:59:00 +01:00
|
|
|
#define DEFAULT_SPEED (uint8_t)128
|
2020-09-07 21:01:10 +02:00
|
|
|
#define DEFAULT_INTENSITY (uint8_t)128
|
2019-03-05 10:59:15 +01:00
|
|
|
#define DEFAULT_COLOR (uint32_t)0xFFAA00
|
2022-05-08 10:50:48 +02:00
|
|
|
#define DEFAULT_C1 (uint8_t)128
|
|
|
|
#define DEFAULT_C2 (uint8_t)128
|
|
|
|
#define DEFAULT_C3 (uint8_t)128
|
2018-09-04 15:51:38 +02:00
|
|
|
|
2020-11-17 22:46:17 +01:00
|
|
|
#ifndef MIN
|
2020-03-26 10:18:19 +01:00
|
|
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
2020-11-17 22:46:17 +01:00
|
|
|
#endif
|
|
|
|
#ifndef MAX
|
2020-03-26 10:18:19 +01:00
|
|
|
#define MAX(a,b) ((a)>(b)?(a):(b))
|
2020-11-17 22:46:17 +01:00
|
|
|
#endif
|
2018-09-04 15:51:38 +02:00
|
|
|
|
2022-03-25 16:36:05 +01:00
|
|
|
//color mangling macros
|
|
|
|
#ifndef RGBW32
|
|
|
|
#define RGBW32(r,g,b,w) (uint32_t((byte(w) << 24) | (byte(r) << 16) | (byte(g) << 8) | (byte(b))))
|
|
|
|
#endif
|
|
|
|
|
2019-10-03 16:33:37 +02:00
|
|
|
/* Not used in all effects yet */
|
2019-10-04 01:21:18 +02:00
|
|
|
#define WLED_FPS 42
|
2021-12-25 01:30:27 +01:00
|
|
|
#define FRAMETIME_FIXED (1000/WLED_FPS)
|
|
|
|
#define FRAMETIME _frametime
|
2019-10-03 16:33:37 +02:00
|
|
|
|
2019-12-31 11:11:05 +01:00
|
|
|
/* each segment uses 52 bytes of SRAM memory, so if you're application fails because of
|
2018-09-04 15:51:38 +02:00
|
|
|
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
|
2019-12-31 11:11:05 +01:00
|
|
|
#ifdef ESP8266
|
2021-09-18 00:31:39 +02:00
|
|
|
#define MAX_NUM_SEGMENTS 16
|
2021-01-09 00:35:48 +01:00
|
|
|
/* How many color transitions can run at once */
|
|
|
|
#define MAX_NUM_TRANSITIONS 8
|
|
|
|
/* How much data bytes all segments combined may allocate */
|
2021-09-08 23:10:54 +02:00
|
|
|
#define MAX_SEGMENT_DATA 4096
|
2019-12-31 11:11:05 +01:00
|
|
|
#else
|
2021-09-08 23:10:54 +02:00
|
|
|
#ifndef MAX_NUM_SEGMENTS
|
|
|
|
#define MAX_NUM_SEGMENTS 32
|
|
|
|
#endif
|
|
|
|
#define MAX_NUM_TRANSITIONS 24
|
|
|
|
#define MAX_SEGMENT_DATA 20480
|
2019-12-31 11:11:05 +01:00
|
|
|
#endif
|
|
|
|
|
2021-09-20 21:22:50 +02:00
|
|
|
/* How much data bytes each segment should max allocate to leave enough space for other segments,
|
|
|
|
assuming each segment uses the same amount of data. 256 for ESP8266, 640 for ESP32. */
|
|
|
|
#define FAIR_DATA_PER_SEG (MAX_SEGMENT_DATA / MAX_NUM_SEGMENTS)
|
|
|
|
|
2021-12-25 01:30:27 +01:00
|
|
|
#define MIN_SHOW_DELAY (_frametime < 16 ? 8 : 15)
|
2020-02-24 19:36:25 +01:00
|
|
|
|
2019-05-22 00:23:09 +02:00
|
|
|
#define NUM_COLORS 3 /* number of colors per segment */
|
2018-09-04 15:51:38 +02:00
|
|
|
#define SEGMENT _segments[_segment_index]
|
2021-01-09 00:35:48 +01:00
|
|
|
#define SEGCOLOR(x) _colors_t[x]
|
2019-05-22 00:23:09 +02:00
|
|
|
#define SEGENV _segment_runtimes[_segment_index]
|
2020-01-14 10:57:23 +01:00
|
|
|
#define SEGLEN _virtualSegmentLength
|
2019-06-20 14:40:12 +02:00
|
|
|
#define SEGACT SEGMENT.stop
|
2021-05-30 00:08:24 +02:00
|
|
|
#define SPEED_FORMULA_L 5U + (50U*(255U - SEGMENT.speed))/SEGLEN
|
2016-12-17 23:43:07 +01:00
|
|
|
|
2018-09-04 15:51:38 +02: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 23:43:07 +01:00
|
|
|
|
2018-09-04 15:51:38 +02:00
|
|
|
// options
|
2019-03-05 10:59:15 +01:00
|
|
|
// bit 7: segment is in transition mode
|
2020-08-04 18:50:16 +02:00
|
|
|
// bits 4-6: TBD
|
|
|
|
// bit 3: mirror effect within segment
|
2020-04-23 23:52:33 +02:00
|
|
|
// bit 2: segment is on
|
2019-03-05 10:59:15 +01:00
|
|
|
// bit 1: reverse segment
|
|
|
|
// bit 0: segment is selected
|
2018-09-04 15:51:38 +02:00
|
|
|
#define NO_OPTIONS (uint8_t)0x00
|
2022-05-09 16:15:07 +02:00
|
|
|
#define TRANSPOSED (uint8_t)0x400 // rotated 90deg & reversed
|
|
|
|
#define REVERSE_Y_2D (uint8_t)0x200
|
|
|
|
#define MIRROR_Y_2D (uint8_t)0x100
|
|
|
|
#define TRANSITIONAL (uint8_t)0x080
|
|
|
|
#define MIRROR (uint8_t)0x008
|
|
|
|
#define SEGMENT_ON (uint8_t)0x004
|
|
|
|
#define REVERSE (uint8_t)0x002
|
|
|
|
#define SELECTED (uint8_t)0x001
|
2016-12-17 23:43:07 +01: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 15:51:38 +02:00
|
|
|
#define FX_MODE_COLOR_SWEEP 6
|
2018-04-01 00:08:50 +02:00
|
|
|
#define FX_MODE_DYNAMIC 7
|
2016-12-17 23:43:07 +01: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 21:53:39 +01:00
|
|
|
#define FX_MODE_SAW 16
|
|
|
|
#define FX_MODE_TWINKLE 17
|
2019-01-31 23:42:48 +01:00
|
|
|
#define FX_MODE_DISSOLVE 18
|
|
|
|
#define FX_MODE_DISSOLVE_RANDOM 19
|
2016-12-17 23:43:07 +01: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 23:16:53 +01:00
|
|
|
#define FX_MODE_ANDROID 27
|
2016-12-17 23:43:07 +01: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 23:57:58 +01:00
|
|
|
#define FX_MODE_COLORFUL 34
|
2017-12-14 00:12:02 +01:00
|
|
|
#define FX_MODE_TRAFFIC_LIGHT 35
|
2016-12-17 23:43:07 +01:00
|
|
|
#define FX_MODE_COLOR_SWEEP_RANDOM 36
|
|
|
|
#define FX_MODE_RUNNING_COLOR 37
|
2021-01-04 11:11:36 +01:00
|
|
|
#define FX_MODE_AURORA 38
|
2016-12-17 23:43:07 +01: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 23:49:04 +01:00
|
|
|
#define FX_MODE_RAIN 43
|
2021-12-07 11:03:41 +01:00
|
|
|
#define FX_MODE_TETRIX 44 //was Merry Christmas prior to 0.12.0 (use "Chase 2" with Red/Green)
|
2016-12-17 23:43:07 +01:00
|
|
|
#define FX_MODE_FIRE_FLICKER 45
|
2018-03-18 23:16:53 +01:00
|
|
|
#define FX_MODE_GRADIENT 46
|
|
|
|
#define FX_MODE_LOADING 47
|
2021-11-24 11:02:25 +01:00
|
|
|
#define FX_MODE_POLICE 48 // candidate for removal (after below three)
|
2021-12-07 11:03:41 +01:00
|
|
|
#define FX_MODE_FAIRY 49 //was Police All prior to 0.13.0-b6 (use "Two Dots" with Red/Blue and full intensity)
|
2019-12-04 12:15:12 +01:00
|
|
|
#define FX_MODE_TWO_DOTS 50
|
2021-12-07 11:03:41 +01:00
|
|
|
#define FX_MODE_FAIRYTWINKLE 51 //was Two Areas prior to 0.13.0-b6 (use "Two Dots" with full intensity)
|
2021-04-11 00:50:14 +02:00
|
|
|
#define FX_MODE_RUNNING_DUAL 52
|
2021-11-24 11:02:25 +01:00
|
|
|
#define FX_MODE_HALLOWEEN 53 // candidate for removal
|
2018-09-04 15:51:38 +02:00
|
|
|
#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-11 00:20:12 +02: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 16:21:44 +02: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 20:14:23 +01:00
|
|
|
#define FX_MODE_COLORTWINKLE 74
|
2018-11-07 20:22:05 +01:00
|
|
|
#define FX_MODE_LAKE 75
|
2018-11-20 21:31:07 +01:00
|
|
|
#define FX_MODE_METEOR 76
|
2018-12-02 02:49:05 +01:00
|
|
|
#define FX_MODE_METEOR_SMOOTH 77
|
|
|
|
#define FX_MODE_RAILWAY 78
|
2019-01-31 23:42:48 +01:00
|
|
|
#define FX_MODE_RIPPLE 79
|
2019-08-30 15:39:34 +02:00
|
|
|
#define FX_MODE_TWINKLEFOX 80
|
2019-10-02 01:17:26 +02:00
|
|
|
#define FX_MODE_TWINKLECAT 81
|
|
|
|
#define FX_MODE_HALLOWEEN_EYES 82
|
2019-11-18 12:29:36 +01:00
|
|
|
#define FX_MODE_STATIC_PATTERN 83
|
2019-11-29 18:53:01 +01:00
|
|
|
#define FX_MODE_TRI_STATIC_PATTERN 84
|
2019-12-04 12:15:12 +01:00
|
|
|
#define FX_MODE_SPOTS 85
|
|
|
|
#define FX_MODE_SPOTS_FADE 86
|
2019-12-06 01:44:45 +01:00
|
|
|
#define FX_MODE_GLITTER 87
|
|
|
|
#define FX_MODE_CANDLE 88
|
2019-12-28 15:43:55 +01:00
|
|
|
#define FX_MODE_STARBURST 89
|
2020-01-03 12:58:31 +01:00
|
|
|
#define FX_MODE_EXPLODING_FIREWORKS 90
|
2020-01-03 23:19:40 +01: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 15:04:49 +01:00
|
|
|
#define FX_MODE_DRIP 96
|
2020-01-19 00:06:17 +01:00
|
|
|
#define FX_MODE_PLASMA 97
|
2020-01-19 13:51:49 +01:00
|
|
|
#define FX_MODE_PERCENT 98
|
2020-02-15 20:07:15 +01:00
|
|
|
#define FX_MODE_RIPPLE_RAINBOW 99
|
2020-02-17 11:01:05 +01:00
|
|
|
#define FX_MODE_HEARTBEAT 100
|
2020-03-25 11:17:45 +01:00
|
|
|
#define FX_MODE_PACIFICA 101
|
2020-04-22 00:51:00 +02:00
|
|
|
#define FX_MODE_CANDLE_MULTI 102
|
2020-05-06 15:28:16 +02:00
|
|
|
#define FX_MODE_SOLID_GLITTER 103
|
2020-06-06 00:57:34 +02: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 12:30:31 +02:00
|
|
|
#define FX_MODE_CHUNCHUN 111
|
2020-08-22 20:54:59 +02:00
|
|
|
#define FX_MODE_DANCING_SHADOWS 112
|
2020-09-27 01:58:21 +02:00
|
|
|
#define FX_MODE_WASHING_MACHINE 113
|
2021-10-25 20:15:42 +02:00
|
|
|
#define FX_MODE_CANDY_CANE 114 // candidate for removal
|
2020-12-15 13:35:50 +01:00
|
|
|
#define FX_MODE_BLENDS 115
|
2020-12-22 13:15:57 +01:00
|
|
|
#define FX_MODE_TV_SIMULATOR 116
|
2020-12-22 16:26:19 +01:00
|
|
|
#define FX_MODE_DYNAMIC_SMOOTH 117
|
2022-06-15 17:21:32 +02:00
|
|
|
// new 2D effects
|
|
|
|
#define FX_MODE_SPACESHIPS 118
|
|
|
|
#define FX_MODE_CRAZYBEES 119
|
|
|
|
#define FX_MODE_GHOST_RIDER 120
|
|
|
|
#define FX_MODE_BLOBS 121
|
|
|
|
#define FX_MODE_SCROLL_TEXT 122
|
2022-06-21 22:49:45 +02:00
|
|
|
#define FX_MODE_DRIFT_ROSE 123
|
|
|
|
|
2022-06-15 17:21:32 +02:00
|
|
|
// WLED-SR effects
|
2022-06-21 22:49:45 +02:00
|
|
|
#ifndef USERMOD_AUDIOREACTIVE
|
|
|
|
|
|
|
|
#define FX_MODE_PERLINMOVE 53 // should be moved to 53
|
|
|
|
#define FX_MODE_FLOWSTRIPE 114 // should be moved to 114
|
|
|
|
#define FX_MODE_WAVESINS 48 // should be moved to 48
|
|
|
|
#define FX_MODE_2DBLACKHOLE 124 // non audio
|
|
|
|
#define FX_MODE_2DDNASPIRAL 125 // non audio
|
|
|
|
#define FX_MODE_2DHIPHOTIC 126 // non audio
|
|
|
|
#define FX_MODE_2DPLASMABALL 127 // non audio
|
|
|
|
#define FX_MODE_2DSINDOTS 128 // non audio
|
|
|
|
#define FX_MODE_PIXELWAVE 129 // audio enhanced
|
|
|
|
#define FX_MODE_JUGGLES 130 // audio enhanced
|
|
|
|
#define FX_MODE_MATRIPIX 131 // audio enhanced
|
|
|
|
#define FX_MODE_GRAVIMETER 132 // audio enhanced
|
|
|
|
#define FX_MODE_PLASMOID 133 // audio enhanced
|
|
|
|
#define FX_MODE_PUDDLES 134 // audio enhanced
|
|
|
|
#define FX_MODE_MIDNOISE 135 // audio enhanced
|
|
|
|
#define FX_MODE_NOISEMETER 136 // audio enhanced
|
|
|
|
#define FX_MODE_2DFRIZZLES 137 // non audio
|
|
|
|
#define FX_MODE_2DLISSAJOUS 138 // non audio
|
|
|
|
#define FX_MODE_2DPOLARLIGHTS 139 // non audio
|
|
|
|
#define FX_MODE_2DTARTAN 140 // non audio
|
|
|
|
#define FX_MODE_2DGAMEOFLIFE 141 // non audio
|
|
|
|
#define FX_MODE_2DJULIA 142 // non audio
|
|
|
|
#define FX_MODE_NOISEFIRE 143 // audio enhanced
|
|
|
|
#define FX_MODE_PUDDLEPEAK 144 // audio enhanced
|
|
|
|
#define FX_MODE_2DCOLOREDBURSTS 145 // non audio
|
|
|
|
#define FX_MODE_2DSUNRADIATION 146 // non audio
|
|
|
|
#define FX_MODE_2DNOISE 147 // non audio
|
|
|
|
#define FX_MODE_RIPPLEPEAK 148 // audio enhanced
|
|
|
|
#define FX_MODE_2DFIRENOISE 149 // non audio
|
|
|
|
#define FX_MODE_2DSQUAREDSWIRL 150 // non audio
|
|
|
|
#define FX_MODE_2DDNA 151 // non audio
|
|
|
|
#define FX_MODE_2DMATRIX 152 // non audio
|
|
|
|
#define FX_MODE_2DMETABALLS 153 // non audio
|
|
|
|
#define FX_MODE_2DPULSER 154 // non audio
|
|
|
|
#define FX_MODE_2DDRIFT 155 // non audio
|
|
|
|
#define FX_MODE_2DWAVERLY 156 // audio enhanced
|
|
|
|
#define FX_MODE_GRAVCENTER 157 // audio enhanced
|
|
|
|
#define FX_MODE_GRAVCENTRIC 158 // audio enhanced
|
|
|
|
#define FX_MODE_2DSWIRL 159 // audio enhanced
|
|
|
|
#define FX_MODE_2DAKEMI 160 // audio enhanced
|
|
|
|
|
|
|
|
#define MODE_COUNT 161
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define FX_MODE_PIXELS 128
|
|
|
|
#define FX_MODE_PIXELWAVE 129 // audio enhanced
|
|
|
|
#define FX_MODE_JUGGLES 130 // audio enhanced
|
|
|
|
#define FX_MODE_MATRIPIX 131 // audio enhanced
|
|
|
|
#define FX_MODE_GRAVIMETER 132 // audio enhanced
|
|
|
|
#define FX_MODE_PLASMOID 133 // audio enhanced
|
|
|
|
#define FX_MODE_PUDDLES 134 // audio enhanced
|
|
|
|
#define FX_MODE_MIDNOISE 135 // audio enhanced
|
|
|
|
#define FX_MODE_NOISEMETER 136 // audio enhanced
|
|
|
|
#define FX_MODE_FREQWAVE 137
|
|
|
|
#define FX_MODE_FREQMATRIX 138
|
|
|
|
#define FX_MODE_2DGEQ 139
|
|
|
|
#define FX_MODE_WATERFALL 140
|
|
|
|
#define FX_MODE_FREQPIXELS 141
|
|
|
|
#define FX_MODE_BINMAP 142
|
|
|
|
#define FX_MODE_NOISEFIRE 143 // audio enhanced
|
|
|
|
#define FX_MODE_PUDDLEPEAK 144 // audio enhanced
|
|
|
|
#define FX_MODE_NOISEMOVE 145
|
|
|
|
#define FX_MODE_2DNOISE 146 // non audio
|
|
|
|
#define FX_MODE_PERLINMOVE 147 // should be moved to 53
|
|
|
|
#define FX_MODE_RIPPLEPEAK 148 // audio enhanced
|
|
|
|
#define FX_MODE_2DFIRENOISE 149 // non audio
|
|
|
|
#define FX_MODE_2DSQUAREDSWIRL 150 // non audio
|
|
|
|
//#define FX_MODE_2DFIRE2012 151 // implemented in native Fire2012
|
|
|
|
#define FX_MODE_2DDNA 152 // non audio
|
|
|
|
#define FX_MODE_2DMATRIX 153 // non audio
|
|
|
|
#define FX_MODE_2DMETABALLS 154 // non audio
|
|
|
|
#define FX_MODE_FREQMAP 155
|
|
|
|
#define FX_MODE_GRAVCENTER 156 // audio enhanced
|
|
|
|
#define FX_MODE_GRAVCENTRIC 157 // audio enhanced
|
|
|
|
#define FX_MODE_GRAVFREQ 158
|
|
|
|
#define FX_MODE_DJLIGHT 159
|
|
|
|
#define FX_MODE_2DFUNKYPLANK 160
|
2022-07-03 22:55:37 +02:00
|
|
|
//#define FX_MODE_2DCENTERBARS 161 // obsolete by X & Y mirroring
|
2022-06-21 22:49:45 +02:00
|
|
|
#define FX_MODE_2DPULSER 162 // non audio
|
|
|
|
#define FX_MODE_BLURZ 163
|
|
|
|
#define FX_MODE_2DDRIFT 164 // non audio
|
|
|
|
#define FX_MODE_2DWAVERLY 165 // audio enhanced
|
|
|
|
#define FX_MODE_2DSUNRADIATION 166 // non audio
|
|
|
|
#define FX_MODE_2DCOLOREDBURSTS 167 // non audio
|
|
|
|
#define FX_MODE_2DJULIA 168 // non audio
|
|
|
|
#define FX_MODE_2DPOOLNOISE 169 // reserved in JSON_mode_names
|
|
|
|
#define FX_MODE_2DTWISTER 170 // reserved in JSON_mode_names
|
|
|
|
#define FX_MODE_2DCAELEMENTATY 171 // reserved in JSON_mode_names
|
|
|
|
#define FX_MODE_2DGAMEOFLIFE 172 // non audio
|
|
|
|
#define FX_MODE_2DTARTAN 173 // non audio
|
|
|
|
#define FX_MODE_2DPOLARLIGHTS 174 // non audio
|
|
|
|
#define FX_MODE_2DSWIRL 175 // audio enhanced
|
|
|
|
#define FX_MODE_2DLISSAJOUS 176 // non audio
|
|
|
|
#define FX_MODE_2DFRIZZLES 177 // non audio
|
|
|
|
#define FX_MODE_2DPLASMABALL 178 // non audio
|
|
|
|
#define FX_MODE_FLOWSTRIPE 179 // should be moved to 114
|
|
|
|
#define FX_MODE_2DHIPHOTIC 180 // non audio
|
|
|
|
#define FX_MODE_2DSINDOTS 181 // non audio
|
|
|
|
#define FX_MODE_2DDNASPIRAL 182 // non audio
|
|
|
|
#define FX_MODE_2DBLACKHOLE 183 // non audio
|
|
|
|
#define FX_MODE_WAVESINS 184 // should be moved to 48
|
|
|
|
#define FX_MODE_ROCKTAVES 185
|
|
|
|
#define FX_MODE_2DAKEMI 186 // audio enhanced
|
|
|
|
//#define FX_MODE_CUSTOMEFFECT 187 //WLEDSR Custom Effects
|
|
|
|
|
|
|
|
#define MODE_COUNT 187
|
|
|
|
#endif
|
2018-01-09 23:13:29 +01:00
|
|
|
|
|
|
|
|
2018-04-13 00:28:29 +02:00
|
|
|
class WS2812FX {
|
2018-09-04 15:51:38 +02:00
|
|
|
typedef uint16_t (WS2812FX::*mode_ptr)(void);
|
2020-01-02 22:10:59 +01:00
|
|
|
|
|
|
|
// pre show callback
|
|
|
|
typedef void (*show_callback) (void);
|
2021-01-09 00:35:48 +01:00
|
|
|
|
|
|
|
static WS2812FX* instance;
|
2018-09-04 15:51:38 +02:00
|
|
|
|
2016-12-17 23:43:07 +01:00
|
|
|
public:
|
2022-05-08 10:50:48 +02:00
|
|
|
|
|
|
|
// segment parameters
|
|
|
|
typedef struct Segment { // 35 (36 in memory) bytes
|
|
|
|
uint16_t start; // start index / start X coordinate 2D (left)
|
|
|
|
uint16_t stop; // stop index / stop X coordinate 2D (right); segment is invalid if stop == 0
|
2021-06-30 00:45:36 +02:00
|
|
|
uint16_t offset;
|
2021-11-27 01:33:48 +01:00
|
|
|
uint8_t speed;
|
|
|
|
uint8_t intensity;
|
|
|
|
uint8_t palette;
|
|
|
|
uint8_t mode;
|
2022-05-08 10:50:48 +02:00
|
|
|
uint16_t options; //bit pattern: msb first: [transposed mirrorY reverseY] transitional (tbd) paused needspixelstate mirrored on reverse selected
|
2021-11-27 01:33:48 +01:00
|
|
|
uint8_t grouping, spacing;
|
|
|
|
uint8_t opacity;
|
2018-09-04 15:51:38 +02:00
|
|
|
uint32_t colors[NUM_COLORS];
|
2021-11-27 01:33:48 +01:00
|
|
|
uint8_t cct; //0==1900K, 255==10091K
|
2022-03-05 01:05:26 +01:00
|
|
|
uint8_t _capabilities;
|
2022-05-21 13:19:11 +02:00
|
|
|
uint8_t custom1, custom2, custom3; // custom FX parameters
|
2022-05-08 10:50:48 +02:00
|
|
|
uint16_t startY; // start Y coodrinate 2D (top)
|
|
|
|
uint16_t stopY; // stop Y coordinate 2D (bottom)
|
2021-09-08 23:10:54 +02:00
|
|
|
char *name;
|
2022-05-08 10:50:48 +02:00
|
|
|
inline bool getOption(uint8_t n) { return ((options >> n) & 0x01); }
|
|
|
|
inline bool isSelected() { return getOption(0); }
|
|
|
|
inline bool isActive() { return stop > start; }
|
2022-05-30 22:21:13 +02:00
|
|
|
inline uint16_t width() { return stop - start; }
|
|
|
|
inline uint16_t height() { return stopY - startY; }
|
2022-05-08 10:50:48 +02:00
|
|
|
inline uint16_t length() { return width(); }
|
|
|
|
inline uint16_t groupLength() { return grouping + spacing; }
|
|
|
|
inline uint8_t getLightCapabilities() { return _capabilities; }
|
2021-01-09 00:35:48 +01: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;
|
2021-11-27 01:33:48 +01:00
|
|
|
uint8_t b = (slot == 1) ? cct : opacity;
|
|
|
|
ColorTransition::startTransition(b, colors[slot], instance->_transitionDur, segn, slot);
|
2021-01-09 00:35:48 +01:00
|
|
|
colors[slot] = c; return true;
|
|
|
|
}
|
2021-11-27 01:33:48 +01:00
|
|
|
void setCCT(uint16_t k, uint8_t segn) {
|
|
|
|
if (segn >= MAX_NUM_SEGMENTS) return;
|
|
|
|
if (k > 255) { //kelvin value, convert to 0-255
|
|
|
|
if (k < 1900) k = 1900;
|
|
|
|
if (k > 10091) k = 10091;
|
|
|
|
k = (k - 1900) >> 5;
|
|
|
|
}
|
|
|
|
if (cct == k) return;
|
|
|
|
ColorTransition::startTransition(cct, colors[1], instance->_transitionDur, segn, 1);
|
|
|
|
cct = k;
|
|
|
|
}
|
2021-01-09 00:35:48 +01:00
|
|
|
void setOpacity(uint8_t o, uint8_t segn) {
|
|
|
|
if (segn >= MAX_NUM_SEGMENTS) return;
|
|
|
|
if (opacity == o) return;
|
2021-01-13 11:24:27 +01:00
|
|
|
ColorTransition::startTransition(opacity, colors[0], instance->_transitionDur, segn, 0);
|
2021-01-09 00:35:48 +01:00
|
|
|
opacity = o;
|
|
|
|
}
|
2022-05-08 10:50:48 +02:00
|
|
|
void setOption(uint8_t n, bool val, uint8_t segn = 255) {
|
2021-09-20 21:22:04 +02:00
|
|
|
bool prevOn = false;
|
2021-09-21 23:37:35 +02:00
|
|
|
if (n == SEG_OPTION_ON) {
|
|
|
|
prevOn = getOption(SEG_OPTION_ON);
|
|
|
|
if (!val && prevOn) { //fade off
|
|
|
|
ColorTransition::startTransition(opacity, colors[0], instance->_transitionDur, segn, 0);
|
|
|
|
}
|
|
|
|
}
|
2022-05-08 10:50:48 +02:00
|
|
|
if (val) options |= 0x01 << n;
|
|
|
|
else options &= ~(0x01 << n);
|
2021-09-21 23:37:35 +02:00
|
|
|
if (n == SEG_OPTION_ON && val && !prevOn) { //fade on
|
|
|
|
ColorTransition::startTransition(0, colors[0], instance->_transitionDur, segn, 0);
|
2021-09-20 21:22:04 +02:00
|
|
|
}
|
2019-03-06 01:20:38 +01:00
|
|
|
}
|
2022-05-21 13:19:11 +02:00
|
|
|
// 2D matrix
|
2022-05-08 10:50:48 +02:00
|
|
|
uint16_t virtualWidth() {
|
|
|
|
uint16_t groupLen = groupLength();
|
2022-05-30 22:21:13 +02:00
|
|
|
uint16_t vWidth = ((getOption(SEG_OPTION_TRANSPOSED) ? height() : width()) + groupLen - 1) / groupLen;
|
2022-05-11 09:37:38 +02:00
|
|
|
if (getOption(SEG_OPTION_MIRROR)) vWidth = (vWidth + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
2022-05-08 10:50:48 +02:00
|
|
|
return vWidth;
|
2019-05-22 00:23:09 +02:00
|
|
|
}
|
2022-05-08 10:50:48 +02:00
|
|
|
uint16_t virtualHeight() {
|
|
|
|
uint16_t groupLen = groupLength();
|
2022-05-30 22:21:13 +02:00
|
|
|
uint16_t vHeight = ((getOption(SEG_OPTION_TRANSPOSED) ? width() : height()) + groupLen - 1) / groupLen;
|
2022-05-11 09:37:38 +02:00
|
|
|
if (getOption(SEG_OPTION_MIRROR_Y)) vHeight = (vHeight + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
2022-05-08 10:50:48 +02:00
|
|
|
return vHeight;
|
2020-01-14 10:57:23 +01:00
|
|
|
}
|
2022-05-21 13:19:11 +02:00
|
|
|
// 1D strip
|
2022-05-08 10:50:48 +02:00
|
|
|
uint16_t virtualLength() {
|
2020-01-14 10:57:23 +01:00
|
|
|
uint16_t groupLen = groupLength();
|
2020-08-07 00:50:19 +02:00
|
|
|
uint16_t vLength = (length() + groupLen - 1) / groupLen;
|
2022-05-11 09:37:38 +02:00
|
|
|
if (getOption(SEG_OPTION_MIRROR)) vLength = (vLength + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
2020-08-04 18:50:16 +02:00
|
|
|
return vLength;
|
2019-12-05 07:59:05 +01:00
|
|
|
}
|
2022-02-10 16:09:16 +01:00
|
|
|
uint8_t differs(Segment& b);
|
2022-03-05 01:05:26 +01:00
|
|
|
void refreshLightCapabilities();
|
2018-09-04 15:51:38 +02:00
|
|
|
} segment;
|
|
|
|
|
|
|
|
// segment runtime parameters
|
2019-12-31 11:11:05 +01:00
|
|
|
typedef struct Segment_runtime { // 28 bytes
|
2021-09-08 23:10:54 +02: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 11:11:05 +01:00
|
|
|
byte* data = nullptr;
|
|
|
|
bool allocateData(uint16_t len){
|
|
|
|
if (data && _dataLen == len) return true; //already allocated
|
|
|
|
deallocateData();
|
2021-01-09 00:35:48 +01:00
|
|
|
if (WS2812FX::instance->_usedSegmentData + len > MAX_SEGMENT_DATA) return false; //not enough memory
|
2021-09-08 23:10:54 +02:00
|
|
|
// if possible use SPI RAM on ESP32
|
|
|
|
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
|
|
|
|
if (psramFound())
|
|
|
|
data = (byte*) ps_malloc(len);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
data = (byte*) malloc(len);
|
2019-12-31 11:11:05 +01:00
|
|
|
if (!data) return false; //allocation failed
|
2021-01-09 00:35:48 +01:00
|
|
|
WS2812FX::instance->_usedSegmentData += len;
|
2019-12-31 11:11:05 +01:00
|
|
|
_dataLen = len;
|
|
|
|
memset(data, 0, len);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
void deallocateData(){
|
2021-09-08 23:10:54 +02:00
|
|
|
free(data);
|
2019-12-31 11:11:05 +01:00
|
|
|
data = nullptr;
|
2021-01-09 00:35:48 +01:00
|
|
|
WS2812FX::instance->_usedSegmentData -= _dataLen;
|
2019-12-31 11:11:05 +01:00
|
|
|
_dataLen = 0;
|
|
|
|
}
|
2020-12-10 02:55:14 +01: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.
|
2022-02-09 08:43:35 +01:00
|
|
|
* Safe to call from interrupts and network requests.
|
2020-12-10 02:55:14 +01:00
|
|
|
*/
|
2022-02-09 08:43:35 +01:00
|
|
|
inline void markForReset() { _requiresReset = true; }
|
2019-12-31 11:11:05 +01:00
|
|
|
private:
|
|
|
|
uint16_t _dataLen = 0;
|
2020-12-10 02:55:14 +01:00
|
|
|
bool _requiresReset = false;
|
2018-09-04 15:51:38 +02:00
|
|
|
} segment_runtime;
|
2018-01-10 23:57:58 +01:00
|
|
|
|
2021-01-09 00:35:48 +01: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 11:24:27 +01: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-09-21 23:37:35 +02:00
|
|
|
if (!instance->_segments[segn].getOption(SEG_OPTION_ON)) return; //not if segment is off either
|
2021-01-09 00:35:48 +01: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
|
|
|
|
{
|
2021-09-21 23:37:35 +02:00
|
|
|
bool wasTurningOff = (oldBri == 0);
|
2021-11-27 01:33:48 +01:00
|
|
|
t.briOld = t.currentBri(wasTurningOff, slot);
|
2021-01-09 00:35:48 +01:00
|
|
|
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 11:24:27 +01: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-09 00:35:48 +01:00
|
|
|
}
|
|
|
|
uint16_t progress(bool allowEnd = false) { //transition progression between 0-65535
|
|
|
|
uint32_t timeNow = millis();
|
2021-01-13 11:24:27 +01: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-09 00:35:48 +01: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);
|
|
|
|
}
|
2021-11-27 01:33:48 +01:00
|
|
|
uint8_t currentBri(bool turningOff = false, uint8_t slot = 0) {
|
2021-01-09 00:35:48 +01:00
|
|
|
uint8_t segn = segment & 0x3F;
|
|
|
|
if (segn >= MAX_NUM_SEGMENTS) return 0;
|
2021-01-13 11:24:27 +01:00
|
|
|
uint8_t briNew = instance->_segments[segn].opacity;
|
2021-11-27 01:33:48 +01:00
|
|
|
if (slot == 0) {
|
|
|
|
if (!instance->_segments[segn].getOption(SEG_OPTION_ON) || turningOff) briNew = 0;
|
|
|
|
} else { //transition slot 1 brightness for CCT transition
|
|
|
|
briNew = instance->_segments[segn].cct;
|
|
|
|
}
|
2021-01-13 11:24:27 +01:00
|
|
|
uint32_t prog = progress() + 1;
|
|
|
|
return ((briNew * prog) + (briOld * (0x10000 - prog))) >> 16;
|
2021-01-09 00:35:48 +01:00
|
|
|
}
|
|
|
|
} color_transition;
|
|
|
|
|
2018-09-04 15:51:38 +02:00
|
|
|
WS2812FX() {
|
2021-01-09 00:35:48 +01:00
|
|
|
WS2812FX::instance = this;
|
2022-06-21 22:49:45 +02:00
|
|
|
setupEffectData();
|
2016-12-17 23:43:07 +01:00
|
|
|
_brightness = DEFAULT_BRIGHTNESS;
|
2019-02-09 16:37:20 +01:00
|
|
|
currentPalette = CRGBPalette16(CRGB::Black);
|
|
|
|
targetPalette = CloudColors_p;
|
2022-03-16 00:35:49 +01:00
|
|
|
ablMilliampsMax = ABL_MILLIAMPS_DEFAULT;
|
2018-12-04 00:58:06 +01:00
|
|
|
currentMilliamps = 0;
|
2019-10-18 12:19:52 +02:00
|
|
|
timebase = 0;
|
2019-06-20 14:40:12 +02:00
|
|
|
resetSegments();
|
2016-12-17 23:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-10-11 02:19:33 +02:00
|
|
|
finalizeInit(),
|
2016-12-17 23:43:07 +01:00
|
|
|
service(void),
|
2019-02-11 23:49:04 +01:00
|
|
|
blur(uint8_t),
|
2022-06-26 23:01:22 +02:00
|
|
|
fill(uint32_t c, uint8_t seg=255),
|
2018-09-04 15:51:38 +02:00
|
|
|
fade_out(uint8_t r),
|
2022-06-17 18:57:32 +02:00
|
|
|
fadeToBlackBy(uint8_t fadeBy),
|
2019-06-20 14:40:12 +02: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),
|
2022-02-23 19:20:07 +01:00
|
|
|
setCCT(uint16_t k),
|
2022-03-10 20:40:48 +01:00
|
|
|
setBrightness(uint8_t b, bool direct = false),
|
2018-09-04 15:51:38 +02:00
|
|
|
setRange(uint16_t i, uint16_t i2, uint32_t col),
|
2020-01-02 22:10:59 +01:00
|
|
|
setShowCallback(show_callback cb),
|
2021-01-09 00:35:48 +01:00
|
|
|
setTransition(uint16_t t),
|
2018-09-06 02:05:56 +02:00
|
|
|
setTransitionMode(bool t),
|
2020-11-04 11:04:40 +01:00
|
|
|
calcGammaTable(float),
|
2017-02-04 22:17:28 +01:00
|
|
|
trigger(void),
|
2022-05-08 10:50:48 +02:00
|
|
|
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0, uint16_t offset = UINT16_MAX, uint16_t startY=0, uint16_t stopY=0),
|
2022-02-20 22:24:11 +01:00
|
|
|
setMainSegmentId(uint8_t n),
|
2021-12-20 11:29:03 +01:00
|
|
|
restartRuntime(),
|
2018-09-04 15:51:38 +02:00
|
|
|
resetSegments(),
|
2022-02-10 16:09:16 +01:00
|
|
|
makeAutoSegments(bool forceReset = false),
|
2021-10-11 02:19:33 +02:00
|
|
|
fixInvalidSegments(),
|
2022-06-29 16:30:50 +02:00
|
|
|
setPixelColor(int n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
|
2022-06-17 18:57:32 +02:00
|
|
|
setPixelColor(float i, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0, bool aa = false),
|
2020-02-22 17:20:34 +01:00
|
|
|
show(void),
|
2021-12-25 01:30:27 +01:00
|
|
|
setTargetFps(uint8_t fps),
|
2021-09-08 23:10:54 +02:00
|
|
|
deserializeMap(uint8_t n=0);
|
2016-12-17 23:43:07 +01:00
|
|
|
|
2022-06-26 23:01:22 +02:00
|
|
|
void addEffect(uint8_t id, mode_ptr mode_fn, const char *mode_name) { if (id < _modeCount) { _mode[id] = mode_fn; _modeData[id] = mode_name;} }
|
2022-06-21 22:49:45 +02:00
|
|
|
void setupEffectData(void); // defined in FX.cpp
|
|
|
|
|
2022-06-23 17:42:02 +02:00
|
|
|
// outsmart the compiler :) by correctly overloading
|
2022-06-29 16:30:50 +02:00
|
|
|
inline void setPixelColor(int n, uint32_t c) {setPixelColor(n, byte(c>>16), byte(c>>8), byte(c), byte(c>>24));}
|
|
|
|
inline void setPixelColor(int n, CRGB c) {setPixelColor(n, c.red, c.green, c.blue);}
|
2022-06-23 17:42:02 +02:00
|
|
|
inline void setPixelColor(float i, uint32_t c, bool aa=true) {setPixelColor(i, byte(c>>16), byte(c>>8), byte(c), byte(c>>24), aa);}
|
|
|
|
inline void setPixelColor(float i, CRGB c, bool aa=true) {setPixelColor(i, c.red, c.green, c.blue, 0, aa);}
|
2022-03-25 16:36:05 +01:00
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
bool
|
2019-05-22 00:23:09 +02:00
|
|
|
gammaCorrectBri = false,
|
|
|
|
gammaCorrectCol = true,
|
2021-10-11 02:19:33 +02:00
|
|
|
checkSegmentAlignment(void),
|
2022-02-20 22:24:11 +01:00
|
|
|
hasRGBWBus(void),
|
|
|
|
hasCCTBus(void),
|
2020-12-10 05:29:53 +01:00
|
|
|
// return true if the strip is being sent pixel updates
|
|
|
|
isUpdating(void);
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2018-09-04 15:51:38 +02:00
|
|
|
uint8_t
|
2019-05-22 00:23:09 +02:00
|
|
|
paletteFade = 0,
|
|
|
|
paletteBlend = 0,
|
2019-11-12 19:33:34 +01:00
|
|
|
milliampsPerLed = 55,
|
2022-03-08 02:16:33 +01:00
|
|
|
cctBlending = 0,
|
2018-09-04 15:51:38 +02:00
|
|
|
getBrightness(void),
|
2019-02-22 22:53:33 +01:00
|
|
|
getPaletteCount(void),
|
2019-03-06 01:20:38 +01:00
|
|
|
getMaxSegments(void),
|
2021-09-20 21:22:50 +02:00
|
|
|
getActiveSegmentsNum(void),
|
2022-02-23 19:20:07 +01:00
|
|
|
getFirstSelectedSegId(void),
|
2019-11-30 19:17:25 +01:00
|
|
|
getMainSegmentId(void),
|
2022-02-20 22:24:11 +01:00
|
|
|
getLastActiveSegmentId(void),
|
|
|
|
getTargetFps(void),
|
2022-01-31 20:35:11 +01:00
|
|
|
setPixelSegment(uint8_t n),
|
2019-05-22 00:23:09 +02:00
|
|
|
gamma8(uint8_t),
|
2020-11-04 11:04:40 +01:00
|
|
|
gamma8_cal(uint8_t, float),
|
2018-09-04 15:51:38 +02:00
|
|
|
get_random_wheel_index(uint8_t);
|
2016-12-17 23:43:07 +01:00
|
|
|
|
2022-06-26 23:01:22 +02:00
|
|
|
inline uint8_t getModeCount() { return _modeCount; }
|
2022-03-10 11:20:39 +01:00
|
|
|
inline uint8_t sin_gap(uint16_t in) {
|
|
|
|
if (in & 0x100) return 0;
|
|
|
|
return sin8(in + 192); // correct phase shift of sine so that it starts and stops at 0
|
|
|
|
}
|
2022-03-10 22:36:09 +01:00
|
|
|
|
2020-09-27 14:42:14 +02:00
|
|
|
int8_t
|
|
|
|
tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec);
|
|
|
|
|
2019-08-30 15:39:34 +02:00
|
|
|
uint16_t
|
|
|
|
ablMilliampsMax,
|
2019-12-01 01:42:52 +01:00
|
|
|
currentMilliamps,
|
2021-02-05 01:33:26 +01:00
|
|
|
triwave16(uint16_t),
|
2021-10-11 02:19:53 +02:00
|
|
|
getLengthTotal(void),
|
|
|
|
getLengthPhysical(void),
|
2021-02-05 01:33:26 +01:00
|
|
|
getFps();
|
2019-08-30 15:39:34 +02:00
|
|
|
|
2022-06-17 18:57:32 +02:00
|
|
|
inline uint16_t getMinShowDelay() { return MIN_SHOW_DELAY; }
|
|
|
|
|
2016-12-17 23:43:07 +01:00
|
|
|
uint32_t
|
2020-08-25 17:23:17 +02:00
|
|
|
now,
|
2019-10-18 12:19:52 +02:00
|
|
|
timebase,
|
2018-09-04 15:51:38 +02:00
|
|
|
color_wheel(uint8_t),
|
2020-06-06 00:57:34 +02:00
|
|
|
color_from_palette(uint16_t, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri = 255),
|
2021-01-09 00:35:48 +01:00
|
|
|
color_blend(uint32_t,uint32_t,uint16_t,bool b16=false),
|
2022-06-17 18:57:32 +02:00
|
|
|
color_add(uint32_t,uint32_t),
|
2021-01-09 00:35:48 +01:00
|
|
|
currentColor(uint32_t colorNew, uint8_t tNr),
|
2019-05-22 00:23:09 +02:00
|
|
|
gamma32(uint32_t),
|
2019-11-18 20:43:27 +01:00
|
|
|
getLastShow(void),
|
2022-02-23 19:20:07 +01:00
|
|
|
getPixelColor(uint16_t);
|
2016-12-17 23:43:07 +01:00
|
|
|
|
2022-06-21 22:49:45 +02:00
|
|
|
const char *
|
2022-06-26 23:01:22 +02:00
|
|
|
getModeData(uint8_t id = 0) { return id<_modeCount ? _modeData[id] : nullptr; }
|
2022-06-21 22:49:45 +02:00
|
|
|
|
|
|
|
const char **
|
|
|
|
getModeDataSrc(void) { return _modeData; }
|
|
|
|
|
2022-02-20 22:24:11 +01:00
|
|
|
WS2812FX::Segment
|
|
|
|
&getSegment(uint8_t n),
|
2022-02-23 19:20:07 +01:00
|
|
|
&getFirstSelectedSeg(void),
|
2022-02-20 22:24:11 +01:00
|
|
|
&getMainSegment(void);
|
2018-09-04 15:51:38 +02:00
|
|
|
|
|
|
|
WS2812FX::Segment*
|
|
|
|
getSegments(void);
|
|
|
|
|
|
|
|
// builtin modes
|
|
|
|
uint16_t
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_static(void),
|
|
|
|
mode_blink(void),
|
2018-09-04 15:51:38 +02:00
|
|
|
mode_blink_rainbow(void),
|
|
|
|
mode_strobe(void),
|
|
|
|
mode_strobe_rainbow(void),
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_color_wipe(void),
|
2018-09-04 15:51:38 +02:00
|
|
|
mode_color_sweep(void),
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_color_wipe_random(void),
|
2018-09-04 15:51:38 +02:00
|
|
|
mode_color_sweep_random(void),
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_random_color(void),
|
2018-04-01 00:08:50 +02:00
|
|
|
mode_dynamic(void),
|
2016-12-17 23:43:07 +01: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 21:53:39 +01:00
|
|
|
mode_saw(void),
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_twinkle(void),
|
2019-01-31 23:42:48 +01:00
|
|
|
mode_dissolve(void),
|
|
|
|
mode_dissolve_random(void),
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_sparkle(void),
|
|
|
|
mode_flash_sparkle(void),
|
|
|
|
mode_hyper_sparkle(void),
|
|
|
|
mode_multi_strobe(void),
|
2018-03-18 23:16:53 +01:00
|
|
|
mode_android(void),
|
2016-12-17 23:43:07 +01: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 23:57:58 +01:00
|
|
|
mode_colorful(void),
|
2017-12-14 00:12:02 +01:00
|
|
|
mode_traffic_light(void),
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_running_color(void),
|
2021-01-04 11:11:36 +01:00
|
|
|
mode_aurora(void),
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_running_random(void),
|
|
|
|
mode_larson_scanner(void),
|
|
|
|
mode_comet(void),
|
|
|
|
mode_fireworks(void),
|
2019-02-11 23:49:04 +01:00
|
|
|
mode_rain(void),
|
2021-02-10 00:37:05 +01:00
|
|
|
mode_tetrix(void),
|
2018-09-04 15:51:38 +02:00
|
|
|
mode_halloween(void),
|
2016-12-17 23:43:07 +01:00
|
|
|
mode_fire_flicker(void),
|
2018-03-18 23:16:53 +01:00
|
|
|
mode_gradient(void),
|
|
|
|
mode_loading(void),
|
2019-12-04 12:15:12 +01:00
|
|
|
mode_police(void),
|
2021-12-07 11:03:41 +01:00
|
|
|
mode_fairy(void),
|
2019-12-04 12:15:12 +01:00
|
|
|
mode_two_dots(void),
|
2021-12-07 11:03:41 +01:00
|
|
|
mode_fairytwinkle(void),
|
2021-04-11 00:50:14 +02:00
|
|
|
mode_running_dual(void),
|
2018-09-04 15:51:38 +02:00
|
|
|
mode_bicolor_chase(void),
|
|
|
|
mode_tricolor_chase(void),
|
|
|
|
mode_tricolor_wipe(void),
|
|
|
|
mode_tricolor_fade(void),
|
2019-01-31 23:42:48 +01:00
|
|
|
mode_lightning(void),
|
2018-09-04 15:51:38 +02: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 16:21:44 +02:00
|
|
|
mode_pride_2015(void),
|
2018-09-04 15:51:38 +02:00
|
|
|
mode_bpm(void),
|
|
|
|
mode_juggle(void),
|
|
|
|
mode_palette(void),
|
2018-09-08 16:21:44 +02:00
|
|
|
mode_colorwaves(void),
|
2018-09-04 15:51:38 +02:00
|
|
|
mode_fillnoise8(void),
|
|
|
|
mode_noise16_1(void),
|
|
|
|
mode_noise16_2(void),
|
|
|
|
mode_noise16_3(void),
|
|
|
|
mode_noise16_4(void),
|
2018-11-04 20:14:23 +01:00
|
|
|
mode_colortwinkle(void),
|
2018-11-07 20:22:05 +01:00
|
|
|
mode_lake(void),
|
2018-11-20 21:31:07 +01:00
|
|
|
mode_meteor(void),
|
2018-12-02 02:49:05 +01:00
|
|
|
mode_meteor_smooth(void),
|
|
|
|
mode_railway(void),
|
2019-08-30 15:39:34 +02:00
|
|
|
mode_ripple(void),
|
2019-10-02 01:17:26 +02:00
|
|
|
mode_twinklefox(void),
|
|
|
|
mode_twinklecat(void),
|
2019-11-18 12:29:36 +01:00
|
|
|
mode_halloween_eyes(void),
|
2019-11-22 19:19:48 +01:00
|
|
|
mode_static_pattern(void),
|
2020-05-06 15:28:16 +02:00
|
|
|
mode_tri_static_pattern(void),
|
2019-12-04 12:15:12 +01:00
|
|
|
mode_spots(void),
|
2019-12-10 20:06:00 +01:00
|
|
|
mode_spots_fade(void),
|
2019-12-06 01:44:45 +01:00
|
|
|
mode_glitter(void),
|
2019-12-27 20:58:06 +01:00
|
|
|
mode_candle(void),
|
2020-01-03 12:58:31 +01:00
|
|
|
mode_starburst(void),
|
2020-01-03 23:19:40 +01:00
|
|
|
mode_exploding_fireworks(void),
|
2020-01-05 21:26:14 +01:00
|
|
|
mode_bouncing_balls(void),
|
2019-12-10 20:34:59 +01:00
|
|
|
mode_sinelon(void),
|
2019-12-24 20:41:03 +01:00
|
|
|
mode_sinelon_dual(void),
|
|
|
|
mode_sinelon_rainbow(void),
|
2020-01-12 15:04:49 +01:00
|
|
|
mode_popcorn(void),
|
2020-01-19 00:06:17 +01:00
|
|
|
mode_drip(void),
|
2020-01-19 13:51:49 +01:00
|
|
|
mode_plasma(void),
|
2020-02-15 20:07:15 +01:00
|
|
|
mode_percent(void),
|
2020-02-17 11:12:39 +01:00
|
|
|
mode_ripple_rainbow(void),
|
2020-02-18 21:28:46 +01:00
|
|
|
mode_heartbeat(void),
|
2020-04-22 00:51:00 +02:00
|
|
|
mode_pacifica(void),
|
2020-05-06 15:28:16 +02:00
|
|
|
mode_candle_multi(void),
|
2020-06-06 00:57:34 +02: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 12:30:31 +02:00
|
|
|
mode_flow(void),
|
2020-08-22 20:54:59 +02:00
|
|
|
mode_chunchun(void),
|
2020-09-27 01:58:21 +02:00
|
|
|
mode_dancing_shadows(void),
|
2020-12-07 08:33:08 +01:00
|
|
|
mode_washing_machine(void),
|
2020-12-15 13:35:50 +01:00
|
|
|
mode_candy_cane(void),
|
2020-12-22 13:15:57 +01:00
|
|
|
mode_blends(void),
|
2020-12-22 16:26:19 +01:00
|
|
|
mode_tv_simulator(void),
|
2022-06-14 12:06:51 +02:00
|
|
|
mode_dynamic_smooth(void),
|
2022-06-15 17:21:32 +02:00
|
|
|
// non-audio transfered from WLED-SR
|
2022-06-14 12:06:51 +02:00
|
|
|
mode_perlinmove(void),
|
|
|
|
mode_wavesins(void),
|
|
|
|
mode_FlowStripe(void);
|
2018-09-04 15:51:38 +02:00
|
|
|
|
2022-05-08 10:50:48 +02:00
|
|
|
// 2D support (panels)
|
|
|
|
bool
|
|
|
|
isMatrix = false;
|
|
|
|
|
|
|
|
uint8_t
|
|
|
|
hPanels = 1,
|
|
|
|
vPanels = 1;
|
|
|
|
|
|
|
|
uint16_t
|
|
|
|
panelH = 8,
|
|
|
|
panelW = 8,
|
|
|
|
matrixWidth = DEFAULT_LED_COUNT,
|
|
|
|
matrixHeight = 1;
|
|
|
|
|
|
|
|
#define WLED_MAX_PANELS 64
|
|
|
|
typedef struct panel_bitfield_t {
|
|
|
|
unsigned char
|
|
|
|
bottomStart : 1, // starts at bottom?
|
|
|
|
rightStart : 1, // starts on right?
|
|
|
|
vertical : 1, // is vertical?
|
|
|
|
serpentine : 1; // is serpentine?
|
|
|
|
} Panel;
|
|
|
|
Panel
|
|
|
|
matrix = {0,0,0,0},
|
|
|
|
panel[WLED_MAX_PANELS] = {{0,0,0,0}};
|
|
|
|
|
|
|
|
void
|
|
|
|
setUpMatrix(),
|
2022-06-29 16:30:50 +02:00
|
|
|
setPixelColorXY(int x, int y, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
|
2022-06-13 21:55:51 +02:00
|
|
|
setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = false),
|
2022-05-11 09:37:38 +02:00
|
|
|
blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend),
|
2022-06-28 23:32:29 +02:00
|
|
|
addPixelColorXY(uint16_t x, uint16_t y, uint32_t color),
|
2022-05-10 00:35:26 +02:00
|
|
|
blur1d(CRGB* leds, fract8 blur_amount),
|
2022-05-27 13:39:22 +02:00
|
|
|
blur1d(uint16_t i, bool vertical, fract8 blur_amount, CRGB* leds=nullptr), // 1D box blur (with weight)
|
2022-05-10 00:35:26 +02:00
|
|
|
blur2d(CRGB* leds, fract8 blur_amount),
|
|
|
|
blurRow(uint16_t row, fract8 blur_amount, CRGB* leds=nullptr),
|
|
|
|
blurCol(uint16_t col, fract8 blur_amount, CRGB* leds=nullptr),
|
2022-05-19 18:27:04 +02:00
|
|
|
moveX(CRGB *leds, int8_t delta),
|
|
|
|
moveY(CRGB *leds, int8_t delta),
|
2022-05-30 22:21:13 +02:00
|
|
|
move(uint8_t dir, uint8_t delta, CRGB *leds=nullptr),
|
2022-05-20 19:35:22 +02:00
|
|
|
fill_solid(CRGB* leds, CRGB c),
|
|
|
|
fill_circle(CRGB* leds, uint16_t cx, uint16_t cy, uint8_t radius, CRGB c),
|
2022-05-10 00:35:26 +02:00
|
|
|
fadeToBlackBy(CRGB* leds, uint8_t fadeBy),
|
|
|
|
nscale8(CRGB* leds, uint8_t scale),
|
2022-05-19 22:49:04 +02:00
|
|
|
setPixels(CRGB* leds),
|
2022-05-20 19:35:22 +02:00
|
|
|
drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c, CRGB *leds = nullptr),
|
2022-06-17 21:19:12 +02:00
|
|
|
drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB color, CRGB *leds = nullptr),
|
2022-05-20 19:35:22 +02:00
|
|
|
wu_pixel(CRGB *leds, uint32_t x, uint32_t y, CRGB c);
|
2022-05-08 10:50:48 +02:00
|
|
|
|
2022-06-23 17:42:02 +02:00
|
|
|
// outsmart the compiler :) by correctly overloading
|
2022-06-29 16:30:50 +02:00
|
|
|
inline void setPixelColorXY(int x, int y, uint32_t c) { setPixelColorXY(x, y, byte(c>>16), byte(c>>8), byte(c), byte(c>>24)); }
|
|
|
|
inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, c.red, c.green, c.blue, 0); }
|
2022-06-23 17:42:02 +02:00
|
|
|
inline void setPixelColorXY(float x, float y, uint32_t c, bool aa=true) { setPixelColorXY(x, y, byte(c>>16), byte(c>>8), byte(c), byte(c>>24), aa); }
|
|
|
|
inline void setPixelColorXY(float x, float y, CRGB c, bool aa=true) { setPixelColorXY(x, y, c.red, c.green, c.blue, 0, aa); }
|
2022-05-20 14:48:40 +02:00
|
|
|
inline void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c) { drawLine(x0, y0, x1, y1, CRGB(byte(c>>16), byte(c>>8), byte(c))); }
|
2022-06-17 21:19:12 +02:00
|
|
|
inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t c) { drawCharacter(chr, x, y, w, h, CRGB(byte(c>>16), byte(c>>8), byte(c))); }
|
2022-05-08 10:50:48 +02:00
|
|
|
|
|
|
|
uint16_t
|
2022-05-10 00:35:26 +02:00
|
|
|
XY(uint16_t, uint16_t),
|
2022-05-21 13:19:11 +02:00
|
|
|
get2DPixelIndex(uint16_t x, uint16_t y, uint8_t seg=255);
|
2022-05-08 10:50:48 +02:00
|
|
|
|
|
|
|
uint32_t
|
|
|
|
getPixelColorXY(uint16_t, uint16_t);
|
|
|
|
|
2022-06-13 21:29:08 +02:00
|
|
|
// end 2D support
|
|
|
|
|
|
|
|
// 2D modes
|
2022-06-17 18:57:32 +02:00
|
|
|
uint16_t
|
2022-06-13 21:29:08 +02:00
|
|
|
mode_2Dspaceships(void),
|
|
|
|
mode_2Dcrazybees(void),
|
|
|
|
mode_2Dghostrider(void),
|
|
|
|
mode_2Dfloatingblobs(void),
|
|
|
|
mode_2Dscrollingtext(void),
|
|
|
|
mode_2Ddriftrose(void);
|
|
|
|
|
2022-06-15 17:21:32 +02:00
|
|
|
// WLED-SR modes
|
2022-06-21 22:49:45 +02:00
|
|
|
#ifndef USERMOD_AUDIOREACTIVE
|
|
|
|
uint16_t
|
|
|
|
mode_2Dnoise(void),
|
2022-06-17 18:57:32 +02:00
|
|
|
mode_2Dfirenoise(void),
|
2022-06-21 22:49:45 +02:00
|
|
|
mode_2Dsquaredswirl(void),
|
|
|
|
mode_2Ddna(void),
|
|
|
|
mode_2Dmatrix(void),
|
|
|
|
mode_2Dmetaballs(void),
|
|
|
|
mode_2DPulser(void),
|
2022-06-17 18:57:32 +02:00
|
|
|
mode_2Dgameoflife(void),
|
2022-06-21 22:49:45 +02:00
|
|
|
mode_2Dtartan(void),
|
|
|
|
mode_2DPolarLights(void),
|
|
|
|
mode_2DSwirl(void),
|
|
|
|
mode_2DLissajous(void),
|
|
|
|
mode_2DFrizzles(void),
|
|
|
|
mode_2DPlasmaball(void),
|
2022-06-17 18:57:32 +02:00
|
|
|
mode_2DHiphotic(void),
|
2022-06-21 22:49:45 +02:00
|
|
|
mode_2DSindots(void),
|
|
|
|
mode_2DDNASpiral(void),
|
|
|
|
mode_2DBlackHole(void),
|
|
|
|
mode_2DSunradiation(void),
|
|
|
|
mode_2DWaverly(void),
|
|
|
|
mode_2DDrift(void),
|
|
|
|
mode_2DColoredBursts(void),
|
2022-06-17 18:57:32 +02:00
|
|
|
mode_2DJulia(void),
|
2022-06-21 22:49:45 +02:00
|
|
|
mode_gravimeter(void),
|
|
|
|
mode_gravcenter(void),
|
|
|
|
mode_gravcentric(void),
|
|
|
|
mode_juggles(void),
|
|
|
|
mode_matripix(void),
|
|
|
|
mode_midnoise(void),
|
|
|
|
mode_noisemeter(void),
|
|
|
|
mode_noisefire(void),
|
|
|
|
mode_pixelwave(void),
|
|
|
|
mode_plasmoid(void),
|
|
|
|
mode_puddles(void),
|
|
|
|
mode_puddlepeak(void),
|
|
|
|
mode_ripplepeak(void),
|
|
|
|
mode_2DAkemi(void);
|
|
|
|
#else
|
2022-06-13 21:29:08 +02:00
|
|
|
uint16_t
|
2022-06-14 18:16:18 +02:00
|
|
|
mode_pixels(void),
|
|
|
|
mode_pixelwave(void),
|
2022-06-15 17:21:32 +02:00
|
|
|
mode_juggles(void),
|
|
|
|
mode_matripix(void),
|
|
|
|
mode_gravimeter(void),
|
|
|
|
mode_plasmoid(void),
|
|
|
|
mode_puddles(void),
|
|
|
|
mode_midnoise(void),
|
2022-06-14 18:16:18 +02:00
|
|
|
mode_noisemeter(void),
|
2022-06-15 17:21:32 +02:00
|
|
|
mode_freqwave(void),
|
|
|
|
mode_freqmatrix(void),
|
|
|
|
mode_2DGEQ(void),
|
|
|
|
mode_waterfall(void),
|
|
|
|
mode_freqpixels(void),
|
|
|
|
mode_binmap(void),
|
2022-06-14 18:16:18 +02:00
|
|
|
mode_noisefire(void),
|
2022-06-15 17:21:32 +02:00
|
|
|
mode_puddlepeak(void),
|
|
|
|
mode_noisemove(void),
|
|
|
|
mode_2Dnoise(void),
|
|
|
|
mode_ripplepeak(void),
|
|
|
|
mode_2Dfirenoise(void),
|
|
|
|
mode_2Dsquaredswirl(void),
|
|
|
|
mode_2Ddna(void),
|
2022-06-17 18:57:32 +02:00
|
|
|
mode_2Dmatrix(void),
|
|
|
|
mode_2Dmetaballs(void),
|
2022-06-15 17:21:32 +02:00
|
|
|
mode_freqmap(void),
|
|
|
|
mode_gravcenter(void),
|
|
|
|
mode_gravcentric(void),
|
|
|
|
mode_gravfreq(void),
|
|
|
|
mode_DJLight(void),
|
|
|
|
mode_2DFunkyPlank(void),
|
2022-06-17 18:57:32 +02:00
|
|
|
mode_2DPulser(void),
|
2022-06-15 17:21:32 +02:00
|
|
|
mode_blurz(void),
|
|
|
|
mode_2Dgameoflife(void),
|
|
|
|
mode_2Dtartan(void),
|
|
|
|
mode_2DPolarLights(void),
|
|
|
|
mode_2DSwirl(void),
|
|
|
|
mode_2DLissajous(void),
|
|
|
|
mode_2DFrizzles(void),
|
|
|
|
mode_2DPlasmaball(void),
|
|
|
|
mode_2DHiphotic(void),
|
2022-06-17 18:57:32 +02:00
|
|
|
mode_2DSindots(void),
|
2022-06-15 17:21:32 +02:00
|
|
|
mode_2DDNASpiral(void),
|
|
|
|
mode_2DBlackHole(void),
|
|
|
|
mode_rocktaves(void),
|
|
|
|
mode_2DAkemi(void),
|
2022-06-17 18:57:32 +02:00
|
|
|
mode_2DSunradiation(void),
|
|
|
|
mode_2DWaverly(void),
|
2022-06-15 17:21:32 +02:00
|
|
|
mode_2DDrift(void),
|
|
|
|
mode_2DColoredBursts(void),
|
|
|
|
mode_2DJulia(void),
|
|
|
|
mode_customEffect(void); //WLEDSR Custom Effects
|
2022-06-21 22:49:45 +02:00
|
|
|
#endif
|
2022-05-08 10:50:48 +02:00
|
|
|
|
2018-09-04 15:51:38 +02:00
|
|
|
private:
|
2019-08-30 15:39:34 +02:00
|
|
|
uint32_t crgb_to_col(CRGB fastled);
|
|
|
|
CRGB col_to_crgb(uint32_t);
|
2019-02-09 16:37:20 +01:00
|
|
|
CRGBPalette16 currentPalette;
|
|
|
|
CRGBPalette16 targetPalette;
|
2019-10-02 01:17:26 +02:00
|
|
|
|
2021-06-24 02:29:14 +02:00
|
|
|
uint16_t _length, _virtualSegmentLength;
|
2018-09-04 15:51:38 +02:00
|
|
|
uint16_t _rand16seed;
|
|
|
|
uint8_t _brightness;
|
2021-01-09 00:35:48 +01:00
|
|
|
uint16_t _usedSegmentData = 0;
|
|
|
|
uint16_t _transitionDur = 750;
|
2018-09-04 15:51:38 +02:00
|
|
|
|
2021-12-25 01:30:27 +01:00
|
|
|
uint8_t _targetFps = 42;
|
|
|
|
uint16_t _frametime = (1000/42);
|
2021-02-05 01:33:26 +01:00
|
|
|
uint16_t _cumulativeFps = 2;
|
|
|
|
|
2019-02-11 23:49:04 +01:00
|
|
|
bool
|
2022-02-04 13:28:00 +01:00
|
|
|
_isOffRefreshRequired = false, //periodic refresh is required for the strip to remain off.
|
|
|
|
_hasWhiteChannel = false,
|
2018-09-04 15:51:38 +02:00
|
|
|
_triggered;
|
2016-12-17 23:43:07 +01:00
|
|
|
|
2022-06-26 23:01:22 +02:00
|
|
|
uint8_t _modeCount = MODE_COUNT;
|
2022-07-03 22:55:37 +02:00
|
|
|
// TODO: allocate memory using new or malloc()
|
2018-09-04 15:51:38 +02:00
|
|
|
mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element
|
2022-07-03 22:55:37 +02:00
|
|
|
const char *_modeData[MODE_COUNT]; // mode (effect) name and its slider control data array
|
2016-12-17 23:43:07 +01:00
|
|
|
|
2020-01-02 22:10:59 +01:00
|
|
|
show_callback _callback = nullptr;
|
|
|
|
|
2019-08-30 15:39:34 +02:00
|
|
|
// mode helper functions
|
|
|
|
uint16_t
|
|
|
|
blink(uint32_t, uint32_t, bool strobe, bool),
|
2020-04-22 00:51:00 +02:00
|
|
|
candle(bool),
|
2019-10-03 20:57:22 +02:00
|
|
|
color_wipe(bool, bool),
|
2020-12-22 16:26:19 +01:00
|
|
|
dynamic(bool),
|
2019-08-30 15:39:34 +02:00
|
|
|
scan(bool),
|
2022-05-10 00:35:26 +02:00
|
|
|
fireworks_base(CRGB*),
|
2020-02-18 21:28:46 +01:00
|
|
|
running_base(bool,bool),
|
2019-12-23 18:38:54 +01:00
|
|
|
larson_scanner(bool),
|
2019-12-24 20:41:03 +01:00
|
|
|
sinelon_base(bool,bool),
|
2019-08-30 15:39:34 +02:00
|
|
|
dissolve(uint32_t),
|
|
|
|
chase(uint32_t, uint32_t, uint32_t, bool),
|
|
|
|
gradient_base(bool),
|
2020-02-15 20:07:15 +01:00
|
|
|
ripple_base(bool),
|
2021-12-07 11:03:41 +01:00
|
|
|
police_base(uint32_t, uint32_t),
|
2021-09-08 23:10:54 +02:00
|
|
|
running(uint32_t, uint32_t, bool theatre=false),
|
2019-12-04 12:15:12 +01:00
|
|
|
tricolor_chase(uint32_t, uint32_t),
|
|
|
|
twinklefox_base(bool),
|
2020-06-06 00:57:34 +02:00
|
|
|
spots_base(uint16_t),
|
|
|
|
phased_base(uint8_t);
|
2019-08-30 15:39:34 +02:00
|
|
|
|
2019-10-02 01:17:26 +02:00
|
|
|
CRGB twinklefox_one_twinkle(uint32_t ms, uint8_t salt, bool cat);
|
2020-03-25 11:17:45 +01: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 20:54:59 +02:00
|
|
|
|
2021-01-09 00:35:48 +01:00
|
|
|
void
|
|
|
|
blendPixelColor(uint16_t n, uint32_t color, uint8_t blend),
|
2021-10-11 02:19:53 +02:00
|
|
|
startTransition(uint8_t oldBri, uint32_t oldCol, uint16_t dur, uint8_t segn, uint8_t slot),
|
|
|
|
estimateCurrentAndLimitBri(void),
|
|
|
|
load_gradient_palette(uint8_t),
|
|
|
|
handle_palette(void);
|
2021-02-13 01:02:14 +01:00
|
|
|
|
|
|
|
uint16_t* customMappingTable = nullptr;
|
|
|
|
uint16_t customMappingSize = 0;
|
2018-09-06 02:05:56 +02:00
|
|
|
|
|
|
|
uint32_t _lastPaletteChange = 0;
|
2019-03-05 10:59:15 +01:00
|
|
|
uint32_t _lastShow = 0;
|
2021-01-09 00:35:48 +01:00
|
|
|
|
|
|
|
uint32_t _colors_t[3];
|
|
|
|
uint8_t _bri_t;
|
2022-03-05 01:05:26 +01:00
|
|
|
bool _no_rgb = false;
|
2018-09-06 02:05:56 +02:00
|
|
|
|
2018-09-04 15:51:38 +02:00
|
|
|
uint8_t _segment_index = 0;
|
2018-09-06 02:05:56 +02:00
|
|
|
uint8_t _segment_index_palette_last = 99;
|
2022-02-20 22:24:11 +01:00
|
|
|
uint8_t _mainSegment;
|
|
|
|
|
2022-05-08 10:50:48 +02:00
|
|
|
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 27 bytes per element
|
|
|
|
// start, stop, offset, speed, intensity, palette, mode, options, grouping, spacing, opacity (unused), color[], capabilities, custom 1, custom 2, custom 3
|
|
|
|
{0, 7, 0, DEFAULT_SPEED, DEFAULT_INTENSITY, 0, DEFAULT_MODE, NO_OPTIONS, 1, 0, 255, {DEFAULT_COLOR}, 0, DEFAULT_C1, DEFAULT_C2, DEFAULT_C3, 0, 1}
|
2018-09-04 15:51:38 +02:00
|
|
|
};
|
2019-12-31 11:11:05 +01:00
|
|
|
segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 28 bytes per element
|
|
|
|
friend class Segment_runtime;
|
2020-01-14 10:57:23 +01:00
|
|
|
|
2021-01-09 00:35:48 +01:00
|
|
|
ColorTransition transitions[MAX_NUM_TRANSITIONS]; //12 bytes per element
|
|
|
|
friend class ColorTransition;
|
2016-12-17 23:43:07 +01:00
|
|
|
|
2021-01-09 00:35:48 +01:00
|
|
|
uint16_t
|
|
|
|
transitionProgress(uint8_t tNr);
|
2022-02-04 13:28:00 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
inline bool hasWhiteChannel(void) {return _hasWhiteChannel;}
|
|
|
|
inline bool isOffRefreshRequired(void) {return _isOffRefreshRequired;}
|
2016-12-17 23:43:07 +01:00
|
|
|
};
|
2019-02-10 23:05:06 +01:00
|
|
|
|
2021-12-28 18:09:52 +01:00
|
|
|
extern const char JSON_mode_names[];
|
|
|
|
extern const char JSON_palette_names[];
|
|
|
|
|
2016-12-17 23:43:07 +01:00
|
|
|
#endif
|