From 413c83b4cf8daa2b39505f04dd5e85a7f10201b1 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Wed, 13 Feb 2019 22:27:19 +0100 Subject: [PATCH] no message --- LED-Mesh.ino | 132 + libraries/FastLED/FastLED.cpp | 272 ++ libraries/FastLED/FastLED.h | 584 +++++ libraries/FastLED/LICENSE | 20 + libraries/FastLED/PORTING.md | 29 + libraries/FastLED/README.md | 90 + libraries/FastLED/bitswap.cpp | 28 + libraries/FastLED/bitswap.h | 276 ++ libraries/FastLED/chipsets.h | 591 +++++ libraries/FastLED/color.h | 84 + libraries/FastLED/colorpalettes.cpp | 174 ++ libraries/FastLED/colorpalettes.h | 57 + libraries/FastLED/colorutils.cpp | 1198 +++++++++ libraries/FastLED/colorutils.h | 1706 ++++++++++++ libraries/FastLED/component.mk | 1 + libraries/FastLED/controller.h | 418 +++ libraries/FastLED/cpp_compat.h | 16 + libraries/FastLED/dmx.h | 65 + libraries/FastLED/docs/Doxyfile | 2331 +++++++++++++++++ libraries/FastLED/docs/mainpage.dox | 10 + .../examples/AnalogOutput/AnalogOutput.ino | 65 + libraries/FastLED/examples/Blink/Blink.ino | 54 + .../examples/ColorPalette/ColorPalette.ino | 188 ++ .../ColorTemperature/ColorTemperature.ino | 85 + libraries/FastLED/examples/Cylon/Cylon.ino | 53 + .../examples/DemoReel100/DemoReel100.ino | 126 + .../FastLED/examples/Fire2012/Fire2012.ino | 105 + .../Fire2012WithPalette.ino | 164 ++ .../examples/FirstLight/FirstLight.ino | 78 + .../ArrayOfLedArrays/ArrayOfLedArrays.ino | 37 + .../MirroringSample/MirroringSample.ino | 44 + .../Multiple/MultiArrays/MultiArrays.ino | 52 + .../MultipleStripsInOneArray.ino | 34 + .../OctoWS2811Demo/OctoWS2811Demo.ino | 37 + .../ParallelOutputDemo/ParallelOutputDemo.ino | 47 + libraries/FastLED/examples/Noise/Noise.ino | 112 + .../NoisePlayground/NoisePlayground.ino | 73 + .../NoisePlusPalette/NoisePlusPalette.ino | 273 ++ .../FastLED/examples/Pintest/Pintest.ino | 105 + .../PJRCSpectrumAnalyzer.ino | 136 + .../examples/RGBCalibrate/RGBCalibrate.ino | 72 + .../examples/RGBSetDemo/RGBSetDemo.ino | 22 + .../examples/SmartMatrix/SmartMatrix.ino | 121 + .../FastLED/examples/XYMatrix/XYMatrix.ino | 196 ++ libraries/FastLED/extras/AppleII.s65 | 40 + libraries/FastLED/extras/FastLED6502.s65 | 633 +++++ libraries/FastLED/extras/RainbowDemo.bin.zip | Bin 0 -> 848 bytes libraries/FastLED/extras/RainbowDemo.s65 | 89 + libraries/FastLED/fastled_config.h | 69 + libraries/FastLED/fastled_delay.h | 139 + libraries/FastLED/fastled_progmem.h | 81 + libraries/FastLED/fastpin.h | 248 ++ libraries/FastLED/fastspi.h | 134 + libraries/FastLED/fastspi_bitbang.h | 374 +++ libraries/FastLED/fastspi_dma.h | 0 libraries/FastLED/fastspi_nop.h | 64 + libraries/FastLED/fastspi_ref.h | 95 + libraries/FastLED/fastspi_types.h | 43 + libraries/FastLED/hsv2rgb.cpp | 714 +++++ libraries/FastLED/hsv2rgb.h | 91 + libraries/FastLED/keywords.txt | 384 +++ libraries/FastLED/led_sysdefs.h | 48 + libraries/FastLED/lib8tion.cpp | 251 ++ libraries/FastLED/lib8tion.h | 1141 ++++++++ libraries/FastLED/lib8tion/math8.h | 552 ++++ libraries/FastLED/lib8tion/random8.h | 94 + libraries/FastLED/lib8tion/scale8.h | 712 +++++ libraries/FastLED/lib8tion/trig8.h | 259 ++ libraries/FastLED/library.json | 40 + libraries/FastLED/library.properties | 9 + libraries/FastLED/noise.cpp | 807 ++++++ libraries/FastLED/noise.h | 97 + libraries/FastLED/pixelset.h | 305 +++ libraries/FastLED/pixeltypes.h | 871 ++++++ libraries/FastLED/platforms.h | 37 + .../platforms/arm/common/m0clockless.h | 318 +++ .../platforms/arm/d21/clockless_arm_d21.h | 61 + .../platforms/arm/d21/fastled_arm_d21.h | 7 + .../platforms/arm/d21/fastpin_arm_d21.h | 200 ++ .../platforms/arm/d21/led_sysdefs_arm_d21.h | 26 + .../platforms/arm/d51/clockless_arm_d51.h | 62 + .../platforms/arm/d51/fastled_arm_d51.h | 7 + .../platforms/arm/d51/fastpin_arm_d51.h | 95 + .../platforms/arm/d51/led_sysdefs_arm_d51.h | 27 + .../platforms/arm/k20/clockless_arm_k20.h | 124 + .../arm/k20/clockless_block_arm_k20.h | 330 +++ .../platforms/arm/k20/fastled_arm_k20.h | 13 + .../platforms/arm/k20/fastpin_arm_k20.h | 120 + .../platforms/arm/k20/fastspi_arm_k20.h | 466 ++++ .../platforms/arm/k20/led_sysdefs_arm_k20.h | 46 + .../platforms/arm/k20/octows2811_controller.h | 66 + .../platforms/arm/k20/smartmatrix_t3.h | 55 + .../arm/k20/ws2812serial_controller.h | 46 + .../platforms/arm/k66/clockless_arm_k66.h | 124 + .../arm/k66/clockless_block_arm_k66.h | 344 +++ .../platforms/arm/k66/fastled_arm_k66.h | 14 + .../platforms/arm/k66/fastpin_arm_k66.h | 128 + .../platforms/arm/k66/fastspi_arm_k66.h | 470 ++++ .../platforms/arm/k66/led_sysdefs_arm_k66.h | 46 + .../platforms/arm/kl26/clockless_arm_kl26.h | 65 + .../platforms/arm/kl26/fastled_arm_kl26.h | 10 + .../platforms/arm/kl26/fastpin_arm_kl26.h | 88 + .../platforms/arm/kl26/fastspi_arm_kl26.h | 252 ++ .../platforms/arm/kl26/led_sysdefs_arm_kl26.h | 47 + .../platforms/arm/nrf51/clockless_arm_nrf51.h | 83 + .../platforms/arm/nrf51/fastled_arm_nrf51.h | 9 + .../platforms/arm/nrf51/fastpin_arm_nrf51.h | 119 + .../platforms/arm/nrf51/fastspi_arm_nrf51.h | 150 ++ .../arm/nrf51/led_sysdefs_arm_nrf51.h | 46 + .../platforms/arm/sam/clockless_arm_sam.h | 120 + .../arm/sam/clockless_block_arm_sam.h | 184 ++ .../platforms/arm/sam/fastled_arm_sam.h | 10 + .../platforms/arm/sam/fastpin_arm_sam.h | 137 + .../platforms/arm/sam/fastspi_arm_sam.h | 163 ++ .../platforms/arm/sam/led_sysdefs_arm_sam.h | 39 + .../platforms/arm/stm32/clockless_arm_stm32.h | 126 + .../FastLED/platforms/arm/stm32/cm3_regs.h | 63 + .../platforms/arm/stm32/fastled_arm_stm32.h | 9 + .../platforms/arm/stm32/fastpin_arm_stm32.h | 158 ++ .../arm/stm32/led_sysdefs_arm_stm32.h | 61 + .../FastLED/platforms/avr/clockless_trinket.h | 464 ++++ libraries/FastLED/platforms/avr/fastled_avr.h | 13 + libraries/FastLED/platforms/avr/fastpin_avr.h | 341 +++ libraries/FastLED/platforms/avr/fastspi_avr.h | 682 +++++ .../FastLED/platforms/avr/led_sysdefs_avr.h | 67 + .../platforms/esp/32/clockless_block_esp32.h | 168 ++ .../platforms/esp/32/clockless_esp32.h | 569 ++++ .../platforms/esp/32/clockless_esp32.h.orig | 786 ++++++ .../FastLED/platforms/esp/32/fastled_esp32.h | 5 + .../FastLED/platforms/esp/32/fastpin_esp32.h | 116 + .../platforms/esp/32/led_sysdefs_esp32.h | 33 + .../esp/8266/clockless_block_esp8266.h | 159 ++ .../platforms/esp/8266/clockless_esp8266.h | 117 + .../platforms/esp/8266/fastled_esp8266.h | 5 + .../platforms/esp/8266/fastpin_esp8266.h | 101 + .../platforms/esp/8266/led_sysdefs_esp8266.h | 39 + libraries/FastLED/power_mgt.cpp | 185 ++ libraries/FastLED/power_mgt.h | 88 + libraries/FastLED/preview_changes.txt | 19 + libraries/FastLED/release_notes.md | 221 ++ libraries/FastLED/wiring.cpp | 238 ++ libraries/LEDText-master/.gitattributes | 17 + libraries/LEDText-master/.gitignore | 43 + libraries/LEDText-master/ComicSansP24.h | 107 + libraries/LEDText-master/Font12x16.h | 106 + libraries/LEDText-master/Font16x24.h | 106 + libraries/LEDText-master/Font4x5.h | 107 + libraries/LEDText-master/FontMatrise.h | 107 + libraries/LEDText-master/FontP16x16.h | 112 + libraries/LEDText-master/FontRobotron.h | 531 ++++ libraries/LEDText-master/LEDText.cpp | 550 ++++ libraries/LEDText-master/LEDText.h | 116 + libraries/LEDText-master/README.md | 3 + .../examples/TextExample1/TextExample1.ino | 66 + .../examples/TextExample2/TextExample2.ino | 66 + .../examples/TextExample3/TextExample3.ino | 120 + .../examples/TextExample4/TextExample4.ino | 76 + .../examples/TextExample5/TextExample5.ino | 107 + libraries/LEDText-master/keywords.txt | 84 + 159 files changed, 30756 insertions(+) create mode 100644 LED-Mesh.ino create mode 100644 libraries/FastLED/FastLED.cpp create mode 100644 libraries/FastLED/FastLED.h create mode 100644 libraries/FastLED/LICENSE create mode 100644 libraries/FastLED/PORTING.md create mode 100644 libraries/FastLED/README.md create mode 100644 libraries/FastLED/bitswap.cpp create mode 100644 libraries/FastLED/bitswap.h create mode 100644 libraries/FastLED/chipsets.h create mode 100644 libraries/FastLED/color.h create mode 100644 libraries/FastLED/colorpalettes.cpp create mode 100644 libraries/FastLED/colorpalettes.h create mode 100644 libraries/FastLED/colorutils.cpp create mode 100644 libraries/FastLED/colorutils.h create mode 100644 libraries/FastLED/component.mk create mode 100644 libraries/FastLED/controller.h create mode 100644 libraries/FastLED/cpp_compat.h create mode 100644 libraries/FastLED/dmx.h create mode 100644 libraries/FastLED/docs/Doxyfile create mode 100644 libraries/FastLED/docs/mainpage.dox create mode 100644 libraries/FastLED/examples/AnalogOutput/AnalogOutput.ino create mode 100644 libraries/FastLED/examples/Blink/Blink.ino create mode 100644 libraries/FastLED/examples/ColorPalette/ColorPalette.ino create mode 100644 libraries/FastLED/examples/ColorTemperature/ColorTemperature.ino create mode 100644 libraries/FastLED/examples/Cylon/Cylon.ino create mode 100644 libraries/FastLED/examples/DemoReel100/DemoReel100.ino create mode 100644 libraries/FastLED/examples/Fire2012/Fire2012.ino create mode 100644 libraries/FastLED/examples/Fire2012WithPalette/Fire2012WithPalette.ino create mode 100644 libraries/FastLED/examples/FirstLight/FirstLight.ino create mode 100644 libraries/FastLED/examples/Multiple/ArrayOfLedArrays/ArrayOfLedArrays.ino create mode 100644 libraries/FastLED/examples/Multiple/MirroringSample/MirroringSample.ino create mode 100644 libraries/FastLED/examples/Multiple/MultiArrays/MultiArrays.ino create mode 100644 libraries/FastLED/examples/Multiple/MultipleStripsInOneArray/MultipleStripsInOneArray.ino create mode 100644 libraries/FastLED/examples/Multiple/OctoWS2811Demo/OctoWS2811Demo.ino create mode 100644 libraries/FastLED/examples/Multiple/ParallelOutputDemo/ParallelOutputDemo.ino create mode 100644 libraries/FastLED/examples/Noise/Noise.ino create mode 100644 libraries/FastLED/examples/NoisePlayground/NoisePlayground.ino create mode 100644 libraries/FastLED/examples/NoisePlusPalette/NoisePlusPalette.ino create mode 100644 libraries/FastLED/examples/Pintest/Pintest.ino create mode 100644 libraries/FastLED/examples/Ports/PJRCSpectrumAnalyzer/PJRCSpectrumAnalyzer.ino create mode 100644 libraries/FastLED/examples/RGBCalibrate/RGBCalibrate.ino create mode 100644 libraries/FastLED/examples/RGBSetDemo/RGBSetDemo.ino create mode 100644 libraries/FastLED/examples/SmartMatrix/SmartMatrix.ino create mode 100644 libraries/FastLED/examples/XYMatrix/XYMatrix.ino create mode 100644 libraries/FastLED/extras/AppleII.s65 create mode 100644 libraries/FastLED/extras/FastLED6502.s65 create mode 100644 libraries/FastLED/extras/RainbowDemo.bin.zip create mode 100644 libraries/FastLED/extras/RainbowDemo.s65 create mode 100644 libraries/FastLED/fastled_config.h create mode 100644 libraries/FastLED/fastled_delay.h create mode 100644 libraries/FastLED/fastled_progmem.h create mode 100644 libraries/FastLED/fastpin.h create mode 100644 libraries/FastLED/fastspi.h create mode 100644 libraries/FastLED/fastspi_bitbang.h create mode 100644 libraries/FastLED/fastspi_dma.h create mode 100644 libraries/FastLED/fastspi_nop.h create mode 100644 libraries/FastLED/fastspi_ref.h create mode 100644 libraries/FastLED/fastspi_types.h create mode 100644 libraries/FastLED/hsv2rgb.cpp create mode 100644 libraries/FastLED/hsv2rgb.h create mode 100644 libraries/FastLED/keywords.txt create mode 100644 libraries/FastLED/led_sysdefs.h create mode 100644 libraries/FastLED/lib8tion.cpp create mode 100644 libraries/FastLED/lib8tion.h create mode 100644 libraries/FastLED/lib8tion/math8.h create mode 100644 libraries/FastLED/lib8tion/random8.h create mode 100644 libraries/FastLED/lib8tion/scale8.h create mode 100644 libraries/FastLED/lib8tion/trig8.h create mode 100644 libraries/FastLED/library.json create mode 100644 libraries/FastLED/library.properties create mode 100644 libraries/FastLED/noise.cpp create mode 100644 libraries/FastLED/noise.h create mode 100644 libraries/FastLED/pixelset.h create mode 100644 libraries/FastLED/pixeltypes.h create mode 100644 libraries/FastLED/platforms.h create mode 100644 libraries/FastLED/platforms/arm/common/m0clockless.h create mode 100644 libraries/FastLED/platforms/arm/d21/clockless_arm_d21.h create mode 100644 libraries/FastLED/platforms/arm/d21/fastled_arm_d21.h create mode 100644 libraries/FastLED/platforms/arm/d21/fastpin_arm_d21.h create mode 100644 libraries/FastLED/platforms/arm/d21/led_sysdefs_arm_d21.h create mode 100644 libraries/FastLED/platforms/arm/d51/clockless_arm_d51.h create mode 100644 libraries/FastLED/platforms/arm/d51/fastled_arm_d51.h create mode 100644 libraries/FastLED/platforms/arm/d51/fastpin_arm_d51.h create mode 100644 libraries/FastLED/platforms/arm/d51/led_sysdefs_arm_d51.h create mode 100644 libraries/FastLED/platforms/arm/k20/clockless_arm_k20.h create mode 100644 libraries/FastLED/platforms/arm/k20/clockless_block_arm_k20.h create mode 100644 libraries/FastLED/platforms/arm/k20/fastled_arm_k20.h create mode 100644 libraries/FastLED/platforms/arm/k20/fastpin_arm_k20.h create mode 100644 libraries/FastLED/platforms/arm/k20/fastspi_arm_k20.h create mode 100644 libraries/FastLED/platforms/arm/k20/led_sysdefs_arm_k20.h create mode 100644 libraries/FastLED/platforms/arm/k20/octows2811_controller.h create mode 100644 libraries/FastLED/platforms/arm/k20/smartmatrix_t3.h create mode 100644 libraries/FastLED/platforms/arm/k20/ws2812serial_controller.h create mode 100644 libraries/FastLED/platforms/arm/k66/clockless_arm_k66.h create mode 100644 libraries/FastLED/platforms/arm/k66/clockless_block_arm_k66.h create mode 100644 libraries/FastLED/platforms/arm/k66/fastled_arm_k66.h create mode 100644 libraries/FastLED/platforms/arm/k66/fastpin_arm_k66.h create mode 100644 libraries/FastLED/platforms/arm/k66/fastspi_arm_k66.h create mode 100644 libraries/FastLED/platforms/arm/k66/led_sysdefs_arm_k66.h create mode 100644 libraries/FastLED/platforms/arm/kl26/clockless_arm_kl26.h create mode 100644 libraries/FastLED/platforms/arm/kl26/fastled_arm_kl26.h create mode 100644 libraries/FastLED/platforms/arm/kl26/fastpin_arm_kl26.h create mode 100644 libraries/FastLED/platforms/arm/kl26/fastspi_arm_kl26.h create mode 100644 libraries/FastLED/platforms/arm/kl26/led_sysdefs_arm_kl26.h create mode 100644 libraries/FastLED/platforms/arm/nrf51/clockless_arm_nrf51.h create mode 100644 libraries/FastLED/platforms/arm/nrf51/fastled_arm_nrf51.h create mode 100644 libraries/FastLED/platforms/arm/nrf51/fastpin_arm_nrf51.h create mode 100644 libraries/FastLED/platforms/arm/nrf51/fastspi_arm_nrf51.h create mode 100644 libraries/FastLED/platforms/arm/nrf51/led_sysdefs_arm_nrf51.h create mode 100644 libraries/FastLED/platforms/arm/sam/clockless_arm_sam.h create mode 100644 libraries/FastLED/platforms/arm/sam/clockless_block_arm_sam.h create mode 100644 libraries/FastLED/platforms/arm/sam/fastled_arm_sam.h create mode 100644 libraries/FastLED/platforms/arm/sam/fastpin_arm_sam.h create mode 100644 libraries/FastLED/platforms/arm/sam/fastspi_arm_sam.h create mode 100644 libraries/FastLED/platforms/arm/sam/led_sysdefs_arm_sam.h create mode 100644 libraries/FastLED/platforms/arm/stm32/clockless_arm_stm32.h create mode 100644 libraries/FastLED/platforms/arm/stm32/cm3_regs.h create mode 100644 libraries/FastLED/platforms/arm/stm32/fastled_arm_stm32.h create mode 100644 libraries/FastLED/platforms/arm/stm32/fastpin_arm_stm32.h create mode 100644 libraries/FastLED/platforms/arm/stm32/led_sysdefs_arm_stm32.h create mode 100644 libraries/FastLED/platforms/avr/clockless_trinket.h create mode 100644 libraries/FastLED/platforms/avr/fastled_avr.h create mode 100644 libraries/FastLED/platforms/avr/fastpin_avr.h create mode 100644 libraries/FastLED/platforms/avr/fastspi_avr.h create mode 100644 libraries/FastLED/platforms/avr/led_sysdefs_avr.h create mode 100644 libraries/FastLED/platforms/esp/32/clockless_block_esp32.h create mode 100644 libraries/FastLED/platforms/esp/32/clockless_esp32.h create mode 100644 libraries/FastLED/platforms/esp/32/clockless_esp32.h.orig create mode 100644 libraries/FastLED/platforms/esp/32/fastled_esp32.h create mode 100644 libraries/FastLED/platforms/esp/32/fastpin_esp32.h create mode 100644 libraries/FastLED/platforms/esp/32/led_sysdefs_esp32.h create mode 100644 libraries/FastLED/platforms/esp/8266/clockless_block_esp8266.h create mode 100644 libraries/FastLED/platforms/esp/8266/clockless_esp8266.h create mode 100644 libraries/FastLED/platforms/esp/8266/fastled_esp8266.h create mode 100644 libraries/FastLED/platforms/esp/8266/fastpin_esp8266.h create mode 100644 libraries/FastLED/platforms/esp/8266/led_sysdefs_esp8266.h create mode 100644 libraries/FastLED/power_mgt.cpp create mode 100644 libraries/FastLED/power_mgt.h create mode 100644 libraries/FastLED/preview_changes.txt create mode 100644 libraries/FastLED/release_notes.md create mode 100644 libraries/FastLED/wiring.cpp create mode 100644 libraries/LEDText-master/.gitattributes create mode 100644 libraries/LEDText-master/.gitignore create mode 100644 libraries/LEDText-master/ComicSansP24.h create mode 100644 libraries/LEDText-master/Font12x16.h create mode 100644 libraries/LEDText-master/Font16x24.h create mode 100644 libraries/LEDText-master/Font4x5.h create mode 100644 libraries/LEDText-master/FontMatrise.h create mode 100644 libraries/LEDText-master/FontP16x16.h create mode 100644 libraries/LEDText-master/FontRobotron.h create mode 100644 libraries/LEDText-master/LEDText.cpp create mode 100644 libraries/LEDText-master/LEDText.h create mode 100644 libraries/LEDText-master/README.md create mode 100644 libraries/LEDText-master/examples/TextExample1/TextExample1.ino create mode 100644 libraries/LEDText-master/examples/TextExample2/TextExample2.ino create mode 100644 libraries/LEDText-master/examples/TextExample3/TextExample3.ino create mode 100644 libraries/LEDText-master/examples/TextExample4/TextExample4.ino create mode 100644 libraries/LEDText-master/examples/TextExample5/TextExample5.ino create mode 100644 libraries/LEDText-master/keywords.txt diff --git a/LED-Mesh.ino b/LED-Mesh.ino new file mode 100644 index 0000000..cc9c156 --- /dev/null +++ b/LED-Mesh.ino @@ -0,0 +1,132 @@ +#include + +#include +#include +#include + +// Change the next 6 defines to match your matrix type and size + +#define LED_PIN 5 +#define COLOR_ORDER RGB +#define CHIPSET PL9823 + +#define NUM_LEDS 90 + +#define MATRIX_WIDTH 18 +#define MATRIX_HEIGHT 5 +#define MATRIX_TYPE VERTICAL_ZIGZAG_MATRIX +cLEDMatrix < -MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE > leds; +CRGB leds2[NUM_LEDS]; + +cLEDText ScrollingMsg; + +const unsigned char TxtDemo[] = { /* + EFFECT_FRAME_RATE "\x06" EFFECT_BACKGND_DIMMING "\x20" + EFFECT_SCROLL_LEFT " LEEFT SCROLL " + EFFECT_SCROLL_RIGHT " LLORCS THGIR" + EFFECT_CHAR_UP EFFECT_SCROLL_LEFT " UP" + EFFECT_SCROLL_LEFT " Magande 2811 ABCDEFGHIJK " + EFFECT_FRAME_RATE "\x10" + EFFECT_SCROLL_LEFT " LMNOPQRSTUVWXYZ 0123456789 +*~,;:.-_!$%&/()=\" {[]}`^^#<>" + EFFECT_FRAME_RATE "\x06" + EFFECT_CHAR_RIGHT " RIGHT" + EFFECT_CHAR_DOWN " DOWN" + EFFECT_CHAR_LEFT " LEFT" + EFFECT_HSV_CV "\x00\xff\xff\x40\xff\xff" EFFECT_CHAR_UP " HSV_CV 00-40" + EFFECT_HSV_CH "\x00\xff\xff\x40\xff\xff" "HSV_CH 00-40" + EFFECT_HSV_AV "\x00\xff\xff\x40\xff\xff" "HSV_AV 00-40" + EFFECT_HSV_AH "\x00\xff\xff\xff\xff\xff" "HSV_AH 00-FF" + EFFECT_HSV "\x00\xff\xff" "R" EFFECT_HSV "\x20\xff\xff" "A" EFFECT_HSV "\x40\xff\xff" "I" EFFECT_HSV "\x60\xff\xff" "N" EFFECT_HSV "\xe0\xff\xff" "B" EFFECT_HSV "\xc0\xff\xff" "O" + EFFECT_HSV "\xa0\xff\xff" "W" EFFECT_HSV "\x80\xff\xff" "S " EFFECT_DELAY_FRAMES "\x00\x96" EFFECT_RGB "\xff\xff\xff" +*/ + EFFECT_FRAME_RATE "\x05" + EFFECT_SCROLL_LEFT EFFECT_RGB "\x52\xff\xa3" " KIESELSTEIN " + //EFFECT_RGB "\xbb\xff\x44" " IM " + EFFECT_HSV_AV "\xaa\xff\xff\x2c\xaa\xb9" " INTERNATIONAL " + EFFECT_HSV_CH "\x03\xff\xff\xaf\xff\xff" " GMBH " + EFFECT_RGB "\xaa\xaa\xf0" " --" + EFFECT_HSV_CH "\x00\xff\xff\xd0\xff\xff" " STRUCTWIRE " + // EFFECT_HSV_CH "\xaa\xff\xff\xe2\xff\xff" " DIE ZWEITE " + + }; +int demo2; +/* +String StringRead = + EFFECT_FRAME_RATE "\x06" + EFFECT_SCROLL_LEFT EFFECT_RGB "\x52\xff\xa3" "Hallo weLT:"; +*/ +static uint8_t hue; +int16_t x, y; +uint8_t h; + +int UPDATES_PER_SECOND; + + + +void setup() +{ + //StringRead.reserve(100); + FastLED.addLeds(leds[0], leds.Size()); + FastLED.setBrightness(63); + FastLED.clear(true); + + delay(500); + FastLED.showColor(CRGB::Red); + delay(1000); + FastLED.showColor(CRGB::Lime); + delay(1000); + FastLED.showColor(CRGB::Blue); + delay(1000); + FastLED.showColor(CRGB::White); + delay(1000); + FastLED.show(); + + ScrollingMsg.SetFont(MatriseFontData); + ScrollingMsg.Init(&leds, leds.Width(), ScrollingMsg.FontHeight() + 1, 0, 0); + ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1); + ScrollingMsg.SetTextColrOptions(COLR_RGB | COLR_SINGLE, 0xff, 0x00, 0xff); + //ScrollingMsg.SetBackgroundMode(BACKGND_DIMMING, 0x05); + //ScrollingMsg.SetFrameRate(FrameRate); + + // currentPalette = RainbowColors_p; + // currentBlending = LINEARBLEND; + +} + + +void loop() +{ + h = hue; + if (ScrollingMsg.UpdateText() == -1) { + ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1); + //ScrollingMsg.SetText((unsigned char *) StringRead.c_str(), StringRead.length()); + // demo2=40; + } + else { + FastLED.show(); + //delay(3); + //FastLED.clear(); + } + delay(8); + +/* if (Serial.available()) { + if (Serial.available() != 0) { + StringRead = Serial.readString(); + } + } +*/ + + /* if(demo2>=20){ + for (x=0; x 0) ? nLedsOrOffset : 0; + int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset; + + pLed->init(); + pLed->setLeds(data + nOffset, nLeds); + FastLED.setMaxRefreshRate(pLed->getMaxRefreshRate(),true); + return *pLed; +} + +void CFastLED::show(uint8_t scale) { + // guard against showing too rapidly + while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros)); + lastshow = micros(); + + // If we have a function for computing power, use it! + if(m_pPowerFunc) { + scale = (*m_pPowerFunc)(scale, m_nPowerData); + } + + CLEDController *pCur = CLEDController::head(); + while(pCur) { + uint8_t d = pCur->getDither(); + if(m_nFPS < 100) { pCur->setDither(0); } + pCur->showLeds(scale); + pCur->setDither(d); + pCur = pCur->next(); + } + countFPS(); +} + +int CFastLED::count() { + int x = 0; + CLEDController *pCur = CLEDController::head(); + while( pCur) { + x++; + pCur = pCur->next(); + } + return x; +} + +CLEDController & CFastLED::operator[](int x) { + CLEDController *pCur = CLEDController::head(); + while(x-- && pCur) { + pCur = pCur->next(); + } + if(pCur == NULL) { + return *(CLEDController::head()); + } else { + return *pCur; + } +} + +void CFastLED::showColor(const struct CRGB & color, uint8_t scale) { + while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros)); + lastshow = micros(); + + // If we have a function for computing power, use it! + if(m_pPowerFunc) { + scale = (*m_pPowerFunc)(scale, m_nPowerData); + } + + CLEDController *pCur = CLEDController::head(); + while(pCur) { + uint8_t d = pCur->getDither(); + if(m_nFPS < 100) { pCur->setDither(0); } + pCur->showColor(color, scale); + pCur->setDither(d); + pCur = pCur->next(); + } + countFPS(); +} + +void CFastLED::clear(bool writeData) { + if(writeData) { + showColor(CRGB(0,0,0), 0); + } + clearData(); +} + +void CFastLED::clearData() { + CLEDController *pCur = CLEDController::head(); + while(pCur) { + pCur->clearLedData(); + pCur = pCur->next(); + } +} + +void CFastLED::delay(unsigned long ms) { + unsigned long start = millis(); + do { +#ifndef FASTLED_ACCURATE_CLOCK + // make sure to allow at least one ms to pass to ensure the clock moves + // forward + ::delay(1); +#endif + show(); + yield(); + } + while((millis()-start) < ms); +} + +void CFastLED::setTemperature(const struct CRGB & temp) { + CLEDController *pCur = CLEDController::head(); + while(pCur) { + pCur->setTemperature(temp); + pCur = pCur->next(); + } +} + +void CFastLED::setCorrection(const struct CRGB & correction) { + CLEDController *pCur = CLEDController::head(); + while(pCur) { + pCur->setCorrection(correction); + pCur = pCur->next(); + } +} + +void CFastLED::setDither(uint8_t ditherMode) { + CLEDController *pCur = CLEDController::head(); + while(pCur) { + pCur->setDither(ditherMode); + pCur = pCur->next(); + } +} + +// +// template void transpose8(unsigned char A[8], unsigned char B[8]) { +// uint32_t x, y, t; +// +// // Load the array and pack it into x and y. +// y = *(unsigned int*)(A); +// x = *(unsigned int*)(A+4); +// +// // x = (A[0]<<24) | (A[m]<<16) | (A[2*m]<<8) | A[3*m]; +// // y = (A[4*m]<<24) | (A[5*m]<<16) | (A[6*m]<<8) | A[7*m]; +// + // // pre-transform x + // t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7); + // t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14); + // + // // pre-transform y + // t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7); + // t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14); + // + // // final transform + // t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F); + // y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F); + // x = t; +// +// B[7*n] = y; y >>= 8; +// B[6*n] = y; y >>= 8; +// B[5*n] = y; y >>= 8; +// B[4*n] = y; +// +// B[3*n] = x; x >>= 8; +// B[2*n] = x; x >>= 8; +// B[n] = x; x >>= 8; +// B[0] = x; +// // B[0]=x>>24; B[n]=x>>16; B[2*n]=x>>8; B[3*n]=x>>0; +// // B[4*n]=y>>24; B[5*n]=y>>16; B[6*n]=y>>8; B[7*n]=y>>0; +// } +// +// void transposeLines(Lines & out, Lines & in) { +// transpose8<1,2>(in.bytes, out.bytes); +// transpose8<1,2>(in.bytes + 8, out.bytes + 1); +// } + +extern int noise_min; +extern int noise_max; + +void CFastLED::countFPS(int nFrames) { + static int br = 0; + static uint32_t lastframe = 0; // millis(); + + if(br++ >= nFrames) { + uint32_t now = millis(); + now -= lastframe; + m_nFPS = (br * 1000) / now; + br = 0; + lastframe = millis(); + } +} + +void CFastLED::setMaxRefreshRate(uint16_t refresh, bool constrain) { + if(constrain) { + // if we're constraining, the new value of m_nMinMicros _must_ be higher than previously (because we're only + // allowed to slow things down if constraining) + if(refresh > 0) { + m_nMinMicros = ( (1000000/refresh) > m_nMinMicros) ? (1000000/refresh) : m_nMinMicros; + } + } else if(refresh > 0) { + m_nMinMicros = 1000000 / refresh; + } else { + m_nMinMicros = 0; + } +} + +extern "C" int atexit(void (* /*func*/ )()) { return 0; } + +#ifdef FASTLED_NEEDS_YIELD +extern "C" void yield(void) { } +#endif + +#ifdef NEED_CXX_BITS +namespace __cxxabiv1 +{ + #if !defined(ESP8266) && !defined(ESP32) + extern "C" void __cxa_pure_virtual (void) {} + #endif + + /* guard variables */ + + /* The ABI requires a 64-bit type. */ + __extension__ typedef int __guard __attribute__((mode(__DI__))); + + extern "C" int __cxa_guard_acquire (__guard *) __attribute__((weak)); + extern "C" void __cxa_guard_release (__guard *) __attribute__((weak)); + extern "C" void __cxa_guard_abort (__guard *) __attribute__((weak)); + + extern "C" int __cxa_guard_acquire (__guard *g) + { + return !*(char *)(g); + } + + extern "C" void __cxa_guard_release (__guard *g) + { + *(char *)g = 1; + } + + extern "C" void __cxa_guard_abort (__guard *) + { + + } +} +#endif + +FASTLED_NAMESPACE_END diff --git a/libraries/FastLED/FastLED.h b/libraries/FastLED/FastLED.h new file mode 100644 index 0000000..5bb0752 --- /dev/null +++ b/libraries/FastLED/FastLED.h @@ -0,0 +1,584 @@ +#ifndef __INC_FASTSPI_LED2_H +#define __INC_FASTSPI_LED2_H + +///@file FastLED.h +/// central include file for FastLED, defines the CFastLED class/object + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +#define FASTLED_HAS_PRAGMA_MESSAGE +#endif + +#define FASTLED_VERSION 3002006 +#ifndef FASTLED_INTERNAL +# ifdef FASTLED_HAS_PRAGMA_MESSAGE +# pragma message "FastLED version 3.002.006" +# else +# warning FastLED version 3.002.006 (Not really a warning, just telling you here.) +# endif +#endif + +#ifndef __PROG_TYPES_COMPAT__ +#define __PROG_TYPES_COMPAT__ +#endif + +#ifdef SmartMatrix_h +#include +#endif + +#ifdef DmxSimple_h +#include +#endif + +#ifdef DmxSerial_h +#include +#endif + +#include + +#include "cpp_compat.h" + +#include "fastled_config.h" +#include "led_sysdefs.h" + +// Utility functions +#include "fastled_delay.h" +#include "bitswap.h" + +#include "controller.h" +#include "fastpin.h" +#include "fastspi_types.h" +#include "dmx.h" + +#include "platforms.h" +#include "fastled_progmem.h" + +#include "lib8tion.h" +#include "pixeltypes.h" +#include "hsv2rgb.h" +#include "colorutils.h" +#include "pixelset.h" +#include "colorpalettes.h" + +#include "noise.h" +#include "power_mgt.h" + +#include "fastspi.h" +#include "chipsets.h" + +FASTLED_NAMESPACE_BEGIN + +/// definitions for the spi chipset constants +enum ESPIChipsets { + LPD6803, + LPD8806, + WS2801, + WS2803, + SM16716, + P9813, + APA102, + SK9822, + DOTSTAR +}; + +enum ESM { SMART_MATRIX }; +enum OWS2811 { OCTOWS2811,OCTOWS2811_400, OCTOWS2813}; +enum SWS2812 { WS2812SERIAL }; + +#ifdef HAS_PIXIE +template class PIXIE : public PixieController {}; +#endif + +#ifdef FASTLED_HAS_CLOCKLESS +template class NEOPIXEL : public WS2812Controller800Khz {}; +template class SM16703 : public SM16703Controller {}; +template class TM1829 : public TM1829Controller800Khz {}; +template class TM1812 : public TM1809Controller800Khz {}; +template class TM1809 : public TM1809Controller800Khz {}; +template class TM1804 : public TM1809Controller800Khz {}; +template class TM1803 : public TM1803Controller400Khz {}; +template class UCS1903 : public UCS1903Controller400Khz {}; +template class UCS1903B : public UCS1903BController800Khz {}; +template class UCS1904 : public UCS1904Controller800Khz {}; +template class UCS2903 : public UCS2903Controller {}; +template class WS2812 : public WS2812Controller800Khz {}; +template class WS2852 : public WS2812Controller800Khz {}; +template class WS2812B : public WS2812Controller800Khz {}; +template class GS1903 : public WS2812Controller800Khz {}; +template class SK6812 : public SK6812Controller {}; +template class SK6822 : public SK6822Controller {}; +template class APA106 : public SK6822Controller {}; +template class PL9823 : public PL9823Controller {}; +template class WS2811 : public WS2811Controller800Khz {}; +template class WS2813 : public WS2813Controller {}; +template class APA104 : public WS2811Controller800Khz {}; +template class WS2811_400 : public WS2811Controller400Khz {}; +template class GE8822 : public GE8822Controller800Khz {}; +template class GW6205 : public GW6205Controller800Khz {}; +template class GW6205_400 : public GW6205Controller400Khz {}; +template class LPD1886 : public LPD1886Controller1250Khz {}; +template class LPD1886_8BIT : public LPD1886Controller1250Khz_8bit {}; +#ifdef DmxSimple_h +template class DMXSIMPLE : public DMXSimpleController {}; +#endif +#ifdef DmxSerial_h +template class DMXSERIAL : public DMXSerialController {}; +#endif +#endif + +enum EBlockChipsets { +#ifdef PORTA_FIRST_PIN + WS2811_PORTA, + WS2813_PORTA, + WS2811_400_PORTA, + TM1803_PORTA, + UCS1903_PORTA, +#endif +#ifdef PORTB_FIRST_PIN + WS2811_PORTB, + WS2813_PORTB, + WS2811_400_PORTB, + TM1803_PORTB, + UCS1903_PORTB, +#endif +#ifdef PORTC_FIRST_PIN + WS2811_PORTC, + WS2813_PORTC, + WS2811_400_PORTC, + TM1803_PORTC, + UCS1903_PORTC, +#endif +#ifdef PORTD_FIRST_PIN + WS2811_PORTD, + WS2813_PORTD, + WS2811_400_PORTD, + TM1803_PORTD, + UCS1903_PORTD, +#endif +#ifdef HAS_PORTDC + WS2811_PORTDC, + WS2813_PORTDC, + WS2811_400_PORTDC, + TM1803_PORTDC, + UCS1903_PORTDC, +#endif +}; + +#if defined(LIB8_ATTINY) +#define NUM_CONTROLLERS 2 +#else +#define NUM_CONTROLLERS 8 +#endif + +typedef uint8_t (*power_func)(uint8_t scale, uint32_t data); + +/// High level controller interface for FastLED. This class manages controllers, global settings and trackings +/// such as brightness, and refresh rates, and provides access functions for driving led data to controllers +/// via the show/showColor/clear methods. +/// @nosubgrouping +class CFastLED { + // int m_nControllers; + uint8_t m_Scale; ///< The current global brightness scale setting + uint16_t m_nFPS; ///< Tracking for current FPS value + uint32_t m_nMinMicros; ///< minimum µs between frames, used for capping frame rates. + uint32_t m_nPowerData; ///< max power use parameter + power_func m_pPowerFunc; ///< function for overriding brightness when using FastLED.show(); + +public: + CFastLED(); + + + /// Add a CLEDController instance to the world. Exposed to the public to allow people to implement their own + /// CLEDController objects or instances. There are two ways to call this method (as well as the other addLeds) + /// variations. The first is with 3 arguments, in which case the arguments are the controller, a pointer to + /// led data, and the number of leds used by this controller. The second is with 4 arguments, in which case + /// the first two arguments are the same, the third argument is an offset into the CRGB data where this controller's + /// CRGB data begins, and the fourth argument is the number of leds for this controller object. + /// @param pLed - the led controller being added + /// @param data - base point to an array of CRGB data structures + /// @param nLedsOrOffset - number of leds (3 argument version) or offset into the data array + /// @param nLedsIfOffset - number of leds (4 argument version) + /// @returns a reference to the added controller + static CLEDController &addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0); + + /// @name Adding SPI based controllers + //@{ + /// Add an SPI based CLEDController instance to the world. + /// There are two ways to call this method (as well as the other addLeds) + /// variations. The first is with 2 arguments, in which case the arguments are a pointer to + /// led data, and the number of leds used by this controller. The second is with 3 arguments, in which case + /// the first argument is the same, the second argument is an offset into the CRGB data where this controller's + /// CRGB data begins, and the third argument is the number of leds for this controller object. + /// + /// This method also takes a 1 to 5 template parameters for identifying the specific chipset, data and clock pins, + /// RGB ordering, and SPI data rate + /// @param data - base point to an array of CRGB data structures + /// @param nLedsOrOffset - number of leds (3 argument version) or offset into the data array + /// @param nLedsIfOffset - number of leds (4 argument version) + /// @tparam CHIPSET - the chipset type + /// @tparam DATA_PIN - the optional data pin for the leds (if omitted, will default to the first hardware SPI MOSI pin) + /// @tparam CLOCK_PIN - the optional clock pin for the leds (if omitted, will default to the first hardware SPI clock pin) + /// @tparam RGB_ORDER - the rgb ordering for the leds (e.g. what order red, green, and blue data is written out in) + /// @tparam SPI_DATA_RATE - the data rate to drive the SPI clock at, defined using DATA_RATE_MHZ or DATA_RATE_KHZ macros + /// @returns a reference to the added controller + template CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + switch(CHIPSET) { + case LPD6803: { static LPD6803Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case LPD8806: { static LPD8806Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case WS2801: { static WS2801Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case WS2803: { static WS2803Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case SM16716: { static SM16716Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case P9813: { static P9813Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case DOTSTAR: + case APA102: { static APA102Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case SK9822: { static SK9822Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + } + } + + template static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + switch(CHIPSET) { + case LPD6803: { static LPD6803Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case LPD8806: { static LPD8806Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case WS2801: { static WS2801Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case WS2803: { static WS2803Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case SM16716: { static SM16716Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case P9813: { static P9813Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case DOTSTAR: + case APA102: { static APA102Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case SK9822: { static SK9822Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + } + } + + template static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + switch(CHIPSET) { + case LPD6803: { static LPD6803Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case LPD8806: { static LPD8806Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case WS2801: { static WS2801Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case WS2803: { static WS2803Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case SM16716: { static SM16716Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case P9813: { static P9813Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case DOTSTAR: + case APA102: { static APA102Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + case SK9822: { static SK9822Controller c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); } + } + } + +#ifdef SPI_DATA + template static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + return addLeds(data, nLedsOrOffset, nLedsIfOffset); + } + + template static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + return addLeds(data, nLedsOrOffset, nLedsIfOffset); + } + + template static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + return addLeds(data, nLedsOrOffset, nLedsIfOffset); + } + +#endif + //@} + +#ifdef FASTLED_HAS_CLOCKLESS + /// @name Adding 3-wire led controllers + //@{ + /// Add a clockless (aka 3wire, also DMX) based CLEDController instance to the world. + /// There are two ways to call this method (as well as the other addLeds) + /// variations. The first is with 2 arguments, in which case the arguments are a pointer to + /// led data, and the number of leds used by this controller. The second is with 3 arguments, in which case + /// the first argument is the same, the second argument is an offset into the CRGB data where this controller's + /// CRGB data begins, and the third argument is the number of leds for this controller object. + /// + /// This method also takes a 2 to 3 template parameters for identifying the specific chipset, data pin, and rgb ordering + /// RGB ordering, and SPI data rate + /// @param data - base point to an array of CRGB data structures + /// @param nLedsOrOffset - number of leds (3 argument version) or offset into the data array + /// @param nLedsIfOffset - number of leds (4 argument version) + /// @tparam CHIPSET - the chipset type (required) + /// @tparam DATA_PIN - the optional data pin for the leds (required) + /// @tparam RGB_ORDER - the rgb ordering for the leds (e.g. what order red, green, and blue data is written out in) + /// @returns a reference to the added controller + template class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER> + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CHIPSET c; + return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); + } + + template class CHIPSET, uint8_t DATA_PIN> + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CHIPSET c; + return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); + } + + template class CHIPSET, uint8_t DATA_PIN> + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CHIPSET c; + return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); + } + + #ifdef FASTSPI_USE_DMX_SIMPLE + template + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) + { + switch(CHIPSET) { + case DMX: { static DMXController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } + } + } + #endif + //@} +#endif + + /// @name Adding 3rd party library controllers + //@{ + /// Add a 3rd party library based CLEDController instance to the world. + /// There are two ways to call this method (as well as the other addLeds) + /// variations. The first is with 2 arguments, in which case the arguments are a pointer to + /// led data, and the number of leds used by this controller. The second is with 3 arguments, in which case + /// the first argument is the same, the second argument is an offset into the CRGB data where this controller's + /// CRGB data begins, and the third argument is the number of leds for this controller object. This class includes the SmartMatrix + /// and OctoWS2811 based controllers + /// + /// This method also takes a 1 to 2 template parameters for identifying the specific chipset and rgb ordering + /// RGB ordering, and SPI data rate + /// @param data - base point to an array of CRGB data structures + /// @param nLedsOrOffset - number of leds (3 argument version) or offset into the data array + /// @param nLedsIfOffset - number of leds (4 argument version) + /// @tparam CHIPSET - the chipset type (required) + /// @tparam RGB_ORDER - the rgb ordering for the leds (e.g. what order red, green, and blue data is written out in) + /// @returns a reference to the added controller + template class CHIPSET, EOrder RGB_ORDER> + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CHIPSET c; + return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); + } + + template class CHIPSET> + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + static CHIPSET c; + return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); + } + +#ifdef USE_OCTOWS2811 + template + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) + { + switch(CHIPSET) { + case OCTOWS2811: { static COctoWS2811Controller controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } + case OCTOWS2811_400: { static COctoWS2811Controller controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } +#ifdef WS2813_800kHz + case OCTOWS2813: { static COctoWS2811Controller controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } +#endif + } + } + + template + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) + { + return addLeds(data,nLedsOrOffset,nLedsIfOffset); + } + +#endif + +#ifdef USE_WS2812SERIAL + template + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) + { + static CWS2812SerialController controller; + return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); + } +#endif + +#ifdef SmartMatrix_h + template + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) + { + switch(CHIPSET) { + case SMART_MATRIX: { static CSmartMatrixController controller; return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); } + } + } +#endif + //@} + + +#ifdef FASTLED_HAS_BLOCKLESS + + /// @name adding parallel output controllers + //@{ + /// Add a block based CLEDController instance to the world. + /// There are two ways to call this method (as well as the other addLeds) + /// variations. The first is with 2 arguments, in which case the arguments are a pointer to + /// led data, and the number of leds used by this controller. The second is with 3 arguments, in which case + /// the first argument is the same, the second argument is an offset into the CRGB data where this controller's + /// CRGB data begins, and the third argument is the number of leds for this controller object. + /// + /// This method also takes a 2 to 3 template parameters for identifying the specific chipset and rgb ordering + /// RGB ordering, and SPI data rate + /// @param data - base point to an array of CRGB data structures + /// @param nLedsOrOffset - number of leds (3 argument version) or offset into the data array + /// @param nLedsIfOffset - number of leds (4 argument version) + /// @tparam CHIPSET - the chipset/port type (required) + /// @tparam NUM_LANES - how many parallel lanes of output to write + /// @tparam RGB_ORDER - the rgb ordering for the leds (e.g. what order red, green, and blue data is written out in) + /// @returns a reference to the added controller + template + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + switch(CHIPSET) { + #ifdef PORTA_FIRST_PIN + case WS2811_PORTA: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2811_400_PORTA: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2813_PORTA: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case TM1803_PORTA: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case UCS1903_PORTA: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + #endif + #ifdef PORTB_FIRST_PIN + case WS2811_PORTB: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2811_400_PORTB: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2813_PORTB: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case TM1803_PORTB: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case UCS1903_PORTB: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + #endif + #ifdef PORTC_FIRST_PIN + case WS2811_PORTC: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2811_400_PORTC: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2813_PORTC: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case TM1803_PORTC: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case UCS1903_PORTC: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + #endif + #ifdef PORTD_FIRST_PIN + case WS2811_PORTD: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2811_400_PORTD: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2813_PORTD: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case TM1803_PORTD: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case UCS1903_PORTD: return addLeds(new InlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + #endif + #ifdef HAS_PORTDC + case WS2811_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2811_400_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case WS2813_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case TM1803_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + case UCS1903_PORTDC: return addLeds(new SixteenWayInlineBlockClocklessController(), data, nLedsOrOffset, nLedsIfOffset); + #endif + } + } + + template + static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) { + return addLeds(data,nLedsOrOffset,nLedsIfOffset); + } + //@} +#endif + + /// Set the global brightness scaling + /// @param scale a 0-255 value for how much to scale all leds before writing them out + void setBrightness(uint8_t scale) { m_Scale = scale; } + + /// Get the current global brightness setting + /// @returns the current global brightness value + uint8_t getBrightness() { return m_Scale; } + + /// Set the maximum power to be used, given in volts and milliamps. + /// @param volts - how many volts the leds are being driven at (usually 5) + /// @param milliamps - the maximum milliamps of power draw you want + inline void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps) { setMaxPowerInMilliWatts(volts * milliamps); } + + /// Set the maximum power to be used, given in milliwatts + /// @param milliwatts - the max power draw desired, in milliwatts + inline void setMaxPowerInMilliWatts(uint32_t milliwatts) { m_pPowerFunc = &calculate_max_brightness_for_power_mW; m_nPowerData = milliwatts; } + + /// Update all our controllers with the current led colors, using the passed in brightness + /// @param scale temporarily override the scale + void show(uint8_t scale); + + /// Update all our controllers with the current led colors + void show() { show(m_Scale); } + + /// clear the leds, wiping the local array of data, optionally black out the leds as well + /// @param writeData whether or not to write out to the leds as well + void clear(bool writeData = false); + + /// clear out the local data array + void clearData(); + + /// Set all leds on all controllers to the given color/scale + /// @param color what color to set the leds to + /// @param scale what brightness scale to show at + void showColor(const struct CRGB & color, uint8_t scale); + + /// Set all leds on all controllers to the given color + /// @param color what color to set the leds to + void showColor(const struct CRGB & color) { showColor(color, m_Scale); } + + /// Delay for the given number of milliseconds. Provided to allow the library to be used on platforms + /// that don't have a delay function (to allow code to be more portable). Note: this will call show + /// constantly to drive the dithering engine (and will call show at least once). + /// @param ms the number of milliseconds to pause for + void delay(unsigned long ms); + + /// Set a global color temperature. Sets the color temperature for all added led strips, overriding whatever + /// previous color temperature those controllers may have had + /// @param temp A CRGB structure describing the color temperature + void setTemperature(const struct CRGB & temp); + + /// Set a global color correction. Sets the color correction for all added led strips, + /// overriding whatever previous color correction those controllers may have had. + /// @param correction A CRGB structure describin the color correction. + void setCorrection(const struct CRGB & correction); + + /// Set the dithering mode. Sets the dithering mode for all added led strips, overriding + /// whatever previous dithering option those controllers may have had. + /// @param ditherMode - what type of dithering to use, either BINARY_DITHER or DISABLE_DITHER + void setDither(uint8_t ditherMode = BINARY_DITHER); + + /// Set the maximum refresh rate. This is global for all leds. Attempts to + /// call show faster than this rate will simply wait. Note that the refresh rate + /// defaults to the slowest refresh rate of all the leds added through addLeds. If + /// you wish to set/override this rate, be sure to call setMaxRefreshRate _after_ + /// adding all of your leds. + /// @param refresh - maximum refresh rate in hz + /// @param constrain - constrain refresh rate to the slowest speed yet set + void setMaxRefreshRate(uint16_t refresh, bool constrain=false); + + /// for debugging, will keep track of time between calls to countFPS, and every + /// nFrames calls, it will update an internal counter for the current FPS. + /// @todo make this a rolling counter + /// @param nFrames - how many frames to time for determining FPS + void countFPS(int nFrames=25); + + /// Get the number of frames/second being written out + /// @returns the most recently computed FPS value + uint16_t getFPS() { return m_nFPS; } + + /// Get how many controllers have been registered + /// @returns the number of controllers (strips) that have been added with addLeds + int count(); + + /// Get a reference to a registered controller + /// @returns a reference to the Nth controller + CLEDController & operator[](int x); + + /// Get the number of leds in the first controller + /// @returns the number of LEDs in the first controller + int size() { return (*this)[0].size(); } + + /// Get a pointer to led data for the first controller + /// @returns pointer to the CRGB buffer for the first controller + CRGB *leds() { return (*this)[0].leds(); } +}; + +#define FastSPI_LED FastLED +#define FastSPI_LED2 FastLED +#ifndef LEDS +#define LEDS FastLED +#endif + +extern CFastLED FastLED; + +// Warnings for undefined things +#ifndef HAS_HARDWARE_PIN_SUPPORT +#warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info." +#define NO_HARDWARE_PIN_SUPPORT +#endif + + +FASTLED_NAMESPACE_END + +#endif diff --git a/libraries/FastLED/LICENSE b/libraries/FastLED/LICENSE new file mode 100644 index 0000000..ebe4763 --- /dev/null +++ b/libraries/FastLED/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 FastLED + +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. diff --git a/libraries/FastLED/PORTING.md b/libraries/FastLED/PORTING.md new file mode 100644 index 0000000..2b4ade2 --- /dev/null +++ b/libraries/FastLED/PORTING.md @@ -0,0 +1,29 @@ +=New platform porting guide= + +== Setting up the basic files/folders == + +* Create platform directory (e.g. platforms/arm/kl26) +* Create configuration header led_sysdefs_arm_kl26.h: + * Define platform flags (like FASTLED_ARM/FASTLED_TEENSY) + * Define configuration parameters re: interrupts, or clock doubling + * Include extar system header files if needed +* Create main platform include, fastled_arm_kl26.h + * Include the various other header files as needed +* Modify led_sysdefs.h to conditionally include platform sysdefs header file +* Modify platforms.h to conditionally include platform fastled header + +== Porting fastpin.h == + +The heart of the FastLED library is the fast pin accesss. This is a templated class that provides 1-2 cycle pin access, bypassing digital write and other such things. As such, this will usually be the first bit of the library that you will want to port when moving to a new platform. Once you have FastPIN up and running then you can do some basic work like testing toggles or running bit-bang'd SPI output. + +There's two low level FastPin classes. There's the base FastPIN template class, and then there is FastPinBB which is for bit-banded access on those MCUs that support bitbanding. Note that the bitband class is optional and primarily useful in the implementation of other functionality internal to the platform. This file is also where you would do the pin to port/bit mapping defines. + +Explaining how the macros work and should be used is currently beyond the scope of this document. + +== Porting fastspi.h == + +This is where you define the low level interface to the hardware SPI system (including a writePixels method that does a bunch of housekeeping for writing led data). Use the fastspi_nop.h file as a reference for the methods that need to be implemented. There are ofteh other useful methods that can help with the internals of the SPI code, I recommend taking a look at how the various platforms implement their SPI classes. + +== Porting clockless.h == + +This is where you define the code for the clockless controllers. Across ARM platforms this will usually be fairly similar - though different arm platforms will have different clock sources that you can/should use. diff --git a/libraries/FastLED/README.md b/libraries/FastLED/README.md new file mode 100644 index 0000000..8660b90 --- /dev/null +++ b/libraries/FastLED/README.md @@ -0,0 +1,90 @@ +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/FastLED/public) +[![arduino-library-badge](https://www.ardu-badge.com/badge/FastLED.svg)](https://www.ardu-badge.com/FastLED) + +IMPORTANT NOTE: For AVR based systems, avr-gcc 4.8.x is supported and tested. This means Arduino 1.6.5 and later. + + +FastLED 3.2 +=========== + +This is a library for easily & efficiently controlling a wide variety of LED chipsets, like the ones +sold by adafruit (Neopixel, DotStar, LPD8806), Sparkfun (WS2801), and aliexpress. In addition to writing to the +leds, this library also includes a number of functions for high-performing 8bit math for manipulating +your RGB values, as well as low level classes for abstracting out access to pins and SPI hardware, while +still keeping things as fast as possible. Tested with Arduino up to 1.6.5 from arduino.cc. + +Quick note for people installing from GitHub repo zips, rename the folder FastLED before copying it to your Arduino/libraries folder. Github likes putting -branchname into the name of the folder, which unfortunately, makes Arduino cranky! + +We have multiple goals with this library: + +* Quick start for new developers - hook up your leds and go, no need to think about specifics of the led chipsets being used +* Zero pain switching LED chipsets - you get some new leds that the library supports, just change the definition of LEDs you're using, et. voila! Your code is running with the new leds. +* High performance - with features like zero cost global brightness scaling, high performance 8-bit math for RGB manipulation, and some of the fastest bit-bang'd SPI support around, FastLED wants to keep as many CPU cycles available for your led patterns as possible + +## Getting help + +If you need help with using the library, please consider going to the google+ community first, which is at http://fastled.io/+ - there are hundreds of people in that group and many times you will get a quicker answer to your question there, as you will be likely to run into other people who have had the same issue. If you run into bugs with the library (compilation failures, the library doing the wrong thing), or if you'd like to request that we support a particular platform or LED chipset, then please open an issue at http://fastled.io/issues and we will try to figure out what is going wrong. + +## Simple example + +How quickly can you get up and running with the library? Here's a simple blink program: + + #include "FastLED.h" + #define NUM_LEDS 60 + CRGB leds[NUM_LEDS]; + void setup() { FastLED.addLeds(leds, NUM_LEDS); } + void loop() { + leds[0] = CRGB::White; FastLED.show(); delay(30); + leds[0] = CRGB::Black; FastLED.show(); delay(30); + } + +## Supported LED chipsets + +Here's a list of all the LED chipsets are supported. More details on the led chipsets are included *TODO: Link to wiki page* + +* Adafruit's DotStars - AKA the APA102 +* Adafruit's Neopixel - aka the WS2812B (also WS2811/WS2812/WS2813, also supported in lo-speed mode) - a 3 wire addressable led chipset +* TM1809/4 - 3 wire chipset, cheaply available on aliexpress.com +* TM1803 - 3 wire chipset, sold by radio shack +* UCS1903 - another 3 wire led chipset, cheap +* GW6205 - another 3 wire led chipset +* LPD8806 - SPI based chpiset, very high speed +* WS2801 - SPI based chipset, cheap and widely available +* SM16716 - SPI based chipset +* APA102 - SPI based chipset +* P9813 - aka Cool Neon's Total Control Lighting +* DMX - send rgb data out over DMX using arduino DMX libraries +* SmartMatrix panels - needs the SmartMatrix library - https://github.com/pixelmatix/SmartMatrix +* LPD6803 - SPI based chpiset, chip CMODE pin must be set to 1 (inside oscillator mode) + + +HL1606, and "595"-style shift registers are no longer supported by the library. The older Version 1 of the library ("FastSPI_LED") has support for these, but is missing many of the advanced features of current versions and is no longer being maintained. + + +## Supported platforms + +Right now the library is supported on a variety of arduino compatable platforms. If it's ARM or AVR and uses the arduino software (or a modified version of it to build) then it is likely supported. Note that we have a long list of upcoming platforms to support, so if you don't see what you're looking for here, ask, it may be on the roadmap (or may already be supported). N.B. at the moment we are only supporting the stock compilers that ship with the arduino software. Support for upgraded compilers, as well as using AVR studio and skipping the arduino entirely, should be coming in a near future release. + +* Arduino & compatibles - straight up arduino devices, uno, duo, leonardo, mega, nano, etc... +* Arduino Yún +* Adafruit Trinket & Gemma - Trinket Pro may be supported, but haven't tested to confirm yet +* Teensy 2, Teensy++ 2, Teensy 3.0, Teensy 3.1/3.2, Teensy LC - arduino compataible from pjrc.com with some extra goodies (note the teensy 3, 3.1, and LC are ARM, not AVR!) +* Arduino Due and the digistump DigiX +* RFDuino +* SparkCore +* Arduino Zero +* ESP8266 using the arduino board definitions from http://arduino.esp8266.com/stable/package_esp8266com_index.json - please be sure to also read https://github.com/FastLED/FastLED/wiki/ESP8266-notes for information specific to the 8266. +* The wino board - http://wino-board.com + +What types of platforms are we thinking about supporting in the future? Here's a short list: ChipKit32, Maple, Beagleboard + +## What about that name? + +Wait, what happend to FastSPI_LED and FastSPI_LED2? The library was initially named FastSPI_LED because it was focused on very fast and efficient SPI access. However, since then, the library has expanded to support a number of LED chipsets that don't use SPI, as well as a number of math and utility functions for LED processing across the board. We decided that the name FastLED more accurately represents the totality of what the library provides, everything fast, for LEDs. + +## For more information + +Check out the official site http://fastled.io for links to documentation, issues, and news + + +*TODO* - get candy diff --git a/libraries/FastLED/bitswap.cpp b/libraries/FastLED/bitswap.cpp new file mode 100644 index 0000000..67530c7 --- /dev/null +++ b/libraries/FastLED/bitswap.cpp @@ -0,0 +1,28 @@ +#define FASTLED_INTERNAL +#include "FastLED.h" + +/// Simplified form of bits rotating function. Based on code found here - http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt - rotating +/// data into LSB for a faster write (the code using this data can happily walk the array backwards) +void transpose8x1_noinline(unsigned char *A, unsigned char *B) { + uint32_t x, y, t; + + // Load the array and pack it into x and y. + y = *(unsigned int*)(A); + x = *(unsigned int*)(A+4); + + // pre-transform x + t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7); + t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14); + + // pre-transform y + t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7); + t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14); + + // final transform + t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F); + y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F); + x = t; + + *((uint32_t*)B) = y; + *((uint32_t*)(B+4)) = x; +} diff --git a/libraries/FastLED/bitswap.h b/libraries/FastLED/bitswap.h new file mode 100644 index 0000000..64fed49 --- /dev/null +++ b/libraries/FastLED/bitswap.h @@ -0,0 +1,276 @@ +#ifndef __INC_BITSWAP_H +#define __INC_BITSWAP_H + +#include "FastLED.h" + +FASTLED_NAMESPACE_BEGIN + +///@file bitswap.h +///Functions for rotating bits/bytes + +///@defgroup Bitswap Bit swapping/rotate +///Functions for doing a rotation of bits/bytes used by parallel output +///@{ +#if defined(FASTLED_ARM) || defined(FASTLED_ESP8266) +/// structure representing 8 bits of access +typedef union { + uint8_t raw; + struct { + uint32_t a0:1; + uint32_t a1:1; + uint32_t a2:1; + uint32_t a3:1; + uint32_t a4:1; + uint32_t a5:1; + uint32_t a6:1; + uint32_t a7:1; + }; +} just8bits; + +/// structure representing 32 bits of access +typedef struct { + uint32_t a0:1; + uint32_t a1:1; + uint32_t a2:1; + uint32_t a3:1; + uint32_t a4:1; + uint32_t a5:1; + uint32_t a6:1; + uint32_t a7:1; + uint32_t b0:1; + uint32_t b1:1; + uint32_t b2:1; + uint32_t b3:1; + uint32_t b4:1; + uint32_t b5:1; + uint32_t b6:1; + uint32_t b7:1; + uint32_t c0:1; + uint32_t c1:1; + uint32_t c2:1; + uint32_t c3:1; + uint32_t c4:1; + uint32_t c5:1; + uint32_t c6:1; + uint32_t c7:1; + uint32_t d0:1; + uint32_t d1:1; + uint32_t d2:1; + uint32_t d3:1; + uint32_t d4:1; + uint32_t d5:1; + uint32_t d6:1; + uint32_t d7:1; +} sub4; + +/// union containing a full 8 bytes to swap the bit orientation on +typedef union { + uint32_t word[2]; + uint8_t bytes[8]; + struct { + sub4 a; + sub4 b; + }; +} bitswap_type; + + +#define SWAPSA(X,N) out. X ## 0 = in.a.a ## N; \ + out. X ## 1 = in.a.b ## N; \ + out. X ## 2 = in.a.c ## N; \ + out. X ## 3 = in.a.d ## N; + +#define SWAPSB(X,N) out. X ## 0 = in.b.a ## N; \ + out. X ## 1 = in.b.b ## N; \ + out. X ## 2 = in.b.c ## N; \ + out. X ## 3 = in.b.d ## N; + +#define SWAPS(X,N) out. X ## 0 = in.a.a ## N; \ + out. X ## 1 = in.a.b ## N; \ + out. X ## 2 = in.a.c ## N; \ + out. X ## 3 = in.a.d ## N; \ + out. X ## 4 = in.b.a ## N; \ + out. X ## 5 = in.b.b ## N; \ + out. X ## 6 = in.b.c ## N; \ + out. X ## 7 = in.b.d ## N; + + +/// Do an 8byte by 8bit rotation +__attribute__((always_inline)) inline void swapbits8(bitswap_type in, bitswap_type & out) { + + // SWAPS(a.a,7); + // SWAPS(a.b,6); + // SWAPS(a.c,5); + // SWAPS(a.d,4); + // SWAPS(b.a,3); + // SWAPS(b.b,2); + // SWAPS(b.c,1); + // SWAPS(b.d,0); + + // SWAPSA(a.a,7); + // SWAPSA(a.b,6); + // SWAPSA(a.c,5); + // SWAPSA(a.d,4); + // + // SWAPSB(a.a,7); + // SWAPSB(a.b,6); + // SWAPSB(a.c,5); + // SWAPSB(a.d,4); + // + // SWAPSA(b.a,3); + // SWAPSA(b.b,2); + // SWAPSA(b.c,1); + // SWAPSA(b.d,0); + // // + // SWAPSB(b.a,3); + // SWAPSB(b.b,2); + // SWAPSB(b.c,1); + // SWAPSB(b.d,0); + + for(int i = 0; i < 8; i++) { + just8bits work; + work.a3 = in.word[0] >> 31; + work.a2 = in.word[0] >> 23; + work.a1 = in.word[0] >> 15; + work.a0 = in.word[0] >> 7; + in.word[0] <<= 1; + work.a7 = in.word[1] >> 31; + work.a6 = in.word[1] >> 23; + work.a5 = in.word[1] >> 15; + work.a4 = in.word[1] >> 7; + in.word[1] <<= 1; + out.bytes[i] = work.raw; + } +} + +/// Slow version of the 8 byte by 8 bit rotation +__attribute__((always_inline)) inline void slowswap(unsigned char *A, unsigned char *B) { + + for(int row = 0; row < 7; row++) { + uint8_t x = A[row]; + + uint8_t bit = (1<>= 1) { + if(x & mask) { + *p++ |= bit; + } else { + *p++ &= ~bit; + } + } + // B[7] |= (x & 0x01) << row; x >>= 1; + // B[6] |= (x & 0x01) << row; x >>= 1; + // B[5] |= (x & 0x01) << row; x >>= 1; + // B[4] |= (x & 0x01) << row; x >>= 1; + // B[3] |= (x & 0x01) << row; x >>= 1; + // B[2] |= (x & 0x01) << row; x >>= 1; + // B[1] |= (x & 0x01) << row; x >>= 1; + // B[0] |= (x & 0x01) << row; x >>= 1; + } +} + +void transpose8x1_noinline(unsigned char *A, unsigned char *B); + +/// Simplified form of bits rotating function. Based on code found here - http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt - rotating +/// data into LSB for a faster write (the code using this data can happily walk the array backwards) +__attribute__((always_inline)) inline void transpose8x1(unsigned char *A, unsigned char *B) { + uint32_t x, y, t; + + // Load the array and pack it into x and y. + y = *(unsigned int*)(A); + x = *(unsigned int*)(A+4); + + // pre-transform x + t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7); + t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14); + + // pre-transform y + t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7); + t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14); + + // final transform + t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F); + y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F); + x = t; + + *((uint32_t*)B) = y; + *((uint32_t*)(B+4)) = x; +} + +/// Simplified form of bits rotating function. Based on code found here - http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt +__attribute__((always_inline)) inline void transpose8x1_MSB(unsigned char *A, unsigned char *B) { + uint32_t x, y, t; + + // Load the array and pack it into x and y. + y = *(unsigned int*)(A); + x = *(unsigned int*)(A+4); + + // pre-transform x + t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7); + t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14); + + // pre-transform y + t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7); + t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14); + + // final transform + t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F); + y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F); + x = t; + + B[7] = y; y >>= 8; + B[6] = y; y >>= 8; + B[5] = y; y >>= 8; + B[4] = y; + + B[3] = x; x >>= 8; + B[2] = x; x >>= 8; + B[1] = x; x >>= 8; + B[0] = x; /* */ +} + +/// templated bit-rotating function. Based on code found here - http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt +template +__attribute__((always_inline)) inline void transpose8(unsigned char *A, unsigned char *B) { + uint32_t x, y, t; + + // Load the array and pack it into x and y. + if(m == 1) { + y = *(unsigned int*)(A); + x = *(unsigned int*)(A+4); + } else { + x = (A[0]<<24) | (A[m]<<16) | (A[2*m]<<8) | A[3*m]; + y = (A[4*m]<<24) | (A[5*m]<<16) | (A[6*m]<<8) | A[7*m]; + } + + // pre-transform x + t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7); + t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14); + + // pre-transform y + t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7); + t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14); + + // final transform + t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F); + y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F); + x = t; + + B[7*n] = y; y >>= 8; + B[6*n] = y; y >>= 8; + B[5*n] = y; y >>= 8; + B[4*n] = y; + + B[3*n] = x; x >>= 8; + B[2*n] = x; x >>= 8; + B[n] = x; x >>= 8; + B[0] = x; + // B[0]=x>>24; B[n]=x>>16; B[2*n]=x>>8; B[3*n]=x>>0; + // B[4*n]=y>>24; B[5*n]=y>>16; B[6*n]=y>>8; B[7*n]=y>>0; +} + +#endif + +FASTLED_NAMESPACE_END + +///@} +#endif diff --git a/libraries/FastLED/chipsets.h b/libraries/FastLED/chipsets.h new file mode 100644 index 0000000..97ddc94 --- /dev/null +++ b/libraries/FastLED/chipsets.h @@ -0,0 +1,591 @@ +#ifndef __INC_CHIPSETS_H +#define __INC_CHIPSETS_H + +#include "FastLED.h" +#include "pixeltypes.h" + +///@file chipsets.h +/// contains the bulk of the definitions for the various LED chipsets supported. + +FASTLED_NAMESPACE_BEGIN +///@defgroup chipsets +/// Implementations of CLEDController classes for various led chipsets. +/// +///@{ + +#if defined(ARDUINO) //&& defined(SoftwareSerial_h) + + +#if defined(SoftwareSerial_h) +#include + +#define HAS_PIXIE + +/// Adafruit Pixie controller class +/// @tparam DATAPIN the pin to write data out on +/// @tparam RGB_ORDER the RGB ordering for the led data +template +class PixieController : public CPixelLEDController { + SoftwareSerial Serial; + CMinWait<2000> mWait; +public: + PixieController() : Serial(-1, DATA_PIN) {} + +protected: + virtual void init() { + Serial.begin(115200); + mWait.mark(); + } + + virtual void showPixels(PixelController & pixels) { + mWait.wait(); + while(pixels.has(1)) { + uint8_t r = pixels.loadAndScale0(); + Serial.write(r); + uint8_t g = pixels.loadAndScale1(); + Serial.write(g); + uint8_t b = pixels.loadAndScale2(); + Serial.write(b); + pixels.advanceData(); + pixels.stepDithering(); + } + mWait.mark(); + } + +}; + +// template +// class PixieController : public PixieBaseController { +// public: +// virtual void init() { +// STREAM.begin(115200); +// } +// }; +#endif +#endif + +///@name Clocked chipsets - nominally SPI based these chipsets have a data and a clock line. +///@{ +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// LPD8806 controller class - takes data/clock/select pin values (N.B. should take an SPI definition?) +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/// LPD8806 controller class. +/// @tparam DATA_PIN the data pin for these leds +/// @tparam CLOCK_PIN the clock pin for these leds +/// @tparam RGB_ORDER the RGB ordering for these leds +/// @tparam SPI_SPEED the clock divider used for these leds. Set using the DATA_RATE_MHZ/DATA_RATE_KHZ macros. Defaults to DATA_RATE_MHZ(12) +template +class LPD8806Controller : public CPixelLEDController { + typedef SPIOutput SPI; + + class LPD8806_ADJUST { + public: + // LPD8806 spec wants the high bit of every rgb data byte sent out to be set. + __attribute__((always_inline)) inline static uint8_t adjust(register uint8_t data) { return ((data>>1) | 0x80) + ((data && (data<254)) & 0x01); } + __attribute__((always_inline)) inline static void postBlock(int len) { + SPI::writeBytesValueRaw(0, ((len*3+63)>>6)); + } + + }; + + SPI mSPI; +public: + + LPD8806Controller() {} + virtual void init() { + mSPI.init(); + } + +protected: + + virtual void showPixels(PixelController & pixels) { + mSPI.template writePixels<0, LPD8806_ADJUST, RGB_ORDER>(pixels); + } +}; + + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// WS2801 definition - takes data/clock/select pin values (N.B. should take an SPI definition?) +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/// WS2801 controller class. +/// @tparam DATA_PIN the data pin for these leds +/// @tparam CLOCK_PIN the clock pin for these leds +/// @tparam RGB_ORDER the RGB ordering for these leds +/// @tparam SPI_SPEED the clock divider used for these leds. Set using the DATA_RATE_MHZ/DATA_RATE_KHZ macros. Defaults to DATA_RATE_MHZ(1) +template +class WS2801Controller : public CPixelLEDController { + typedef SPIOutput SPI; + SPI mSPI; + CMinWait<1000> mWaitDelay; +public: + WS2801Controller() {} + + virtual void init() { + mSPI.init(); + mWaitDelay.mark(); + } + +protected: + + virtual void showPixels(PixelController & pixels) { + mWaitDelay.wait(); + mSPI.template writePixels<0, DATA_NOP, RGB_ORDER>(pixels); + mWaitDelay.mark(); + } +}; + +template +class WS2803Controller : public WS2801Controller {}; + +/// LPD6803 controller class (LPD1101). +/// 16 bit (1 bit - const "1", 5 bit - red, 5 bit - green, 5 bit blue). +/// In chip CMODE pin must be set to 1 (inside oscillator mode). +/// Datasheet: https://cdn-shop.adafruit.com/datasheets/LPD6803.pdf +/// @tparam DATA_PIN the data pin for these leds +/// @tparam CLOCK_PIN the clock pin for these leds +/// @tparam RGB_ORDER the RGB ordering for these leds +/// @tparam SPI_SPEED the clock divider used for these leds. Set using the DATA_RATE_MHZ/DATA_RATE_KHZ macros. Defaults to DATA_RATE_MHZ(12) +template +class LPD6803Controller : public CPixelLEDController { + typedef SPIOutput SPI; + SPI mSPI; + + void startBoundary() { mSPI.writeByte(0); mSPI.writeByte(0); mSPI.writeByte(0); mSPI.writeByte(0); } + +public: + LPD6803Controller() {} + + virtual void init() { + mSPI.init(); + } + +protected: + + virtual void showPixels(PixelController & pixels) { + mSPI.select(); + + startBoundary(); + while(pixels.has(1)) { + register uint16_t command; + command = 0x8000; + command |= (pixels.loadAndScale0() & 0xF8) << 7; // red is the high 5 bits + command |= (pixels.loadAndScale1() & 0xF8) << 2; // green is the middle 5 bits + mSPI.writeByte((command >> 8) & 0xFF); + command |= pixels.loadAndScale2() >> 3 ; // blue is the low 5 bits + mSPI.writeByte(command & 0xFF); + + pixels.stepDithering(); + pixels.advanceData(); + } + //endBoundary(pixels.size()); + mSPI.waitFully(); + mSPI.release(); + } + +}; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// APA102 definition - takes data/clock/select pin values (N.B. should take an SPI definition?) +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/// APA102 controller class. +/// @tparam DATA_PIN the data pin for these leds +/// @tparam CLOCK_PIN the clock pin for these leds +/// @tparam RGB_ORDER the RGB ordering for these leds +/// @tparam SPI_SPEED the clock divider used for these leds. Set using the DATA_RATE_MHZ/DATA_RATE_KHZ macros. Defaults to DATA_RATE_MHZ(12) +template +class APA102Controller : public CPixelLEDController { + typedef SPIOutput SPI; + SPI mSPI; + + void startBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); } + void endBoundary(int nLeds) { int nDWords = (nLeds/32); do { mSPI.writeByte(0xFF); mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); } while(nDWords--); } + + inline void writeLed(uint8_t brightness, uint8_t b0, uint8_t b1, uint8_t b2) __attribute__((always_inline)) { +#ifdef FASTLED_SPI_BYTE_ONLY + mSPI.writeByte(0xE0 | brightness); + mSPI.writeByte(b0); + mSPI.writeByte(b1); + mSPI.writeByte(b2); +#else + uint16_t b = 0xE000 | (brightness << 8) | (uint16_t)b0; + mSPI.writeWord(b); + uint16_t w = b1 << 8; + w |= b2; + mSPI.writeWord(w); +#endif + } + +public: + APA102Controller() {} + + virtual void init() { + mSPI.init(); + } + +protected: + + virtual void showPixels(PixelController & pixels) { + mSPI.select(); + + uint8_t s0 = pixels.getScale0(), s1 = pixels.getScale1(), s2 = pixels.getScale2(); +#if FASTLED_USE_GLOBAL_BRIGHTNESS == 1 + const uint16_t maxBrightness = 0x1F; + uint16_t brightness = ((((uint16_t)max(max(s0, s1), s2) + 1) * maxBrightness - 1) >> 8) + 1; + s0 = (maxBrightness * s0 + (brightness >> 1)) / brightness; + s1 = (maxBrightness * s1 + (brightness >> 1)) / brightness; + s2 = (maxBrightness * s2 + (brightness >> 1)) / brightness; +#else + const uint8_t brightness = 0x1F; +#endif + + startBoundary(); + while (pixels.has(1)) { + writeLed(brightness, pixels.loadAndScale0(0, s0), pixels.loadAndScale1(0, s1), pixels.loadAndScale2(0, s2)); + pixels.stepDithering(); + pixels.advanceData(); + } + endBoundary(pixels.size()); + + mSPI.waitFully(); + mSPI.release(); + } + +}; + +/// SK9822 controller class. +/// @tparam DATA_PIN the data pin for these leds +/// @tparam CLOCK_PIN the clock pin for these leds +/// @tparam RGB_ORDER the RGB ordering for these leds +/// @tparam SPI_SPEED the clock divider used for these leds. Set using the DATA_RATE_MHZ/DATA_RATE_KHZ macros. Defaults to DATA_RATE_MHZ(24) +template +class SK9822Controller : public CPixelLEDController { + typedef SPIOutput SPI; + SPI mSPI; + + void startBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); } + void endBoundary(int nLeds) { int nLongWords = (nLeds/32); do { mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); } while(nLongWords--); } + + inline void writeLed(uint8_t brightness, uint8_t b0, uint8_t b1, uint8_t b2) __attribute__((always_inline)) { +#ifdef FASTLED_SPI_BYTE_ONLY + mSPI.writeByte(0xE0 | brightness); + mSPI.writeByte(b0); + mSPI.writeByte(b1); + mSPI.writeByte(b2); +#else + uint16_t b = 0xE000 | (brightness << 8) | (uint16_t)b0; + mSPI.writeWord(b); + uint16_t w = b1 << 8; + w |= b2; + mSPI.writeWord(w); +#endif + } + +public: + SK9822Controller() {} + + virtual void init() { + mSPI.init(); + } + +protected: + + virtual void showPixels(PixelController & pixels) { + mSPI.select(); + + uint8_t s0 = pixels.getScale0(), s1 = pixels.getScale1(), s2 = pixels.getScale2(); +#if FASTLED_USE_GLOBAL_BRIGHTNESS == 1 + const uint16_t maxBrightness = 0x1F; + uint16_t brightness = ((((uint16_t)max(max(s0, s1), s2) + 1) * maxBrightness - 1) >> 8) + 1; + s0 = (maxBrightness * s0 + (brightness >> 1)) / brightness; + s1 = (maxBrightness * s1 + (brightness >> 1)) / brightness; + s2 = (maxBrightness * s2 + (brightness >> 1)) / brightness; +#else + const uint8_t brightness = 0x1F; +#endif + + startBoundary(); + while (pixels.has(1)) { + writeLed(brightness, pixels.loadAndScale0(0, s0), pixels.loadAndScale1(0, s1), pixels.loadAndScale2(0, s2)); + pixels.stepDithering(); + pixels.advanceData(); + } + + endBoundary(pixels.size()); + + mSPI.waitFully(); + mSPI.release(); + } + +}; + + + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// P9813 definition - takes data/clock/select pin values (N.B. should take an SPI definition?) +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/// P9813 controller class. +/// @tparam DATA_PIN the data pin for these leds +/// @tparam CLOCK_PIN the clock pin for these leds +/// @tparam RGB_ORDER the RGB ordering for these leds +/// @tparam SPI_SPEED the clock divider used for these leds. Set using the DATA_RATE_MHZ/DATA_RATE_KHZ macros. Defaults to DATA_RATE_MHZ(10) +template +class P9813Controller : public CPixelLEDController { + typedef SPIOutput SPI; + SPI mSPI; + + void writeBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); } + + inline void writeLed(uint8_t r, uint8_t g, uint8_t b) __attribute__((always_inline)) { + register uint8_t top = 0xC0 | ((~b & 0xC0) >> 2) | ((~g & 0xC0) >> 4) | ((~r & 0xC0) >> 6); + mSPI.writeByte(top); mSPI.writeByte(b); mSPI.writeByte(g); mSPI.writeByte(r); + } + +public: + P9813Controller() {} + + virtual void init() { + mSPI.init(); + } + +protected: + + virtual void showPixels(PixelController & pixels) { + mSPI.select(); + + writeBoundary(); + while(pixels.has(1)) { + writeLed(pixels.loadAndScale0(), pixels.loadAndScale1(), pixels.loadAndScale2()); + pixels.advanceData(); + pixels.stepDithering(); + } + writeBoundary(); + mSPI.waitFully(); + + mSPI.release(); + } + +}; + + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// SM16716 definition - takes data/clock/select pin values (N.B. should take an SPI definition?) +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/// SM16716 controller class. +/// @tparam DATA_PIN the data pin for these leds +/// @tparam CLOCK_PIN the clock pin for these leds +/// @tparam RGB_ORDER the RGB ordering for these leds +/// @tparam SPI_SPEED the clock divider used for these leds. Set using the DATA_RATE_MHZ/DATA_RATE_KHZ macros. Defaults to DATA_RATE_MHZ(16) +template +class SM16716Controller : public CPixelLEDController { + typedef SPIOutput SPI; + SPI mSPI; + + void writeHeader() { + // Write out 50 zeros to the spi line (6 blocks of 8 followed by two single bit writes) + mSPI.select(); + mSPI.writeBytesValueRaw(0, 6); + mSPI.waitFully(); + mSPI.template writeBit<0>(0); + mSPI.template writeBit<0>(0); + mSPI.release(); + } + +public: + SM16716Controller() {} + + virtual void init() { + mSPI.init(); + } + +protected: + + virtual void showPixels(PixelController & pixels) { + // Make sure the FLAG_START_BIT flag is set to ensure that an extra 1 bit is sent at the start + // of each triplet of bytes for rgb data + // writeHeader(); + mSPI.template writePixels( pixels ); + writeHeader(); + } + +}; +/// @} +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Clockless template instantiations - see clockless.h for how the timing values are used +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef FASTLED_HAS_CLOCKLESS +/// @name clockless controllers +/// Provides timing definitions for the variety of clockless controllers supplied by the library. +/// @{ + +// We want to force all avr's to use the Trinket controller when running at 8Mhz, because even the 328's at 8Mhz +// need the more tightly defined timeframes. +#if (F_CPU == 8000000 || F_CPU == 16000000 || F_CPU == 24000000) // || F_CPU == 48000000 || F_CPU == 96000000) // 125ns/clock +#define FMUL (F_CPU/8000000) + +// GE8822 +template +class GE8822Controller800Khz : public ClocklessController {}; + +// LPD1886 +template +class LPD1886Controller1250Khz : public ClocklessController {}; + +// LPD1886 +template +class LPD1886Controller1250Khz_8bit : public ClocklessController {}; + +// WS2811@800khz 2 clocks, 5 clocks, 3 clocks +template +class WS2812Controller800Khz : public ClocklessController {}; + +template +class WS2811Controller800Khz : public ClocklessController {}; + +template //not tested +class WS2813Controller : public ClocklessController {}; + +template +class WS2811Controller400Khz : public ClocklessController {}; + +template +class SK6822Controller : public ClocklessController {}; + +template +class SM16703Controller : public ClocklessController {}; + +template +class SK6812Controller : public ClocklessController {}; + +template +class UCS1903Controller400Khz : public ClocklessController {}; + +template +class UCS1903BController800Khz : public ClocklessController {}; + +template +class UCS1904Controller800Khz : public ClocklessController {}; + +template +class UCS2903Controller : public ClocklessController {}; + +template +class TM1809Controller800Khz : public ClocklessController {}; + +template +class TM1803Controller400Khz : public ClocklessController {}; + +template +class TM1829Controller800Khz : public ClocklessController {}; + +template +class GW6205Controller400Khz : public ClocklessController {}; + +template +class GW6205Controller800Khz : public ClocklessController {}; + +template +class PL9823Controller : public ClocklessController {}; + +#else +// GE8822 - 350ns 660ns 350ns +template +class GE8822Controller800Khz : public ClocklessController {}; + +// GW6205@400khz - 800ns, 800ns, 800ns +template +class GW6205Controller400Khz : public ClocklessController {}; + +// GW6205@400khz - 400ns, 400ns, 400ns +template +class GW6205Controller800Khz : public ClocklessController {}; + +// UCS1903 - 500ns, 1500ns, 500ns +template +class UCS1903Controller400Khz : public ClocklessController {}; + +// UCS1903B - 400ns, 450ns, 450ns +template +class UCS1903BController800Khz : public ClocklessController {}; + +// UCS1904 - 400ns, 400ns, 450ns +template +class UCS1904Controller800Khz : public ClocklessController {}; + +// UCS2903 - 250ns, 750ns, 250ns +template +class UCS2903Controller : public ClocklessController {}; + +// TM1809 - 350ns, 350ns, 550ns +template +class TM1809Controller800Khz : public ClocklessController {}; + +// WS2811 - 320ns, 320ns, 640ns +template +class WS2811Controller800Khz : public ClocklessController {}; + +// WS2813 - 320ns, 320ns, 640ns +template +class WS2813Controller : public ClocklessController {}; + +// WS2812 - 250ns, 625ns, 375ns +template +class WS2812Controller800Khz : public ClocklessController {}; + +// WS2811@400khz - 800ns, 800ns, 900ns +template +class WS2811Controller400Khz : public ClocklessController {}; + +// 750NS, 750NS, 750NS +template +class TM1803Controller400Khz : public ClocklessController {}; + +template +class TM1829Controller800Khz : public ClocklessController {}; + +template +class TM1829Controller1600Khz : public ClocklessController {}; + +template +class LPD1886Controller1250Khz : public ClocklessController {}; + +template +class LPD1886Controller1250Khz_8bit : public ClocklessController {}; + + +template +class SK6822Controller : public ClocklessController {}; + +template +class SK6812Controller : public ClocklessController {}; + +template +class SM16703Controller : public ClocklessController {}; + +template +class PL9823Controller : public ClocklessController {}; +#endif +///@} + +#endif +///@} +FASTLED_NAMESPACE_END + +#endif diff --git a/libraries/FastLED/color.h b/libraries/FastLED/color.h new file mode 100644 index 0000000..1ed60b4 --- /dev/null +++ b/libraries/FastLED/color.h @@ -0,0 +1,84 @@ +#ifndef __INC_COLOR_H +#define __INC_COLOR_H + +#include "FastLED.h" + +FASTLED_NAMESPACE_BEGIN + +///@file color.h +/// contains definitions for color correction and temperature +///@defgroup ColorEnums Color correction/temperature +/// definitions for color correction and light temperatures +///@{ +typedef enum { + // Color correction starting points + + /// typical values for SMD5050 LEDs + ///@{ + TypicalSMD5050=0xFFB0F0 /* 255, 176, 240 */, + TypicalLEDStrip=0xFFB0F0 /* 255, 176, 240 */, + ///@} + + /// typical values for 8mm "pixels on a string" + /// also for many through-hole 'T' package LEDs + ///@{ + Typical8mmPixel=0xFFE08C /* 255, 224, 140 */, + TypicalPixelString=0xFFE08C /* 255, 224, 140 */, + ///@} + + /// uncorrected color + UncorrectedColor=0xFFFFFF + +} LEDColorCorrection; + + +typedef enum { + /// @name Black-body radiation light sources + /// Black-body radiation light sources emit a (relatively) continuous + /// spectrum, and can be described as having a Kelvin 'temperature' + ///@{ + /// 1900 Kelvin + Candle=0xFF9329 /* 1900 K, 255, 147, 41 */, + /// 2600 Kelvin + Tungsten40W=0xFFC58F /* 2600 K, 255, 197, 143 */, + /// 2850 Kelvin + Tungsten100W=0xFFD6AA /* 2850 K, 255, 214, 170 */, + /// 3200 Kelvin + Halogen=0xFFF1E0 /* 3200 K, 255, 241, 224 */, + /// 5200 Kelvin + CarbonArc=0xFFFAF4 /* 5200 K, 255, 250, 244 */, + /// 5400 Kelvin + HighNoonSun=0xFFFFFB /* 5400 K, 255, 255, 251 */, + /// 6000 Kelvin + DirectSunlight=0xFFFFFF /* 6000 K, 255, 255, 255 */, + /// 7000 Kelvin + OvercastSky=0xC9E2FF /* 7000 K, 201, 226, 255 */, + /// 20000 Kelvin + ClearBlueSky=0x409CFF /* 20000 K, 64, 156, 255 */, + ///@} + + /// @name Gaseous light sources + /// Gaseous light sources emit discrete spectral bands, and while we can + /// approximate their aggregate hue with RGB values, they don't actually + /// have a proper Kelvin temperature. + ///@{ + WarmFluorescent=0xFFF4E5 /* 0 K, 255, 244, 229 */, + StandardFluorescent=0xF4FFFA /* 0 K, 244, 255, 250 */, + CoolWhiteFluorescent=0xD4EBFF /* 0 K, 212, 235, 255 */, + FullSpectrumFluorescent=0xFFF4F2 /* 0 K, 255, 244, 242 */, + GrowLightFluorescent=0xFFEFF7 /* 0 K, 255, 239, 247 */, + BlackLightFluorescent=0xA700FF /* 0 K, 167, 0, 255 */, + MercuryVapor=0xD8F7FF /* 0 K, 216, 247, 255 */, + SodiumVapor=0xFFD1B2 /* 0 K, 255, 209, 178 */, + MetalHalide=0xF2FCFF /* 0 K, 242, 252, 255 */, + HighPressureSodium=0xFFB74C /* 0 K, 255, 183, 76 */, + ///@} + + /// Uncorrected temperature 0xFFFFFF + UncorrectedTemperature=0xFFFFFF +} ColorTemperature; + +FASTLED_NAMESPACE_END + +///@} +#endif diff --git a/libraries/FastLED/colorpalettes.cpp b/libraries/FastLED/colorpalettes.cpp new file mode 100644 index 0000000..3c3a1f5 --- /dev/null +++ b/libraries/FastLED/colorpalettes.cpp @@ -0,0 +1,174 @@ +#ifndef __INC_COLORPALETTES_H +#define __INC_COLORPALETTES_H +#define FASTLED_INTERNAL +#include "FastLED.h" +#include "colorutils.h" +#include "colorpalettes.h" + +FASTLED_USING_NAMESPACE + + +// Preset color schemes, such as they are. + +// These schemes are all declared as "PROGMEM", meaning +// that they won't take up SRAM on AVR chips until used. +// Furthermore, the compiler won't even include these +// in your PROGMEM (flash) storage unless you specifically +// use each one, so you only 'pay for' those you actually use. + + +extern const TProgmemRGBPalette16 CloudColors_p FL_PROGMEM = +{ + CRGB::Blue, + CRGB::DarkBlue, + CRGB::DarkBlue, + CRGB::DarkBlue, + + CRGB::DarkBlue, + CRGB::DarkBlue, + CRGB::DarkBlue, + CRGB::DarkBlue, + + CRGB::Blue, + CRGB::DarkBlue, + CRGB::SkyBlue, + CRGB::SkyBlue, + + CRGB::LightBlue, + CRGB::White, + CRGB::LightBlue, + CRGB::SkyBlue +}; + +extern const TProgmemRGBPalette16 LavaColors_p FL_PROGMEM = +{ + CRGB::Black, + CRGB::Maroon, + CRGB::Black, + CRGB::Maroon, + + CRGB::DarkRed, + CRGB::Maroon, + CRGB::DarkRed, + + CRGB::DarkRed, + CRGB::DarkRed, + CRGB::Red, + CRGB::Orange, + + CRGB::White, + CRGB::Orange, + CRGB::Red, + CRGB::DarkRed +}; + + +extern const TProgmemRGBPalette16 OceanColors_p FL_PROGMEM = +{ + CRGB::MidnightBlue, + CRGB::DarkBlue, + CRGB::MidnightBlue, + CRGB::Navy, + + CRGB::DarkBlue, + CRGB::MediumBlue, + CRGB::SeaGreen, + CRGB::Teal, + + CRGB::CadetBlue, + CRGB::Blue, + CRGB::DarkCyan, + CRGB::CornflowerBlue, + + CRGB::Aquamarine, + CRGB::SeaGreen, + CRGB::Aqua, + CRGB::LightSkyBlue +}; + +extern const TProgmemRGBPalette16 ForestColors_p FL_PROGMEM = +{ + CRGB::DarkGreen, + CRGB::DarkGreen, + CRGB::DarkOliveGreen, + CRGB::DarkGreen, + + CRGB::Green, + CRGB::ForestGreen, + CRGB::OliveDrab, + CRGB::Green, + + CRGB::SeaGreen, + CRGB::MediumAquamarine, + CRGB::LimeGreen, + CRGB::YellowGreen, + + CRGB::LightGreen, + CRGB::LawnGreen, + CRGB::MediumAquamarine, + CRGB::ForestGreen +}; + +/// HSV Rainbow +extern const TProgmemRGBPalette16 RainbowColors_p FL_PROGMEM = +{ + 0xFF0000, 0xD52A00, 0xAB5500, 0xAB7F00, + 0xABAB00, 0x56D500, 0x00FF00, 0x00D52A, + 0x00AB55, 0x0056AA, 0x0000FF, 0x2A00D5, + 0x5500AB, 0x7F0081, 0xAB0055, 0xD5002B +}; + +/// HSV Rainbow colors with alternatating stripes of black +#define RainbowStripesColors_p RainbowStripeColors_p +extern const TProgmemRGBPalette16 RainbowStripeColors_p FL_PROGMEM = +{ + 0xFF0000, 0x000000, 0xAB5500, 0x000000, + 0xABAB00, 0x000000, 0x00FF00, 0x000000, + 0x00AB55, 0x000000, 0x0000FF, 0x000000, + 0x5500AB, 0x000000, 0xAB0055, 0x000000 +}; + +/// HSV color ramp: blue purple ping red orange yellow (and back) +/// Basically, everything but the greens, which tend to make +/// people's skin look unhealthy. This palette is good for +/// lighting at a club or party, where it'll be shining on people. +extern const TProgmemRGBPalette16 PartyColors_p FL_PROGMEM = +{ + 0x5500AB, 0x84007C, 0xB5004B, 0xE5001B, + 0xE81700, 0xB84700, 0xAB7700, 0xABAB00, + 0xAB5500, 0xDD2200, 0xF2000E, 0xC2003E, + 0x8F0071, 0x5F00A1, 0x2F00D0, 0x0007F9 +}; + +/// Approximate "black body radiation" palette, akin to +/// the FastLED 'HeatColor' function. +/// Recommend that you use values 0-240 rather than +/// the usual 0-255, as the last 15 colors will be +/// 'wrapping around' from the hot end to the cold end, +/// which looks wrong. +extern const TProgmemRGBPalette16 HeatColors_p FL_PROGMEM = +{ + 0x000000, + 0x330000, 0x660000, 0x990000, 0xCC0000, 0xFF0000, + 0xFF3300, 0xFF6600, 0xFF9900, 0xFFCC00, 0xFFFF00, + 0xFFFF33, 0xFFFF66, 0xFFFF99, 0xFFFFCC, 0xFFFFFF +}; + + +// Gradient palette "Rainbow_gp", +// provided for situations where you're going +// to use a number of other gradient palettes, AND +// you want a 'standard' FastLED rainbow as well. + +DEFINE_GRADIENT_PALETTE( Rainbow_gp ) { + 0, 255, 0, 0, // Red + 32, 171, 85, 0, // Orange + 64, 171,171, 0, // Yellow + 96, 0,255, 0, // Green + 128, 0,171, 85, // Aqua + 160, 0, 0,255, // Blue + 192, 85, 0,171, // Purple + 224, 171, 0, 85, // Pink + 255, 255, 0, 0};// and back to Red + +#endif diff --git a/libraries/FastLED/colorpalettes.h b/libraries/FastLED/colorpalettes.h new file mode 100644 index 0000000..4458575 --- /dev/null +++ b/libraries/FastLED/colorpalettes.h @@ -0,0 +1,57 @@ +#ifndef __INC_COLORPALETTES_H +#define __INC_COLORPALETTES_H + +#include "FastLED.h" +#include "colorutils.h" + +///@file colorpalettes.h +/// contains definitions for the predefined color palettes supplied by FastLED. + +FASTLED_NAMESPACE_BEGIN + +///@defgroup Colorpalletes Pre-defined color palletes +/// These schemes are all declared as "PROGMEM", meaning +/// that they won't take up SRAM on AVR chips until used. +/// Furthermore, the compiler won't even include these +/// in your PROGMEM (flash) storage unless you specifically +/// use each one, so you only 'pay for' those you actually use. + +///@{ + +/// Cloudy color pallete +extern const TProgmemRGBPalette16 CloudColors_p FL_PROGMEM; +/// Lava colors +extern const TProgmemRGBPalette16 LavaColors_p FL_PROGMEM; +/// Ocean colors, blues and whites +extern const TProgmemRGBPalette16 OceanColors_p FL_PROGMEM; +/// Forest colors, greens +extern const TProgmemRGBPalette16 ForestColors_p FL_PROGMEM; + +/// HSV Rainbow +extern const TProgmemRGBPalette16 RainbowColors_p FL_PROGMEM; + +#define RainbowStripesColors_p RainbowStripeColors_p +/// HSV Rainbow colors with alternatating stripes of black +extern const TProgmemRGBPalette16 RainbowStripeColors_p FL_PROGMEM; + +/// HSV color ramp: blue purple ping red orange yellow (and back) +/// Basically, everything but the greens, which tend to make +/// people's skin look unhealthy. This palette is good for +/// lighting at a club or party, where it'll be shining on people. +extern const TProgmemRGBPalette16 PartyColors_p FL_PROGMEM; + +/// Approximate "black body radiation" palette, akin to +/// the FastLED 'HeatColor' function. +/// Recommend that you use values 0-240 rather than +/// the usual 0-255, as the last 15 colors will be +/// 'wrapping around' from the hot end to the cold end, +/// which looks wrong. +extern const TProgmemRGBPalette16 HeatColors_p FL_PROGMEM; + + +DECLARE_GRADIENT_PALETTE( Rainbow_gp); + +FASTLED_NAMESPACE_END + +///@} +#endif diff --git a/libraries/FastLED/colorutils.cpp b/libraries/FastLED/colorutils.cpp new file mode 100644 index 0000000..10d3592 --- /dev/null +++ b/libraries/FastLED/colorutils.cpp @@ -0,0 +1,1198 @@ +#define FASTLED_INTERNAL +#define __PROG_TYPES_COMPAT__ + +#include +#include + +#include "FastLED.h" + +FASTLED_NAMESPACE_BEGIN + + + +void fill_solid( struct CRGB * leds, int numToFill, + const struct CRGB& color) +{ + for( int i = 0; i < numToFill; i++) { + leds[i] = color; + } +} + +void fill_solid( struct CHSV * targetArray, int numToFill, + const struct CHSV& hsvColor) +{ + for( int i = 0; i < numToFill; i++) { + targetArray[i] = hsvColor; + } +} + + +// void fill_solid( struct CRGB* targetArray, int numToFill, +// const struct CHSV& hsvColor) +// { +// fill_solid( targetArray, numToFill, (CRGB) hsvColor); +// } + +void fill_rainbow( struct CRGB * pFirstLED, int numToFill, + uint8_t initialhue, + uint8_t deltahue ) +{ + CHSV hsv; + hsv.hue = initialhue; + hsv.val = 255; + hsv.sat = 240; + for( int i = 0; i < numToFill; i++) { + pFirstLED[i] = hsv; + hsv.hue += deltahue; + } +} + +void fill_rainbow( struct CHSV * targetArray, int numToFill, + uint8_t initialhue, + uint8_t deltahue ) +{ + CHSV hsv; + hsv.hue = initialhue; + hsv.val = 255; + hsv.sat = 240; + for( int i = 0; i < numToFill; i++) { + targetArray[i] = hsv; + hsv.hue += deltahue; + } +} + + +void fill_gradient_RGB( CRGB* leds, + uint16_t startpos, CRGB startcolor, + uint16_t endpos, CRGB endcolor ) +{ + // if the points are in the wrong order, straighten them + if( endpos < startpos ) { + uint16_t t = endpos; + CRGB tc = endcolor; + endcolor = startcolor; + endpos = startpos; + startpos = t; + startcolor = tc; + } + + saccum87 rdistance87; + saccum87 gdistance87; + saccum87 bdistance87; + + rdistance87 = (endcolor.r - startcolor.r) << 7; + gdistance87 = (endcolor.g - startcolor.g) << 7; + bdistance87 = (endcolor.b - startcolor.b) << 7; + + uint16_t pixeldistance = endpos - startpos; + int16_t divisor = pixeldistance ? pixeldistance : 1; + + saccum87 rdelta87 = rdistance87 / divisor; + saccum87 gdelta87 = gdistance87 / divisor; + saccum87 bdelta87 = bdistance87 / divisor; + + rdelta87 *= 2; + gdelta87 *= 2; + bdelta87 *= 2; + + accum88 r88 = startcolor.r << 8; + accum88 g88 = startcolor.g << 8; + accum88 b88 = startcolor.b << 8; + for( uint16_t i = startpos; i <= endpos; i++) { + leds[i] = CRGB( r88 >> 8, g88 >> 8, b88 >> 8); + r88 += rdelta87; + g88 += gdelta87; + b88 += bdelta87; + } +} + +#if 0 +void fill_gradient( const CHSV& c1, const CHSV& c2) +{ + fill_gradient( FastLED[0].leds(), FastLED[0].size(), c1, c2); +} + +void fill_gradient( const CHSV& c1, const CHSV& c2, const CHSV& c3) +{ + fill_gradient( FastLED[0].leds(), FastLED[0].size(), c1, c2, c3); +} + +void fill_gradient( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4) +{ + fill_gradient( FastLED[0].leds(), FastLED[0].size(), c1, c2, c3, c4); +} + +void fill_gradient_RGB( const CRGB& c1, const CRGB& c2) +{ + fill_gradient_RGB( FastLED[0].leds(), FastLED[0].size(), c1, c2); +} + +void fill_gradient_RGB( const CRGB& c1, const CRGB& c2, const CRGB& c3) +{ + fill_gradient_RGB( FastLED[0].leds(), FastLED[0].size(), c1, c2, c3); +} + +void fill_gradient_RGB( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4) +{ + fill_gradient_RGB( FastLED[0].leds(), FastLED[0].size(), c1, c2, c3, c4); +} +#endif + + + + +void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2) +{ + uint16_t last = numLeds - 1; + fill_gradient_RGB( leds, 0, c1, last, c2); +} + + +void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2, const CRGB& c3) +{ + uint16_t half = (numLeds / 2); + uint16_t last = numLeds - 1; + fill_gradient_RGB( leds, 0, c1, half, c2); + fill_gradient_RGB( leds, half, c2, last, c3); +} + +void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4) +{ + uint16_t onethird = (numLeds / 3); + uint16_t twothirds = ((numLeds * 2) / 3); + uint16_t last = numLeds - 1; + fill_gradient_RGB( leds, 0, c1, onethird, c2); + fill_gradient_RGB( leds, onethird, c2, twothirds, c3); + fill_gradient_RGB( leds, twothirds, c3, last, c4); +} + + + + +void nscale8_video( CRGB* leds, uint16_t num_leds, uint8_t scale) +{ + for( uint16_t i = 0; i < num_leds; i++) { + leds[i].nscale8_video( scale); + } +} + +void fade_video(CRGB* leds, uint16_t num_leds, uint8_t fadeBy) +{ + nscale8_video( leds, num_leds, 255 - fadeBy); +} + +void fadeLightBy(CRGB* leds, uint16_t num_leds, uint8_t fadeBy) +{ + nscale8_video( leds, num_leds, 255 - fadeBy); +} + + +void fadeToBlackBy( CRGB* leds, uint16_t num_leds, uint8_t fadeBy) +{ + nscale8( leds, num_leds, 255 - fadeBy); +} + +void fade_raw( CRGB* leds, uint16_t num_leds, uint8_t fadeBy) +{ + nscale8( leds, num_leds, 255 - fadeBy); +} + +void nscale8_raw( CRGB* leds, uint16_t num_leds, uint8_t scale) +{ + nscale8( leds, num_leds, scale); +} + +void nscale8( CRGB* leds, uint16_t num_leds, uint8_t scale) +{ + for( uint16_t i = 0; i < num_leds; i++) { + leds[i].nscale8( scale); + } +} + +void fadeUsingColor( CRGB* leds, uint16_t numLeds, const CRGB& colormask) +{ + uint8_t fr, fg, fb; + fr = colormask.r; + fg = colormask.g; + fb = colormask.b; + + for( uint16_t i = 0; i < numLeds; i++) { + leds[i].r = scale8_LEAVING_R1_DIRTY( leds[i].r, fr); + leds[i].g = scale8_LEAVING_R1_DIRTY( leds[i].g, fg); + leds[i].b = scale8 ( leds[i].b, fb); + } +} + + +CRGB& nblend( CRGB& existing, const CRGB& overlay, fract8 amountOfOverlay ) +{ + if( amountOfOverlay == 0) { + return existing; + } + + if( amountOfOverlay == 255) { + existing = overlay; + return existing; + } + +#if 0 + // Old blend method which unfortunately had some rounding errors + fract8 amountOfKeep = 255 - amountOfOverlay; + + existing.red = scale8_LEAVING_R1_DIRTY( existing.red, amountOfKeep) + + scale8_LEAVING_R1_DIRTY( overlay.red, amountOfOverlay); + existing.green = scale8_LEAVING_R1_DIRTY( existing.green, amountOfKeep) + + scale8_LEAVING_R1_DIRTY( overlay.green, amountOfOverlay); + existing.blue = scale8_LEAVING_R1_DIRTY( existing.blue, amountOfKeep) + + scale8_LEAVING_R1_DIRTY( overlay.blue, amountOfOverlay); + + cleanup_R1(); +#else + // Corrected blend method, with no loss-of-precision rounding errors + existing.red = blend8( existing.red, overlay.red, amountOfOverlay); + existing.green = blend8( existing.green, overlay.green, amountOfOverlay); + existing.blue = blend8( existing.blue, overlay.blue, amountOfOverlay); +#endif + + return existing; +} + + + +void nblend( CRGB* existing, CRGB* overlay, uint16_t count, fract8 amountOfOverlay) +{ + for( uint16_t i = count; i; i--) { + nblend( *existing, *overlay, amountOfOverlay); + existing++; + overlay++; + } +} + +CRGB blend( const CRGB& p1, const CRGB& p2, fract8 amountOfP2 ) +{ + CRGB nu(p1); + nblend( nu, p2, amountOfP2); + return nu; +} + +CRGB* blend( const CRGB* src1, const CRGB* src2, CRGB* dest, uint16_t count, fract8 amountOfsrc2 ) +{ + for( uint16_t i = 0; i < count; i++) { + dest[i] = blend(src1[i], src2[i], amountOfsrc2); + } + return dest; +} + + + +CHSV& nblend( CHSV& existing, const CHSV& overlay, fract8 amountOfOverlay, TGradientDirectionCode directionCode) +{ + if( amountOfOverlay == 0) { + return existing; + } + + if( amountOfOverlay == 255) { + existing = overlay; + return existing; + } + + fract8 amountOfKeep = 255 - amountOfOverlay; + + uint8_t huedelta8 = overlay.hue - existing.hue; + + if( directionCode == SHORTEST_HUES ) { + directionCode = FORWARD_HUES; + if( huedelta8 > 127) { + directionCode = BACKWARD_HUES; + } + } + + if( directionCode == LONGEST_HUES ) { + directionCode = FORWARD_HUES; + if( huedelta8 < 128) { + directionCode = BACKWARD_HUES; + } + } + + if( directionCode == FORWARD_HUES) { + existing.hue = existing.hue + scale8( huedelta8, amountOfOverlay); + } + else /* directionCode == BACKWARD_HUES */ + { + huedelta8 = -huedelta8; + existing.hue = existing.hue - scale8( huedelta8, amountOfOverlay); + } + + existing.sat = scale8_LEAVING_R1_DIRTY( existing.sat, amountOfKeep) + + scale8_LEAVING_R1_DIRTY( overlay.sat, amountOfOverlay); + existing.val = scale8_LEAVING_R1_DIRTY( existing.val, amountOfKeep) + + scale8_LEAVING_R1_DIRTY( overlay.val, amountOfOverlay); + + cleanup_R1(); + + return existing; +} + + + +void nblend( CHSV* existing, CHSV* overlay, uint16_t count, fract8 amountOfOverlay, TGradientDirectionCode directionCode ) +{ + if(existing == overlay) return; + for( uint16_t i = count; i; i--) { + nblend( *existing, *overlay, amountOfOverlay, directionCode); + existing++; + overlay++; + } +} + +CHSV blend( const CHSV& p1, const CHSV& p2, fract8 amountOfP2, TGradientDirectionCode directionCode ) +{ + CHSV nu(p1); + nblend( nu, p2, amountOfP2, directionCode); + return nu; +} + +CHSV* blend( const CHSV* src1, const CHSV* src2, CHSV* dest, uint16_t count, fract8 amountOfsrc2, TGradientDirectionCode directionCode ) +{ + for( uint16_t i = 0; i < count; i++) { + dest[i] = blend(src1[i], src2[i], amountOfsrc2, directionCode); + } + return dest; +} + + + +// Forward declaration of the function "XY" which must be provided by +// the application for use in two-dimensional filter functions. +uint16_t XY( uint8_t, uint8_t);// __attribute__ ((weak)); + + +// blur1d: one-dimensional blur filter. Spreads light to 2 line neighbors. +// blur2d: two-dimensional blur filter. Spreads light to 8 XY neighbors. +// +// 0 = no spread at all +// 64 = moderate spreading +// 172 = maximum smooth, even spreading +// +// 173..255 = wider spreading, but increasing flicker +// +// Total light is NOT entirely conserved, so many repeated +// calls to 'blur' will also result in the light fading, +// eventually all the way to black; this is by design so that +// it can be used to (slowly) clear the LEDs to black. +void blur1d( CRGB* leds, uint16_t numLeds, fract8 blur_amount) +{ + uint8_t keep = 255 - blur_amount; + uint8_t seep = blur_amount >> 1; + CRGB carryover = CRGB::Black; + for( uint16_t i = 0; i < numLeds; i++) { + CRGB cur = leds[i]; + CRGB part = cur; + part.nscale8( seep); + cur.nscale8( keep); + cur += carryover; + if( i) leds[i-1] += part; + leds[i] = cur; + carryover = part; + } +} + +void blur2d( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount) +{ + blurRows(leds, width, height, blur_amount); + blurColumns(leds, width, height, blur_amount); +} + +// blurRows: perform a blur1d on every row of a rectangular matrix +void blurRows( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount) +{ + for( uint8_t row = 0; row < height; row++) { + CRGB* rowbase = leds + (row * width); + blur1d( rowbase, width, blur_amount); + } +} + +// blurColumns: perform a blur1d on each column of a rectangular matrix +void blurColumns(CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount) +{ + // blur columns + uint8_t keep = 255 - blur_amount; + uint8_t seep = blur_amount >> 1; + for( uint8_t col = 0; col < width; col++) { + CRGB carryover = CRGB::Black; + for( uint8_t i = 0; i < height; i++) { + CRGB cur = leds[XY(col,i)]; + CRGB part = cur; + part.nscale8( seep); + cur.nscale8( keep); + cur += carryover; + if( i) leds[XY(col,i-1)] += part; + leds[XY(col,i)] = cur; + carryover = part; + } + } +} + + + +// CRGB HeatColor( uint8_t temperature) +// +// Approximates a 'black body radiation' spectrum for +// a given 'heat' level. This is useful for animations of 'fire'. +// Heat is specified as an arbitrary scale from 0 (cool) to 255 (hot). +// This is NOT a chromatically correct 'black body radiation' +// spectrum, but it's surprisingly close, and it's fast and small. +// +// On AVR/Arduino, this typically takes around 70 bytes of program memory, +// versus 768 bytes for a full 256-entry RGB lookup table. + +CRGB HeatColor( uint8_t temperature) +{ + CRGB heatcolor; + + // Scale 'heat' down from 0-255 to 0-191, + // which can then be easily divided into three + // equal 'thirds' of 64 units each. + uint8_t t192 = scale8_video( temperature, 191); + + // calculate a value that ramps up from + // zero to 255 in each 'third' of the scale. + uint8_t heatramp = t192 & 0x3F; // 0..63 + heatramp <<= 2; // scale up to 0..252 + + // now figure out which third of the spectrum we're in: + if( t192 & 0x80) { + // we're in the hottest third + heatcolor.r = 255; // full red + heatcolor.g = 255; // full green + heatcolor.b = heatramp; // ramp up blue + + } else if( t192 & 0x40 ) { + // we're in the middle third + heatcolor.r = 255; // full red + heatcolor.g = heatramp; // ramp up green + heatcolor.b = 0; // no blue + + } else { + // we're in the coolest third + heatcolor.r = heatramp; // ramp up red + heatcolor.g = 0; // no green + heatcolor.b = 0; // no blue + } + + return heatcolor; +} + + +// lsrX4: helper function to divide a number by 16, aka four LSR's. +// On avr-gcc, "u8 >> 4" generates a loop, which is big, and slow. +// merely forcing it to be four /=2's causes avr-gcc to emit +// a SWAP instruction followed by an AND 0x0F, which is faster, and smaller. +inline uint8_t lsrX4( uint8_t dividend) __attribute__((always_inline)); +inline uint8_t lsrX4( uint8_t dividend) +{ +#if defined(__AVR__) + dividend /= 2; + dividend /= 2; + dividend /= 2; + dividend /= 2; +#else + dividend >>= 4; +#endif + return dividend; +} + + +CRGB ColorFromPalette( const CRGBPalette16& pal, uint8_t index, uint8_t brightness, TBlendType blendType) +{ + // hi4 = index >> 4; + uint8_t hi4 = lsrX4(index); + uint8_t lo4 = index & 0x0F; + + // const CRGB* entry = &(pal[0]) + hi4; + // since hi4 is always 0..15, hi4 * sizeof(CRGB) can be a single-byte value, + // instead of the two byte 'int' that avr-gcc defaults to. + // So, we multiply hi4 X sizeof(CRGB), giving hi4XsizeofCRGB; + uint8_t hi4XsizeofCRGB = hi4 * sizeof(CRGB); + // We then add that to a base array pointer. + const CRGB* entry = (CRGB*)( (uint8_t*)(&(pal[0])) + hi4XsizeofCRGB); + + uint8_t blend = lo4 && (blendType != NOBLEND); + + uint8_t red1 = entry->red; + uint8_t green1 = entry->green; + uint8_t blue1 = entry->blue; + + + if( blend ) { + + if( hi4 == 15 ) { + entry = &(pal[0]); + } else { + entry++; + } + + uint8_t f2 = lo4 << 4; + uint8_t f1 = 255 - f2; + + // rgb1.nscale8(f1); + uint8_t red2 = entry->red; + red1 = scale8_LEAVING_R1_DIRTY( red1, f1); + red2 = scale8_LEAVING_R1_DIRTY( red2, f2); + red1 += red2; + + uint8_t green2 = entry->green; + green1 = scale8_LEAVING_R1_DIRTY( green1, f1); + green2 = scale8_LEAVING_R1_DIRTY( green2, f2); + green1 += green2; + + uint8_t blue2 = entry->blue; + blue1 = scale8_LEAVING_R1_DIRTY( blue1, f1); + blue2 = scale8_LEAVING_R1_DIRTY( blue2, f2); + blue1 += blue2; + + cleanup_R1(); + } + + if( brightness != 255) { + if( brightness ) { + brightness++; // adjust for rounding + // Now, since brightness is nonzero, we don't need the full scale8_video logic; + // we can just to scale8 and then add one (unless scale8 fixed) to all nonzero inputs. + if( red1 ) { + red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + red1++; +#endif + } + if( green1 ) { + green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + green1++; +#endif + } + if( blue1 ) { + blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + blue1++; +#endif + } + cleanup_R1(); + } else { + red1 = 0; + green1 = 0; + blue1 = 0; + } + } + + return CRGB( red1, green1, blue1); +} + +CRGB ColorFromPalette( const TProgmemRGBPalette16& pal, uint8_t index, uint8_t brightness, TBlendType blendType) +{ + // hi4 = index >> 4; + uint8_t hi4 = lsrX4(index); + uint8_t lo4 = index & 0x0F; + + CRGB entry = FL_PGM_READ_DWORD_NEAR( &(pal[0]) + hi4 ); + + + uint8_t red1 = entry.red; + uint8_t green1 = entry.green; + uint8_t blue1 = entry.blue; + + uint8_t blend = lo4 && (blendType != NOBLEND); + + if( blend ) { + + if( hi4 == 15 ) { + entry = FL_PGM_READ_DWORD_NEAR( &(pal[0]) ); + } else { + entry = FL_PGM_READ_DWORD_NEAR( &(pal[1]) + hi4 ); + } + + uint8_t f2 = lo4 << 4; + uint8_t f1 = 255 - f2; + + uint8_t red2 = entry.red; + red1 = scale8_LEAVING_R1_DIRTY( red1, f1); + red2 = scale8_LEAVING_R1_DIRTY( red2, f2); + red1 += red2; + + uint8_t green2 = entry.green; + green1 = scale8_LEAVING_R1_DIRTY( green1, f1); + green2 = scale8_LEAVING_R1_DIRTY( green2, f2); + green1 += green2; + + uint8_t blue2 = entry.blue; + blue1 = scale8_LEAVING_R1_DIRTY( blue1, f1); + blue2 = scale8_LEAVING_R1_DIRTY( blue2, f2); + blue1 += blue2; + + cleanup_R1(); + } + + if( brightness != 255) { + if( brightness ) { + brightness++; // adjust for rounding + // Now, since brightness is nonzero, we don't need the full scale8_video logic; + // we can just to scale8 and then add one (unless scale8 fixed) to all nonzero inputs. + if( red1 ) { + red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + red1++; +#endif + } + if( green1 ) { + green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + green1++; +#endif + } + if( blue1 ) { + blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + blue1++; +#endif + } + cleanup_R1(); + } else { + red1 = 0; + green1 = 0; + blue1 = 0; + } + } + + return CRGB( red1, green1, blue1); +} + + +CRGB ColorFromPalette( const CRGBPalette32& pal, uint8_t index, uint8_t brightness, TBlendType blendType) +{ + uint8_t hi5 = index; +#if defined(__AVR__) + hi5 /= 2; + hi5 /= 2; + hi5 /= 2; +#else + hi5 >>= 3; +#endif + uint8_t lo3 = index & 0x07; + + // const CRGB* entry = &(pal[0]) + hi5; + // since hi5 is always 0..31, hi4 * sizeof(CRGB) can be a single-byte value, + // instead of the two byte 'int' that avr-gcc defaults to. + // So, we multiply hi5 X sizeof(CRGB), giving hi5XsizeofCRGB; + uint8_t hi5XsizeofCRGB = hi5 * sizeof(CRGB); + // We then add that to a base array pointer. + const CRGB* entry = (CRGB*)( (uint8_t*)(&(pal[0])) + hi5XsizeofCRGB); + + uint8_t red1 = entry->red; + uint8_t green1 = entry->green; + uint8_t blue1 = entry->blue; + + uint8_t blend = lo3 && (blendType != NOBLEND); + + if( blend ) { + + if( hi5 == 31 ) { + entry = &(pal[0]); + } else { + entry++; + } + + uint8_t f2 = lo3 << 5; + uint8_t f1 = 255 - f2; + + uint8_t red2 = entry->red; + red1 = scale8_LEAVING_R1_DIRTY( red1, f1); + red2 = scale8_LEAVING_R1_DIRTY( red2, f2); + red1 += red2; + + uint8_t green2 = entry->green; + green1 = scale8_LEAVING_R1_DIRTY( green1, f1); + green2 = scale8_LEAVING_R1_DIRTY( green2, f2); + green1 += green2; + + uint8_t blue2 = entry->blue; + blue1 = scale8_LEAVING_R1_DIRTY( blue1, f1); + blue2 = scale8_LEAVING_R1_DIRTY( blue2, f2); + blue1 += blue2; + + cleanup_R1(); + + } + + if( brightness != 255) { + if( brightness ) { + brightness++; // adjust for rounding + // Now, since brightness is nonzero, we don't need the full scale8_video logic; + // we can just to scale8 and then add one (unless scale8 fixed) to all nonzero inputs. + if( red1 ) { + red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + red1++; +#endif + } + if( green1 ) { + green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + green1++; +#endif + } + if( blue1 ) { + blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + blue1++; +#endif + } + cleanup_R1(); + } else { + red1 = 0; + green1 = 0; + blue1 = 0; + } + } + + return CRGB( red1, green1, blue1); +} + + +CRGB ColorFromPalette( const TProgmemRGBPalette32& pal, uint8_t index, uint8_t brightness, TBlendType blendType) +{ + uint8_t hi5 = index; +#if defined(__AVR__) + hi5 /= 2; + hi5 /= 2; + hi5 /= 2; +#else + hi5 >>= 3; +#endif + uint8_t lo3 = index & 0x07; + + CRGB entry = FL_PGM_READ_DWORD_NEAR( &(pal[0]) + hi5); + + uint8_t red1 = entry.red; + uint8_t green1 = entry.green; + uint8_t blue1 = entry.blue; + + uint8_t blend = lo3 && (blendType != NOBLEND); + + if( blend ) { + + if( hi5 == 31 ) { + entry = FL_PGM_READ_DWORD_NEAR( &(pal[0]) ); + } else { + entry = FL_PGM_READ_DWORD_NEAR( &(pal[1]) + hi5 ); + } + + uint8_t f2 = lo3 << 5; + uint8_t f1 = 255 - f2; + + uint8_t red2 = entry.red; + red1 = scale8_LEAVING_R1_DIRTY( red1, f1); + red2 = scale8_LEAVING_R1_DIRTY( red2, f2); + red1 += red2; + + uint8_t green2 = entry.green; + green1 = scale8_LEAVING_R1_DIRTY( green1, f1); + green2 = scale8_LEAVING_R1_DIRTY( green2, f2); + green1 += green2; + + uint8_t blue2 = entry.blue; + blue1 = scale8_LEAVING_R1_DIRTY( blue1, f1); + blue2 = scale8_LEAVING_R1_DIRTY( blue2, f2); + blue1 += blue2; + + cleanup_R1(); + } + + if( brightness != 255) { + if( brightness ) { + brightness++; // adjust for rounding + // Now, since brightness is nonzero, we don't need the full scale8_video logic; + // we can just to scale8 and then add one (unless scale8 fixed) to all nonzero inputs. + if( red1 ) { + red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + red1++; +#endif + } + if( green1 ) { + green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + green1++; +#endif + } + if( blue1 ) { + blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + blue1++; +#endif + } + cleanup_R1(); + } else { + red1 = 0; + green1 = 0; + blue1 = 0; + } + } + + return CRGB( red1, green1, blue1); +} + + + +CRGB ColorFromPalette( const CRGBPalette256& pal, uint8_t index, uint8_t brightness, TBlendType) +{ + const CRGB* entry = &(pal[0]) + index; + + uint8_t red = entry->red; + uint8_t green = entry->green; + uint8_t blue = entry->blue; + + if( brightness != 255) { + brightness++; // adjust for rounding + red = scale8_video_LEAVING_R1_DIRTY( red, brightness); + green = scale8_video_LEAVING_R1_DIRTY( green, brightness); + blue = scale8_video_LEAVING_R1_DIRTY( blue, brightness); + cleanup_R1(); + } + + return CRGB( red, green, blue); +} + + +CHSV ColorFromPalette( const struct CHSVPalette16& pal, uint8_t index, uint8_t brightness, TBlendType blendType) +{ + // hi4 = index >> 4; + uint8_t hi4 = lsrX4(index); + uint8_t lo4 = index & 0x0F; + + // CRGB rgb1 = pal[ hi4]; + const CHSV* entry = &(pal[0]) + hi4; + + uint8_t hue1 = entry->hue; + uint8_t sat1 = entry->sat; + uint8_t val1 = entry->val; + + uint8_t blend = lo4 && (blendType != NOBLEND); + + if( blend ) { + + if( hi4 == 15 ) { + entry = &(pal[0]); + } else { + entry++; + } + + uint8_t f2 = lo4 << 4; + uint8_t f1 = 255 - f2; + + uint8_t hue2 = entry->hue; + uint8_t sat2 = entry->sat; + uint8_t val2 = entry->val; + + // Now some special casing for blending to or from + // either black or white. Black and white don't have + // proper 'hue' of their own, so when ramping from + // something else to/from black/white, we set the 'hue' + // of the black/white color to be the same as the hue + // of the other color, so that you get the expected + // brightness or saturation ramp, with hue staying + // constant: + + // If we are starting from white (sat=0) + // or black (val=0), adopt the target hue. + if( sat1 == 0 || val1 == 0) { + hue1 = hue2; + } + + // If we are ending at white (sat=0) + // or black (val=0), adopt the starting hue. + if( sat2 == 0 || val2 == 0) { + hue2 = hue1; + } + + + sat1 = scale8_LEAVING_R1_DIRTY( sat1, f1); + val1 = scale8_LEAVING_R1_DIRTY( val1, f1); + + sat2 = scale8_LEAVING_R1_DIRTY( sat2, f2); + val2 = scale8_LEAVING_R1_DIRTY( val2, f2); + + // cleanup_R1(); + + // These sums can't overflow, so no qadd8 needed. + sat1 += sat2; + val1 += val2; + + uint8_t deltaHue = (uint8_t)(hue2 - hue1); + if( deltaHue & 0x80 ) { + // go backwards + hue1 -= scale8( 256 - deltaHue, f2); + } else { + // go forwards + hue1 += scale8( deltaHue, f2); + } + + cleanup_R1(); + } + + if( brightness != 255) { + val1 = scale8_video( val1, brightness); + } + + return CHSV( hue1, sat1, val1); +} + + +CHSV ColorFromPalette( const struct CHSVPalette32& pal, uint8_t index, uint8_t brightness, TBlendType blendType) +{ + uint8_t hi5 = index; +#if defined(__AVR__) + hi5 /= 2; + hi5 /= 2; + hi5 /= 2; +#else + hi5 >>= 3; +#endif + uint8_t lo3 = index & 0x07; + + uint8_t hi5XsizeofCHSV = hi5 * sizeof(CHSV); + const CHSV* entry = (CHSV*)( (uint8_t*)(&(pal[0])) + hi5XsizeofCHSV); + + uint8_t hue1 = entry->hue; + uint8_t sat1 = entry->sat; + uint8_t val1 = entry->val; + + uint8_t blend = lo3 && (blendType != NOBLEND); + + if( blend ) { + + if( hi5 == 31 ) { + entry = &(pal[0]); + } else { + entry++; + } + + uint8_t f2 = lo3 << 5; + uint8_t f1 = 255 - f2; + + uint8_t hue2 = entry->hue; + uint8_t sat2 = entry->sat; + uint8_t val2 = entry->val; + + // Now some special casing for blending to or from + // either black or white. Black and white don't have + // proper 'hue' of their own, so when ramping from + // something else to/from black/white, we set the 'hue' + // of the black/white color to be the same as the hue + // of the other color, so that you get the expected + // brightness or saturation ramp, with hue staying + // constant: + + // If we are starting from white (sat=0) + // or black (val=0), adopt the target hue. + if( sat1 == 0 || val1 == 0) { + hue1 = hue2; + } + + // If we are ending at white (sat=0) + // or black (val=0), adopt the starting hue. + if( sat2 == 0 || val2 == 0) { + hue2 = hue1; + } + + + sat1 = scale8_LEAVING_R1_DIRTY( sat1, f1); + val1 = scale8_LEAVING_R1_DIRTY( val1, f1); + + sat2 = scale8_LEAVING_R1_DIRTY( sat2, f2); + val2 = scale8_LEAVING_R1_DIRTY( val2, f2); + + // cleanup_R1(); + + // These sums can't overflow, so no qadd8 needed. + sat1 += sat2; + val1 += val2; + + uint8_t deltaHue = (uint8_t)(hue2 - hue1); + if( deltaHue & 0x80 ) { + // go backwards + hue1 -= scale8( 256 - deltaHue, f2); + } else { + // go forwards + hue1 += scale8( deltaHue, f2); + } + + cleanup_R1(); + } + + if( brightness != 255) { + val1 = scale8_video( val1, brightness); + } + + return CHSV( hue1, sat1, val1); +} + +CHSV ColorFromPalette( const struct CHSVPalette256& pal, uint8_t index, uint8_t brightness, TBlendType) +{ + CHSV hsv = *( &(pal[0]) + index ); + + if( brightness != 255) { + hsv.value = scale8_video( hsv.value, brightness); + } + + return hsv; +} + + +void UpscalePalette(const struct CRGBPalette16& srcpal16, struct CRGBPalette256& destpal256) +{ + for( int i = 0; i < 256; i++) { + destpal256[(uint8_t)(i)] = ColorFromPalette( srcpal16, i); + } +} + +void UpscalePalette(const struct CHSVPalette16& srcpal16, struct CHSVPalette256& destpal256) +{ + for( int i = 0; i < 256; i++) { + destpal256[(uint8_t)(i)] = ColorFromPalette( srcpal16, i); + } +} + + +void UpscalePalette(const struct CRGBPalette16& srcpal16, struct CRGBPalette32& destpal32) +{ + for( uint8_t i = 0; i < 16; i++) { + uint8_t j = i * 2; + destpal32[j+0] = srcpal16[i]; + destpal32[j+1] = srcpal16[i]; + } +} + +void UpscalePalette(const struct CHSVPalette16& srcpal16, struct CHSVPalette32& destpal32) +{ + for( uint8_t i = 0; i < 16; i++) { + uint8_t j = i * 2; + destpal32[j+0] = srcpal16[i]; + destpal32[j+1] = srcpal16[i]; + } +} + +void UpscalePalette(const struct CRGBPalette32& srcpal32, struct CRGBPalette256& destpal256) +{ + for( int i = 0; i < 256; i++) { + destpal256[(uint8_t)(i)] = ColorFromPalette( srcpal32, i); + } +} + +void UpscalePalette(const struct CHSVPalette32& srcpal32, struct CHSVPalette256& destpal256) +{ + for( int i = 0; i < 256; i++) { + destpal256[(uint8_t)(i)] = ColorFromPalette( srcpal32, i); + } +} + + + +#if 0 +// replaced by PartyColors_p +void SetupPartyColors(CRGBPalette16& pal) +{ + fill_gradient( pal, 0, CHSV( HUE_PURPLE,255,255), 7, CHSV(HUE_YELLOW - 18,255,255), FORWARD_HUES); + fill_gradient( pal, 8, CHSV( HUE_ORANGE,255,255), 15, CHSV(HUE_BLUE + 18,255,255), BACKWARD_HUES); +} +#endif + + +void nblendPaletteTowardPalette( CRGBPalette16& current, CRGBPalette16& target, uint8_t maxChanges) +{ + uint8_t* p1; + uint8_t* p2; + uint8_t changes = 0; + + p1 = (uint8_t*)current.entries; + p2 = (uint8_t*)target.entries; + + const uint8_t totalChannels = sizeof(CRGBPalette16); + for( uint8_t i = 0; i < totalChannels; i++) { + // if the values are equal, no changes are needed + if( p1[i] == p2[i] ) { continue; } + + // if the current value is less than the target, increase it by one + if( p1[i] < p2[i] ) { p1[i]++; changes++; } + + // if the current value is greater than the target, + // increase it by one (or two if it's still greater). + if( p1[i] > p2[i] ) { + p1[i]--; changes++; + if( p1[i] > p2[i] ) { p1[i]--; } + } + + // if we've hit the maximum number of changes, exit + if( changes >= maxChanges) { break; } + } +} + + +uint8_t applyGamma_video( uint8_t brightness, float gamma) +{ + float orig; + float adj; + orig = (float)(brightness) / (255.0); + adj = pow( orig, gamma) * (255.0); + uint8_t result = (uint8_t)(adj); + if( (brightness > 0) && (result == 0)) { + result = 1; // never gamma-adjust a positive number down to zero + } + return result; +} + +CRGB applyGamma_video( const CRGB& orig, float gamma) +{ + CRGB adj; + adj.r = applyGamma_video( orig.r, gamma); + adj.g = applyGamma_video( orig.g, gamma); + adj.b = applyGamma_video( orig.b, gamma); + return adj; +} + +CRGB applyGamma_video( const CRGB& orig, float gammaR, float gammaG, float gammaB) +{ + CRGB adj; + adj.r = applyGamma_video( orig.r, gammaR); + adj.g = applyGamma_video( orig.g, gammaG); + adj.b = applyGamma_video( orig.b, gammaB); + return adj; +} + +CRGB& napplyGamma_video( CRGB& rgb, float gamma) +{ + rgb = applyGamma_video( rgb, gamma); + return rgb; +} + +CRGB& napplyGamma_video( CRGB& rgb, float gammaR, float gammaG, float gammaB) +{ + rgb = applyGamma_video( rgb, gammaR, gammaG, gammaB); + return rgb; +} + +void napplyGamma_video( CRGB* rgbarray, uint16_t count, float gamma) +{ + for( uint16_t i = 0; i < count; i++) { + rgbarray[i] = applyGamma_video( rgbarray[i], gamma); + } +} + +void napplyGamma_video( CRGB* rgbarray, uint16_t count, float gammaR, float gammaG, float gammaB) +{ + for( uint16_t i = 0; i < count; i++) { + rgbarray[i] = applyGamma_video( rgbarray[i], gammaR, gammaG, gammaB); + } +} + + +FASTLED_NAMESPACE_END diff --git a/libraries/FastLED/colorutils.h b/libraries/FastLED/colorutils.h new file mode 100644 index 0000000..4fcf394 --- /dev/null +++ b/libraries/FastLED/colorutils.h @@ -0,0 +1,1706 @@ +#ifndef __INC_COLORUTILS_H +#define __INC_COLORUTILS_H + +///@file colorutils.h +/// functions for color fill, paletters, blending, and more + +#include "FastLED.h" +#include "pixeltypes.h" +#include "fastled_progmem.h" + +FASTLED_NAMESPACE_BEGIN +///@defgroup Colorutils Color utility functions +///A variety of functions for working with color, palletes, and leds +///@{ + +/// fill_solid - fill a range of LEDs with a solid color +/// Example: fill_solid( leds, NUM_LEDS, CRGB(50,0,200)); +void fill_solid( struct CRGB * leds, int numToFill, + const struct CRGB& color); + +/// fill_solid - fill a range of LEDs with a solid color +/// Example: fill_solid( leds, NUM_LEDS, CRGB(50,0,200)); +void fill_solid( struct CHSV* targetArray, int numToFill, + const struct CHSV& hsvColor); + + +/// fill_rainbow - fill a range of LEDs with a rainbow of colors, at +/// full saturation and full value (brightness) +void fill_rainbow( struct CRGB * pFirstLED, int numToFill, + uint8_t initialhue, + uint8_t deltahue = 5); + +/// fill_rainbow - fill a range of LEDs with a rainbow of colors, at +/// full saturation and full value (brightness) +void fill_rainbow( struct CHSV * targetArray, int numToFill, + uint8_t initialhue, + uint8_t deltahue = 5); + + +// fill_gradient - fill an array of colors with a smooth HSV gradient +// between two specified HSV colors. +// Since 'hue' is a value around a color wheel, +// there are always two ways to sweep from one hue +// to another. +// This function lets you specify which way you want +// the hue gradient to sweep around the color wheel: +// FORWARD_HUES: hue always goes clockwise +// BACKWARD_HUES: hue always goes counter-clockwise +// SHORTEST_HUES: hue goes whichever way is shortest +// LONGEST_HUES: hue goes whichever way is longest +// The default is SHORTEST_HUES, as this is nearly +// always what is wanted. +// +// fill_gradient can write the gradient colors EITHER +// (1) into an array of CRGBs (e.g., into leds[] array, or an RGB Palette) +// OR +// (2) into an array of CHSVs (e.g. an HSV Palette). +// +// In the case of writing into a CRGB array, the gradient is +// computed in HSV space, and then HSV values are converted to RGB +// as they're written into the RGB array. + +typedef enum { FORWARD_HUES, BACKWARD_HUES, SHORTEST_HUES, LONGEST_HUES } TGradientDirectionCode; + + + +#define saccum87 int16_t + +/// fill_gradient - fill an array of colors with a smooth HSV gradient +/// between two specified HSV colors. +/// Since 'hue' is a value around a color wheel, +/// there are always two ways to sweep from one hue +/// to another. +/// This function lets you specify which way you want +/// the hue gradient to sweep around the color wheel: +/// +/// FORWARD_HUES: hue always goes clockwise +/// BACKWARD_HUES: hue always goes counter-clockwise +/// SHORTEST_HUES: hue goes whichever way is shortest +/// LONGEST_HUES: hue goes whichever way is longest +/// +/// The default is SHORTEST_HUES, as this is nearly +/// always what is wanted. +/// +/// fill_gradient can write the gradient colors EITHER +/// (1) into an array of CRGBs (e.g., into leds[] array, or an RGB Palette) +/// OR +/// (2) into an array of CHSVs (e.g. an HSV Palette). +/// +/// In the case of writing into a CRGB array, the gradient is +/// computed in HSV space, and then HSV values are converted to RGB +/// as they're written into the RGB array. +template +void fill_gradient( T* targetArray, + uint16_t startpos, CHSV startcolor, + uint16_t endpos, CHSV endcolor, + TGradientDirectionCode directionCode = SHORTEST_HUES ) +{ + // if the points are in the wrong order, straighten them + if( endpos < startpos ) { + uint16_t t = endpos; + CHSV tc = endcolor; + endcolor = startcolor; + endpos = startpos; + startpos = t; + startcolor = tc; + } + + // If we're fading toward black (val=0) or white (sat=0), + // then set the endhue to the starthue. + // This lets us ramp smoothly to black or white, regardless + // of what 'hue' was set in the endcolor (since it doesn't matter) + if( endcolor.value == 0 || endcolor.saturation == 0) { + endcolor.hue = startcolor.hue; + } + + // Similarly, if we're fading in from black (val=0) or white (sat=0) + // then set the starthue to the endhue. + // This lets us ramp smoothly up from black or white, regardless + // of what 'hue' was set in the startcolor (since it doesn't matter) + if( startcolor.value == 0 || startcolor.saturation == 0) { + startcolor.hue = endcolor.hue; + } + + saccum87 huedistance87; + saccum87 satdistance87; + saccum87 valdistance87; + + satdistance87 = (endcolor.sat - startcolor.sat) << 7; + valdistance87 = (endcolor.val - startcolor.val) << 7; + + uint8_t huedelta8 = endcolor.hue - startcolor.hue; + + if( directionCode == SHORTEST_HUES ) { + directionCode = FORWARD_HUES; + if( huedelta8 > 127) { + directionCode = BACKWARD_HUES; + } + } + + if( directionCode == LONGEST_HUES ) { + directionCode = FORWARD_HUES; + if( huedelta8 < 128) { + directionCode = BACKWARD_HUES; + } + } + + if( directionCode == FORWARD_HUES) { + huedistance87 = huedelta8 << 7; + } + else /* directionCode == BACKWARD_HUES */ + { + huedistance87 = (uint8_t)(256 - huedelta8) << 7; + huedistance87 = -huedistance87; + } + + uint16_t pixeldistance = endpos - startpos; + int16_t divisor = pixeldistance ? pixeldistance : 1; + + saccum87 huedelta87 = huedistance87 / divisor; + saccum87 satdelta87 = satdistance87 / divisor; + saccum87 valdelta87 = valdistance87 / divisor; + + huedelta87 *= 2; + satdelta87 *= 2; + valdelta87 *= 2; + + accum88 hue88 = startcolor.hue << 8; + accum88 sat88 = startcolor.sat << 8; + accum88 val88 = startcolor.val << 8; + for( uint16_t i = startpos; i <= endpos; i++) { + targetArray[i] = CHSV( hue88 >> 8, sat88 >> 8, val88 >> 8); + hue88 += huedelta87; + sat88 += satdelta87; + val88 += valdelta87; + } +} + + +// Convenience functions to fill an array of colors with a +// two-color, three-color, or four-color gradient +template +void fill_gradient( T* targetArray, uint16_t numLeds, const CHSV& c1, const CHSV& c2, + TGradientDirectionCode directionCode = SHORTEST_HUES ) +{ + uint16_t last = numLeds - 1; + fill_gradient( targetArray, 0, c1, last, c2, directionCode); +} + +template +void fill_gradient( T* targetArray, uint16_t numLeds, + const CHSV& c1, const CHSV& c2, const CHSV& c3, + TGradientDirectionCode directionCode = SHORTEST_HUES ) +{ + uint16_t half = (numLeds / 2); + uint16_t last = numLeds - 1; + fill_gradient( targetArray, 0, c1, half, c2, directionCode); + fill_gradient( targetArray, half, c2, last, c3, directionCode); +} + +template +void fill_gradient( T* targetArray, uint16_t numLeds, + const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4, + TGradientDirectionCode directionCode = SHORTEST_HUES ) +{ + uint16_t onethird = (numLeds / 3); + uint16_t twothirds = ((numLeds * 2) / 3); + uint16_t last = numLeds - 1; + fill_gradient( targetArray, 0, c1, onethird, c2, directionCode); + fill_gradient( targetArray, onethird, c2, twothirds, c3, directionCode); + fill_gradient( targetArray, twothirds, c3, last, c4, directionCode); +} + +// convenience synonym +#define fill_gradient_HSV fill_gradient + + +// fill_gradient_RGB - fill a range of LEDs with a smooth RGB gradient +// between two specified RGB colors. +// Unlike HSV, there is no 'color wheel' in RGB space, +// and therefore there's only one 'direction' for the +// gradient to go, and no 'direction code' is needed. +void fill_gradient_RGB( CRGB* leds, + uint16_t startpos, CRGB startcolor, + uint16_t endpos, CRGB endcolor ); +void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2); +void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2, const CRGB& c3); +void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4); + + +// fadeLightBy and fade_video - reduce the brightness of an array +// of pixels all at once. Guaranteed +// to never fade all the way to black. +// (The two names are synonyms.) +void fadeLightBy( CRGB* leds, uint16_t num_leds, uint8_t fadeBy); +void fade_video( CRGB* leds, uint16_t num_leds, uint8_t fadeBy); + +// nscale8_video - scale down the brightness of an array of pixels +// all at once. Guaranteed to never scale a pixel +// all the way down to black, unless 'scale' is zero. +void nscale8_video( CRGB* leds, uint16_t num_leds, uint8_t scale); + +// fadeToBlackBy and fade_raw - reduce the brightness of an array +// of pixels all at once. These +// functions will eventually fade all +// the way to black. +// (The two names are synonyms.) +void fadeToBlackBy( CRGB* leds, uint16_t num_leds, uint8_t fadeBy); +void fade_raw( CRGB* leds, uint16_t num_leds, uint8_t fadeBy); + +// nscale8 - scale down the brightness of an array of pixels +// all at once. This function can scale pixels all the +// way down to black even if 'scale' is not zero. +void nscale8( CRGB* leds, uint16_t num_leds, uint8_t scale); + +// fadeUsingColor - scale down the brightness of an array of pixels, +// as though it were seen through a transparent +// filter with the specified color. +// For example, if the colormask is +// CRGB( 200, 100, 50) +// then the pixels' red will be faded to 200/256ths, +// their green to 100/256ths, and their blue to 50/256ths. +// This particular example give a 'hot fade' look, +// with white fading to yellow, then red, then black. +// You can also use colormasks like CRGB::Blue to +// zero out the red and green elements, leaving blue +// (largely) the same. +void fadeUsingColor( CRGB* leds, uint16_t numLeds, const CRGB& colormask); + + +// Pixel blending +// +// blend - computes a new color blended some fraction of the way +// between two other colors. +CRGB blend( const CRGB& p1, const CRGB& p2, fract8 amountOfP2 ); + +CHSV blend( const CHSV& p1, const CHSV& p2, fract8 amountOfP2, + TGradientDirectionCode directionCode = SHORTEST_HUES ); + +// blend - computes a new color blended array of colors, each +// a given fraction of the way between corresponding +// elements of two source arrays of colors. +// Useful for blending palettes. +CRGB* blend( const CRGB* src1, const CRGB* src2, CRGB* dest, + uint16_t count, fract8 amountOfsrc2 ); + +CHSV* blend( const CHSV* src1, const CHSV* src2, CHSV* dest, + uint16_t count, fract8 amountOfsrc2, + TGradientDirectionCode directionCode = SHORTEST_HUES ); + +// nblend - destructively modifies one color, blending +// in a given fraction of an overlay color +CRGB& nblend( CRGB& existing, const CRGB& overlay, fract8 amountOfOverlay ); + +CHSV& nblend( CHSV& existing, const CHSV& overlay, fract8 amountOfOverlay, + TGradientDirectionCode directionCode = SHORTEST_HUES ); + +// nblend - destructively blends a given fraction of +// a new color array into an existing color array +void nblend( CRGB* existing, CRGB* overlay, uint16_t count, fract8 amountOfOverlay); + +void nblend( CHSV* existing, CHSV* overlay, uint16_t count, fract8 amountOfOverlay, + TGradientDirectionCode directionCode = SHORTEST_HUES); + + +// blur1d: one-dimensional blur filter. Spreads light to 2 line neighbors. +// blur2d: two-dimensional blur filter. Spreads light to 8 XY neighbors. +// +// 0 = no spread at all +// 64 = moderate spreading +// 172 = maximum smooth, even spreading +// +// 173..255 = wider spreading, but increasing flicker +// +// Total light is NOT entirely conserved, so many repeated +// calls to 'blur' will also result in the light fading, +// eventually all the way to black; this is by design so that +// it can be used to (slowly) clear the LEDs to black. +void blur1d( CRGB* leds, uint16_t numLeds, fract8 blur_amount); +void blur2d( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount); + +// blurRows: perform a blur1d on every row of a rectangular matrix +void blurRows( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount); +// blurColumns: perform a blur1d on each column of a rectangular matrix +void blurColumns(CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount); + + +// CRGB HeatColor( uint8_t temperature) +// +// Approximates a 'black body radiation' spectrum for +// a given 'heat' level. This is useful for animations of 'fire'. +// Heat is specified as an arbitrary scale from 0 (cool) to 255 (hot). +// This is NOT a chromatically correct 'black body radiation' +// spectrum, but it's surprisingly close, and it's fast and small. +CRGB HeatColor( uint8_t temperature); + + +// Palettes +// +// RGB Palettes map an 8-bit value (0..255) to an RGB color. +// +// You can create any color palette you wish; a couple of starters +// are provided: Forest, Clouds, Lava, Ocean, Rainbow, and Rainbow Stripes. +// +// Palettes come in the traditional 256-entry variety, which take +// up 768 bytes of RAM, and lightweight 16-entry varieties. The 16-entry +// variety automatically interpolates between its entries to produce +// a full 256-element color map, but at a cost of only 48 bytes or RAM. +// +// Basic operation is like this: (example shows the 16-entry variety) +// 1. Declare your palette storage: +// CRGBPalette16 myPalette; +// +// 2. Fill myPalette with your own 16 colors, or with a preset color scheme. +// You can specify your 16 colors a variety of ways: +// CRGBPalette16 myPalette( +// CRGB::Black, +// CRGB::Black, +// CRGB::Red, +// CRGB::Yellow, +// CRGB::Green, +// CRGB::Blue, +// CRGB::Purple, +// CRGB::Black, +// +// 0x100000, +// 0x200000, +// 0x400000, +// 0x800000, +// +// CHSV( 30,255,255), +// CHSV( 50,255,255), +// CHSV( 70,255,255), +// CHSV( 90,255,255) +// ); +// +// Or you can initiaize your palette with a preset color scheme: +// myPalette = RainbowStripesColors_p; +// +// 3. Any time you want to set a pixel to a color from your palette, use +// "ColorFromPalette(...)" as shown: +// +// uint8_t index = /* any value 0..255 */; +// leds[i] = ColorFromPalette( myPalette, index); +// +// Even though your palette has only 16 explicily defined entries, you +// can use an 'index' from 0..255. The 16 explicit palette entries will +// be spread evenly across the 0..255 range, and the intermedate values +// will be RGB-interpolated between adjacent explicit entries. +// +// It's easier to use than it sounds. +// + +class CRGBPalette16; +class CRGBPalette32; +class CRGBPalette256; +class CHSVPalette16; +class CHSVPalette32; +class CHSVPalette256; +typedef uint32_t TProgmemRGBPalette16[16]; +typedef uint32_t TProgmemHSVPalette16[16]; +#define TProgmemPalette16 TProgmemRGBPalette16 +typedef uint32_t TProgmemRGBPalette32[32]; +typedef uint32_t TProgmemHSVPalette32[32]; +#define TProgmemPalette32 TProgmemRGBPalette32 + +typedef const uint8_t TProgmemRGBGradientPalette_byte ; +typedef const TProgmemRGBGradientPalette_byte *TProgmemRGBGradientPalette_bytes; +typedef TProgmemRGBGradientPalette_bytes TProgmemRGBGradientPalettePtr; +typedef union { + struct { + uint8_t index; + uint8_t r; + uint8_t g; + uint8_t b; + }; + uint32_t dword; + uint8_t bytes[4]; +} TRGBGradientPaletteEntryUnion; + +typedef uint8_t TDynamicRGBGradientPalette_byte ; +typedef const TDynamicRGBGradientPalette_byte *TDynamicRGBGradientPalette_bytes; +typedef TDynamicRGBGradientPalette_bytes TDynamicRGBGradientPalettePtr; + +// Convert a 16-entry palette to a 256-entry palette +void UpscalePalette(const struct CRGBPalette16& srcpal16, struct CRGBPalette256& destpal256); +void UpscalePalette(const struct CHSVPalette16& srcpal16, struct CHSVPalette256& destpal256); + +// Convert a 16-entry palette to a 32-entry palette +void UpscalePalette(const struct CRGBPalette16& srcpal16, struct CRGBPalette32& destpal32); +void UpscalePalette(const struct CHSVPalette16& srcpal16, struct CHSVPalette32& destpal32); + +// Convert a 32-entry palette to a 256-entry palette +void UpscalePalette(const struct CRGBPalette32& srcpal32, struct CRGBPalette256& destpal256); +void UpscalePalette(const struct CHSVPalette32& srcpal32, struct CHSVPalette256& destpal256); + + +class CHSVPalette16 { +public: + CHSV entries[16]; + CHSVPalette16() {}; + CHSVPalette16( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03, + const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07, + const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11, + const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 ) + { + entries[0]=c00; entries[1]=c01; entries[2]=c02; entries[3]=c03; + entries[4]=c04; entries[5]=c05; entries[6]=c06; entries[7]=c07; + entries[8]=c08; entries[9]=c09; entries[10]=c10; entries[11]=c11; + entries[12]=c12; entries[13]=c13; entries[14]=c14; entries[15]=c15; + }; + + CHSVPalette16( const CHSVPalette16& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + } + CHSVPalette16& operator=( const CHSVPalette16& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + return *this; + } + + CHSVPalette16( const TProgmemHSVPalette16& rhs) + { + for( uint8_t i = 0; i < 16; i++) { + CRGB xyz = FL_PGM_READ_DWORD_NEAR( rhs + i); + entries[i].hue = xyz.red; + entries[i].sat = xyz.green; + entries[i].val = xyz.blue; + } + } + CHSVPalette16& operator=( const TProgmemHSVPalette16& rhs) + { + for( uint8_t i = 0; i < 16; i++) { + CRGB xyz = FL_PGM_READ_DWORD_NEAR( rhs + i); + entries[i].hue = xyz.red; + entries[i].sat = xyz.green; + entries[i].val = xyz.blue; + } + return *this; + } + + inline CHSV& operator[] (uint8_t x) __attribute__((always_inline)) + { + return entries[x]; + } + inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline)) + { + return entries[x]; + } + + inline CHSV& operator[] (int x) __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + inline const CHSV& operator[] (int x) const __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + + operator CHSV*() + { + return &(entries[0]); + } + + bool operator==( const CHSVPalette16 rhs) + { + const uint8_t* p = (const uint8_t*)(&(this->entries[0])); + const uint8_t* q = (const uint8_t*)(&(rhs.entries[0])); + if( p == q) return true; + for( uint8_t i = 0; i < (sizeof( entries)); i++) { + if( *p != *q) return false; + p++; + q++; + } + return true; + } + bool operator!=( const CHSVPalette16 rhs) + { + return !( *this == rhs); + } + + CHSVPalette16( const CHSV& c1) + { + fill_solid( &(entries[0]), 16, c1); + } + CHSVPalette16( const CHSV& c1, const CHSV& c2) + { + fill_gradient( &(entries[0]), 16, c1, c2); + } + CHSVPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3) + { + fill_gradient( &(entries[0]), 16, c1, c2, c3); + } + CHSVPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4) + { + fill_gradient( &(entries[0]), 16, c1, c2, c3, c4); + } + +}; + +class CHSVPalette256 { +public: + CHSV entries[256]; + CHSVPalette256() {}; + CHSVPalette256( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03, + const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07, + const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11, + const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 ) + { + CHSVPalette16 p16(c00,c01,c02,c03,c04,c05,c06,c07, + c08,c09,c10,c11,c12,c13,c14,c15); + *this = p16; + }; + + CHSVPalette256( const CHSVPalette256& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + } + CHSVPalette256& operator=( const CHSVPalette256& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + return *this; + } + + CHSVPalette256( const CHSVPalette16& rhs16) + { + UpscalePalette( rhs16, *this); + } + CHSVPalette256& operator=( const CHSVPalette16& rhs16) + { + UpscalePalette( rhs16, *this); + return *this; + } + + CHSVPalette256( const TProgmemRGBPalette16& rhs) + { + CHSVPalette16 p16(rhs); + *this = p16; + } + CHSVPalette256& operator=( const TProgmemRGBPalette16& rhs) + { + CHSVPalette16 p16(rhs); + *this = p16; + return *this; + } + + inline CHSV& operator[] (uint8_t x) __attribute__((always_inline)) + { + return entries[x]; + } + inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline)) + { + return entries[x]; + } + + inline CHSV& operator[] (int x) __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + inline const CHSV& operator[] (int x) const __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + + operator CHSV*() + { + return &(entries[0]); + } + + bool operator==( const CHSVPalette256 rhs) + { + const uint8_t* p = (const uint8_t*)(&(this->entries[0])); + const uint8_t* q = (const uint8_t*)(&(rhs.entries[0])); + if( p == q) return true; + for( uint16_t i = 0; i < (sizeof( entries)); i++) { + if( *p != *q) return false; + p++; + q++; + } + return true; + } + bool operator!=( const CHSVPalette256 rhs) + { + return !( *this == rhs); + } + + CHSVPalette256( const CHSV& c1) + { + fill_solid( &(entries[0]), 256, c1); + } + CHSVPalette256( const CHSV& c1, const CHSV& c2) + { + fill_gradient( &(entries[0]), 256, c1, c2); + } + CHSVPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3) + { + fill_gradient( &(entries[0]), 256, c1, c2, c3); + } + CHSVPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4) + { + fill_gradient( &(entries[0]), 256, c1, c2, c3, c4); + } +}; + +class CRGBPalette16 { +public: + CRGB entries[16]; + CRGBPalette16() {}; + CRGBPalette16( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03, + const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07, + const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11, + const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 ) + { + entries[0]=c00; entries[1]=c01; entries[2]=c02; entries[3]=c03; + entries[4]=c04; entries[5]=c05; entries[6]=c06; entries[7]=c07; + entries[8]=c08; entries[9]=c09; entries[10]=c10; entries[11]=c11; + entries[12]=c12; entries[13]=c13; entries[14]=c14; entries[15]=c15; + }; + + CRGBPalette16( const CRGBPalette16& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + } + CRGBPalette16( const CRGB rhs[16]) + { + memmove8( &(entries[0]), &(rhs[0]), sizeof( entries)); + } + CRGBPalette16& operator=( const CRGBPalette16& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + return *this; + } + CRGBPalette16& operator=( const CRGB rhs[16]) + { + memmove8( &(entries[0]), &(rhs[0]), sizeof( entries)); + return *this; + } + + CRGBPalette16( const CHSVPalette16& rhs) + { + for( uint8_t i = 0; i < 16; i++) { + entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion + } + } + CRGBPalette16( const CHSV rhs[16]) + { + for( uint8_t i = 0; i < 16; i++) { + entries[i] = rhs[i]; // implicit HSV-to-RGB conversion + } + } + CRGBPalette16& operator=( const CHSVPalette16& rhs) + { + for( uint8_t i = 0; i < 16; i++) { + entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion + } + return *this; + } + CRGBPalette16& operator=( const CHSV rhs[16]) + { + for( uint8_t i = 0; i < 16; i++) { + entries[i] = rhs[i]; // implicit HSV-to-RGB conversion + } + return *this; + } + + CRGBPalette16( const TProgmemRGBPalette16& rhs) + { + for( uint8_t i = 0; i < 16; i++) { + entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i); + } + } + CRGBPalette16& operator=( const TProgmemRGBPalette16& rhs) + { + for( uint8_t i = 0; i < 16; i++) { + entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i); + } + return *this; + } + + bool operator==( const CRGBPalette16 rhs) + { + const uint8_t* p = (const uint8_t*)(&(this->entries[0])); + const uint8_t* q = (const uint8_t*)(&(rhs.entries[0])); + if( p == q) return true; + for( uint8_t i = 0; i < (sizeof( entries)); i++) { + if( *p != *q) return false; + p++; + q++; + } + return true; + } + bool operator!=( const CRGBPalette16 rhs) + { + return !( *this == rhs); + } + + inline CRGB& operator[] (uint8_t x) __attribute__((always_inline)) + { + return entries[x]; + } + inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline)) + { + return entries[x]; + } + + inline CRGB& operator[] (int x) __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + inline const CRGB& operator[] (int x) const __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + + operator CRGB*() + { + return &(entries[0]); + } + + CRGBPalette16( const CHSV& c1) + { + fill_solid( &(entries[0]), 16, c1); + } + CRGBPalette16( const CHSV& c1, const CHSV& c2) + { + fill_gradient( &(entries[0]), 16, c1, c2); + } + CRGBPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3) + { + fill_gradient( &(entries[0]), 16, c1, c2, c3); + } + CRGBPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4) + { + fill_gradient( &(entries[0]), 16, c1, c2, c3, c4); + } + + CRGBPalette16( const CRGB& c1) + { + fill_solid( &(entries[0]), 16, c1); + } + CRGBPalette16( const CRGB& c1, const CRGB& c2) + { + fill_gradient_RGB( &(entries[0]), 16, c1, c2); + } + CRGBPalette16( const CRGB& c1, const CRGB& c2, const CRGB& c3) + { + fill_gradient_RGB( &(entries[0]), 16, c1, c2, c3); + } + CRGBPalette16( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4) + { + fill_gradient_RGB( &(entries[0]), 16, c1, c2, c3, c4); + } + + + // Gradient palettes are loaded into CRGB16Palettes in such a way + // that, if possible, every color represented in the gradient palette + // is also represented in the CRGBPalette16. + // For example, consider a gradient palette that is all black except + // for a single, one-element-wide (1/256th!) spike of red in the middle: + // 0, 0,0,0 + // 124, 0,0,0 + // 125, 255,0,0 // one 1/256th-palette-wide red stripe + // 126, 0,0,0 + // 255, 0,0,0 + // A naive conversion of this 256-element palette to a 16-element palette + // might accidentally completely eliminate the red spike, rendering the + // palette completely black. + // However, the conversions provided here would attempt to include a + // the red stripe in the output, more-or-less as faithfully as possible. + // So in this case, the resulting CRGBPalette16 palette would have a red + // stripe in the middle which was 1/16th of a palette wide -- the + // narrowest possible in a CRGBPalette16. + // This means that the relative width of stripes in a CRGBPalette16 + // will be, by definition, different from the widths in the gradient + // palette. This code attempts to preserve "all the colors", rather than + // the exact stripe widths at the expense of dropping some colors. + CRGBPalette16( TProgmemRGBGradientPalette_bytes progpal ) + { + *this = progpal; + } + CRGBPalette16& operator=( TProgmemRGBGradientPalette_bytes progpal ) + { + TRGBGradientPaletteEntryUnion* progent = (TRGBGradientPaletteEntryUnion*)(progpal); + TRGBGradientPaletteEntryUnion u; + + // Count entries + uint16_t count = 0; + do { + u.dword = FL_PGM_READ_DWORD_NEAR(progent + count); + count++;; + } while ( u.index != 255); + + int8_t lastSlotUsed = -1; + + u.dword = FL_PGM_READ_DWORD_NEAR( progent); + CRGB rgbstart( u.r, u.g, u.b); + + int indexstart = 0; + uint8_t istart8 = 0; + uint8_t iend8 = 0; + while( indexstart < 255) { + progent++; + u.dword = FL_PGM_READ_DWORD_NEAR( progent); + int indexend = u.index; + CRGB rgbend( u.r, u.g, u.b); + istart8 = indexstart / 16; + iend8 = indexend / 16; + if( count < 16) { + if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) { + istart8 = lastSlotUsed + 1; + if( iend8 < istart8) { + iend8 = istart8; + } + } + lastSlotUsed = iend8; + } + fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend); + indexstart = indexend; + rgbstart = rgbend; + } + return *this; + } + CRGBPalette16& loadDynamicGradientPalette( TDynamicRGBGradientPalette_bytes gpal ) + { + TRGBGradientPaletteEntryUnion* ent = (TRGBGradientPaletteEntryUnion*)(gpal); + TRGBGradientPaletteEntryUnion u; + + // Count entries + uint16_t count = 0; + do { + u = *(ent + count); + count++;; + } while ( u.index != 255); + + int8_t lastSlotUsed = -1; + + + u = *ent; + CRGB rgbstart( u.r, u.g, u.b); + + int indexstart = 0; + uint8_t istart8 = 0; + uint8_t iend8 = 0; + while( indexstart < 255) { + ent++; + u = *ent; + int indexend = u.index; + CRGB rgbend( u.r, u.g, u.b); + istart8 = indexstart / 16; + iend8 = indexend / 16; + if( count < 16) { + if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) { + istart8 = lastSlotUsed + 1; + if( iend8 < istart8) { + iend8 = istart8; + } + } + lastSlotUsed = iend8; + } + fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend); + indexstart = indexend; + rgbstart = rgbend; + } + return *this; + } + +}; + + + +class CHSVPalette32 { +public: + CHSV entries[32]; + CHSVPalette32() {}; + CHSVPalette32( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03, + const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07, + const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11, + const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 ) + { + for( uint8_t i = 0; i < 2; i++) { + entries[0+i]=c00; entries[2+i]=c01; entries[4+i]=c02; entries[6+i]=c03; + entries[8+i]=c04; entries[10+i]=c05; entries[12+i]=c06; entries[14+i]=c07; + entries[16+i]=c08; entries[18+i]=c09; entries[20+i]=c10; entries[22+i]=c11; + entries[24+i]=c12; entries[26+i]=c13; entries[28+i]=c14; entries[30+i]=c15; + } + }; + + CHSVPalette32( const CHSVPalette32& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + } + CHSVPalette32& operator=( const CHSVPalette32& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + return *this; + } + + CHSVPalette32( const TProgmemHSVPalette32& rhs) + { + for( uint8_t i = 0; i < 32; i++) { + CRGB xyz = FL_PGM_READ_DWORD_NEAR( rhs + i); + entries[i].hue = xyz.red; + entries[i].sat = xyz.green; + entries[i].val = xyz.blue; + } + } + CHSVPalette32& operator=( const TProgmemHSVPalette32& rhs) + { + for( uint8_t i = 0; i < 32; i++) { + CRGB xyz = FL_PGM_READ_DWORD_NEAR( rhs + i); + entries[i].hue = xyz.red; + entries[i].sat = xyz.green; + entries[i].val = xyz.blue; + } + return *this; + } + + inline CHSV& operator[] (uint8_t x) __attribute__((always_inline)) + { + return entries[x]; + } + inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline)) + { + return entries[x]; + } + + inline CHSV& operator[] (int x) __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + inline const CHSV& operator[] (int x) const __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + + operator CHSV*() + { + return &(entries[0]); + } + + bool operator==( const CHSVPalette32 rhs) + { + const uint8_t* p = (const uint8_t*)(&(this->entries[0])); + const uint8_t* q = (const uint8_t*)(&(rhs.entries[0])); + if( p == q) return true; + for( uint8_t i = 0; i < (sizeof( entries)); i++) { + if( *p != *q) return false; + p++; + q++; + } + return true; + } + bool operator!=( const CHSVPalette32 rhs) + { + return !( *this == rhs); + } + + CHSVPalette32( const CHSV& c1) + { + fill_solid( &(entries[0]), 32, c1); + } + CHSVPalette32( const CHSV& c1, const CHSV& c2) + { + fill_gradient( &(entries[0]), 32, c1, c2); + } + CHSVPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3) + { + fill_gradient( &(entries[0]), 32, c1, c2, c3); + } + CHSVPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4) + { + fill_gradient( &(entries[0]), 32, c1, c2, c3, c4); + } + +}; + +class CRGBPalette32 { +public: + CRGB entries[32]; + CRGBPalette32() {}; + CRGBPalette32( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03, + const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07, + const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11, + const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 ) + { + for( uint8_t i = 0; i < 2; i++) { + entries[0+i]=c00; entries[2+i]=c01; entries[4+i]=c02; entries[6+i]=c03; + entries[8+i]=c04; entries[10+i]=c05; entries[12+i]=c06; entries[14+i]=c07; + entries[16+i]=c08; entries[18+i]=c09; entries[20+i]=c10; entries[22+i]=c11; + entries[24+i]=c12; entries[26+i]=c13; entries[28+i]=c14; entries[30+i]=c15; + } + }; + + CRGBPalette32( const CRGBPalette32& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + } + CRGBPalette32( const CRGB rhs[32]) + { + memmove8( &(entries[0]), &(rhs[0]), sizeof( entries)); + } + CRGBPalette32& operator=( const CRGBPalette32& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + return *this; + } + CRGBPalette32& operator=( const CRGB rhs[32]) + { + memmove8( &(entries[0]), &(rhs[0]), sizeof( entries)); + return *this; + } + + CRGBPalette32( const CHSVPalette32& rhs) + { + for( uint8_t i = 0; i < 32; i++) { + entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion + } + } + CRGBPalette32( const CHSV rhs[32]) + { + for( uint8_t i = 0; i < 32; i++) { + entries[i] = rhs[i]; // implicit HSV-to-RGB conversion + } + } + CRGBPalette32& operator=( const CHSVPalette32& rhs) + { + for( uint8_t i = 0; i < 32; i++) { + entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion + } + return *this; + } + CRGBPalette32& operator=( const CHSV rhs[32]) + { + for( uint8_t i = 0; i < 32; i++) { + entries[i] = rhs[i]; // implicit HSV-to-RGB conversion + } + return *this; + } + + CRGBPalette32( const TProgmemRGBPalette32& rhs) + { + for( uint8_t i = 0; i < 32; i++) { + entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i); + } + } + CRGBPalette32& operator=( const TProgmemRGBPalette32& rhs) + { + for( uint8_t i = 0; i < 32; i++) { + entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i); + } + return *this; + } + + bool operator==( const CRGBPalette32 rhs) + { + const uint8_t* p = (const uint8_t*)(&(this->entries[0])); + const uint8_t* q = (const uint8_t*)(&(rhs.entries[0])); + if( p == q) return true; + for( uint8_t i = 0; i < (sizeof( entries)); i++) { + if( *p != *q) return false; + p++; + q++; + } + return true; + } + bool operator!=( const CRGBPalette32 rhs) + { + return !( *this == rhs); + } + + inline CRGB& operator[] (uint8_t x) __attribute__((always_inline)) + { + return entries[x]; + } + inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline)) + { + return entries[x]; + } + + inline CRGB& operator[] (int x) __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + inline const CRGB& operator[] (int x) const __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + + operator CRGB*() + { + return &(entries[0]); + } + + CRGBPalette32( const CHSV& c1) + { + fill_solid( &(entries[0]), 32, c1); + } + CRGBPalette32( const CHSV& c1, const CHSV& c2) + { + fill_gradient( &(entries[0]), 32, c1, c2); + } + CRGBPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3) + { + fill_gradient( &(entries[0]), 32, c1, c2, c3); + } + CRGBPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4) + { + fill_gradient( &(entries[0]), 32, c1, c2, c3, c4); + } + + CRGBPalette32( const CRGB& c1) + { + fill_solid( &(entries[0]), 32, c1); + } + CRGBPalette32( const CRGB& c1, const CRGB& c2) + { + fill_gradient_RGB( &(entries[0]), 32, c1, c2); + } + CRGBPalette32( const CRGB& c1, const CRGB& c2, const CRGB& c3) + { + fill_gradient_RGB( &(entries[0]), 32, c1, c2, c3); + } + CRGBPalette32( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4) + { + fill_gradient_RGB( &(entries[0]), 32, c1, c2, c3, c4); + } + + + CRGBPalette32( const CRGBPalette16& rhs16) + { + UpscalePalette( rhs16, *this); + } + CRGBPalette32& operator=( const CRGBPalette16& rhs16) + { + UpscalePalette( rhs16, *this); + return *this; + } + + CRGBPalette32( const TProgmemRGBPalette16& rhs) + { + CRGBPalette16 p16(rhs); + *this = p16; + } + CRGBPalette32& operator=( const TProgmemRGBPalette16& rhs) + { + CRGBPalette16 p16(rhs); + *this = p16; + return *this; + } + + + // Gradient palettes are loaded into CRGB16Palettes in such a way + // that, if possible, every color represented in the gradient palette + // is also represented in the CRGBPalette32. + // For example, consider a gradient palette that is all black except + // for a single, one-element-wide (1/256th!) spike of red in the middle: + // 0, 0,0,0 + // 124, 0,0,0 + // 125, 255,0,0 // one 1/256th-palette-wide red stripe + // 126, 0,0,0 + // 255, 0,0,0 + // A naive conversion of this 256-element palette to a 16-element palette + // might accidentally completely eliminate the red spike, rendering the + // palette completely black. + // However, the conversions provided here would attempt to include a + // the red stripe in the output, more-or-less as faithfully as possible. + // So in this case, the resulting CRGBPalette32 palette would have a red + // stripe in the middle which was 1/16th of a palette wide -- the + // narrowest possible in a CRGBPalette32. + // This means that the relative width of stripes in a CRGBPalette32 + // will be, by definition, different from the widths in the gradient + // palette. This code attempts to preserve "all the colors", rather than + // the exact stripe widths at the expense of dropping some colors. + CRGBPalette32( TProgmemRGBGradientPalette_bytes progpal ) + { + *this = progpal; + } + CRGBPalette32& operator=( TProgmemRGBGradientPalette_bytes progpal ) + { + TRGBGradientPaletteEntryUnion* progent = (TRGBGradientPaletteEntryUnion*)(progpal); + TRGBGradientPaletteEntryUnion u; + + // Count entries + uint16_t count = 0; + do { + u.dword = FL_PGM_READ_DWORD_NEAR(progent + count); + count++;; + } while ( u.index != 255); + + int8_t lastSlotUsed = -1; + + u.dword = FL_PGM_READ_DWORD_NEAR( progent); + CRGB rgbstart( u.r, u.g, u.b); + + int indexstart = 0; + uint8_t istart8 = 0; + uint8_t iend8 = 0; + while( indexstart < 255) { + progent++; + u.dword = FL_PGM_READ_DWORD_NEAR( progent); + int indexend = u.index; + CRGB rgbend( u.r, u.g, u.b); + istart8 = indexstart / 8; + iend8 = indexend / 8; + if( count < 16) { + if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) { + istart8 = lastSlotUsed + 1; + if( iend8 < istart8) { + iend8 = istart8; + } + } + lastSlotUsed = iend8; + } + fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend); + indexstart = indexend; + rgbstart = rgbend; + } + return *this; + } + CRGBPalette32& loadDynamicGradientPalette( TDynamicRGBGradientPalette_bytes gpal ) + { + TRGBGradientPaletteEntryUnion* ent = (TRGBGradientPaletteEntryUnion*)(gpal); + TRGBGradientPaletteEntryUnion u; + + // Count entries + uint16_t count = 0; + do { + u = *(ent + count); + count++;; + } while ( u.index != 255); + + int8_t lastSlotUsed = -1; + + + u = *ent; + CRGB rgbstart( u.r, u.g, u.b); + + int indexstart = 0; + uint8_t istart8 = 0; + uint8_t iend8 = 0; + while( indexstart < 255) { + ent++; + u = *ent; + int indexend = u.index; + CRGB rgbend( u.r, u.g, u.b); + istart8 = indexstart / 8; + iend8 = indexend / 8; + if( count < 16) { + if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) { + istart8 = lastSlotUsed + 1; + if( iend8 < istart8) { + iend8 = istart8; + } + } + lastSlotUsed = iend8; + } + fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend); + indexstart = indexend; + rgbstart = rgbend; + } + return *this; + } + +}; + + + +class CRGBPalette256 { +public: + CRGB entries[256]; + CRGBPalette256() {}; + CRGBPalette256( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03, + const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07, + const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11, + const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 ) + { + CRGBPalette16 p16(c00,c01,c02,c03,c04,c05,c06,c07, + c08,c09,c10,c11,c12,c13,c14,c15); + *this = p16; + }; + + CRGBPalette256( const CRGBPalette256& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + } + CRGBPalette256( const CRGB rhs[256]) + { + memmove8( &(entries[0]), &(rhs[0]), sizeof( entries)); + } + CRGBPalette256& operator=( const CRGBPalette256& rhs) + { + memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries)); + return *this; + } + CRGBPalette256& operator=( const CRGB rhs[256]) + { + memmove8( &(entries[0]), &(rhs[0]), sizeof( entries)); + return *this; + } + + CRGBPalette256( const CHSVPalette256& rhs) + { + for( int i = 0; i < 256; i++) { + entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion + } + } + CRGBPalette256( const CHSV rhs[256]) + { + for( int i = 0; i < 256; i++) { + entries[i] = rhs[i]; // implicit HSV-to-RGB conversion + } + } + CRGBPalette256& operator=( const CHSVPalette256& rhs) + { + for( int i = 0; i < 256; i++) { + entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion + } + return *this; + } + CRGBPalette256& operator=( const CHSV rhs[256]) + { + for( int i = 0; i < 256; i++) { + entries[i] = rhs[i]; // implicit HSV-to-RGB conversion + } + return *this; + } + + CRGBPalette256( const CRGBPalette16& rhs16) + { + UpscalePalette( rhs16, *this); + } + CRGBPalette256& operator=( const CRGBPalette16& rhs16) + { + UpscalePalette( rhs16, *this); + return *this; + } + + CRGBPalette256( const TProgmemRGBPalette16& rhs) + { + CRGBPalette16 p16(rhs); + *this = p16; + } + CRGBPalette256& operator=( const TProgmemRGBPalette16& rhs) + { + CRGBPalette16 p16(rhs); + *this = p16; + return *this; + } + + bool operator==( const CRGBPalette256 rhs) + { + const uint8_t* p = (const uint8_t*)(&(this->entries[0])); + const uint8_t* q = (const uint8_t*)(&(rhs.entries[0])); + if( p == q) return true; + for( uint16_t i = 0; i < (sizeof( entries)); i++) { + if( *p != *q) return false; + p++; + q++; + } + return true; + } + bool operator!=( const CRGBPalette256 rhs) + { + return !( *this == rhs); + } + + inline CRGB& operator[] (uint8_t x) __attribute__((always_inline)) + { + return entries[x]; + } + inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline)) + { + return entries[x]; + } + + inline CRGB& operator[] (int x) __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + inline const CRGB& operator[] (int x) const __attribute__((always_inline)) + { + return entries[(uint8_t)x]; + } + + operator CRGB*() + { + return &(entries[0]); + } + + CRGBPalette256( const CHSV& c1) + { + fill_solid( &(entries[0]), 256, c1); + } + CRGBPalette256( const CHSV& c1, const CHSV& c2) + { + fill_gradient( &(entries[0]), 256, c1, c2); + } + CRGBPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3) + { + fill_gradient( &(entries[0]), 256, c1, c2, c3); + } + CRGBPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4) + { + fill_gradient( &(entries[0]), 256, c1, c2, c3, c4); + } + + CRGBPalette256( const CRGB& c1) + { + fill_solid( &(entries[0]), 256, c1); + } + CRGBPalette256( const CRGB& c1, const CRGB& c2) + { + fill_gradient_RGB( &(entries[0]), 256, c1, c2); + } + CRGBPalette256( const CRGB& c1, const CRGB& c2, const CRGB& c3) + { + fill_gradient_RGB( &(entries[0]), 256, c1, c2, c3); + } + CRGBPalette256( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4) + { + fill_gradient_RGB( &(entries[0]), 256, c1, c2, c3, c4); + } + + CRGBPalette256( TProgmemRGBGradientPalette_bytes progpal ) + { + *this = progpal; + } + CRGBPalette256& operator=( TProgmemRGBGradientPalette_bytes progpal ) + { + TRGBGradientPaletteEntryUnion* progent = (TRGBGradientPaletteEntryUnion*)(progpal); + TRGBGradientPaletteEntryUnion u; + u.dword = FL_PGM_READ_DWORD_NEAR( progent); + CRGB rgbstart( u.r, u.g, u.b); + + int indexstart = 0; + while( indexstart < 255) { + progent++; + u.dword = FL_PGM_READ_DWORD_NEAR( progent); + int indexend = u.index; + CRGB rgbend( u.r, u.g, u.b); + fill_gradient_RGB( &(entries[0]), indexstart, rgbstart, indexend, rgbend); + indexstart = indexend; + rgbstart = rgbend; + } + return *this; + } + CRGBPalette256& loadDynamicGradientPalette( TDynamicRGBGradientPalette_bytes gpal ) + { + TRGBGradientPaletteEntryUnion* ent = (TRGBGradientPaletteEntryUnion*)(gpal); + TRGBGradientPaletteEntryUnion u; + u = *ent; + CRGB rgbstart( u.r, u.g, u.b); + + int indexstart = 0; + while( indexstart < 255) { + ent++; + u = *ent; + int indexend = u.index; + CRGB rgbend( u.r, u.g, u.b); + fill_gradient_RGB( &(entries[0]), indexstart, rgbstart, indexend, rgbend); + indexstart = indexend; + rgbstart = rgbend; + } + return *this; + } +}; + + + +typedef enum { NOBLEND=0, LINEARBLEND=1 } TBlendType; + +CRGB ColorFromPalette( const CRGBPalette16& pal, + uint8_t index, + uint8_t brightness=255, + TBlendType blendType=LINEARBLEND); + +CRGB ColorFromPalette( const TProgmemRGBPalette16& pal, + uint8_t index, + uint8_t brightness=255, + TBlendType blendType=LINEARBLEND); + +CRGB ColorFromPalette( const CRGBPalette256& pal, + uint8_t index, + uint8_t brightness=255, + TBlendType blendType=NOBLEND ); + +CHSV ColorFromPalette( const CHSVPalette16& pal, + uint8_t index, + uint8_t brightness=255, + TBlendType blendType=LINEARBLEND); + +CHSV ColorFromPalette( const CHSVPalette256& pal, + uint8_t index, + uint8_t brightness=255, + TBlendType blendType=NOBLEND ); + +CRGB ColorFromPalette( const CRGBPalette32& pal, + uint8_t index, + uint8_t brightness=255, + TBlendType blendType=LINEARBLEND); + +CRGB ColorFromPalette( const TProgmemRGBPalette32& pal, + uint8_t index, + uint8_t brightness=255, + TBlendType blendType=LINEARBLEND); + +CHSV ColorFromPalette( const CHSVPalette32& pal, + uint8_t index, + uint8_t brightness=255, + TBlendType blendType=LINEARBLEND); + + +// Fill a range of LEDs with a sequece of entryies from a palette +template +void fill_palette(CRGB* L, uint16_t N, uint8_t startIndex, uint8_t incIndex, + const PALETTE& pal, uint8_t brightness, TBlendType blendType) +{ + uint8_t colorIndex = startIndex; + for( uint16_t i = 0; i < N; i++) { + L[i] = ColorFromPalette( pal, colorIndex, brightness, blendType); + colorIndex += incIndex; + } +} + +template +void map_data_into_colors_through_palette( + uint8_t *dataArray, uint16_t dataCount, + CRGB* targetColorArray, + const PALETTE& pal, + uint8_t brightness=255, + uint8_t opacity=255, + TBlendType blendType=LINEARBLEND) +{ + for( uint16_t i = 0; i < dataCount; i++) { + uint8_t d = dataArray[i]; + CRGB rgb = ColorFromPalette( pal, d, brightness, blendType); + if( opacity == 255 ) { + targetColorArray[i] = rgb; + } else { + targetColorArray[i].nscale8( 256 - opacity); + rgb.nscale8_video( opacity); + targetColorArray[i] += rgb; + } + } +} + +// nblendPaletteTowardPalette: +// Alter one palette by making it slightly more like +// a 'target palette', used for palette cross-fades. +// +// It does this by comparing each of the R, G, and B channels +// of each entry in the current palette to the corresponding +// entry in the target palette and making small adjustments: +// If the Red channel is too low, it will be increased. +// If the Red channel is too high, it will be slightly reduced. +// ... and likewise for Green and Blue channels. +// +// Additionally, there are two significant visual improvements +// to this algorithm implemented here. First is this: +// When increasing a channel, it is stepped up by ONE. +// When decreasing a channel, it is stepped down by TWO. +// Due to the way the eye perceives light, and the way colors +// are represented in RGB, this produces a more uniform apparent +// brightness when cross-fading between most palette colors. +// +// The second visual tweak is limiting the number of changes +// that will be made to the palette at once. If all the palette +// entries are changed at once, it can give a muddled appearance. +// However, if only a few palette entries are changed at once, +// you get a visually smoother transition: in the middle of the +// cross-fade your current palette will actually contain some +// colors from the old palette, a few blended colors, and some +// colors from the new palette. +// The maximum number of possible palette changes per call +// is 48 (sixteen color entries time three channels each). +// The default 'maximim number of changes' here is 12, meaning +// that only approximately a quarter of the palette entries +// will be changed per call. +void nblendPaletteTowardPalette( CRGBPalette16& currentPalette, + CRGBPalette16& targetPalette, + uint8_t maxChanges=24); + + + + +// You can also define a static RGB palette very compactly in terms of a series +// of connected color gradients. +// For example, if you want the first 3/4ths of the palette to be a slow +// gradient ramping from black to red, and then the remaining 1/4 of the +// palette to be a quicker ramp to white, you specify just three points: the +// starting black point (at index 0), the red midpoint (at index 192), +// and the final white point (at index 255). It looks like this: +// +// index: 0 192 255 +// |----------r-r-r-rrrrrrrrRrRrRrRrRRRR-|-RRWRWWRWWW-| +// color: (0,0,0) (255,0,0) (255,255,255) +// +// Here's how you'd define that gradient palette: +// +// DEFINE_GRADIENT_PALETTE( black_to_red_to_white_p ) { +// 0, 0, 0, 0, /* at index 0, black(0,0,0) */ +// 192, 255, 0, 0, /* at index 192, red(255,0,0) */ +// 255, 255,255,255 /* at index 255, white(255,255,255) */ +// }; +// +// This format is designed for compact storage. The example palette here +// takes up just 12 bytes of PROGMEM (flash) storage, and zero bytes +// of SRAM when not currently in use. +// +// To use one of these gradient palettes, simply assign it into a +// CRGBPalette16 or a CRGBPalette256, like this: +// +// CRGBPalette16 pal = black_to_red_to_white_p; +// +// When the assignment is made, the gradients are expanded out into +// either 16 or 256 palette entries, depending on the kind of palette +// object they're assigned to. +// +// IMPORTANT NOTES & CAVEATS: +// +// - The last 'index' position MUST BE 255! Failure to end with +// index 255 will result in program hangs or crashes. +// +// - At this point, these gradient palette definitions MUST BE +// stored in PROGMEM on AVR-based Arduinos. If you use the +// DEFINE_GRADIENT_PALETTE macro, this is taken care of automatically. +// + +#define DEFINE_GRADIENT_PALETTE(X) \ + FL_ALIGN_PROGMEM \ + extern const TProgmemRGBGradientPalette_byte X[] FL_PROGMEM = + +#define DECLARE_GRADIENT_PALETTE(X) \ + FL_ALIGN_PROGMEM \ + extern const TProgmemRGBGradientPalette_byte X[] FL_PROGMEM + + +// Functions to apply gamma adjustments, either: +// - a single gamma adjustment to a single scalar value, +// - a single gamma adjustment to each channel of a CRGB color, or +// - different gamma adjustments for each channel of a CRFB color. +// +// Note that the gamma is specified as a traditional floating point value +// e.g., "2.5", and as such these functions should not be called in +// your innermost pixel loops, or in animations that are extremely +// low on program storage space. Nevertheless, if you need these +// functions, here they are. +// +// Furthermore, bear in mind that CRGB leds have only eight bits +// per channel of color resolution, and that very small, subtle shadings +// may not be visible. +uint8_t applyGamma_video( uint8_t brightness, float gamma); +CRGB applyGamma_video( const CRGB& orig, float gamma); +CRGB applyGamma_video( const CRGB& orig, float gammaR, float gammaG, float gammaB); +// The "n" versions below modify their arguments in-place. +CRGB& napplyGamma_video( CRGB& rgb, float gamma); +CRGB& napplyGamma_video( CRGB& rgb, float gammaR, float gammaG, float gammaB); +void napplyGamma_video( CRGB* rgbarray, uint16_t count, float gamma); +void napplyGamma_video( CRGB* rgbarray, uint16_t count, float gammaR, float gammaG, float gammaB); + + +FASTLED_NAMESPACE_END + +///@} +#endif diff --git a/libraries/FastLED/component.mk b/libraries/FastLED/component.mk new file mode 100644 index 0000000..27ad11a --- /dev/null +++ b/libraries/FastLED/component.mk @@ -0,0 +1 @@ +COMPONENT_ADD_INCLUDEDIRS := . diff --git a/libraries/FastLED/controller.h b/libraries/FastLED/controller.h new file mode 100644 index 0000000..30e4c11 --- /dev/null +++ b/libraries/FastLED/controller.h @@ -0,0 +1,418 @@ +#ifndef __INC_CONTROLLER_H +#define __INC_CONTROLLER_H + +///@file controller.h +/// base definitions used by led controllers for writing out led data + +#include "FastLED.h" +#include "led_sysdefs.h" +#include "pixeltypes.h" +#include "color.h" +#include + +FASTLED_NAMESPACE_BEGIN + +#define RO(X) RGB_BYTE(RGB_ORDER, X) +#define RGB_BYTE(RO,X) (((RO)>>(3*(2-(X)))) & 0x3) + +#define RGB_BYTE0(RO) ((RO>>6) & 0x3) +#define RGB_BYTE1(RO) ((RO>>3) & 0x3) +#define RGB_BYTE2(RO) ((RO) & 0x3) + +// operator byte *(struct CRGB[] arr) { return (byte*)arr; } + +#define DISABLE_DITHER 0x00 +#define BINARY_DITHER 0x01 +typedef uint8_t EDitherMode; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// LED Controller interface definition +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/// Base definition for an LED controller. Pretty much the methods that every LED controller object will make available. +/// Note that the showARGB method is not impelemented for all controllers yet. Note also the methods for eventual checking +/// of background writing of data (I'm looking at you, teensy 3.0 DMA controller!). If you want to pass LED controllers around +/// to methods, make them references to this type, keeps your code saner. However, most people won't be seeing/using these objects +/// directly at all +class CLEDController { +protected: + friend class CFastLED; + CRGB *m_Data; + CLEDController *m_pNext; + CRGB m_ColorCorrection; + CRGB m_ColorTemperature; + EDitherMode m_DitherMode; + int m_nLeds; + static CLEDController *m_pHead; + static CLEDController *m_pTail; + + /// set all the leds on the controller to a given color + ///@param data the crgb color to set the leds to + ///@param nLeds the numner of leds to set to this color + ///@param scale the rgb scaling value for outputting color + virtual void showColor(const struct CRGB & data, int nLeds, CRGB scale) = 0; + + /// write the passed in rgb data out to the leds managed by this controller + ///@param data the rgb data to write out to the strip + ///@param nLeds the number of leds being written out + ///@param scale the rgb scaling to apply to each led before writing it out + virtual void show(const struct CRGB *data, int nLeds, CRGB scale) = 0; + +public: + /// create an led controller object, add it to the chain of controllers + CLEDController() : m_Data(NULL), m_ColorCorrection(UncorrectedColor), m_ColorTemperature(UncorrectedTemperature), m_DitherMode(BINARY_DITHER), m_nLeds(0) { + m_pNext = NULL; + if(m_pHead==NULL) { m_pHead = this; } + if(m_pTail != NULL) { m_pTail->m_pNext = this; } + m_pTail = this; + } + + ///initialize the LED controller + virtual void init() = 0; + + ///clear out/zero out the given number of leds. + virtual void clearLeds(int nLeds) { showColor(CRGB::Black, nLeds, CRGB::Black); } + + /// show function w/integer brightness, will scale for color correction and temperature + void show(const struct CRGB *data, int nLeds, uint8_t brightness) { + show(data, nLeds, getAdjustment(brightness)); + } + + /// show function w/integer brightness, will scale for color correction and temperature + void showColor(const struct CRGB &data, int nLeds, uint8_t brightness) { + showColor(data, nLeds, getAdjustment(brightness)); + } + + /// show function using the "attached to this controller" led data + void showLeds(uint8_t brightness=255) { + show(m_Data, m_nLeds, getAdjustment(brightness)); + } + + /// show the given color on the led strip + void showColor(const struct CRGB & data, uint8_t brightness=255) { + showColor(data, m_nLeds, getAdjustment(brightness)); + } + + /// get the first led controller in the chain of controllers + static CLEDController *head() { return m_pHead; } + /// get the next controller in the chain after this one. will return NULL at the end of the chain + CLEDController *next() { return m_pNext; } + + /// set the default array of leds to be used by this controller + CLEDController & setLeds(CRGB *data, int nLeds) { + m_Data = data; + m_nLeds = nLeds; + return *this; + } + + /// zero out the led data managed by this controller + void clearLedData() { + if(m_Data) { + memset8((void*)m_Data, 0, sizeof(struct CRGB) * m_nLeds); + } + } + + /// How many leds does this controller manage? + virtual int size() { return m_nLeds; } + + /// Pointer to the CRGB array for this controller + CRGB* leds() { return m_Data; } + + /// Reference to the n'th item in the controller + CRGB &operator[](int x) { return m_Data[x]; } + + /// set the dithering mode for this controller to use + inline CLEDController & setDither(uint8_t ditherMode = BINARY_DITHER) { m_DitherMode = ditherMode; return *this; } + /// get the dithering option currently set for this controller + inline uint8_t getDither() { return m_DitherMode; } + + /// the the color corrction to use for this controller, expressed as an rgb object + CLEDController & setCorrection(CRGB correction) { m_ColorCorrection = correction; return *this; } + /// set the color correction to use for this controller + CLEDController & setCorrection(LEDColorCorrection correction) { m_ColorCorrection = correction; return *this; } + /// get the correction value used by this controller + CRGB getCorrection() { return m_ColorCorrection; } + + /// set the color temperature, aka white point, for this controller + CLEDController & setTemperature(CRGB temperature) { m_ColorTemperature = temperature; return *this; } + /// set the color temperature, aka white point, for this controller + CLEDController & setTemperature(ColorTemperature temperature) { m_ColorTemperature = temperature; return *this; } + /// get the color temperature, aka whipe point, for this controller + CRGB getTemperature() { return m_ColorTemperature; } + + /// Get the combined brightness/color adjustment for this controller + CRGB getAdjustment(uint8_t scale) { + return computeAdjustment(scale, m_ColorCorrection, m_ColorTemperature); + } + + static CRGB computeAdjustment(uint8_t scale, const CRGB & colorCorrection, const CRGB & colorTemperature) { + #if defined(NO_CORRECTION) && (NO_CORRECTION==1) + return CRGB(scale,scale,scale); + #else + CRGB adj(0,0,0); + + if(scale > 0) { + for(uint8_t i = 0; i < 3; i++) { + uint8_t cc = colorCorrection.raw[i]; + uint8_t ct = colorTemperature.raw[i]; + if(cc > 0 && ct > 0) { + uint32_t work = (((uint32_t)cc)+1) * (((uint32_t)ct)+1) * scale; + work /= 0x10000L; + adj.raw[i] = work & 0xFF; + } + } + } + + return adj; + #endif + } + virtual uint16_t getMaxRefreshRate() const { return 0; } +}; + +// Pixel controller class. This is the class that we use to centralize pixel access in a block of data, including +// support for things like RGB reordering, scaling, dithering, skipping (for ARGB data), and eventually, we will +// centralize 8/12/16 conversions here as well. +template +struct PixelController { + const uint8_t *mData; + int mLen,mLenRemaining; + uint8_t d[3]; + uint8_t e[3]; + CRGB mScale; + int8_t mAdvance; + int mOffsets[LANES]; + + PixelController(const PixelController & other) { + d[0] = other.d[0]; + d[1] = other.d[1]; + d[2] = other.d[2]; + e[0] = other.e[0]; + e[1] = other.e[1]; + e[2] = other.e[2]; + mData = other.mData; + mScale = other.mScale; + mAdvance = other.mAdvance; + mLenRemaining = mLen = other.mLen; + for(int i = 0; i < LANES; i++) { mOffsets[i] = other.mOffsets[i]; } + + } + + void initOffsets(int len) { + int nOffset = 0; + for(int i = 0; i < LANES; i++) { + mOffsets[i] = nOffset; + if((1<1) + \ + (UPDATES_PER_FULL_DITHER_CYCLE>2) + \ + (UPDATES_PER_FULL_DITHER_CYCLE>4) + \ + (UPDATES_PER_FULL_DITHER_CYCLE>8) + \ + (UPDATES_PER_FULL_DITHER_CYCLE>16) + \ + (UPDATES_PER_FULL_DITHER_CYCLE>32) + \ + (UPDATES_PER_FULL_DITHER_CYCLE>64) + \ + (UPDATES_PER_FULL_DITHER_CYCLE>128) ) +#define VIRTUAL_BITS RECOMMENDED_VIRTUAL_BITS + + // R is the digther signal 'counter'. + static uint8_t R = 0; + R++; + + // R is wrapped around at 2^ditherBits, + // so if ditherBits is 2, R will cycle through (0,1,2,3) + uint8_t ditherBits = VIRTUAL_BITS; + R &= (0x01 << ditherBits) - 1; + + // Q is the "unscaled dither signal" itself. + // It's initialized to the reversed bits of R. + // If 'ditherBits' is 2, Q here will cycle through (0,128,64,192) + uint8_t Q = 0; + + // Reverse bits in a byte + { + if(R & 0x01) { Q |= 0x80; } + if(R & 0x02) { Q |= 0x40; } + if(R & 0x04) { Q |= 0x20; } + if(R & 0x08) { Q |= 0x10; } + if(R & 0x10) { Q |= 0x08; } + if(R & 0x20) { Q |= 0x04; } + if(R & 0x40) { Q |= 0x02; } + if(R & 0x80) { Q |= 0x01; } + } + + // Now we adjust Q to fall in the center of each range, + // instead of at the start of the range. + // If ditherBits is 2, Q will be (0, 128, 64, 192) at first, + // and this adjustment makes it (31, 159, 95, 223). + if( ditherBits < 8) { + Q += 0x01 << (7 - ditherBits); + } + + // D and E form the "scaled dither signal" + // which is added to pixel values to affect the + // actual dithering. + + // Setup the initial D and E values + for(int i = 0; i < 3; i++) { + uint8_t s = mScale.raw[i]; + e[i] = s ? (256/s) + 1 : 0; + d[i] = scale8(Q, e[i]); +#if (FASTLED_SCALE8_FIXED == 1) + if(d[i]) (d[i]--); +#endif + if(e[i]) e[i]--; + } +#endif + } + + // Do we have n pixels left to process? + __attribute__((always_inline)) inline bool has(int n) { + return mLenRemaining >= n; + } + + // toggle dithering enable + void enable_dithering(EDitherMode dither) { + switch(dither) { + case BINARY_DITHER: init_binary_dithering(); break; + default: d[0]=d[1]=d[2]=e[0]=e[1]=e[2]=0; break; + } + } + + __attribute__((always_inline)) inline int size() { return mLen; } + + // get the amount to advance the pointer by + __attribute__((always_inline)) inline int advanceBy() { return mAdvance; } + + // advance the data pointer forward, adjust position counter + __attribute__((always_inline)) inline void advanceData() { mData += mAdvance; mLenRemaining--;} + + // step the dithering forward + __attribute__((always_inline)) inline void stepDithering() { + // IF UPDATING HERE, BE SURE TO UPDATE THE ASM VERSION IN + // clockless_trinket.h! + d[0] = e[0] - d[0]; + d[1] = e[1] - d[1]; + d[2] = e[2] - d[2]; + } + + // Some chipsets pre-cycle the first byte, which means we want to cycle byte 0's dithering separately + __attribute__((always_inline)) inline void preStepFirstByteDithering() { + d[RO(0)] = e[RO(0)] - d[RO(0)]; + } + + template __attribute__((always_inline)) inline static uint8_t loadByte(PixelController & pc) { return pc.mData[RO(SLOT)]; } + template __attribute__((always_inline)) inline static uint8_t loadByte(PixelController & pc, int lane) { return pc.mData[pc.mOffsets[lane] + RO(SLOT)]; } + + template __attribute__((always_inline)) inline static uint8_t dither(PixelController & pc, uint8_t b) { return b ? qadd8(b, pc.d[RO(SLOT)]) : 0; } + template __attribute__((always_inline)) inline static uint8_t dither(PixelController & , uint8_t b, uint8_t d) { return b ? qadd8(b,d) : 0; } + + template __attribute__((always_inline)) inline static uint8_t scale(PixelController & pc, uint8_t b) { return scale8(b, pc.mScale.raw[RO(SLOT)]); } + template __attribute__((always_inline)) inline static uint8_t scale(PixelController & , uint8_t b, uint8_t scale) { return scale8(b, scale); } + + // composite shortcut functions for loading, dithering, and scaling + template __attribute__((always_inline)) inline static uint8_t loadAndScale(PixelController & pc) { return scale(pc, pc.dither(pc, pc.loadByte(pc))); } + template __attribute__((always_inline)) inline static uint8_t loadAndScale(PixelController & pc, int lane) { return scale(pc, pc.dither(pc, pc.loadByte(pc, lane))); } + template __attribute__((always_inline)) inline static uint8_t loadAndScale(PixelController & pc, int lane, uint8_t d, uint8_t scale) { return scale8(pc.dither(pc, pc.loadByte(pc, lane), d), scale); } + template __attribute__((always_inline)) inline static uint8_t loadAndScale(PixelController & pc, int lane, uint8_t scale) { return scale8(pc.loadByte(pc, lane), scale); } + + template __attribute__((always_inline)) inline static uint8_t advanceAndLoadAndScale(PixelController & pc) { pc.advanceData(); return pc.loadAndScale(pc); } + template __attribute__((always_inline)) inline static uint8_t advanceAndLoadAndScale(PixelController & pc, int lane) { pc.advanceData(); return pc.loadAndScale(pc, lane); } + template __attribute__((always_inline)) inline static uint8_t advanceAndLoadAndScale(PixelController & pc, int lane, uint8_t scale) { pc.advanceData(); return pc.loadAndScale(pc, lane, scale); } + + template __attribute__((always_inline)) inline static uint8_t getd(PixelController & pc) { return pc.d[RO(SLOT)]; } + template __attribute__((always_inline)) inline static uint8_t getscale(PixelController & pc) { return pc.mScale.raw[RO(SLOT)]; } + + // Helper functions to get around gcc stupidities + __attribute__((always_inline)) inline uint8_t loadAndScale0(int lane, uint8_t scale) { return loadAndScale<0>(*this, lane, scale); } + __attribute__((always_inline)) inline uint8_t loadAndScale1(int lane, uint8_t scale) { return loadAndScale<1>(*this, lane, scale); } + __attribute__((always_inline)) inline uint8_t loadAndScale2(int lane, uint8_t scale) { return loadAndScale<2>(*this, lane, scale); } + __attribute__((always_inline)) inline uint8_t advanceAndLoadAndScale0(int lane, uint8_t scale) { return advanceAndLoadAndScale<0>(*this, lane, scale); } + __attribute__((always_inline)) inline uint8_t stepAdvanceAndLoadAndScale0(int lane, uint8_t scale) { stepDithering(); return advanceAndLoadAndScale<0>(*this, lane, scale); } + + __attribute__((always_inline)) inline uint8_t loadAndScale0(int lane) { return loadAndScale<0>(*this, lane); } + __attribute__((always_inline)) inline uint8_t loadAndScale1(int lane) { return loadAndScale<1>(*this, lane); } + __attribute__((always_inline)) inline uint8_t loadAndScale2(int lane) { return loadAndScale<2>(*this, lane); } + __attribute__((always_inline)) inline uint8_t advanceAndLoadAndScale0(int lane) { return advanceAndLoadAndScale<0>(*this, lane); } + __attribute__((always_inline)) inline uint8_t stepAdvanceAndLoadAndScale0(int lane) { stepDithering(); return advanceAndLoadAndScale<0>(*this, lane); } + + __attribute__((always_inline)) inline uint8_t loadAndScale0() { return loadAndScale<0>(*this); } + __attribute__((always_inline)) inline uint8_t loadAndScale1() { return loadAndScale<1>(*this); } + __attribute__((always_inline)) inline uint8_t loadAndScale2() { return loadAndScale<2>(*this); } + __attribute__((always_inline)) inline uint8_t advanceAndLoadAndScale0() { return advanceAndLoadAndScale<0>(*this); } + __attribute__((always_inline)) inline uint8_t stepAdvanceAndLoadAndScale0() { stepDithering(); return advanceAndLoadAndScale<0>(*this); } + + __attribute__((always_inline)) inline uint8_t getScale0() { return getscale<0>(*this); } + __attribute__((always_inline)) inline uint8_t getScale1() { return getscale<1>(*this); } + __attribute__((always_inline)) inline uint8_t getScale2() { return getscale<2>(*this); } +}; + +template class CPixelLEDController : public CLEDController { +protected: + virtual void showPixels(PixelController & pixels) = 0; + + /// set all the leds on the controller to a given color + ///@param data the crgb color to set the leds to + ///@param nLeds the numner of leds to set to this color + ///@param scale the rgb scaling value for outputting color + virtual void showColor(const struct CRGB & data, int nLeds, CRGB scale) { + PixelController pixels(data, nLeds, scale, getDither()); + showPixels(pixels); + } + +/// write the passed in rgb data out to the leds managed by this controller +///@param data the rgb data to write out to the strip +///@param nLeds the number of leds being written out +///@param scale the rgb scaling to apply to each led before writing it out + virtual void show(const struct CRGB *data, int nLeds, CRGB scale) { + PixelController pixels(data, nLeds, scale, getDither()); + showPixels(pixels); + } + +public: + CPixelLEDController() : CLEDController() {} +}; + + +FASTLED_NAMESPACE_END + +#endif diff --git a/libraries/FastLED/cpp_compat.h b/libraries/FastLED/cpp_compat.h new file mode 100644 index 0000000..ab5b773 --- /dev/null +++ b/libraries/FastLED/cpp_compat.h @@ -0,0 +1,16 @@ +#ifndef __INC_CPP_COMPAT_H +#define __INC_CPP_COMPAT_H + +#include "FastLED.h" + +#if __cplusplus <= 199711L + +#define static_assert(expression, message) +#define constexpr const + +#else + +// things that we can turn on if we're in a C++11 environment +#endif + +#endif diff --git a/libraries/FastLED/dmx.h b/libraries/FastLED/dmx.h new file mode 100644 index 0000000..04cb5de --- /dev/null +++ b/libraries/FastLED/dmx.h @@ -0,0 +1,65 @@ +#ifndef __INC_DMX_H +#define __INC_DMX_H + +#include "FastLED.h" + +#ifdef DmxSimple_h +#include +#define HAS_DMX_SIMPLE + +///@ingroup chipsets +///@{ +FASTLED_NAMESPACE_BEGIN + +// note - dmx simple must be included before FastSPI for this code to be enabled +template class DMXSimpleController : public CPixelLEDController { +public: + // initialize the LED controller + virtual void init() { DmxSimple.usePin(DATA_PIN); } + +protected: + virtual void showPixels(PixelController & pixels) { + int iChannel = 1; + while(pixels.has(1)) { + DmxSimple.write(iChannel++, pixels.loadAndScale0()); + DmxSimple.write(iChannel++, pixels.loadAndScale1()); + DmxSimple.write(iChannel++, pixels.loadAndScale2()); + pixels.advanceData(); + pixels.stepDithering(); + } + } +}; + +FASTLED_NAMESPACE_END + +#endif + +#ifdef DmxSerial_h +#include + +FASTLED_NAMESPACE_BEGIN + +template class DMXSerialController : public CPixelLEDController { +public: + // initialize the LED controller + virtual void init() { DMXSerial.init(DMXController); } + + virtual void showPixels(PixelController & pixels) { + int iChannel = 1; + while(pixels.has(1)) { + DMXSerial.write(iChannel++, pixels.loadAndScale0()); + DMXSerial.write(iChannel++, pixels.loadAndScale1()); + DMXSerial.write(iChannel++, pixels.loadAndScale2()); + pixels.advanceData(); + pixels.stepDithering(); + } + } +}; + +FASTLED_NAMESPACE_END +///@} + +#define HAS_DMX_SERIAL +#endif + +#endif diff --git a/libraries/FastLED/docs/Doxyfile b/libraries/FastLED/docs/Doxyfile new file mode 100644 index 0000000..eb30023 --- /dev/null +++ b/libraries/FastLED/docs/Doxyfile @@ -0,0 +1,2331 @@ +# Doxyfile 1.8.8 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "FastLED" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = 3.1 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is included in +# the documentation. The maximum height of the logo should not exceed 55 pixels +# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo +# to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a +# new page for each member. If set to NO, the documentation of a member will be +# part of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by by putting a % sign in front of the word +# or globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO these classes will be included in the various overviews. This option has +# no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = YES + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the +# todo list. This list is created by putting \todo commands in the +# documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the +# test list. This list is created by putting \test commands in the +# documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES the list +# will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO doxygen will only warn about wrong or incomplete parameter +# documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. +# Note: If this tag is empty the current directory is searched. + +INPUT = . lib8tion + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank the +# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, +# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, +# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, +# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, +# *.qsf, *.as and *.js. + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = M0-clocklessnotes.md TODO.md + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER ) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES, then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html/docs/3.1 + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefor more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra stylesheet files is of importance (e.g. the last +# stylesheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the stylesheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = YES + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler ( hhc.exe). If non-empty +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated ( +# YES) or that it should be included in the master .chm file ( NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated ( +# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: . +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using prerendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /