├── libraries └── FastLED-3.2.9 │ ├── fastspi_dma.h │ ├── component.mk │ ├── extras │ ├── RainbowDemo.bin.zip │ ├── AppleII.s65 │ └── RainbowDemo.s65 │ ├── platforms │ ├── esp │ │ ├── 32 │ │ │ ├── fastled_esp32.h │ │ │ ├── led_sysdefs_esp32.h │ │ │ └── fastpin_esp32.h │ │ └── 8266 │ │ │ ├── fastled_esp8266.h │ │ │ ├── led_sysdefs_esp8266.h │ │ │ ├── clockless_esp8266.h │ │ │ └── fastpin_esp8266.h │ ├── arm │ │ ├── d51 │ │ │ ├── README.txt │ │ │ ├── fastled_arm_d51.h │ │ │ ├── led_sysdefs_arm_d51.h │ │ │ └── clockless_arm_d51.h │ │ ├── d21 │ │ │ ├── fastled_arm_d21.h │ │ │ ├── led_sysdefs_arm_d21.h │ │ │ └── clockless_arm_d21.h │ │ ├── nrf51 │ │ │ ├── fastled_arm_nrf51.h │ │ │ ├── led_sysdefs_arm_nrf51.h │ │ │ └── clockless_arm_nrf51.h │ │ ├── stm32 │ │ │ ├── fastled_arm_stm32.h │ │ │ ├── led_sysdefs_arm_stm32.h │ │ │ ├── cm3_regs.h │ │ │ └── clockless_arm_stm32.h │ │ ├── sam │ │ │ ├── fastled_arm_sam.h │ │ │ ├── led_sysdefs_arm_sam.h │ │ │ └── clockless_arm_sam.h │ │ ├── kl26 │ │ │ ├── fastled_arm_kl26.h │ │ │ ├── led_sysdefs_arm_kl26.h │ │ │ ├── clockless_arm_kl26.h │ │ │ └── fastpin_arm_kl26.h │ │ ├── nrf52 │ │ │ ├── fastled_arm_nrf52.h │ │ │ ├── led_sysdefs_arm_nrf52.h │ │ │ └── arbiter_nrf52.h │ │ ├── k20 │ │ │ ├── fastled_arm_k20.h │ │ │ ├── led_sysdefs_arm_k20.h │ │ │ ├── ws2812serial_controller.h │ │ │ ├── smartmatrix_t3.h │ │ │ ├── octows2811_controller.h │ │ │ └── clockless_arm_k20.h │ │ └── k66 │ │ │ ├── fastled_arm_k66.h │ │ │ ├── led_sysdefs_arm_k66.h │ │ │ └── clockless_arm_k66.h │ └── avr │ │ ├── fastled_avr.h │ │ └── led_sysdefs_avr.h │ ├── docs │ └── mainpage.dox │ ├── cpp_compat.h │ ├── library.properties │ ├── examples │ ├── RGBSetDemo │ │ └── RGBSetDemo.ino │ ├── Multiple │ │ ├── OctoWS2811Demo │ │ │ └── OctoWS2811Demo.ino │ │ ├── MultipleStripsInOneArray │ │ │ └── MultipleStripsInOneArray.ino │ │ ├── ArrayOfLedArrays │ │ │ └── ArrayOfLedArrays.ino │ │ ├── MirroringSample │ │ │ └── MirroringSample.ino │ │ ├── ParallelOutputDemo │ │ │ └── ParallelOutputDemo.ino │ │ └── MultiArrays │ │ │ └── MultiArrays.ino │ ├── Cylon │ │ └── Cylon.ino │ ├── AnalogOutput │ │ └── AnalogOutput.ino │ ├── NoisePlayground │ │ └── NoisePlayground.ino │ ├── Blink │ │ └── Blink.ino │ ├── Pintest │ │ └── Pintest.ino │ ├── RGBCalibrate │ │ └── RGBCalibrate.ino │ ├── ColorTemperature │ │ └── ColorTemperature.ino │ ├── FirstLight │ │ └── FirstLight.ino │ ├── Noise │ │ └── Noise.ino │ ├── Fire2012 │ │ └── Fire2012.ino │ ├── DemoReel100 │ │ └── DemoReel100.ino │ ├── SmartMatrix │ │ └── SmartMatrix.ino │ └── Ports │ │ └── PJRCSpectrumAnalyzer │ │ └── PJRCSpectrumAnalyzer.ino │ ├── preview_changes.txt │ ├── bitswap.cpp │ ├── LICENSE │ ├── library.json │ ├── platforms.h │ ├── platforms.cpp │ ├── fastspi_types.h │ ├── dmx.h │ ├── led_sysdefs.h │ ├── colorpalettes.h │ ├── PORTING.md │ ├── fastspi_nop.h │ ├── fastled_progmem.h │ ├── lib8tion │ └── random8.h │ ├── color.h │ ├── fastspi_ref.h │ ├── fastled_config.h │ ├── hsv2rgb.h │ ├── power_mgt.h │ ├── noise.h │ ├── colorpalettes.cpp │ ├── fastled_delay.h │ └── fastspi.h ├── README.md ├── .gitattributes ├── schemes └── scheme.jpg ├── firmware ├── HyperGyverSound_v1.0 │ └── sound.ino ├── HyperGyverSound_v1.1 │ └── sound.ino ├── HyperGyver │ └── HyperGyver.ino └── HyperGyver_v1.1 │ └── HyperGyver_v1.1.ino └── LICENSE /libraries/FastLED-3.2.9/fastspi_dma.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HyperGyver 2 | Гиперкуб на Ардуино 3 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := . 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /schemes/scheme.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexGyver/HyperGyver/HEAD/schemes/scheme.jpg -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/extras/RainbowDemo.bin.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexGyver/HyperGyver/HEAD/libraries/FastLED-3.2.9/extras/RainbowDemo.bin.zip -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/esp/8266/fastled_esp8266.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fastpin_esp8266.h" 4 | #include "clockless_esp8266.h" 5 | #include "clockless_block_esp8266.h" 6 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/d51/README.txt: -------------------------------------------------------------------------------- 1 | FastLED updates for adafruit FEATHER M4 and fixes to ITSBITSY M4 compiles 2 | SAMD51 3 | 4 | only tested on FEATHER M4 with DOTSTAR and neopixel strips 5 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/d21/fastled_arm_d21.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_D21_H 2 | #define __INC_FASTLED_ARM_D21_H 3 | 4 | #include "fastpin_arm_d21.h" 5 | #include "clockless_arm_d21.h" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/d51/fastled_arm_d51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_D51_H 2 | #define __INC_FASTLED_ARM_D51_H 3 | 4 | #include "fastpin_arm_d51.h" 5 | #include "clockless_arm_d51.h" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/docs/mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @brief Documentation file for FastLED 3 | @author dgarcia at fastled dot io 4 | @file 5 | */ 6 | /** @defgroup FastLED Sources */ 7 | /** 8 | @mainpage FastLED - let there be light! 9 | */ 10 | EOF 11 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/esp/32/fastled_esp32.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fastpin_esp32.h" 4 | 5 | #ifdef FASTLED_ESP32_I2S 6 | #include "clockless_i2s_esp32.h" 7 | #else 8 | #include "clockless_rmt_esp32.h" 9 | #endif 10 | 11 | // #include "clockless_block_esp32.h" 12 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/nrf51/fastled_arm_nrf51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_NRF51_H 2 | #define __INC_FASTLED_ARM_NRF51_H 3 | 4 | // Include the k20 headers 5 | #include "fastpin_arm_nrf51.h" 6 | #include "fastspi_arm_nrf51.h" 7 | #include "clockless_arm_nrf51.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/stm32/fastled_arm_stm32.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_SAM_H 2 | #define __INC_FASTLED_ARM_SAM_H 3 | 4 | // Include the sam headers 5 | #include "fastpin_arm_stm32.h" 6 | // #include "fastspi_arm_stm32.h" 7 | #include "clockless_arm_stm32.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/sam/fastled_arm_sam.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_SAM_H 2 | #define __INC_FASTLED_ARM_SAM_H 3 | 4 | // Include the sam headers 5 | #include "fastpin_arm_sam.h" 6 | #include "fastspi_arm_sam.h" 7 | #include "clockless_arm_sam.h" 8 | #include "clockless_block_arm_sam.h" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/kl26/fastled_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_KL26_H 2 | #define __INC_FASTLED_ARM_KL26_H 3 | 4 | // Include the k20 headers 5 | #include "fastpin_arm_kl26.h" 6 | #include "fastspi_arm_kl26.h" 7 | #include "clockless_arm_kl26.h" 8 | #include "../k20/ws2812serial_controller.h" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/avr/fastled_avr.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_AVR_H 2 | #define __INC_FASTLED_AVR_H 3 | 4 | #include "fastpin_avr.h" 5 | #include "fastspi_avr.h" 6 | #include "clockless_trinket.h" 7 | 8 | // Default to using PROGMEM 9 | #ifndef FASTLED_USE_PROGMEM 10 | #define FASTLED_USE_PROGMEM 1 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/cpp_compat.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CPP_COMPAT_H 2 | #define __INC_CPP_COMPAT_H 3 | 4 | #include "FastLED.h" 5 | 6 | #if __cplusplus <= 199711L 7 | 8 | #define static_assert(expression, message) 9 | #define constexpr const 10 | 11 | #else 12 | 13 | // things that we can turn on if we're in a C++11 environment 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/nrf52/fastled_arm_nrf52.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_NRF52_H 2 | #define __INC_FASTLED_ARM_NRF52_H 3 | 4 | #include "led_sysdefs_arm_nrf52.h" 5 | #include "arbiter_nrf52.h" 6 | #include "fastpin_arm_nrf52.h" 7 | #include "fastspi_arm_nrf52.h" 8 | #include "clockless_arm_nrf52.h" 9 | 10 | #endif // #ifndef __INC_FASTLED_ARM_NRF52_H 11 | 12 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k20/fastled_arm_k20.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_K20_H 2 | #define __INC_FASTLED_ARM_K20_H 3 | 4 | // Include the k20 headers 5 | #include "fastpin_arm_k20.h" 6 | #include "fastspi_arm_k20.h" 7 | #include "octows2811_controller.h" 8 | #include "ws2812serial_controller.h" 9 | #include "smartmatrix_t3.h" 10 | #include "clockless_arm_k20.h" 11 | #include "clockless_block_arm_k20.h" 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k66/fastled_arm_k66.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_K66_H 2 | #define __INC_FASTLED_ARM_K66_H 3 | 4 | // Include the k66 headers 5 | #include "fastpin_arm_k66.h" 6 | #include "fastspi_arm_k66.h" 7 | #include "../k20/octows2811_controller.h" 8 | #include "../k20/ws2812serial_controller.h" 9 | #include "../k20/smartmatrix_t3.h" 10 | #include "clockless_arm_k66.h" 11 | #include "clockless_block_arm_k66.h" 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/library.properties: -------------------------------------------------------------------------------- 1 | name=FastLED 2 | version=3.2.9 3 | author=Daniel Garcia 4 | maintainer=Daniel Garcia 5 | sentence=Multi-platform library for controlling dozens of different types of LEDs along with optimized math, effect, and noise functions. 6 | paragraph=Multi-platform library for controlling dozens of different types of LEDs along with optimized math, effect, and noise functions. 7 | category=Display 8 | url=https://github.com/FastLED/FastLED 9 | architectures=* 10 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/RGBSetDemo/RGBSetDemo.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #define NUM_LEDS 40 3 | 4 | CRGBArray leds; 5 | 6 | void setup() { FastLED.addLeds(leds, NUM_LEDS); } 7 | 8 | void loop(){ 9 | static uint8_t hue; 10 | for(int i = 0; i < NUM_LEDS/2; i++) { 11 | // fade everything out 12 | leds.fadeToBlackBy(40); 13 | 14 | // let's set an led value 15 | leds[i] = CHSV(hue++,255,255); 16 | 17 | // now, let's first 20 leds to the top 20 leds, 18 | leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0); 19 | FastLED.delay(33); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/d21/led_sysdefs_arm_d21.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_D21_H 2 | #define __INC_LED_SYSDEFS_ARM_D21_H 3 | 4 | 5 | #define FASTLED_ARM 6 | #define FASTLED_ARM_M0_PLUS 7 | 8 | #ifndef INTERRUPT_THRESHOLD 9 | #define INTERRUPT_THRESHOLD 1 10 | #endif 11 | 12 | // Default to allowing interrupts 13 | #ifndef FASTLED_ALLOW_INTERRUPTS 14 | #define FASTLED_ALLOW_INTERRUPTS 1 15 | #endif 16 | 17 | #if FASTLED_ALLOW_INTERRUPTS == 1 18 | #define FASTLED_ACCURATE_CLOCK 19 | #endif 20 | 21 | // reusing/abusing cli/sei defs for due 22 | #define cli() __disable_irq(); 23 | #define sei() __enable_irq(); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/d51/led_sysdefs_arm_d51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_D51_H 2 | #define __INC_LED_SYSDEFS_ARM_D51_H 3 | 4 | 5 | #define FASTLED_ARM 6 | // Note this is an M4, not an M0+, but this enables the shared m0clockless.h 7 | #define FASTLED_ARM_M0_PLUS 8 | 9 | #ifndef INTERRUPT_THRESHOLD 10 | #define INTERRUPT_THRESHOLD 1 11 | #endif 12 | 13 | // Default to allowing interrupts 14 | #ifndef FASTLED_ALLOW_INTERRUPTS 15 | #define FASTLED_ALLOW_INTERRUPTS 0 16 | #endif 17 | 18 | #if FASTLED_ALLOW_INTERRUPTS == 1 19 | #define FASTLED_ACCURATE_CLOCK 20 | #endif 21 | 22 | // reusing/abusing cli/sei defs for due 23 | #define cli() __disable_irq(); 24 | #define sei() __enable_irq(); 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/esp/32/led_sysdefs_esp32.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ESP32 4 | #define ESP32 5 | #endif 6 | 7 | #define FASTLED_ESP32 8 | 9 | // Use system millis timer 10 | #define FASTLED_HAS_MILLIS 11 | 12 | typedef volatile uint32_t RoReg; 13 | typedef volatile uint32_t RwReg; 14 | typedef unsigned long prog_uint32_t; 15 | 16 | 17 | // Default to NOT using PROGMEM here 18 | #ifndef FASTLED_USE_PROGMEM 19 | # define FASTLED_USE_PROGMEM 0 20 | #endif 21 | 22 | #ifndef FASTLED_ALLOW_INTERRUPTS 23 | # define FASTLED_ALLOW_INTERRUPTS 1 24 | # define INTERRUPT_THRESHOLD 0 25 | #endif 26 | 27 | #define NEED_CXX_BITS 28 | 29 | // These can be overridden 30 | # define FASTLED_ESP32_RAW_PIN_ORDER 31 | 32 | // #define cli() os_intr_lock(); 33 | // #define sei() os_intr_lock(); 34 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/extras/AppleII.s65: -------------------------------------------------------------------------------- 1 | KBD = $C000 ;Read keydown 2 | KBDSTRB = $C010 ;Reset keybd 3 | 4 | SPKR = $C030 ;Toggle speaker 5 | 6 | ; TTL digital output pins on 7 | ; 16-pin DIP game connector 8 | SETAN0 = $C058 9 | CLRAN0 = $C059 10 | SETAN1 = $C05A 11 | CLRAN1 = $C05B 12 | SETAN2 = $C05C 13 | CLRAN2 = $C05D 14 | SETAN3 = $C05E 15 | CLRAN3 = $C05F 16 | 17 | PIN12ON = CLRAN3 18 | PIN12OFF= SETAN3 19 | PIN13ON = CLRAN2 20 | PIN13OFF= SETAN2 21 | PIN14ON = CLRAN1 22 | PIN14OFF= SETAN1 23 | PIN15ON = CLRAN0 24 | PIN15OFF= SETAN0 25 | 26 | ;Special for pin 5, except on //gs 27 | C040STROBE = $C040 28 | PIN5STROBE = C040STROBE 29 | 30 | SolidApple = $C062 ; read SW1 or SA 31 | OpenApple = $C061 ; read SW0 or OA 32 | 33 | VBL = $C019 ; vertical blanking 34 | 35 | WAIT = $FCA8 ; wait a little while 36 | 37 | CROUT = $FD8E ; print a CR 38 | PRBYTE = $FDDA ; print a hex byte 39 | 40 | 41 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/preview_changes.txt: -------------------------------------------------------------------------------- 1 | FastLED 3.1 preview changes: 2 | * UART in SPI mode support on AVR 3 | * Support for using both hardware SPI pinsets on the Teensy 3.x - 11/13 and 7/14. 4 | * Added UCS1904 support 5 | * Better AVR cycle counting 6 | * Split WS2812/WS2811 timings 7 | * Added DOTSTAR definition for adafruit dotstar pixels (aka APA102) 8 | * 8-way parallel output on teensy 3, 3.1 (portc,portd), due/digix (porta, portb, portd) 9 | * 12-way parallel output on teensy 3, 3.1 (portc) 10 | * 16-way parallel output on teensy 3, 3.1 (portc & portd paired) 11 | * refresh rate limiting 12 | * interrupt friendly code on teensy 3/3.1 13 | * -interrupt friendly code on AVR- <-- disabled for now 14 | * interrupt friendly code on the due 15 | * code re-org for future wider platform support 16 | * Spark Core support 17 | * arduino zero support (no hardware spi yet) 18 | * greatly improved clockless output for avr 19 | * greatly improved clockless output for arm m0 boards 20 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Multiple/OctoWS2811Demo/OctoWS2811Demo.ino: -------------------------------------------------------------------------------- 1 | #define USE_OCTOWS2811 2 | #include 3 | #include 4 | 5 | #define NUM_LEDS_PER_STRIP 64 6 | #define NUM_STRIPS 8 7 | 8 | CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP]; 9 | 10 | // Pin layouts on the teensy 3: 11 | // OctoWS2811: 2,14,7,8,6,20,21,5 12 | 13 | void setup() { 14 | LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); 15 | LEDS.setBrightness(32); 16 | } 17 | 18 | void loop() { 19 | static uint8_t hue = 0; 20 | for(int i = 0; i < NUM_STRIPS; i++) { 21 | for(int j = 0; j < NUM_LEDS_PER_STRIP; j++) { 22 | leds[(i*NUM_LEDS_PER_STRIP) + j] = CHSV((32*i) + hue+j,192,255); 23 | } 24 | } 25 | 26 | // Set the first n leds on each strip to show which strip it is 27 | for(int i = 0; i < NUM_STRIPS; i++) { 28 | for(int j = 0; j <= i; j++) { 29 | leds[(i*NUM_LEDS_PER_STRIP) + j] = CRGB::Red; 30 | } 31 | } 32 | 33 | hue++; 34 | 35 | LEDS.show(); 36 | LEDS.delay(10); 37 | } 38 | -------------------------------------------------------------------------------- /firmware/HyperGyverSound_v1.0/sound.ino: -------------------------------------------------------------------------------- 1 | int getSoundLength() { 2 | int thisMax = 0; 3 | int thisSignal = 0; 4 | for (int i = 0; i < 300; i++) { 5 | thisSignal = analogRead(ADC_PIN); 6 | if (thisSignal > thisMax) thisMax = thisSignal; 7 | } 8 | 9 | static float filMax = 1000, filMin = 1000; 10 | static float filLength; 11 | static int maxMax = 0, minMin = 1023; 12 | static byte counter; 13 | 14 | counter++; 15 | if (counter == 50) { 16 | counter = 0; 17 | maxMax = 0; 18 | minMin = 1023; 19 | } 20 | if (thisMax > maxMax) maxMax = thisMax; 21 | if (thisMax < minMin) minMin = thisMax; 22 | 23 | filMax += (float)(maxMax - filMax) * 0.01; 24 | filMin += (float)(minMin - filMin) * 0.01; 25 | 26 | int thisLenght = map(thisMax - filMin, VOL_THR, filMax - filMin, 0, 100); 27 | thisLenght = constrain(thisLenght, 0, 100); 28 | 29 | filLength += (float)(thisLenght - filLength) * 0.2; 30 | if (thisMax > filMax) filLength = 100; 31 | 32 | if (filMax - filMin > VOL_THR) return filLength; 33 | else return 0; 34 | } 35 | -------------------------------------------------------------------------------- /firmware/HyperGyverSound_v1.1/sound.ino: -------------------------------------------------------------------------------- 1 | int getSoundLength() { 2 | int thisMax = 0; 3 | int thisSignal = 0; 4 | for (int i = 0; i < 300; i++) { 5 | thisSignal = analogRead(ADC_PIN); 6 | if (thisSignal > thisMax) thisMax = thisSignal; 7 | } 8 | 9 | static float filMax = 1000, filMin = 1000; 10 | static float filLength; 11 | static int maxMax = 0, minMin = 1023; 12 | static byte counter; 13 | 14 | counter++; 15 | if (counter == 50) { 16 | counter = 0; 17 | maxMax = 0; 18 | minMin = 1023; 19 | } 20 | if (thisMax > maxMax) maxMax = thisMax; 21 | if (thisMax < minMin) minMin = thisMax; 22 | 23 | filMax += (float)(maxMax - filMax) * 0.01; 24 | filMin += (float)(minMin - filMin) * 0.01; 25 | 26 | int thisLenght = map(thisMax - filMin, VOL_THR, filMax - filMin, 0, 100); 27 | thisLenght = constrain(thisLenght, 0, 100); 28 | 29 | filLength += (float)(thisLenght - filLength) * 0.2; 30 | if (thisMax > filMax) filLength = 100; 31 | 32 | if (filMax - filMin > VOL_THR) return filLength; 33 | else return 0; 34 | } 35 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/nrf51/led_sysdefs_arm_nrf51.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_SYSDEFS_ARM_NRF51 2 | #define __LED_SYSDEFS_ARM_NRF51 3 | 4 | #ifndef NRF51 5 | #define NRF51 6 | #endif 7 | 8 | #define LED_TIMER NRF_TIMER1 9 | #define FASTLED_NO_PINMAP 10 | #define FASTLED_HAS_CLOCKLESS 11 | 12 | #define FASTLED_SPI_BYTE_ONLY 13 | 14 | #define FASTLED_ARM 15 | #define FASTLED_ARM_M0 16 | 17 | #ifndef F_CPU 18 | #define F_CPU 16000000 19 | #endif 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | typedef volatile uint32_t RoReg; 26 | typedef volatile uint32_t RwReg; 27 | typedef uint32_t prog_uint32_t; 28 | typedef uint8_t boolean; 29 | 30 | #define PROGMEM 31 | #define NO_PROGMEM 32 | #define NEED_CXX_BITS 33 | 34 | // Default to NOT using PROGMEM here 35 | #ifndef FASTLED_USE_PROGMEM 36 | #define FASTLED_USE_PROGMEM 0 37 | #endif 38 | 39 | #ifndef FASTLED_ALLOW_INTERRUPTS 40 | #define FASTLED_ALLOW_INTERRUPTS 1 41 | #endif 42 | 43 | #define cli() __disable_irq(); 44 | #define sei() __enable_irq(); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/esp/8266/led_sysdefs_esp8266.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ESP8266 4 | #define ESP8266 5 | #endif 6 | 7 | #define FASTLED_ESP8266 8 | 9 | // Use system millis timer 10 | #define FASTLED_HAS_MILLIS 11 | 12 | typedef volatile uint32_t RoReg; 13 | typedef volatile uint32_t RwReg; 14 | typedef uint32_t prog_uint32_t; 15 | 16 | 17 | // Default to NOT using PROGMEM here 18 | #ifndef FASTLED_USE_PROGMEM 19 | # define FASTLED_USE_PROGMEM 0 20 | #endif 21 | 22 | #ifndef FASTLED_ALLOW_INTERRUPTS 23 | # define FASTLED_ALLOW_INTERRUPTS 1 24 | # define INTERRUPT_THRESHOLD 0 25 | #endif 26 | 27 | #define NEED_CXX_BITS 28 | 29 | // These can be overridden 30 | #if !defined(FASTLED_ESP8266_RAW_PIN_ORDER) && !defined(FASTLED_ESP8266_NODEMCU_PIN_ORDER) && !defined(FASTLED_ESP8266_D1_PIN_ORDER) 31 | # ifdef ARDUINO_ESP8266_NODEMCU 32 | # define FASTLED_ESP8266_NODEMCU_PIN_ORDER 33 | # else 34 | # define FASTLED_ESP8266_RAW_PIN_ORDER 35 | # endif 36 | #endif 37 | 38 | // #define cli() os_intr_lock(); 39 | // #define sei() os_intr_lock(); 40 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/bitswap.cpp: -------------------------------------------------------------------------------- 1 | #define FASTLED_INTERNAL 2 | #include "FastLED.h" 3 | 4 | /// Simplified form of bits rotating function. Based on code found here - http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt - rotating 5 | /// data into LSB for a faster write (the code using this data can happily walk the array backwards) 6 | void transpose8x1_noinline(unsigned char *A, unsigned char *B) { 7 | uint32_t x, y, t; 8 | 9 | // Load the array and pack it into x and y. 10 | y = *(unsigned int*)(A); 11 | x = *(unsigned int*)(A+4); 12 | 13 | // pre-transform x 14 | t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7); 15 | t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14); 16 | 17 | // pre-transform y 18 | t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7); 19 | t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14); 20 | 21 | // final transform 22 | t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F); 23 | y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F); 24 | x = t; 25 | 26 | *((uint32_t*)B) = y; 27 | *((uint32_t*)(B+4)) = x; 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 AlexGyver 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 FastLED 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/sam/led_sysdefs_arm_sam.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_SAM_H 2 | #define __INC_LED_SYSDEFS_ARM_SAM_H 3 | 4 | 5 | #define FASTLED_ARM 6 | 7 | // Setup DUE timer defines/channels/etc... 8 | #ifndef DUE_TIMER_CHANNEL 9 | #define DUE_TIMER_GROUP 0 10 | #endif 11 | 12 | #ifndef DUE_TIMER_CHANNEL 13 | #define DUE_TIMER_CHANNEL 0 14 | #endif 15 | 16 | #define DUE_TIMER ((DUE_TIMER_GROUP==0) ? TC0 : ((DUE_TIMER_GROUP==1) ? TC1 : TC2)) 17 | #define DUE_TIMER_ID (ID_TC0 + (DUE_TIMER_GROUP*3) + DUE_TIMER_CHANNEL) 18 | #define DUE_TIMER_VAL (DUE_TIMER->TC_CHANNEL[DUE_TIMER_CHANNEL].TC_CV << 1) 19 | #define DUE_TIMER_RUNNING ((DUE_TIMER->TC_CHANNEL[DUE_TIMER_CHANNEL].TC_SR & TC_SR_CLKSTA) != 0) 20 | 21 | #ifndef INTERRUPT_THRESHOLD 22 | #define INTERRUPT_THRESHOLD 1 23 | #endif 24 | 25 | // Default to allowing interrupts 26 | #ifndef FASTLED_ALLOW_INTERRUPTS 27 | #define FASTLED_ALLOW_INTERRUPTS 1 28 | #endif 29 | 30 | #if FASTLED_ALLOW_INTERRUPTS == 1 31 | #define FASTLED_ACCURATE_CLOCK 32 | #endif 33 | 34 | // reusing/abusing cli/sei defs for due 35 | #define cli() __disable_irq(); __disable_fault_irq(); 36 | #define sei() __enable_irq(); __enable_fault_irq(); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k20/led_sysdefs_arm_k20.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_K20_H 2 | #define __INC_LED_SYSDEFS_ARM_K20_H 3 | 4 | #define FASTLED_TEENSY3 5 | #define FASTLED_ARM 6 | 7 | #ifndef INTERRUPT_THRESHOLD 8 | #define INTERRUPT_THRESHOLD 1 9 | #endif 10 | 11 | // Default to allowing interrupts 12 | #ifndef FASTLED_ALLOW_INTERRUPTS 13 | #define FASTLED_ALLOW_INTERRUPTS 1 14 | #endif 15 | 16 | #if FASTLED_ALLOW_INTERRUPTS == 1 17 | #define FASTLED_ACCURATE_CLOCK 18 | #endif 19 | 20 | #if (F_CPU == 96000000) 21 | #define CLK_DBL 1 22 | #endif 23 | 24 | // Get some system include files 25 | #include 26 | #include // for cli/se definitions 27 | 28 | // Define the register types 29 | #if defined(ARDUINO) // && ARDUINO < 150 30 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 31 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 32 | #endif 33 | 34 | extern volatile uint32_t systick_millis_count; 35 | # define MS_COUNTER systick_millis_count 36 | 37 | 38 | // Default to using PROGMEM, since TEENSY3 provides it 39 | // even though all it does is ignore it. Just being 40 | // conservative here in case TEENSY3 changes. 41 | #ifndef FASTLED_USE_PROGMEM 42 | #define FASTLED_USE_PROGMEM 1 43 | #endif 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k66/led_sysdefs_arm_k66.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_K66_H 2 | #define __INC_LED_SYSDEFS_ARM_K66_H 3 | 4 | #define FASTLED_TEENSY3 5 | #define FASTLED_ARM 6 | 7 | #ifndef INTERRUPT_THRESHOLD 8 | #define INTERRUPT_THRESHOLD 1 9 | #endif 10 | 11 | // Default to allowing interrupts 12 | #ifndef FASTLED_ALLOW_INTERRUPTS 13 | #define FASTLED_ALLOW_INTERRUPTS 1 14 | #endif 15 | 16 | #if FASTLED_ALLOW_INTERRUPTS == 1 17 | #define FASTLED_ACCURATE_CLOCK 18 | #endif 19 | 20 | #if (F_CPU == 192000000) 21 | #define CLK_DBL 1 22 | #endif 23 | 24 | // Get some system include files 25 | #include 26 | #include // for cli/se definitions 27 | 28 | // Define the register types 29 | #if defined(ARDUINO) // && ARDUINO < 150 30 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 31 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 32 | #endif 33 | 34 | extern volatile uint32_t systick_millis_count; 35 | # define MS_COUNTER systick_millis_count 36 | 37 | 38 | // Default to using PROGMEM, since TEENSY3 provides it 39 | // even though all it does is ignore it. Just being 40 | // conservative here in case TEENSY3 changes. 41 | #ifndef FASTLED_USE_PROGMEM 42 | #define FASTLED_USE_PROGMEM 1 43 | #endif 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FastLED", 3 | "description": "FastLED is a library for programming addressable rgb led strips (APA102/Dotstar, WS2812/Neopixel, LPD8806, and a dozen others) acting both as a driver and as a library for color management and fast math.", 4 | "keywords": "led,noise,rgb,math,fast", 5 | "authors": [ 6 | { 7 | "name": "Daniel Garcia", 8 | "url": "https://github.com/focalintent", 9 | "maintainer": true 10 | }, 11 | { 12 | "name": "Mark Kriegsman", 13 | "url": "https://github.com/kriegsman", 14 | "maintainer": true 15 | } 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/FastLED/FastLED.git" 20 | }, 21 | "version": "3.2.9", 22 | "license": "MIT", 23 | "homepage": "http://fastled.io", 24 | "frameworks": "arduino", 25 | "platforms": "atmelavr, atmelsam, freescalekinetis, nordicnrf51, nxplpc, ststm32, teensy, espressif8266, espressif32, nordicnrf52", 26 | "export": { 27 | "exclude": [ 28 | "docs", 29 | "extras" 30 | ] 31 | }, 32 | "build": { 33 | "srcFilter": [ 34 | "+<*.c>", 35 | "+<*.cpp>", 36 | "+<*.h>" 37 | ], 38 | "libArchive": false 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k20/ws2812serial_controller.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_WS2812SERIAL_CONTROLLER_H 2 | #define __INC_WS2812SERIAL_CONTROLLER_H 3 | 4 | #ifdef USE_WS2812SERIAL 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | template 9 | class CWS2812SerialController : public CPixelLEDController { 10 | WS2812Serial *pserial; 11 | uint8_t *drawbuffer,*framebuffer; 12 | 13 | void _init(int nLeds) { 14 | if (pserial == NULL) { 15 | drawbuffer = (uint8_t*)malloc(nLeds * 3); 16 | framebuffer = (uint8_t*)malloc(nLeds * 12); 17 | pserial = new WS2812Serial(nLeds, framebuffer, drawbuffer, DATA_PIN, WS2812_RGB); 18 | pserial->begin(); 19 | } 20 | } 21 | public: 22 | CWS2812SerialController() { pserial = NULL; } 23 | 24 | virtual void init() { /* do nothing yet */ } 25 | 26 | virtual void showPixels(PixelController & pixels) { 27 | _init(pixels.size()); 28 | 29 | uint8_t *p = drawbuffer; 30 | 31 | while(pixels.has(1)) { 32 | *p++ = pixels.loadAndScale0(); 33 | *p++ = pixels.loadAndScale1(); 34 | *p++ = pixels.loadAndScale2(); 35 | pixels.stepDithering(); 36 | pixels.advanceData(); 37 | } 38 | pserial->show(); 39 | } 40 | 41 | }; 42 | 43 | FASTLED_NAMESPACE_END 44 | 45 | #endif // USE_WS2812SERIAL 46 | #endif // __INC_WS2812SERIAL_CONTROLLER_H 47 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/kl26/led_sysdefs_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_KL26_H 2 | #define __INC_LED_SYSDEFS_ARM_KL26_H 3 | 4 | #define FASTLED_TEENSYLC 5 | #define FASTLED_ARM 6 | #define FASTLED_ARM_M0_PLUS 7 | 8 | #ifndef INTERRUPT_THRESHOLD 9 | #define INTERRUPT_THRESHOLD 1 10 | #endif 11 | 12 | #define FASTLED_SPI_BYTE_ONLY 13 | 14 | // Default to allowing interrupts 15 | #ifndef FASTLED_ALLOW_INTERRUPTS 16 | #define FASTLED_ALLOW_INTERRUPTS 1 17 | #endif 18 | 19 | #if FASTLED_ALLOW_INTERRUPTS == 1 20 | #define FASTLED_ACCURATE_CLOCK 21 | #endif 22 | 23 | #if (F_CPU == 96000000) 24 | #define CLK_DBL 1 25 | #endif 26 | 27 | // Get some system include files 28 | #include 29 | #include // for cli/se definitions 30 | 31 | // Define the register types 32 | #if defined(ARDUINO) // && ARDUINO < 150 33 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 34 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 35 | #endif 36 | 37 | extern volatile uint32_t systick_millis_count; 38 | # define MS_COUNTER systick_millis_count 39 | 40 | // Default to using PROGMEM since TEENSYLC provides it 41 | // even though all it does is ignore it. Just being 42 | // conservative here in case TEENSYLC changes. 43 | #ifndef FASTLED_USE_PROGMEM 44 | #define FASTLED_USE_PROGMEM 1 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_PLATFORMS_H 2 | #define __INC_PLATFORMS_H 3 | 4 | #include "FastLED.h" 5 | 6 | #include "fastled_config.h" 7 | 8 | #if defined(NRF51) 9 | #include "platforms/arm/nrf51/fastled_arm_nrf51.h" 10 | #elif defined(NRF52_SERIES) 11 | #include "platforms/arm/nrf52/fastled_arm_nrf52.h" 12 | #elif defined(__MK20DX128__) || defined(__MK20DX256__) 13 | // Include k20/T3 headers 14 | #include "platforms/arm/k20/fastled_arm_k20.h" 15 | #elif defined(__MK66FX1M0__) || defined(__MK64FX512__) 16 | // Include k66/T3.6 headers 17 | #include "platforms/arm/k66/fastled_arm_k66.h" 18 | #elif defined(__MKL26Z64__) 19 | // Include kl26/T-LC headers 20 | #include "platforms/arm/kl26/fastled_arm_kl26.h" 21 | #elif defined(__SAM3X8E__) 22 | // Include sam/due headers 23 | #include "platforms/arm/sam/fastled_arm_sam.h" 24 | #elif defined(STM32F10X_MD) || defined(__STM32F1__) 25 | #include "platforms/arm/stm32/fastled_arm_stm32.h" 26 | #elif defined(__SAMD21G18A__) || defined(__SAMD21J18A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) 27 | #include "platforms/arm/d21/fastled_arm_d21.h" 28 | #elif defined(__SAMD51G19A__) || defined(__SAMD51J19A__) 29 | #include "platforms/arm/d51/fastled_arm_d51.h" 30 | #elif defined(ESP8266) 31 | #include "platforms/esp/8266/fastled_esp8266.h" 32 | #elif defined(ESP32) 33 | #include "platforms/esp/32/fastled_esp32.h" 34 | #else 35 | // AVR platforms 36 | #include "platforms/avr/fastled_avr.h" 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Multiple/MultipleStripsInOneArray/MultipleStripsInOneArray.ino: -------------------------------------------------------------------------------- 1 | // MultipleStripsInOneArray - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on 2 | // using multiple controllers. In this example, we're going to set up four NEOPIXEL strips on three 3 | // different pins, each strip will be referring to a different part of the single led array 4 | 5 | #include 6 | 7 | #define NUM_STRIPS 3 8 | #define NUM_LEDS_PER_STRIP 60 9 | #define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS 10 | 11 | CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP]; 12 | 13 | // For mirroring strips, all the "special" stuff happens just in setup. We 14 | // just addLeds multiple times, once for each strip 15 | void setup() { 16 | // tell FastLED there's 60 NEOPIXEL leds on pin 10, starting at index 0 in the led array 17 | FastLED.addLeds(leds, 0, NUM_LEDS_PER_STRIP); 18 | 19 | // tell FastLED there's 60 NEOPIXEL leds on pin 11, starting at index 60 in the led array 20 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); 21 | 22 | // tell FastLED there's 60 NEOPIXEL leds on pin 12, starting at index 120 in the led array 23 | FastLED.addLeds(leds, 2 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); 24 | 25 | } 26 | 27 | void loop() { 28 | for(int i = 0; i < NUM_LEDS; i++) { 29 | leds[i] = CRGB::Red; 30 | FastLED.show(); 31 | leds[i] = CRGB::Black; 32 | delay(100); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms.cpp: -------------------------------------------------------------------------------- 1 | #define FASTLED_INTERNAL 2 | 3 | 4 | // Interrupt handlers cannot be defined in the header. 5 | // They must be defined as C functions, or they won't 6 | // be found (due to name mangling), and thus won't 7 | // override any default weak definition. 8 | #if defined(NRF52_SERIES) 9 | 10 | #include "platforms/arm/nrf52/led_sysdefs_arm_nrf52.h" 11 | #include "platforms/arm/nrf52/arbiter_nrf52.h" 12 | 13 | uint32_t isrCount; 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | // NOTE: Update platforms.cpp in root of FastLED library if this changes 19 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE0) 20 | void PWM0_IRQHandler(void) { isrCount++; PWM_Arbiter<0>::isr_handler(); } 21 | #endif 22 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE1) 23 | void PWM1_IRQHandler(void) { isrCount++; PWM_Arbiter<1>::isr_handler(); } 24 | #endif 25 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE2) 26 | void PWM2_IRQHandler(void) { isrCount++; PWM_Arbiter<2>::isr_handler(); } 27 | #endif 28 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE3) 29 | void PWM3_IRQHandler(void) { isrCount++; PWM_Arbiter<3>::isr_handler(); } 30 | #endif 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // defined(NRF52_SERIES) 36 | 37 | 38 | 39 | // FASTLED_NAMESPACE_BEGIN 40 | // FASTLED_NAMESPACE_END 41 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Multiple/ArrayOfLedArrays/ArrayOfLedArrays.ino: -------------------------------------------------------------------------------- 1 | // ArrayOfLedArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on 2 | // using multiple controllers. In this example, we're going to set up three NEOPIXEL strips on three 3 | // different pins, each strip getting its own CRGB array to be played with, only this time they're going 4 | // to be all parts of an array of arrays. 5 | 6 | #include 7 | 8 | #define NUM_STRIPS 3 9 | #define NUM_LEDS_PER_STRIP 60 10 | CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP]; 11 | 12 | // For mirroring strips, all the "special" stuff happens just in setup. We 13 | // just addLeds multiple times, once for each strip 14 | void setup() { 15 | // tell FastLED there's 60 NEOPIXEL leds on pin 10 16 | FastLED.addLeds(leds[0], NUM_LEDS_PER_STRIP); 17 | 18 | // tell FastLED there's 60 NEOPIXEL leds on pin 11 19 | FastLED.addLeds(leds[1], NUM_LEDS_PER_STRIP); 20 | 21 | // tell FastLED there's 60 NEOPIXEL leds on pin 12 22 | FastLED.addLeds(leds[2], NUM_LEDS_PER_STRIP); 23 | 24 | } 25 | 26 | void loop() { 27 | // This outer loop will go over each strip, one at a time 28 | for(int x = 0; x < NUM_STRIPS; x++) { 29 | // This inner loop will go over each led in the current strip, one at a time 30 | for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) { 31 | leds[x][i] = CRGB::Red; 32 | FastLED.show(); 33 | leds[x][i] = CRGB::Black; 34 | delay(100); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k20/smartmatrix_t3.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_SMARTMATRIX_T3_H 2 | #define __INC_SMARTMATRIX_T3_H 3 | 4 | #ifdef SmartMatrix_h 5 | #include 6 | 7 | FASTLED_NAMESPACE_BEGIN 8 | 9 | extern SmartMatrix *pSmartMatrix; 10 | 11 | // note - dmx simple must be included before FastSPI for this code to be enabled 12 | class CSmartMatrixController : public CPixelLEDController { 13 | SmartMatrix matrix; 14 | 15 | public: 16 | // initialize the LED controller 17 | virtual void init() { 18 | // Initialize 32x32 LED Matrix 19 | matrix.begin(); 20 | matrix.setBrightness(255); 21 | matrix.setColorCorrection(ccNone); 22 | 23 | // Clear screen 24 | clearLeds(0); 25 | matrix.swapBuffers(); 26 | pSmartMatrix = &matrix; 27 | } 28 | 29 | virtual void showPixels(PixelController & pixels) { 30 | if(SMART_MATRIX_CAN_TRIPLE_BUFFER) { 31 | rgb24 *md = matrix.getRealBackBuffer(); 32 | } else { 33 | rgb24 *md = matrix.backBuffer(); 34 | } 35 | while(pixels.has(1)) { 36 | md->red = pixels.loadAndScale0(); 37 | md->green = pixels.loadAndScale1(); 38 | md->blue = pixels.loadAndScale2(); 39 | md++; 40 | pixels.advanceData(); 41 | pixels.stepDithering(); 42 | } 43 | matrix.swapBuffers(); 44 | if(SMART_MATRIX_CAN_TRIPLE_BUFFER && pixels.advanceBy() > 0) { 45 | matrix.setBackBuffer(pixels.mData); 46 | } 47 | } 48 | 49 | }; 50 | 51 | FASTLED_NAMESPACE_END 52 | 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/fastspi_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTSPI_TYPES_H 2 | #define __INC_FASTSPI_TYPES_H 3 | 4 | #include "FastLED.h" 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | // Some helper macros for getting at mis-ordered byte values 9 | #define SPI_B0 (RGB_BYTE0(RGB_ORDER) + (MASK_SKIP_BITS & SKIP)) 10 | #define SPI_B1 (RGB_BYTE1(RGB_ORDER) + (MASK_SKIP_BITS & SKIP)) 11 | #define SPI_B2 (RGB_BYTE2(RGB_ORDER) + (MASK_SKIP_BITS & SKIP)) 12 | #define SPI_ADVANCE (3 + (MASK_SKIP_BITS & SKIP)) 13 | 14 | /// Some of the SPI controllers will need to perform a transform on each byte before doing 15 | /// anyting with it. Creating a class of this form and passing it in as a template parameter to 16 | /// writeBytes/writeBytes3 below will ensure that the body of this method will get called on every 17 | /// byte worked on. Recommendation, make the adjust method aggressively inlined. 18 | /// 19 | /// TODO: Convinience macro for building these 20 | class DATA_NOP { 21 | public: 22 | static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data) { return data; } 23 | static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data, register uint8_t scale) { return scale8(data, scale); } 24 | static __attribute__((always_inline)) inline void postBlock(int /* len */) { } 25 | }; 26 | 27 | #define FLAG_START_BIT 0x80 28 | #define MASK_SKIP_BITS 0x3F 29 | 30 | // Clock speed dividers 31 | #define SPEED_DIV_2 2 32 | #define SPEED_DIV_4 4 33 | #define SPEED_DIV_8 8 34 | #define SPEED_DIV_16 16 35 | #define SPEED_DIV_32 32 36 | #define SPEED_DIV_64 64 37 | #define SPEED_DIV_128 128 38 | 39 | #define MAX_DATA_RATE 0 40 | 41 | FASTLED_NAMESPACE_END 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Multiple/MirroringSample/MirroringSample.ino: -------------------------------------------------------------------------------- 1 | // MirroringSample - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on 2 | // using multiple controllers. In this example, we're going to set up four NEOPIXEL strips on four 3 | // different pins, and show the same thing on all four of them, a simple bouncing dot/cyclon type pattern 4 | 5 | #include 6 | 7 | #define NUM_LEDS_PER_STRIP 60 8 | CRGB leds[NUM_LEDS_PER_STRIP]; 9 | 10 | // For mirroring strips, all the "special" stuff happens just in setup. We 11 | // just addLeds multiple times, once for each strip 12 | void setup() { 13 | // tell FastLED there's 60 NEOPIXEL leds on pin 4 14 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP); 15 | 16 | // tell FastLED there's 60 NEOPIXEL leds on pin 5 17 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP); 18 | 19 | // tell FastLED there's 60 NEOPIXEL leds on pin 6 20 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP); 21 | 22 | // tell FastLED there's 60 NEOPIXEL leds on pin 7 23 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP); 24 | } 25 | 26 | void loop() { 27 | for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) { 28 | // set our current dot to red 29 | leds[i] = CRGB::Red; 30 | FastLED.show(); 31 | // clear our current dot before we move on 32 | leds[i] = CRGB::Black; 33 | delay(100); 34 | } 35 | 36 | for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) { 37 | // set our current dot to red 38 | leds[i] = CRGB::Red; 39 | FastLED.show(); 40 | // clear our current dot before we move on 41 | leds[i] = CRGB::Black; 42 | delay(100); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Cylon/Cylon.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // How many leds in your strip? 4 | #define NUM_LEDS 64 5 | 6 | // For led chips like Neopixels, which have a data line, ground, and power, you just 7 | // need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, 8 | // ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN 9 | #define DATA_PIN 7 10 | #define CLOCK_PIN 13 11 | 12 | // Define the array of leds 13 | CRGB leds[NUM_LEDS]; 14 | 15 | void setup() { 16 | Serial.begin(57600); 17 | Serial.println("resetting"); 18 | LEDS.addLeds(leds,NUM_LEDS); 19 | LEDS.setBrightness(84); 20 | } 21 | 22 | void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } } 23 | 24 | void loop() { 25 | static uint8_t hue = 0; 26 | Serial.print("x"); 27 | // First slide the led in one direction 28 | for(int i = 0; i < NUM_LEDS; i++) { 29 | // Set the i'th led to red 30 | leds[i] = CHSV(hue++, 255, 255); 31 | // Show the leds 32 | FastLED.show(); 33 | // now that we've shown the leds, reset the i'th led to black 34 | // leds[i] = CRGB::Black; 35 | fadeall(); 36 | // Wait a little bit before we loop around and do it again 37 | delay(10); 38 | } 39 | Serial.print("x"); 40 | 41 | // Now go in the other direction. 42 | for(int i = (NUM_LEDS)-1; i >= 0; i--) { 43 | // Set the i'th led to red 44 | leds[i] = CHSV(hue++, 255, 255); 45 | // Show the leds 46 | FastLED.show(); 47 | // now that we've shown the leds, reset the i'th led to black 48 | // leds[i] = CRGB::Black; 49 | fadeall(); 50 | // Wait a little bit before we loop around and do it again 51 | delay(10); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/stm32/led_sysdefs_arm_stm32.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_SAM_H 2 | #define __INC_LED_SYSDEFS_ARM_SAM_H 3 | 4 | #if defined(STM32F10X_MD) 5 | 6 | #include 7 | 8 | #define FASTLED_NAMESPACE_BEGIN namespace NSFastLED { 9 | #define FASTLED_NAMESPACE_END } 10 | #define FASTLED_USING_NAMESPACE using namespace NSFastLED; 11 | 12 | // reusing/abusing cli/sei defs for due 13 | #define cli() __disable_irq(); __disable_fault_irq(); 14 | #define sei() __enable_irq(); __enable_fault_irq(); 15 | 16 | #elif defined (__STM32F1__) 17 | 18 | #include "cm3_regs.h" 19 | 20 | #define cli() nvic_globalirq_disable() 21 | #define sei() nvic_globalirq_enable() 22 | 23 | #else 24 | #error "Platform not supported" 25 | #endif 26 | 27 | #define FASTLED_ARM 28 | 29 | #ifndef INTERRUPT_THRESHOLD 30 | #define INTERRUPT_THRESHOLD 1 31 | #endif 32 | 33 | // Default to allowing interrupts 34 | #ifndef FASTLED_ALLOW_INTERRUPTS 35 | #define FASTLED_ALLOW_INTERRUPTS 0 36 | #endif 37 | 38 | #if FASTLED_ALLOW_INTERRUPTS == 1 39 | #define FASTLED_ACCURATE_CLOCK 40 | #endif 41 | 42 | // pgmspace definitions 43 | #define PROGMEM 44 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 45 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 46 | 47 | // Default to NOT using PROGMEM here 48 | #ifndef FASTLED_USE_PROGMEM 49 | #define FASTLED_USE_PROGMEM 0 50 | #endif 51 | 52 | // data type defs 53 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 54 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 55 | 56 | #define FASTLED_NO_PINMAP 57 | 58 | #ifndef F_CPU 59 | #define F_CPU 72000000 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/extras/RainbowDemo.s65: -------------------------------------------------------------------------------- 1 | ; "Rainbow with glitter" demo 2 | ; for "FastLED6502" 3 | ; 4 | ; Runs on an Apple ][, ][+, //e, or //gs 5 | ; 6 | ; Supports APA102, Adafruit DotStar, 7 | ; LPD8806, and WS2801 LED strips. 8 | ; 9 | ; LED strip connects to game port pins, 10 | ; see FastLED6502.s65 for details. 11 | ; 12 | ; Mark Kriegsman, February 2015 13 | 14 | #define NUM_LEDS 100 15 | #define BRIGHTNESS 64 16 | #define CHIPSET APA102 17 | #define DATA_PIN 14 18 | #define CLOCK_PIN 5 19 | 20 | * = $6000 21 | 22 | #include "FastLED6502.s65" 23 | #include "AppleII.s65" 24 | 25 | gHue .byt 0 26 | gHueDelta .byt 17 27 | gHueSpeed .byt 7 28 | 29 | 30 | Setup 31 | lda #0 32 | sta gHue 33 | 34 | Loop 35 | lda gHue 36 | clc 37 | adc gHueSpeed 38 | sta gHue 39 | ldx gHue 40 | ldy gHueDelta 41 | ; Fill RGB array with HSV rainbow 42 | jsr FastLED_FillRainbow_XY 43 | ; Use master brightness control 44 | lda #BRIGHTNESS 45 | sta FastLED_Brightness 46 | CheckOpenApple 47 | bit OpenApple 48 | bpl CheckSolidApple 49 | ; Add glitter if requested 50 | jsr AddGlitter 51 | CheckSolidApple 52 | bit SolidApple 53 | bpl DoDisplay 54 | ; Pulse brightness if requested 55 | jsr PulseBrightness 56 | DoDisplay 57 | ; This is where the magic happens 58 | jsr FastLED_Show 59 | jmp Loop 60 | 61 | 62 | AddGlitter 63 | ldy #3 64 | MaybeAdd1Glitter 65 | jsr FastLED_Random8 66 | cmp FastLED_NumPixels 67 | bcs SkipThis1Glitter 68 | tax 69 | lda #$FF 70 | sta ledsR,x 71 | sta ledsG,x 72 | sta ledsB,x 73 | SkipThis1Glitter 74 | dey 75 | bne MaybeAdd1Glitter 76 | rts 77 | 78 | 79 | PulseBrightness 80 | lda #13 81 | jsr FastLED_Beat8 82 | clc 83 | adc #12 84 | bcc PulseBright1 85 | lda #$FF 86 | PulseBright1 87 | sta FastLED_Brightness 88 | rts 89 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Multiple/ParallelOutputDemo/ParallelOutputDemo.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define NUM_LEDS_PER_STRIP 64 4 | // Note: this can be 12 if you're using a teensy 3 and don't mind soldering the pads on the back 5 | #define NUM_STRIPS 16 6 | 7 | CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP]; 8 | 9 | // Pin layouts on the teensy 3/3.1: 10 | // WS2811_PORTD: 2,14,7,8,6,20,21,5 11 | // WS2811_PORTC: 15,22,23,9,10,13,11,12,28,27,29,30 (these last 4 are pads on the bottom of the teensy) 12 | // WS2811_PORTDC: 2,14,7,8,6,20,21,5,15,22,23,9,10,13,11,12 - 16 way parallel 13 | // 14 | // Pin layouts on the due 15 | // WS2811_PORTA: 69,68,61,60,59,100,58,31 (note: pin 100 only available on the digix) 16 | // WS2811_PORTB: 90,91,92,93,94,95,96,97 (note: only available on the digix) 17 | // WS2811_PORTD: 25,26,27,28,14,15,29,11 18 | // 19 | 20 | void setup() { 21 | // LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); 22 | // LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); 23 | // LEDS.addLeds(leds, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip); 24 | LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); 25 | LEDS.setBrightness(32); 26 | } 27 | 28 | void loop() { 29 | static uint8_t hue = 0; 30 | for(int i = 0; i < NUM_STRIPS; i++) { 31 | for(int j = 0; j < NUM_LEDS_PER_STRIP; j++) { 32 | leds[(i*NUM_LEDS_PER_STRIP) + j] = CHSV((32*i) + hue+j,192,255); 33 | } 34 | } 35 | 36 | // Set the first n leds on each strip to show which strip it is 37 | for(int i = 0; i < NUM_STRIPS; i++) { 38 | for(int j = 0; j <= i; j++) { 39 | leds[(i*NUM_LEDS_PER_STRIP) + j] = CRGB::Red; 40 | } 41 | } 42 | 43 | hue++; 44 | 45 | LEDS.show(); 46 | LEDS.delay(10); 47 | } 48 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/dmx.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_DMX_H 2 | #define __INC_DMX_H 3 | 4 | #include "FastLED.h" 5 | 6 | #ifdef DmxSimple_h 7 | #include 8 | #define HAS_DMX_SIMPLE 9 | 10 | ///@ingroup chipsets 11 | ///@{ 12 | FASTLED_NAMESPACE_BEGIN 13 | 14 | // note - dmx simple must be included before FastSPI for this code to be enabled 15 | template class DMXSimpleController : public CPixelLEDController { 16 | public: 17 | // initialize the LED controller 18 | virtual void init() { DmxSimple.usePin(DATA_PIN); } 19 | 20 | protected: 21 | virtual void showPixels(PixelController & pixels) { 22 | int iChannel = 1; 23 | while(pixels.has(1)) { 24 | DmxSimple.write(iChannel++, pixels.loadAndScale0()); 25 | DmxSimple.write(iChannel++, pixels.loadAndScale1()); 26 | DmxSimple.write(iChannel++, pixels.loadAndScale2()); 27 | pixels.advanceData(); 28 | pixels.stepDithering(); 29 | } 30 | } 31 | }; 32 | 33 | FASTLED_NAMESPACE_END 34 | 35 | #endif 36 | 37 | #ifdef DmxSerial_h 38 | #include 39 | 40 | FASTLED_NAMESPACE_BEGIN 41 | 42 | template class DMXSerialController : public CPixelLEDController { 43 | public: 44 | // initialize the LED controller 45 | virtual void init() { DMXSerial.init(DMXController); } 46 | 47 | virtual void showPixels(PixelController & pixels) { 48 | int iChannel = 1; 49 | while(pixels.has(1)) { 50 | DMXSerial.write(iChannel++, pixels.loadAndScale0()); 51 | DMXSerial.write(iChannel++, pixels.loadAndScale1()); 52 | DMXSerial.write(iChannel++, pixels.loadAndScale2()); 53 | pixels.advanceData(); 54 | pixels.stepDithering(); 55 | } 56 | } 57 | }; 58 | 59 | FASTLED_NAMESPACE_END 60 | ///@} 61 | 62 | #define HAS_DMX_SERIAL 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/nrf52/led_sysdefs_arm_nrf52.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_SYSDEFS_ARM_NRF52 2 | #define __LED_SYSDEFS_ARM_NRF52 3 | 4 | #define FASTLED_ARM 5 | 6 | #ifndef F_CPU 7 | #define F_CPU 64000000 // the NRF52 series has a 64MHz CPU 8 | #endif 9 | 10 | // even though CPU is at 64MHz, use the 8MHz-defined timings because... 11 | // PWM module runs at 16MHz 12 | // SPI0..2 runs at 8MHz 13 | #define CLOCKLESS_FREQUENCY 16000000 // the NRF52 has EasyDMA for PWM module at 16MHz 14 | 15 | #ifndef F_TIMER 16 | #define F_TIMER 16000000 // the NRF52 timer is 16MHz, even though CPU is 64MHz 17 | #endif 18 | 19 | #if !defined(FASTLED_USE_PROGMEM) 20 | #define FASTLED_USE_PROGMEM 0 // nRF52 series have flat memory model 21 | #endif 22 | 23 | #if !defined(FASTLED_ALLOW_INTERRUPTS) 24 | #define FASTLED_ALLOW_INTERRUPTS 1 25 | #endif 26 | 27 | // Use PWM instance 0 28 | // See clockless_arm_nrf52.h and (in root of library) platforms.cpp 29 | #define FASTLED_NRF52_ENABLE_PWM_INSTANCE0 30 | 31 | #if defined(FASTLED_NRF52_NEVER_INLINE) 32 | #define FASTLED_NRF52_INLINE_ATTRIBUTE __attribute__((always_inline)) inline 33 | #else 34 | #define FASTLED_NRF52_INLINE_ATTRIBUTE __attribute__((always_inline)) inline 35 | #endif 36 | 37 | 38 | 39 | #include 40 | #include // for FastSPI 41 | #include // for Clockless 42 | #include // for Clockless / anything else using interrupts 43 | typedef __I uint32_t RoReg; 44 | typedef __IO uint32_t RwReg; 45 | 46 | #define cli() __disable_irq() 47 | #define sei() __enable_irq() 48 | 49 | #define FASTLED_NRF52_DEBUGPRINT(format, ...) 50 | //#define FASTLED_NRF52_DEBUGPRINT(format, ...)\ 51 | // do {\ 52 | // FastLED_NRF52_DebugPrint(format, ##__VA_ARGS__);\ 53 | // } while(0); 54 | 55 | 56 | 57 | 58 | #endif // __LED_SYSDEFS_ARM_NRF52 59 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/led_sysdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_H 2 | #define __INC_LED_SYSDEFS_H 3 | 4 | #include "FastLED.h" 5 | 6 | #include "fastled_config.h" 7 | 8 | #if defined(NRF51) || defined(__RFduino__) || defined (__Simblee__) 9 | #include "platforms/arm/nrf51/led_sysdefs_arm_nrf51.h" 10 | #elif defined(NRF52_SERIES) 11 | #include "platforms/arm/nrf52/led_sysdefs_arm_nrf52.h" 12 | #elif defined(__MK20DX128__) || defined(__MK20DX256__) 13 | // Include k20/T3 headers 14 | #include "platforms/arm/k20/led_sysdefs_arm_k20.h" 15 | #elif defined(__MK66FX1M0__) || defined(__MK64FX512__) 16 | // Include k66/T3.6 headers 17 | #include "platforms/arm/k66/led_sysdefs_arm_k66.h" 18 | #elif defined(__MKL26Z64__) 19 | // Include kl26/T-LC headers 20 | #include "platforms/arm/kl26/led_sysdefs_arm_kl26.h" 21 | #elif defined(__SAM3X8E__) 22 | // Include sam/due headers 23 | #include "platforms/arm/sam/led_sysdefs_arm_sam.h" 24 | #elif defined(STM32F10X_MD) || defined(__STM32F1__) 25 | #include "platforms/arm/stm32/led_sysdefs_arm_stm32.h" 26 | #elif defined(__SAMD21G18A__) || defined(__SAMD21J18A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) || defined(__SAMD51G19A__) || defined(__SAMD51J19A__) 27 | #include "platforms/arm/d21/led_sysdefs_arm_d21.h" 28 | #elif defined(ESP8266) 29 | #include "platforms/esp/8266/led_sysdefs_esp8266.h" 30 | #elif defined(ESP32) 31 | #include "platforms/esp/32/led_sysdefs_esp32.h" 32 | #else 33 | // AVR platforms 34 | #include "platforms/avr/led_sysdefs_avr.h" 35 | #endif 36 | 37 | #ifndef FASTLED_NAMESPACE_BEGIN 38 | #define FASTLED_NAMESPACE_BEGIN 39 | #define FASTLED_NAMESPACE_END 40 | #define FASTLED_USING_NAMESPACE 41 | #endif 42 | 43 | // Arduino.h needed for convenience functions digitalPinToPort/BitMask/portOutputRegister and the pinMode methods. 44 | #ifdef ARDUINO 45 | #include 46 | #endif 47 | 48 | #define CLKS_PER_US (F_CPU/1000000) 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k20/octows2811_controller.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_OCTOWS2811_CONTROLLER_H 2 | #define __INC_OCTOWS2811_CONTROLLER_H 3 | 4 | #ifdef USE_OCTOWS2811 5 | 6 | // #include "OctoWS2811.h" 7 | 8 | FASTLED_NAMESPACE_BEGIN 9 | 10 | template 11 | class COctoWS2811Controller : public CPixelLEDController { 12 | OctoWS2811 *pocto; 13 | uint8_t *drawbuffer,*framebuffer; 14 | 15 | void _init(int nLeds) { 16 | if(pocto == NULL) { 17 | drawbuffer = (uint8_t*)malloc(nLeds * 8 * 3); 18 | framebuffer = (uint8_t*)malloc(nLeds * 8 * 3); 19 | 20 | // byte ordering is handled in show by the pixel controller 21 | int config = WS2811_RGB; 22 | config |= CHIP; 23 | 24 | pocto = new OctoWS2811(nLeds, framebuffer, drawbuffer, config); 25 | 26 | pocto->begin(); 27 | } 28 | } 29 | public: 30 | COctoWS2811Controller() { pocto = NULL; } 31 | 32 | 33 | virtual void init() { /* do nothing yet */ } 34 | 35 | typedef union { 36 | uint8_t bytes[8]; 37 | uint32_t raw[2]; 38 | } Lines; 39 | 40 | virtual void showPixels(PixelController & pixels) { 41 | _init(pixels.size()); 42 | 43 | uint8_t *pData = drawbuffer; 44 | while(pixels.has(1)) { 45 | Lines b; 46 | 47 | for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale0(i); } 48 | transpose8x1_MSB(b.bytes,pData); pData += 8; 49 | for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale1(i); } 50 | transpose8x1_MSB(b.bytes,pData); pData += 8; 51 | for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale2(i); } 52 | transpose8x1_MSB(b.bytes,pData); pData += 8; 53 | pixels.stepDithering(); 54 | pixels.advanceData(); 55 | } 56 | 57 | pocto->show(); 58 | } 59 | 60 | }; 61 | 62 | FASTLED_NAMESPACE_END 63 | 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Multiple/MultiArrays/MultiArrays.ino: -------------------------------------------------------------------------------- 1 | // MultiArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on 2 | // using multiple controllers. In this example, we're going to set up three NEOPIXEL strips on three 3 | // different pins, each strip getting its own CRGB array to be played with 4 | 5 | #include 6 | 7 | #define NUM_LEDS_PER_STRIP 60 8 | CRGB redLeds[NUM_LEDS_PER_STRIP]; 9 | CRGB greenLeds[NUM_LEDS_PER_STRIP]; 10 | CRGB blueLeds[NUM_LEDS_PER_STRIP]; 11 | 12 | // For mirroring strips, all the "special" stuff happens just in setup. We 13 | // just addLeds multiple times, once for each strip 14 | void setup() { 15 | // tell FastLED there's 60 NEOPIXEL leds on pin 10 16 | FastLED.addLeds(redLeds, NUM_LEDS_PER_STRIP); 17 | 18 | // tell FastLED there's 60 NEOPIXEL leds on pin 11 19 | FastLED.addLeds(greenLeds, NUM_LEDS_PER_STRIP); 20 | 21 | // tell FastLED there's 60 NEOPIXEL leds on pin 12 22 | FastLED.addLeds(blueLeds, NUM_LEDS_PER_STRIP); 23 | 24 | } 25 | 26 | void loop() { 27 | for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) { 28 | // set our current dot to red, green, and blue 29 | redLeds[i] = CRGB::Red; 30 | greenLeds[i] = CRGB::Green; 31 | blueLeds[i] = CRGB::Blue; 32 | FastLED.show(); 33 | // clear our current dot before we move on 34 | redLeds[i] = CRGB::Black; 35 | greenLeds[i] = CRGB::Black; 36 | blueLeds[i] = CRGB::Blue; 37 | delay(100); 38 | } 39 | 40 | for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) { 41 | // set our current dot to red, green, and blue 42 | redLeds[i] = CRGB::Red; 43 | greenLeds[i] = CRGB::Green; 44 | blueLeds[i] = CRGB::Blue; 45 | FastLED.show(); 46 | // clear our current dot before we move on 47 | redLeds[i] = CRGB::Black; 48 | greenLeds[i] = CRGB::Black; 49 | blueLeds[i] = CRGB::Blue; 50 | delay(100); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/AnalogOutput/AnalogOutput.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Example showing how to use FastLED color functions 4 | // even when you're NOT using a "pixel-addressible" smart LED strip. 5 | // 6 | // This example is designed to control an "analog" RGB LED strip 7 | // (or a single RGB LED) being driven by Arduino PWM output pins. 8 | // So this code never calls FastLED.addLEDs() or FastLED.show(). 9 | // 10 | // This example illustrates one way you can use just the portions 11 | // of FastLED that you need. In this case, this code uses just the 12 | // fast HSV color conversion code. 13 | // 14 | // In this example, the RGB values are output on three separate 15 | // 'analog' PWM pins, one for red, one for green, and one for blue. 16 | 17 | #define REDPIN 5 18 | #define GREENPIN 6 19 | #define BLUEPIN 3 20 | 21 | // showAnalogRGB: this is like FastLED.show(), but outputs on 22 | // analog PWM output pins instead of sending data to an intelligent, 23 | // pixel-addressable LED strip. 24 | // 25 | // This function takes the incoming RGB values and outputs the values 26 | // on three analog PWM output pins to the r, g, and b values respectively. 27 | void showAnalogRGB( const CRGB& rgb) 28 | { 29 | analogWrite(REDPIN, rgb.r ); 30 | analogWrite(GREENPIN, rgb.g ); 31 | analogWrite(BLUEPIN, rgb.b ); 32 | } 33 | 34 | 35 | 36 | // colorBars: flashes Red, then Green, then Blue, then Black. 37 | // Helpful for diagnosing if you've mis-wired which is which. 38 | void colorBars() 39 | { 40 | showAnalogRGB( CRGB::Red ); delay(500); 41 | showAnalogRGB( CRGB::Green ); delay(500); 42 | showAnalogRGB( CRGB::Blue ); delay(500); 43 | showAnalogRGB( CRGB::Black ); delay(500); 44 | } 45 | 46 | void loop() 47 | { 48 | static uint8_t hue; 49 | hue = hue + 1; 50 | // Use FastLED automatic HSV->RGB conversion 51 | showAnalogRGB( CHSV( hue, 255, 255) ); 52 | 53 | delay(20); 54 | } 55 | 56 | 57 | void setup() { 58 | pinMode(REDPIN, OUTPUT); 59 | pinMode(GREENPIN, OUTPUT); 60 | pinMode(BLUEPIN, OUTPUT); 61 | 62 | // Flash the "hello" color sequence: R, G, B, black. 63 | colorBars(); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/colorpalettes.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_COLORPALETTES_H 2 | #define __INC_COLORPALETTES_H 3 | 4 | #include "FastLED.h" 5 | #include "colorutils.h" 6 | 7 | ///@file colorpalettes.h 8 | /// contains definitions for the predefined color palettes supplied by FastLED. 9 | 10 | FASTLED_NAMESPACE_BEGIN 11 | 12 | ///@defgroup Colorpalletes Pre-defined color palletes 13 | /// These schemes are all declared as "PROGMEM", meaning 14 | /// that they won't take up SRAM on AVR chips until used. 15 | /// Furthermore, the compiler won't even include these 16 | /// in your PROGMEM (flash) storage unless you specifically 17 | /// use each one, so you only 'pay for' those you actually use. 18 | 19 | ///@{ 20 | 21 | /// Cloudy color pallete 22 | extern const TProgmemRGBPalette16 CloudColors_p FL_PROGMEM; 23 | /// Lava colors 24 | extern const TProgmemRGBPalette16 LavaColors_p FL_PROGMEM; 25 | /// Ocean colors, blues and whites 26 | extern const TProgmemRGBPalette16 OceanColors_p FL_PROGMEM; 27 | /// Forest colors, greens 28 | extern const TProgmemRGBPalette16 ForestColors_p FL_PROGMEM; 29 | 30 | /// HSV Rainbow 31 | extern const TProgmemRGBPalette16 RainbowColors_p FL_PROGMEM; 32 | 33 | #define RainbowStripesColors_p RainbowStripeColors_p 34 | /// HSV Rainbow colors with alternatating stripes of black 35 | extern const TProgmemRGBPalette16 RainbowStripeColors_p FL_PROGMEM; 36 | 37 | /// HSV color ramp: blue purple ping red orange yellow (and back) 38 | /// Basically, everything but the greens, which tend to make 39 | /// people's skin look unhealthy. This palette is good for 40 | /// lighting at a club or party, where it'll be shining on people. 41 | extern const TProgmemRGBPalette16 PartyColors_p FL_PROGMEM; 42 | 43 | /// Approximate "black body radiation" palette, akin to 44 | /// the FastLED 'HeatColor' function. 45 | /// Recommend that you use values 0-240 rather than 46 | /// the usual 0-255, as the last 15 colors will be 47 | /// 'wrapping around' from the hot end to the cold end, 48 | /// which looks wrong. 49 | extern const TProgmemRGBPalette16 HeatColors_p FL_PROGMEM; 50 | 51 | 52 | DECLARE_GRADIENT_PALETTE( Rainbow_gp); 53 | 54 | FASTLED_NAMESPACE_END 55 | 56 | ///@} 57 | #endif 58 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/d21/clockless_arm_d21.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_D21 2 | #define __INC_CLOCKLESS_ARM_D21 3 | 4 | #include "../common/m0clockless.h" 5 | FASTLED_NAMESPACE_BEGIN 6 | #define FASTLED_HAS_CLOCKLESS 1 7 | 8 | template 9 | class ClocklessController : public CPixelLEDController { 10 | typedef typename FastPinBB::port_ptr_t data_ptr_t; 11 | typedef typename FastPinBB::port_t data_t; 12 | 13 | data_t mPinMask; 14 | data_ptr_t mPort; 15 | CMinWait mWait; 16 | public: 17 | virtual void init() { 18 | FastPinBB::setOutput(); 19 | mPinMask = FastPinBB::mask(); 20 | mPort = FastPinBB::port(); 21 | } 22 | 23 | virtual uint16_t getMaxRefreshRate() const { return 400; } 24 | 25 | virtual void showPixels(PixelController & pixels) { 26 | mWait.wait(); 27 | cli(); 28 | if(!showRGBInternal(pixels)) { 29 | sei(); delayMicroseconds(WAIT_TIME); cli(); 30 | showRGBInternal(pixels); 31 | } 32 | sei(); 33 | mWait.mark(); 34 | } 35 | 36 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 37 | // gcc will use register Y for the this pointer. 38 | static uint32_t showRGBInternal(PixelController pixels) { 39 | struct M0ClocklessData data; 40 | data.d[0] = pixels.d[0]; 41 | data.d[1] = pixels.d[1]; 42 | data.d[2] = pixels.d[2]; 43 | data.s[0] = pixels.mScale[0]; 44 | data.s[1] = pixels.mScale[1]; 45 | data.s[2] = pixels.mScale[2]; 46 | data.e[0] = pixels.e[0]; 47 | data.e[1] = pixels.e[1]; 48 | data.e[2] = pixels.e[2]; 49 | data.adj = pixels.mAdvance; 50 | 51 | typename FastPin::port_ptr_t portBase = FastPin::port(); 52 | return showLedData<8,4,T1,T2,T3,RGB_ORDER, WAIT_TIME>(portBase, FastPin::mask(), pixels.mData, pixels.mLen, &data); 53 | } 54 | 55 | 56 | }; 57 | 58 | FASTLED_NAMESPACE_END 59 | 60 | 61 | #endif // __INC_CLOCKLESS_ARM_D21 62 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/NoisePlayground/NoisePlayground.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define kMatrixWidth 16 4 | #define kMatrixHeight 16 5 | 6 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 7 | // Param for different pixel layouts 8 | #define kMatrixSerpentineLayout true 9 | 10 | // led array 11 | CRGB leds[kMatrixWidth * kMatrixHeight]; 12 | 13 | // x,y, & time values 14 | uint32_t x,y,v_time,hue_time,hxy; 15 | 16 | // Play with the values of the variables below and see what kinds of effects they 17 | // have! More octaves will make things slower. 18 | 19 | // how many octaves to use for the brightness and hue functions 20 | uint8_t octaves=1; 21 | uint8_t hue_octaves=3; 22 | 23 | // the 'distance' between points on the x and y axis 24 | int xscale=57771; 25 | int yscale=57771; 26 | 27 | // the 'distance' between x/y points for the hue noise 28 | int hue_scale=1; 29 | 30 | // how fast we move through time & hue noise 31 | int time_speed=1111; 32 | int hue_speed=31; 33 | 34 | // adjust these values to move along the x or y axis between frames 35 | int x_speed=331; 36 | int y_speed=1111; 37 | 38 | void loop() { 39 | // fill the led array 2/16-bit noise values 40 | fill_2dnoise16(LEDS.leds(), kMatrixWidth, kMatrixHeight, kMatrixSerpentineLayout, 41 | octaves,x,xscale,y,yscale,v_time, 42 | hue_octaves,hxy,hue_scale,hxy,hue_scale,hue_time, false); 43 | 44 | LEDS.show(); 45 | 46 | // adjust the intra-frame time values 47 | x += x_speed; 48 | y += y_speed; 49 | v_time += time_speed; 50 | hue_time += hue_speed; 51 | // delay(50); 52 | } 53 | 54 | 55 | void setup() { 56 | // initialize the x/y and time values 57 | random16_set_seed(8934); 58 | random16_add_entropy(analogRead(3)); 59 | 60 | Serial.begin(57600); 61 | Serial.println("resetting!"); 62 | 63 | delay(3000); 64 | LEDS.addLeds(leds,NUM_LEDS); 65 | LEDS.setBrightness(96); 66 | 67 | hxy = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 68 | x = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 69 | y = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 70 | v_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 71 | hue_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/PORTING.md: -------------------------------------------------------------------------------- 1 | =New platform porting guide= 2 | 3 | == Setting up the basic files/folders == 4 | 5 | * Create platform directory (e.g. platforms/arm/kl26) 6 | * Create configuration header led_sysdefs_arm_kl26.h: 7 | * Define platform flags (like FASTLED_ARM/FASTLED_TEENSY) 8 | * Define configuration parameters re: interrupts, or clock doubling 9 | * Include extar system header files if needed 10 | * Create main platform include, fastled_arm_kl26.h 11 | * Include the various other header files as needed 12 | * Modify led_sysdefs.h to conditionally include platform sysdefs header file 13 | * Modify platforms.h to conditionally include platform fastled header 14 | 15 | == Porting fastpin.h == 16 | 17 | 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. 18 | 19 | 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. 20 | 21 | Explaining how the macros work and should be used is currently beyond the scope of this document. 22 | 23 | == Porting fastspi.h == 24 | 25 | 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. 26 | 27 | == Porting clockless.h == 28 | 29 | 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. 30 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/kl26/clockless_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_KL26 2 | #define __INC_CLOCKLESS_ARM_KL26 3 | 4 | #include "../common/m0clockless.h" 5 | FASTLED_NAMESPACE_BEGIN 6 | #define FASTLED_HAS_CLOCKLESS 1 7 | 8 | template 9 | class ClocklessController : public CPixelLEDController { 10 | typedef typename FastPinBB::port_ptr_t data_ptr_t; 11 | typedef typename FastPinBB::port_t data_t; 12 | 13 | data_t mPinMask; 14 | data_ptr_t mPort; 15 | CMinWait mWait; 16 | public: 17 | virtual void init() { 18 | FastPinBB::setOutput(); 19 | mPinMask = FastPinBB::mask(); 20 | mPort = FastPinBB::port(); 21 | } 22 | 23 | virtual uint16_t getMaxRefreshRate() const { return 400; } 24 | 25 | virtual void showPixels(PixelController & pixels) { 26 | mWait.wait(); 27 | cli(); 28 | uint32_t clocks = showRGBInternal(pixels); 29 | if(!clocks) { 30 | sei(); delayMicroseconds(WAIT_TIME); cli(); 31 | clocks = showRGBInternal(pixels); 32 | } 33 | long microsTaken = CLKS_TO_MICROS(clocks * ((T1 + T2 + T3) * 24)); 34 | MS_COUNTER += (microsTaken / 1000); 35 | sei(); 36 | mWait.mark(); 37 | } 38 | 39 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 40 | // gcc will use register Y for the this pointer. 41 | static uint32_t showRGBInternal(PixelController pixels) { 42 | struct M0ClocklessData data; 43 | data.d[0] = pixels.d[0]; 44 | data.d[1] = pixels.d[1]; 45 | data.d[2] = pixels.d[2]; 46 | data.s[0] = pixels.mScale[0]; 47 | data.s[1] = pixels.mScale[1]; 48 | data.s[2] = pixels.mScale[2]; 49 | data.e[0] = pixels.e[0]; 50 | data.e[1] = pixels.e[1]; 51 | data.e[2] = pixels.e[2]; 52 | data.adj = pixels.mAdvance; 53 | 54 | typename FastPin::port_ptr_t portBase = FastPin::port(); 55 | return showLedData<4,8,T1,T2,T3,RGB_ORDER, WAIT_TIME>(portBase, FastPin::mask(), pixels.mData, pixels.mLen, &data); 56 | // return 0; // 0x00FFFFFF - _VAL; 57 | } 58 | 59 | 60 | }; 61 | 62 | FASTLED_NAMESPACE_END 63 | 64 | 65 | #endif // __INC_CLOCKLESS_ARM_KL26 66 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // How many leds in your strip? 4 | #define NUM_LEDS 1 5 | 6 | // For led chips like Neopixels, which have a data line, ground, and power, you just 7 | // need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, 8 | // ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN 9 | #define DATA_PIN 3 10 | #define CLOCK_PIN 13 11 | 12 | // Define the array of leds 13 | CRGB leds[NUM_LEDS]; 14 | 15 | void setup() { 16 | // Uncomment/edit one of the following lines for your leds arrangement. 17 | // FastLED.addLeds(leds, NUM_LEDS); 18 | // FastLED.addLeds(leds, NUM_LEDS); 19 | // FastLED.addLeds(leds, NUM_LEDS); 20 | // FastLED.addLeds(leds, NUM_LEDS); 21 | // FastLED.addLeds(leds, NUM_LEDS); 22 | // FastLED.addLeds(leds, NUM_LEDS); 23 | FastLED.addLeds(leds, NUM_LEDS); 24 | // FastLED.addLeds(leds, NUM_LEDS); 25 | // FastLED.addLeds(leds, NUM_LEDS); 26 | // FastLED.addLeds(leds, NUM_LEDS); 27 | // FastLED.addLeds(leds, NUM_LEDS); 28 | // FastLED.addLeds(leds, NUM_LEDS); 29 | 30 | // FastLED.addLeds(leds, NUM_LEDS); 31 | // FastLED.addLeds(leds, NUM_LEDS); 32 | // FastLED.addLeds(leds, NUM_LEDS); 33 | // FastLED.addLeds(leds, NUM_LEDS); 34 | // FastLED.addLeds(leds, NUM_LEDS); 35 | // FastLED.addLeds(leds, NUM_LEDS); 36 | 37 | // FastLED.addLeds(leds, NUM_LEDS); 38 | // FastLED.addLeds(leds, NUM_LEDS); 39 | // FastLED.addLeds(leds, NUM_LEDS); 40 | // FastLED.addLeds(leds, NUM_LEDS); 41 | // FastLED.addLeds(leds, NUM_LEDS); 42 | // FastLED.addLeds(leds, NUM_LEDS); 43 | } 44 | 45 | void loop() { 46 | // Turn the LED on, then pause 47 | leds[0] = CRGB::Red; 48 | FastLED.show(); 49 | delay(500); 50 | // Now turn the LED off, then pause 51 | leds[0] = CRGB::Black; 52 | FastLED.show(); 53 | delay(500); 54 | } 55 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/avr/led_sysdefs_avr.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_AVR_H 2 | #define __INC_LED_SYSDEFS_AVR_H 3 | 4 | #define FASTLED_AVR 5 | 6 | #ifndef INTERRUPT_THRESHOLD 7 | #define INTERRUPT_THRESHOLD 2 8 | #endif 9 | 10 | #define FASTLED_SPI_BYTE_ONLY 11 | 12 | #include 13 | #include // for cli/se definitions 14 | 15 | // Define the register types 16 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 17 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 18 | 19 | 20 | // Default to disallowing interrupts (may want to gate this on teensy2 vs. other arm platforms, since the 21 | // teensy2 has a good, fast millis interrupt implementation) 22 | #ifndef FASTLED_ALLOW_INTERRUPTS 23 | #define FASTLED_ALLOW_INTERRUPTS 0 24 | #endif 25 | 26 | #if FASTLED_ALLOW_INTERRUPTS == 1 27 | #define FASTLED_ACCURATE_CLOCK 28 | #endif 29 | 30 | 31 | // Default to using PROGMEM here 32 | #ifndef FASTLED_USE_PROGMEM 33 | #define FASTLED_USE_PROGMEM 1 34 | #endif 35 | 36 | #if defined(ARDUINO_AVR_DIGISPARK) || defined(ARDUINO_AVR_DIGISPARKPRO) 37 | #ifndef NO_CORRECTION 38 | #define NO_CORRECTION 1 39 | #endif 40 | #endif 41 | 42 | extern "C" { 43 | # if defined(CORE_TEENSY) || defined(TEENSYDUINO) 44 | extern volatile unsigned long timer0_millis_count; 45 | # define MS_COUNTER timer0_millis_count 46 | # elif defined(ATTINY_CORE) 47 | extern volatile unsigned long millis_timer_millis; 48 | # define MS_COUNTER millis_timer_millis 49 | # else 50 | extern volatile unsigned long timer0_millis; 51 | # define MS_COUNTER timer0_millis 52 | # endif 53 | }; 54 | 55 | // special defs for the tiny environments 56 | #if defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny167__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtinyX41__) || defined(__AVR_ATtiny841__) || defined(__AVR_ATtiny441__) 57 | #define LIB8_ATTINY 1 58 | #define FASTLED_NEEDS_YIELD 59 | #endif 60 | 61 | #if defined(ARDUINO) && (ARDUINO > 150) && !defined(IS_BEAN) && !defined (ARDUINO_AVR_DIGISPARK) && !defined (LIB8_TINY) && !defined (ARDUINO_AVR_LARDU_328E) 62 | // don't need YIELD defined by the library 63 | #else 64 | #define FASTLED_NEEDS_YIELD 65 | extern "C" void yield(); 66 | #endif 67 | #endif 68 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/fastspi_nop.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTSPI_NOP_H 2 | #define __INC_FASTSPI_NOP_H 3 | 4 | #if 0 // Guard against the arduino ide idiotically including every header file 5 | 6 | #include "FastLED.h" 7 | 8 | FASTLED_NAMESPACE_BEGIN 9 | 10 | /// A nop/stub class, mostly to show the SPI methods that are needed/used by the various SPI chipset implementations. Should 11 | /// be used as a definition for the set of methods that the spi implementation classes should use (since C++ doesn't support the 12 | /// idea of interfaces - it's possible this could be done with virtual classes, need to decide if i want that overhead) 13 | template 14 | class NOPSPIOutput { 15 | Selectable *m_pSelect; 16 | 17 | public: 18 | NOPSPIOutput() { m_pSelect = NULL; } 19 | NOPSPIOutput(Selectable *pSelect) { m_pSelect = pSelect; } 20 | 21 | /// set the object representing the selectable 22 | void setSelect(Selectable *pSelect) { m_pSelect = pSelect; } 23 | 24 | /// initialize the SPI subssytem 25 | void init() { /* TODO */ } 26 | 27 | /// latch the CS select 28 | void select() { /* TODO */ } 29 | 30 | /// release the CS select 31 | void release() { /* TODO */ } 32 | 33 | /// wait until all queued up data has been written 34 | void waitFully(); 35 | 36 | /// not the most efficient mechanism in the world - but should be enough for sm16716 and friends 37 | template inline static void writeBit(uint8_t b) { /* TODO */ } 38 | 39 | /// write a byte out via SPI (returns immediately on writing register) 40 | void writeByte(uint8_t b) { /* TODO */ } 41 | /// write a word out via SPI (returns immediately on writing register) 42 | void writeWord(uint16_t w) { /* TODO */ } 43 | 44 | /// A raw set of writing byte values, assumes setup/init/waiting done elsewhere (static for use by adjustment classes) 45 | static void writeBytesValueRaw(uint8_t value, int len) { /* TODO */ } 46 | 47 | /// A full cycle of writing a value for len bytes, including select, release, and waiting 48 | void writeBytesValue(uint8_t value, int len) { /* TODO */ } 49 | 50 | /// A full cycle of writing a raw block of data out, including select, release, and waiting 51 | void writeBytes(uint8_t *data, int len) { /* TODO */ } 52 | 53 | /// write a single bit out, which bit from the passed in byte is determined by template parameter 54 | template inline static void writeBit(uint8_t b) { /* TODO */ } 55 | 56 | /// write out pixel data from the given PixelController object 57 | template void writePixels(PixelController pixels) { /* TODO */ } 58 | 59 | }; 60 | 61 | FASTLED_NAMESPACE_END 62 | 63 | #endif 64 | #endif 65 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/fastled_progmem.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FL_PROGMEM_H 2 | #define __INC_FL_PROGMEM_H 3 | 4 | #include "FastLED.h" 5 | 6 | ///@file fastled_progmem.h 7 | /// wrapper definitions to allow seamless use of PROGMEM in environmens that have it 8 | 9 | FASTLED_NAMESPACE_BEGIN 10 | 11 | // Compatibility layer for devices that do or don't 12 | // have "PROGMEM" and the associated pgm_ accessors. 13 | // 14 | // If a platform supports PROGMEM, it should define 15 | // "FASTLED_USE_PROGMEM" as 1, otherwise FastLED will 16 | // fall back to NOT using PROGMEM. 17 | // 18 | // Whether or not pgmspace.h is #included is separately 19 | // controllable by FASTLED_INCLUDE_PGMSPACE, if needed. 20 | 21 | 22 | // If FASTLED_USE_PROGMEM is 1, we'll map FL_PROGMEM 23 | // and the FL_PGM_* accessors to the Arduino equivalents. 24 | #if FASTLED_USE_PROGMEM == 1 25 | #ifndef FASTLED_INCLUDE_PGMSPACE 26 | #define FASTLED_INCLUDE_PGMSPACE 1 27 | #endif 28 | 29 | #if FASTLED_INCLUDE_PGMSPACE == 1 30 | #include 31 | #endif 32 | 33 | #define FL_PROGMEM PROGMEM 34 | 35 | // Note: only the 'near' memory wrappers are provided. 36 | // If you're using 'far' memory, you already have 37 | // portability issues to work through, but you could 38 | // add more support here if needed. 39 | #define FL_PGM_READ_BYTE_NEAR(x) (pgm_read_byte_near(x)) 40 | #define FL_PGM_READ_WORD_NEAR(x) (pgm_read_word_near(x)) 41 | #define FL_PGM_READ_DWORD_NEAR(x) (pgm_read_dword_near(x)) 42 | 43 | // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734 44 | #if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6)) 45 | #ifdef FASTLED_AVR 46 | #ifdef PROGMEM 47 | #undef PROGMEM 48 | #define PROGMEM __attribute__((section(".progmem.data"))) 49 | #endif 50 | #endif 51 | #endif 52 | 53 | #else 54 | // If FASTLED_USE_PROGMEM is 0 or undefined, 55 | // we'll use regular memory (RAM) access. 56 | 57 | //empty PROGMEM simulation 58 | #define FL_PROGMEM 59 | #define FL_PGM_READ_BYTE_NEAR(x) (*((const uint8_t*)(x))) 60 | #define FL_PGM_READ_WORD_NEAR(x) (*((const uint16_t*)(x))) 61 | #define FL_PGM_READ_DWORD_NEAR(x) (*((const uint32_t*)(x))) 62 | 63 | #endif 64 | 65 | 66 | // On some platforms, most notably ARM M0, unaligned access 67 | // to 'PROGMEM' for multibyte values (eg read dword) is 68 | // not allowed and causes a crash. This macro can help 69 | // force 4-byte alignment as needed. The FastLED gradient 70 | // palette code uses 'read dword', and now uses this macro 71 | // to make sure that gradient palettes are 4-byte aligned. 72 | #if defined(FASTLED_ARM) || defined(ESP32) 73 | #define FL_ALIGN_PROGMEM __attribute__ ((aligned (4))) 74 | #else 75 | #define FL_ALIGN_PROGMEM 76 | #endif 77 | 78 | 79 | FASTLED_NAMESPACE_END 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/lib8tion/random8.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LIB8TION_RANDOM_H 2 | #define __INC_LIB8TION_RANDOM_H 3 | ///@ingroup lib8tion 4 | 5 | ///@defgroup Random Fast random number generators 6 | /// Fast 8- and 16- bit unsigned random numbers. 7 | /// Significantly faster than Arduino random(), but 8 | /// also somewhat less random. You can add entropy. 9 | ///@{ 10 | 11 | // X(n+1) = (2053 * X(n)) + 13849) 12 | #define FASTLED_RAND16_2053 ((uint16_t)(2053)) 13 | #define FASTLED_RAND16_13849 ((uint16_t)(13849)) 14 | 15 | /// random number seed 16 | extern uint16_t rand16seed;// = RAND16_SEED; 17 | 18 | /// Generate an 8-bit random number 19 | LIB8STATIC uint8_t random8() 20 | { 21 | rand16seed = (rand16seed * FASTLED_RAND16_2053) + FASTLED_RAND16_13849; 22 | // return the sum of the high and low bytes, for better 23 | // mixing and non-sequential correlation 24 | return (uint8_t)(((uint8_t)(rand16seed & 0xFF)) + 25 | ((uint8_t)(rand16seed >> 8))); 26 | } 27 | 28 | /// Generate a 16 bit random number 29 | LIB8STATIC uint16_t random16() 30 | { 31 | rand16seed = (rand16seed * FASTLED_RAND16_2053) + FASTLED_RAND16_13849; 32 | return rand16seed; 33 | } 34 | 35 | /// Generate an 8-bit random number between 0 and lim 36 | /// @param lim the upper bound for the result 37 | LIB8STATIC uint8_t random8(uint8_t lim) 38 | { 39 | uint8_t r = random8(); 40 | r = (r*lim) >> 8; 41 | return r; 42 | } 43 | 44 | /// Generate an 8-bit random number in the given range 45 | /// @param min the lower bound for the random number 46 | /// @param lim the upper bound for the random number 47 | LIB8STATIC uint8_t random8(uint8_t min, uint8_t lim) 48 | { 49 | uint8_t delta = lim - min; 50 | uint8_t r = random8(delta) + min; 51 | return r; 52 | } 53 | 54 | /// Generate an 16-bit random number between 0 and lim 55 | /// @param lim the upper bound for the result 56 | LIB8STATIC uint16_t random16( uint16_t lim) 57 | { 58 | uint16_t r = random16(); 59 | uint32_t p = (uint32_t)lim * (uint32_t)r; 60 | r = p >> 16; 61 | return r; 62 | } 63 | 64 | /// Generate an 16-bit random number in the given range 65 | /// @param min the lower bound for the random number 66 | /// @param lim the upper bound for the random number 67 | LIB8STATIC uint16_t random16( uint16_t min, uint16_t lim) 68 | { 69 | uint16_t delta = lim - min; 70 | uint16_t r = random16( delta) + min; 71 | return r; 72 | } 73 | 74 | /// Set the 16-bit seed used for the random number generator 75 | LIB8STATIC void random16_set_seed( uint16_t seed) 76 | { 77 | rand16seed = seed; 78 | } 79 | 80 | /// Get the current seed value for the random number generator 81 | LIB8STATIC uint16_t random16_get_seed() 82 | { 83 | return rand16seed; 84 | } 85 | 86 | /// Add entropy into the random number generator 87 | LIB8STATIC void random16_add_entropy( uint16_t entropy) 88 | { 89 | rand16seed += entropy; 90 | } 91 | 92 | ///@} 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/color.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_COLOR_H 2 | #define __INC_COLOR_H 3 | 4 | #include "FastLED.h" 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | ///@file color.h 9 | /// contains definitions for color correction and temperature 10 | ///@defgroup ColorEnums Color correction/temperature 11 | /// definitions for color correction and light temperatures 12 | ///@{ 13 | typedef enum { 14 | // Color correction starting points 15 | 16 | /// typical values for SMD5050 LEDs 17 | ///@{ 18 | TypicalSMD5050=0xFFB0F0 /* 255, 176, 240 */, 19 | TypicalLEDStrip=0xFFB0F0 /* 255, 176, 240 */, 20 | ///@} 21 | 22 | /// typical values for 8mm "pixels on a string" 23 | /// also for many through-hole 'T' package LEDs 24 | ///@{ 25 | Typical8mmPixel=0xFFE08C /* 255, 224, 140 */, 26 | TypicalPixelString=0xFFE08C /* 255, 224, 140 */, 27 | ///@} 28 | 29 | /// uncorrected color 30 | UncorrectedColor=0xFFFFFF 31 | 32 | } LEDColorCorrection; 33 | 34 | 35 | typedef enum { 36 | /// @name Black-body radiation light sources 37 | /// Black-body radiation light sources emit a (relatively) continuous 38 | /// spectrum, and can be described as having a Kelvin 'temperature' 39 | ///@{ 40 | /// 1900 Kelvin 41 | Candle=0xFF9329 /* 1900 K, 255, 147, 41 */, 42 | /// 2600 Kelvin 43 | Tungsten40W=0xFFC58F /* 2600 K, 255, 197, 143 */, 44 | /// 2850 Kelvin 45 | Tungsten100W=0xFFD6AA /* 2850 K, 255, 214, 170 */, 46 | /// 3200 Kelvin 47 | Halogen=0xFFF1E0 /* 3200 K, 255, 241, 224 */, 48 | /// 5200 Kelvin 49 | CarbonArc=0xFFFAF4 /* 5200 K, 255, 250, 244 */, 50 | /// 5400 Kelvin 51 | HighNoonSun=0xFFFFFB /* 5400 K, 255, 255, 251 */, 52 | /// 6000 Kelvin 53 | DirectSunlight=0xFFFFFF /* 6000 K, 255, 255, 255 */, 54 | /// 7000 Kelvin 55 | OvercastSky=0xC9E2FF /* 7000 K, 201, 226, 255 */, 56 | /// 20000 Kelvin 57 | ClearBlueSky=0x409CFF /* 20000 K, 64, 156, 255 */, 58 | ///@} 59 | 60 | /// @name Gaseous light sources 61 | /// Gaseous light sources emit discrete spectral bands, and while we can 62 | /// approximate their aggregate hue with RGB values, they don't actually 63 | /// have a proper Kelvin temperature. 64 | ///@{ 65 | WarmFluorescent=0xFFF4E5 /* 0 K, 255, 244, 229 */, 66 | StandardFluorescent=0xF4FFFA /* 0 K, 244, 255, 250 */, 67 | CoolWhiteFluorescent=0xD4EBFF /* 0 K, 212, 235, 255 */, 68 | FullSpectrumFluorescent=0xFFF4F2 /* 0 K, 255, 244, 242 */, 69 | GrowLightFluorescent=0xFFEFF7 /* 0 K, 255, 239, 247 */, 70 | BlackLightFluorescent=0xA700FF /* 0 K, 167, 0, 255 */, 71 | MercuryVapor=0xD8F7FF /* 0 K, 216, 247, 255 */, 72 | SodiumVapor=0xFFD1B2 /* 0 K, 255, 209, 178 */, 73 | MetalHalide=0xF2FCFF /* 0 K, 242, 252, 255 */, 74 | HighPressureSodium=0xFFB74C /* 0 K, 255, 183, 76 */, 75 | ///@} 76 | 77 | /// Uncorrected temperature 0xFFFFFF 78 | UncorrectedTemperature=0xFFFFFF 79 | } ColorTemperature; 80 | 81 | FASTLED_NAMESPACE_END 82 | 83 | ///@} 84 | #endif 85 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/nrf51/clockless_arm_nrf51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_NRF51 2 | #define __INC_CLOCKLESS_ARM_NRF51 3 | 4 | #if defined(NRF51) 5 | 6 | #include 7 | #define FASTLED_HAS_CLOCKLESS 1 8 | 9 | #if (FASTLED_ALLOW_INTERRUPTS==1) 10 | #define SEI_CHK LED_TIMER->CC[0] = (WAIT_TIME * (F_CPU/1000000)); LED_TIMER->TASKS_CLEAR; LED_TIMER->EVENTS_COMPARE[0] = 0; 11 | #define CLI_CHK cli(); if(LED_TIMER->EVENTS_COMPARE[0]) { LED_TIMER->TASKS_STOP = 1; return 0; } 12 | #define INNER_SEI sei(); 13 | #else 14 | #define SEI_CHK 15 | #define CLI_CHK 16 | #define INNER_SEI delaycycles<1>(); 17 | #endif 18 | 19 | 20 | #include "../common/m0clockless.h" 21 | template 22 | class ClocklessController : public CPixelLEDController { 23 | typedef typename FastPinBB::port_ptr_t data_ptr_t; 24 | typedef typename FastPinBB::port_t data_t; 25 | 26 | data_t mPinMask; 27 | data_ptr_t mPort; 28 | CMinWait mWait; 29 | public: 30 | virtual void init() { 31 | FastPinBB::setOutput(); 32 | mPinMask = FastPinBB::mask(); 33 | mPort = FastPinBB::port(); 34 | } 35 | 36 | virtual uint16_t getMaxRefreshRate() const { return 400; } 37 | 38 | virtual void showPixels(PixelController & pixels) { 39 | mWait.wait(); 40 | cli(); 41 | if(!showRGBInternal(pixels)) { 42 | sei(); delayMicroseconds(WAIT_TIME); cli(); 43 | showRGBInternal(pixels); 44 | } 45 | sei(); 46 | mWait.mark(); 47 | } 48 | 49 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 50 | // gcc will use register Y for the this pointer. 51 | static uint32_t showRGBInternal(PixelController pixels) { 52 | struct M0ClocklessData data; 53 | data.d[0] = pixels.d[0]; 54 | data.d[1] = pixels.d[1]; 55 | data.d[2] = pixels.d[2]; 56 | data.s[0] = pixels.mScale[0]; 57 | data.s[1] = pixels.mScale[1]; 58 | data.s[2] = pixels.mScale[2]; 59 | data.e[0] = pixels.e[0]; 60 | data.e[1] = pixels.e[1]; 61 | data.e[2] = pixels.e[2]; 62 | data.adj = pixels.mAdvance; 63 | 64 | typename FastPin::port_ptr_t portBase = FastPin::port(); 65 | 66 | // timer mode w/prescaler of 0 67 | LED_TIMER->MODE = TIMER_MODE_MODE_Timer; 68 | LED_TIMER->PRESCALER = 0; 69 | LED_TIMER->EVENTS_COMPARE[0] = 0; 70 | LED_TIMER->BITMODE = TIMER_BITMODE_BITMODE_16Bit; 71 | LED_TIMER->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk; 72 | LED_TIMER->TASKS_START = 1; 73 | 74 | int ret = showLedData<4,8,T1,T2,T3,RGB_ORDER,WAIT_TIME>(portBase, FastPin::mask(), pixels.mData, pixels.mLen, &data); 75 | 76 | LED_TIMER->TASKS_STOP = 1; 77 | return ret; // 0x00FFFFFF - _VAL; 78 | } 79 | }; 80 | 81 | 82 | #endif // NRF51 83 | #endif // __INC_CLOCKLESS_ARM_NRF51 84 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Pintest/Pintest.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | const char *getPort(void *portPtr) { 5 | #ifdef PORTA 6 | if(portPtr == (void*)&PORTA) { return "PORTA"; } 7 | #endif 8 | #ifdef PORTB 9 | if(portPtr == (void*)&PORTB) { return "PORTB"; } 10 | #endif 11 | #ifdef PORTC 12 | if(portPtr == (void*)&PORTC) { return "PORTC"; } 13 | #endif 14 | #ifdef PORTD 15 | if(portPtr == (void*)&PORTD) { return "PORTD"; } 16 | #endif 17 | #ifdef PORTE 18 | if(portPtr == (void*)&PORTE) { return "PORTE"; } 19 | #endif 20 | #ifdef PORTF 21 | if(portPtr == (void*)&PORTF) { return "PORTF"; } 22 | #endif 23 | #ifdef PORTG 24 | if(portPtr == (void*)&PORTG) { return "PORTG"; } 25 | #endif 26 | #ifdef PORTH 27 | if(portPtr == (void*)&PORTH) { return "PORTH"; } 28 | #endif 29 | #ifdef PORTI 30 | if(portPtr == (void*)&PORTI) { return "PORTI"; } 31 | #endif 32 | #ifdef PORTJ 33 | if(portPtr == (void*)&PORTJ) { return "PORTJ"; } 34 | #endif 35 | #ifdef PORTK 36 | if(portPtr == (void*)&PORTK) { return "PORTK"; } 37 | #endif 38 | #ifdef PORTL 39 | if(portPtr == (void*)&PORTL) { return "PORTL"; } 40 | #endif 41 | #ifdef GPIO_A_PDOR 42 | if(portPtr == (void*)&GPIO_A_PDOR) { return "GPIO_A_PDOR"; } 43 | #endif 44 | #ifdef GPIO_B_PDOR 45 | if(portPtr == (void*)&GPIO_B_PDOR) { return "GPIO_B_PDOR"; } 46 | #endif 47 | #ifdef GPIO_C_PDOR 48 | if(portPtr == (void*)&GPIO_C_PDOR) { return "GPIO_C_PDOR"; } 49 | #endif 50 | #ifdef GPIO_D_PDOR 51 | if(portPtr == (void*)&GPIO_D_PDOR) { return "GPIO_D_PDOR"; } 52 | #endif 53 | #ifdef GPIO_E_PDOR 54 | if(portPtr == (void*)&GPIO_E_PDOR) { return "GPIO_E_PDOR"; } 55 | #endif 56 | #ifdef REG_PIO_A_ODSR 57 | if(portPtr == (void*)®_PIO_A_ODSR) { return "REG_PIO_A_ODSR"; } 58 | #endif 59 | #ifdef REG_PIO_B_ODSR 60 | if(portPtr == (void*)®_PIO_B_ODSR) { return "REG_PIO_B_ODSR"; } 61 | #endif 62 | #ifdef REG_PIO_C_ODSR 63 | if(portPtr == (void*)®_PIO_C_ODSR) { return "REG_PIO_C_ODSR"; } 64 | #endif 65 | #ifdef REG_PIO_D_ODSR 66 | if(portPtr == (void*)®_PIO_D_ODSR) { return "REG_PIO_D_ODSR"; } 67 | #endif 68 | return "unknown"; 69 | } 70 | 71 | template void CheckPin() 72 | { 73 | CheckPin(); 74 | 75 | RwReg *systemThinksPortIs = portOutputRegister(digitalPinToPort(PIN)); 76 | RwReg systemThinksMaskIs = digitalPinToBitMask(PIN); 77 | 78 | Serial.print("Pin "); Serial.print(PIN); Serial.print(": Port "); 79 | 80 | if(systemThinksPortIs == FastPin::port()) { 81 | Serial.print("valid & mask "); 82 | } else { 83 | Serial.print("invalid, is "); Serial.print(getPort((void*)FastPin::port())); Serial.print(" should be "); 84 | Serial.print(getPort((void*)systemThinksPortIs)); 85 | Serial.print(" & mask "); 86 | } 87 | 88 | if(systemThinksMaskIs == FastPin::mask()) { 89 | Serial.println("valid."); 90 | } else { 91 | Serial.print("invalid, is "); Serial.print(FastPin::mask()); Serial.print(" should be "); Serial.println(systemThinksMaskIs); 92 | } 93 | } 94 | 95 | template<> void CheckPin<-1> () {} 96 | 97 | void setup() { 98 | Serial.begin(38400); 99 | Serial.println("resetting!"); 100 | } 101 | 102 | void loop() { 103 | CheckPin(); 104 | delay(10000); 105 | } 106 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/RGBCalibrate/RGBCalibrate.ino: -------------------------------------------------------------------------------- 1 | #include "FastLED.h" 2 | 3 | 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | // 6 | // RGB Calibration code 7 | // 8 | // Use this sketch to determine what the RGB ordering for your chipset should be. Steps for setting up to use: 9 | 10 | // * Uncomment the line in setup that corresponds to the LED chipset that you are using. (Note that they 11 | // all explicitly specify the RGB order as RGB) 12 | // * Define DATA_PIN to the pin that data is connected to. 13 | // * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin 14 | // * Compile/upload/run the sketch 15 | 16 | // You should see six leds on. If the RGB ordering is correct, you should see 1 red led, 2 green 17 | // leds, and 3 blue leds. If you see different colors, the count of each color tells you what the 18 | // position for that color in the rgb orering should be. So, for example, if you see 1 Blue, and 2 19 | // Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green). 20 | 21 | // You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering 22 | // and it should come out correctly, 1 red, 2 green, and 3 blue. 23 | // 24 | ////////////////////////////////////////////////// 25 | 26 | #define NUM_LEDS 6 27 | 28 | // Data pin that led data will be written out over 29 | #define DATA_PIN 6 30 | // Clock pin only needed for SPI based chipsets when not using hardware SPI 31 | //#define CLOCK_PIN 8 32 | 33 | CRGB leds[NUM_LEDS]; 34 | 35 | void setup() { 36 | // sanity check delay - allows reprogramming if accidently blowing power w/leds 37 | delay(2000); 38 | 39 | // Uncomment one of the following lines for your leds arrangement. 40 | // FastLED.addLeds(leds, NUM_LEDS); 41 | // FastLED.addLeds(leds, NUM_LEDS); 42 | // FastLED.addLeds(leds, NUM_LEDS); 43 | // FastLED.addLeds(leds, NUM_LEDS); 44 | // FastLED.addLeds(leds, NUM_LEDS); 45 | // FastLED.addLeds(leds, NUM_LEDS); 46 | // FastLED.setBrightness(CRGB(255,255,255)); 47 | // FastLED.addLeds(leds, NUM_LEDS); 48 | // FastLED.addLeds(leds, NUM_LEDS); 49 | // FastLED.addLeds(leds, NUM_LEDS); 50 | // FastLED.addLeds(leds, NUM_LEDS); 51 | 52 | // FastLED.addLeds(leds, NUM_LEDS); 53 | // FastLED.addLeds(leds, NUM_LEDS); 54 | // FastLED.addLeds(leds, NUM_LEDS); 55 | FastLED.addLeds(leds, NUM_LEDS); 56 | 57 | // FastLED.addLeds(leds, NUM_LEDS); 58 | // FastLED.addLeds(leds, NUM_LEDS); 59 | // FastLED.addLeds(leds, NUM_LEDS); 60 | } 61 | 62 | void loop() { 63 | leds[0] = CRGB(255,0,0); 64 | leds[1] = CRGB(0,255,0); 65 | leds[2] = CRGB(0,255,0); 66 | leds[3] = CRGB(0,0,255); 67 | leds[4] = CRGB(0,0,255); 68 | leds[5] = CRGB(0,0,255); 69 | leds[6] = CRGB(0,0,0); 70 | FastLED.show(); 71 | delay(1000); 72 | } -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/ColorTemperature/ColorTemperature.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LED_PIN 3 4 | 5 | // Information about the LED strip itself 6 | #define NUM_LEDS 60 7 | #define CHIPSET WS2811 8 | #define COLOR_ORDER GRB 9 | CRGB leds[NUM_LEDS]; 10 | 11 | #define BRIGHTNESS 128 12 | 13 | 14 | // FastLED v2.1 provides two color-management controls: 15 | // (1) color correction settings for each LED strip, and 16 | // (2) master control of the overall output 'color temperature' 17 | // 18 | // THIS EXAMPLE demonstrates the second, "color temperature" control. 19 | // It shows a simple rainbow animation first with one temperature profile, 20 | // and a few seconds later, with a different temperature profile. 21 | // 22 | // The first pixel of the strip will show the color temperature. 23 | // 24 | // HELPFUL HINTS for "seeing" the effect in this demo: 25 | // * Don't look directly at the LED pixels. Shine the LEDs aganst 26 | // a white wall, table, or piece of paper, and look at the reflected light. 27 | // 28 | // * If you watch it for a bit, and then walk away, and then come back 29 | // to it, you'll probably be able to "see" whether it's currently using 30 | // the 'redder' or the 'bluer' temperature profile, even not counting 31 | // the lowest 'indicator' pixel. 32 | // 33 | // 34 | // FastLED provides these pre-conigured incandescent color profiles: 35 | // Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc, 36 | // HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky, 37 | // FastLED provides these pre-configured gaseous-light color profiles: 38 | // WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent, 39 | // FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent, 40 | // MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium, 41 | // FastLED also provides an "Uncorrected temperature" profile 42 | // UncorrectedTemperature; 43 | 44 | #define TEMPERATURE_1 Tungsten100W 45 | #define TEMPERATURE_2 OvercastSky 46 | 47 | // How many seconds to show each temperature before switching 48 | #define DISPLAYTIME 20 49 | // How many seconds to show black between switches 50 | #define BLACKTIME 3 51 | 52 | void loop() 53 | { 54 | // draw a generic, no-name rainbow 55 | static uint8_t starthue = 0; 56 | fill_rainbow( leds + 5, NUM_LEDS - 5, --starthue, 20); 57 | 58 | // Choose which 'color temperature' profile to enable. 59 | uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2); 60 | if( secs < DISPLAYTIME) { 61 | FastLED.setTemperature( TEMPERATURE_1 ); // first temperature 62 | leds[0] = TEMPERATURE_1; // show indicator pixel 63 | } else { 64 | FastLED.setTemperature( TEMPERATURE_2 ); // second temperature 65 | leds[0] = TEMPERATURE_2; // show indicator pixel 66 | } 67 | 68 | // Black out the LEDs for a few secnds between color changes 69 | // to let the eyes and brains adjust 70 | if( (secs % DISPLAYTIME) < BLACKTIME) { 71 | memset8( leds, 0, NUM_LEDS * sizeof(CRGB)); 72 | } 73 | 74 | FastLED.show(); 75 | FastLED.delay(8); 76 | } 77 | 78 | void setup() { 79 | delay( 3000 ); // power-up safety delay 80 | // It's important to set the color correction for your LED strip here, 81 | // so that colors can be more accurately rendered through the 'temperature' profiles 82 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalSMD5050 ); 83 | FastLED.setBrightness( BRIGHTNESS ); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/fastspi_ref.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTSPI_ARM_SAM_H 2 | #define __INC_FASTSPI_ARM_SAM_H 3 | 4 | #if 0 // guard against the arduino ide idiotically including every header file 5 | #include "FastLED.h" 6 | 7 | FASTLED_NAMESPACE_BEGIN 8 | 9 | // A skeletal implementation of hardware SPI support. Fill in the necessary code for init, waiting, and writing. The rest of 10 | // the method implementations should provide a starting point, even if not hte most efficient to start with 11 | template 12 | class REFHardwareSPIOutput { 13 | Selectable *m_pSelect; 14 | public: 15 | SAMHardwareSPIOutput() { m_pSelect = NULL; } 16 | SAMHArdwareSPIOutput(Selectable *pSelect) { m_pSelect = pSelect; } 17 | 18 | // set the object representing the selectable 19 | void setSelect(Selectable *pSelect) { /* TODO */ } 20 | 21 | // initialize the SPI subssytem 22 | void init() { /* TODO */ } 23 | 24 | // latch the CS select 25 | void inline select() __attribute__((always_inline)) { if(m_pSelect != NULL) { m_pSelect->select(); } } 26 | 27 | // release the CS select 28 | void inline release() __attribute__((always_inline)) { if(m_pSelect != NULL) { m_pSelect->release(); } } 29 | 30 | // wait until all queued up data has been written 31 | static void waitFully() { /* TODO */ } 32 | 33 | // write a byte out via SPI (returns immediately on writing register) 34 | static void writeByte(uint8_t b) { /* TODO */ } 35 | 36 | // write a word out via SPI (returns immediately on writing register) 37 | static void writeWord(uint16_t w) { /* TODO */ } 38 | 39 | // A raw set of writing byte values, assumes setup/init/waiting done elsewhere 40 | static void writeBytesValueRaw(uint8_t value, int len) { 41 | while(len--) { writeByte(value); } 42 | } 43 | 44 | // A full cycle of writing a value for len bytes, including select, release, and waiting 45 | void writeBytesValue(uint8_t value, int len) { 46 | select(); writeBytesValueRaw(value, len); release(); 47 | } 48 | 49 | // A full cycle of writing a value for len bytes, including select, release, and waiting 50 | template void writeBytes(register uint8_t *data, int len) { 51 | uint8_t *end = data + len; 52 | select(); 53 | // could be optimized to write 16bit words out instead of 8bit bytes 54 | while(data != end) { 55 | writeByte(D::adjust(*data++)); 56 | } 57 | D::postBlock(len); 58 | waitFully(); 59 | release(); 60 | } 61 | 62 | // A full cycle of writing a value for len bytes, including select, release, and waiting 63 | void writeBytes(register uint8_t *data, int len) { writeBytes(data, len); } 64 | 65 | // write a single bit out, which bit from the passed in byte is determined by template parameter 66 | template inline static void writeBit(uint8_t b) { /* TODO */ } 67 | 68 | // write a block of uint8_ts out in groups of three. len is the total number of uint8_ts to write out. The template 69 | // parameters indicate how many uint8_ts to skip at the beginning and/or end of each grouping 70 | template void writePixels(PixelController pixels) { 71 | select(); 72 | while(data != end) { 73 | if(FLAGS & FLAG_START_BIT) { 74 | writeBit<0>(1); 75 | } 76 | writeByte(D::adjust(pixels.loadAndScale0())); 77 | writeByte(D::adjust(pixels.loadAndScale1())); 78 | writeByte(D::adjust(pixels.loadAndScale2())); 79 | 80 | pixels.advanceData(); 81 | pixels.stepDithering(); 82 | data += (3+skip); 83 | } 84 | D::postBlock(len); 85 | release(); 86 | } 87 | 88 | }; 89 | 90 | FASTLED_NAMESPACE_END 91 | 92 | #endif 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/FirstLight/FirstLight.ino: -------------------------------------------------------------------------------- 1 | // Use if you want to force the software SPI subsystem to be used for some reason (generally, you don't) 2 | // #define FASTLED_FORCE_SOFTWARE_SPI 3 | // Use if you want to force non-accelerated pin access (hint: you really don't, it breaks lots of things) 4 | // #define FASTLED_FORCE_SOFTWARE_SPI 5 | // #define FASTLED_FORCE_SOFTWARE_PINS 6 | #include 7 | 8 | /////////////////////////////////////////////////////////////////////////////////////////// 9 | // 10 | // Move a white dot along the strip of leds. This program simply shows how to configure the leds, 11 | // and then how to turn a single pixel white and then off, moving down the line of pixels. 12 | // 13 | 14 | // How many leds are in the strip? 15 | #define NUM_LEDS 60 16 | 17 | // Data pin that led data will be written out over 18 | #define DATA_PIN 3 19 | 20 | // Clock pin only needed for SPI based chipsets when not using hardware SPI 21 | //#define CLOCK_PIN 8 22 | 23 | // This is an array of leds. One item for each led in your strip. 24 | CRGB leds[NUM_LEDS]; 25 | 26 | // This function sets up the ledsand tells the controller about them 27 | void setup() { 28 | // sanity check delay - allows reprogramming if accidently blowing power w/leds 29 | delay(2000); 30 | 31 | // Uncomment one of the following lines for your leds arrangement. 32 | // FastLED.addLeds(leds, NUM_LEDS); 33 | // FastLED.addLeds(leds, NUM_LEDS); 34 | // FastLED.addLeds(leds, NUM_LEDS); 35 | FastLED.addLeds(leds, NUM_LEDS); 36 | // FastLED.addLeds(leds, NUM_LEDS); 37 | // FastLED.addLeds(leds, NUM_LEDS); 38 | // FastLED.addLeds(leds, NUM_LEDS); 39 | // FastLED.addLeds(leds, NUM_LEDS); 40 | // FastLED.addLeds(leds, NUM_LEDS); 41 | // FastLED.addLeds(leds, NUM_LEDS); 42 | // FastLED.addLeds(leds, NUM_LEDS); 43 | // FastLED.addLeds(leds, NUM_LEDS); 44 | // FastLED.addLeds(leds, NUM_LEDS); 45 | 46 | // FastLED.addLeds(leds, NUM_LEDS); 47 | // FastLED.addLeds(leds, NUM_LEDS); 48 | // FastLED.addLeds(leds, NUM_LEDS); 49 | // FastLED.addLeds(leds, NUM_LEDS); 50 | // FastLED.addLeds(leds, NUM_LEDS); 51 | // FastLED.addLeds(leds, NUM_LEDS); 52 | 53 | // FastLED.addLeds(leds, NUM_LEDS); 54 | // FastLED.addLeds(leds, NUM_LEDS); 55 | // FastLED.addLeds(leds, NUM_LEDS); 56 | // FastLED.addLeds(leds, NUM_LEDS); 57 | // FastLED.addLeds(leds, NUM_LEDS); 58 | // FastLED.addLeds(leds, NUM_LEDS); 59 | } 60 | 61 | // This function runs over and over, and is where you do the magic to light 62 | // your leds. 63 | void loop() { 64 | // Move a single white led 65 | for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) { 66 | // Turn our current led on to white, then show the leds 67 | leds[whiteLed] = CRGB::White; 68 | 69 | // Show the leds (only one of which is set to white, from above) 70 | FastLED.show(); 71 | 72 | // Wait a little bit 73 | delay(100); 74 | 75 | // Turn our current led back to black for the next loop around 76 | leds[whiteLed] = CRGB::Black; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Noise/Noise.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // 4 | // Mark's xy coordinate mapping code. See the XYMatrix for more information on it. 5 | // 6 | 7 | // Params for width and height 8 | const uint8_t kMatrixWidth = 16; 9 | const uint8_t kMatrixHeight = 16; 10 | #define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight) 11 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 12 | // Param for different pixel layouts 13 | const bool kMatrixSerpentineLayout = true; 14 | 15 | 16 | uint16_t XY( uint8_t x, uint8_t y) 17 | { 18 | uint16_t i; 19 | 20 | if( kMatrixSerpentineLayout == false) { 21 | i = (y * kMatrixWidth) + x; 22 | } 23 | 24 | if( kMatrixSerpentineLayout == true) { 25 | if( y & 0x01) { 26 | // Odd rows run backwards 27 | uint8_t reverseX = (kMatrixWidth - 1) - x; 28 | i = (y * kMatrixWidth) + reverseX; 29 | } else { 30 | // Even rows run forwards 31 | i = (y * kMatrixWidth) + x; 32 | } 33 | } 34 | 35 | return i; 36 | } 37 | 38 | // The leds 39 | CRGB leds[kMatrixWidth * kMatrixHeight]; 40 | 41 | // The 32bit version of our coordinates 42 | static uint16_t x; 43 | static uint16_t y; 44 | static uint16_t z; 45 | 46 | // We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll 47 | // use the z-axis for "time". speed determines how fast time moves forward. Try 48 | // 1 for a very slow moving effect, or 60 for something that ends up looking like 49 | // water. 50 | // uint16_t speed = 1; // almost looks like a painting, moves very slowly 51 | uint16_t speed = 20; // a nice starting speed, mixes well with a scale of 100 52 | // uint16_t speed = 33; 53 | // uint16_t speed = 100; // wicked fast! 54 | 55 | // Scale determines how far apart the pixels in our noise matrix are. Try 56 | // changing these values around to see how it affects the motion of the display. The 57 | // higher the value of scale, the more "zoomed out" the noise iwll be. A value 58 | // of 1 will be so zoomed in, you'll mostly see solid colors. 59 | 60 | // uint16_t scale = 1; // mostly just solid colors 61 | // uint16_t scale = 4011; // very zoomed out and shimmery 62 | uint16_t scale = 311; 63 | 64 | // This is the array that we keep our computed noise values in 65 | uint8_t noise[MAX_DIMENSION][MAX_DIMENSION]; 66 | 67 | void setup() { 68 | // uncomment the following lines if you want to see FPS count information 69 | // Serial.begin(38400); 70 | // Serial.println("resetting!"); 71 | delay(3000); 72 | LEDS.addLeds(leds,NUM_LEDS); 73 | LEDS.setBrightness(96); 74 | 75 | // Initialize our coordinates to some random values 76 | x = random16(); 77 | y = random16(); 78 | z = random16(); 79 | } 80 | 81 | // Fill the x/y array of 8-bit noise values using the inoise8 function. 82 | void fillnoise8() { 83 | for(int i = 0; i < MAX_DIMENSION; i++) { 84 | int ioffset = scale * i; 85 | for(int j = 0; j < MAX_DIMENSION; j++) { 86 | int joffset = scale * j; 87 | noise[i][j] = inoise8(x + ioffset,y + joffset,z); 88 | } 89 | } 90 | z += speed; 91 | } 92 | 93 | 94 | void loop() { 95 | static uint8_t ihue=0; 96 | fillnoise8(); 97 | for(int i = 0; i < kMatrixWidth; i++) { 98 | for(int j = 0; j < kMatrixHeight; j++) { 99 | // We use the value at the (i,j) coordinate in the noise 100 | // array for our brightness, and the flipped value from (j,i) 101 | // for our pixel's hue. 102 | leds[XY(i,j)] = CHSV(noise[j][i],255,noise[i][j]); 103 | 104 | // You can also explore other ways to constrain the hue used, like below 105 | // leds[XY(i,j)] = CHSV(ihue + (noise[j][i]>>2),255,noise[i][j]); 106 | } 107 | } 108 | ihue+=1; 109 | 110 | LEDS.show(); 111 | // delay(10); 112 | } 113 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Fire2012/Fire2012.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LED_PIN 5 4 | #define COLOR_ORDER GRB 5 | #define CHIPSET WS2811 6 | #define NUM_LEDS 30 7 | 8 | #define BRIGHTNESS 200 9 | #define FRAMES_PER_SECOND 60 10 | 11 | bool gReverseDirection = false; 12 | 13 | CRGB leds[NUM_LEDS]; 14 | 15 | void setup() { 16 | delay(3000); // sanity delay 17 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); 18 | FastLED.setBrightness( BRIGHTNESS ); 19 | } 20 | 21 | void loop() 22 | { 23 | // Add entropy to random number generator; we use a lot of it. 24 | // random16_add_entropy( random()); 25 | 26 | Fire2012(); // run simulation frame 27 | 28 | FastLED.show(); // display this frame 29 | FastLED.delay(1000 / FRAMES_PER_SECOND); 30 | } 31 | 32 | 33 | // Fire2012 by Mark Kriegsman, July 2012 34 | // as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY 35 | //// 36 | // This basic one-dimensional 'fire' simulation works roughly as follows: 37 | // There's a underlying array of 'heat' cells, that model the temperature 38 | // at each point along the line. Every cycle through the simulation, 39 | // four steps are performed: 40 | // 1) All cells cool down a little bit, losing heat to the air 41 | // 2) The heat from each cell drifts 'up' and diffuses a little 42 | // 3) Sometimes randomly new 'sparks' of heat are added at the bottom 43 | // 4) The heat from each cell is rendered as a color into the leds array 44 | // The heat-to-color mapping uses a black-body radiation approximation. 45 | // 46 | // Temperature is in arbitrary units from 0 (cold black) to 255 (white hot). 47 | // 48 | // This simulation scales it self a bit depending on NUM_LEDS; it should look 49 | // "OK" on anywhere from 20 to 100 LEDs without too much tweaking. 50 | // 51 | // I recommend running this simulation at anywhere from 30-100 frames per second, 52 | // meaning an interframe delay of about 10-35 milliseconds. 53 | // 54 | // Looks best on a high-density LED setup (60+ pixels/meter). 55 | // 56 | // 57 | // There are two main parameters you can play with to control the look and 58 | // feel of your fire: COOLING (used in step 1 above), and SPARKING (used 59 | // in step 3 above). 60 | // 61 | // COOLING: How much does the air cool as it rises? 62 | // Less cooling = taller flames. More cooling = shorter flames. 63 | // Default 50, suggested range 20-100 64 | #define COOLING 55 65 | 66 | // SPARKING: What chance (out of 255) is there that a new spark will be lit? 67 | // Higher chance = more roaring fire. Lower chance = more flickery fire. 68 | // Default 120, suggested range 50-200. 69 | #define SPARKING 120 70 | 71 | 72 | void Fire2012() 73 | { 74 | // Array of temperature readings at each simulation cell 75 | static byte heat[NUM_LEDS]; 76 | 77 | // Step 1. Cool down every cell a little 78 | for( int i = 0; i < NUM_LEDS; i++) { 79 | heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); 80 | } 81 | 82 | // Step 2. Heat from each cell drifts 'up' and diffuses a little 83 | for( int k= NUM_LEDS - 1; k >= 2; k--) { 84 | heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; 85 | } 86 | 87 | // Step 3. Randomly ignite new 'sparks' of heat near the bottom 88 | if( random8() < SPARKING ) { 89 | int y = random8(7); 90 | heat[y] = qadd8( heat[y], random8(160,255) ); 91 | } 92 | 93 | // Step 4. Map from heat cells to LED colors 94 | for( int j = 0; j < NUM_LEDS; j++) { 95 | CRGB color = HeatColor( heat[j]); 96 | int pixelnumber; 97 | if( gReverseDirection ) { 98 | pixelnumber = (NUM_LEDS-1) - j; 99 | } else { 100 | pixelnumber = j; 101 | } 102 | leds[pixelnumber] = color; 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/fastled_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_CONFIG_H 2 | #define __INC_FASTLED_CONFIG_H 3 | 4 | #include "FastLED.h" 5 | 6 | ///@file fastled_config.h 7 | /// contains definitions that can be used to configure FastLED at compile time 8 | 9 | // Use this option only for debugging pin access and forcing software pin access. Note that 10 | // software pin access only works in Arduino based environments. Forces use of digitalWrite 11 | // methods for pin access vs. direct hardware port access 12 | // #define FASTLED_FORCE_SOFTWARE_PINS 13 | 14 | // Use this option only for debugging bitbang'd spi access or to work around bugs in hardware 15 | // spi access. Forces use of bit-banged spi, even on pins that has hardware SPI available. 16 | // #define FASTLED_FORCE_SOFTWARE_SPI 17 | 18 | // Use this to force FastLED to allow interrupts in the clockless chipsets (or to force it to 19 | // disallow), overriding the default on platforms that support this. Set the value to 1 to 20 | // allow interrupts or 0 to disallow them. 21 | #define FASTLED_ALLOW_INTERRUPTS 1 22 | // #define FASTLED_ALLOW_INTERRUPTS 0 23 | 24 | // Use this to allow some integer overflows/underflows in the inoise functions. 25 | // The original implementions allowed this, and had some discontinuties in the noise 26 | // output. It's technically an implementation bug, and was fixed, but you may wish 27 | // to preserve the old look and feel of the inoise functions in your existing animations. 28 | // The default is 0: NO overflow, and 'continuous' noise output, aka the fixed way. 29 | // #define FASTLED_NOISE_ALLOW_AVERAGE_TO_OVERFLOW 0 30 | // #define FASTLED_NOISE_ALLOW_AVERAGE_TO_OVERFLOW 1 31 | 32 | // Use this toggle whether or not to use the 'fixed' FastLED scale8. The initial scale8 33 | // had a problem where scale8(255,255) would give you 254. This is now fixed, and that 34 | // fix is enabled by default. However, if for some reason you have code that is not 35 | // working right as a result of this (e.g. code that was expecting the old scale8 behavior) 36 | // you can disable it here. 37 | #define FASTLED_SCALE8_FIXED 1 38 | // #define FASTLED_SCALE8_FIXED 0 39 | 40 | // Use this toggle whether to use 'fixed' FastLED pixel blending, including ColorFromPalette. 41 | // The prior pixel blend functions had integer-rounding math errors that led to 42 | // small errors being inadvertently added to the low bits of blended colors, including colors 43 | // retrieved from color palettes using LINEAR_BLEND. This is now fixed, and the 44 | // fix is enabled by default. However, if for some reason you wish to run with the old 45 | // blending, including the integer rounding and color errors, you can disable the bugfix here. 46 | #define FASTLED_BLEND_FIXED 1 47 | // #define FASTLED_BLEND_FIXED 0 48 | 49 | // Use this toggle whether to use 'fixed' FastLED 8- and 16-bit noise functions. 50 | // The prior noise functions had some math errors that led to 'discontinuities' in the 51 | // output, which by definition should be smooth and continuous. The bug led to 52 | // noise function output that had 'edges' and glitches in it. This is now fixed, and the 53 | // fix is enabled by default. However, if for some reason you wish to run with the old 54 | // noise code, including the glitches, you can disable the bugfix here. 55 | #define FASTLED_NOISE_FIXED 1 56 | //#define FASTLED_NOISE_FIXED 0 57 | 58 | // Use this to determine how many times FastLED will attempt to re-transmit a frame if interrupted 59 | // for too long by interrupts. 60 | #ifndef FASTLED_INTERRUPT_RETRY_COUNT 61 | #define FASTLED_INTERRUPT_RETRY_COUNT 2 62 | #endif 63 | 64 | // Use this toggle to enable global brightness in contollers that support is (ADA102 and SK9822). 65 | // It changes how color scaling works and uses global brightness before scaling down color values. 66 | // This enable much more accurate color control on low brightness settings. 67 | //#define FASTLED_USE_GLOBAL_BRIGHTNESS 1 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/hsv2rgb.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_HSV2RGB_H 2 | #define __INC_HSV2RGB_H 3 | 4 | #include "FastLED.h" 5 | 6 | #include "pixeltypes.h" 7 | 8 | FASTLED_NAMESPACE_BEGIN 9 | 10 | // hsv2rgb_rainbow - convert a hue, saturation, and value to RGB 11 | // using a visually balanced rainbow (vs a straight 12 | // mathematical spectrum). 13 | // This 'rainbow' yields better yellow and orange 14 | // than a straight 'spectrum'. 15 | // 16 | // NOTE: here hue is 0-255, not just 0-191 17 | 18 | void hsv2rgb_rainbow( const struct CHSV& hsv, struct CRGB& rgb); 19 | void hsv2rgb_rainbow( const struct CHSV* phsv, struct CRGB * prgb, int numLeds); 20 | #define HUE_MAX_RAINBOW 255 21 | 22 | 23 | // hsv2rgb_spectrum - convert a hue, saturation, and value to RGB 24 | // using a mathematically straight spectrum (vs 25 | // a visually balanced rainbow). 26 | // This 'spectrum' will have more green & blue 27 | // than a 'rainbow', and less yellow and orange. 28 | // 29 | // NOTE: here hue is 0-255, not just 0-191 30 | 31 | void hsv2rgb_spectrum( const struct CHSV& hsv, struct CRGB& rgb); 32 | void hsv2rgb_spectrum( const struct CHSV* phsv, struct CRGB * prgb, int numLeds); 33 | #define HUE_MAX_SPECTRUM 255 34 | 35 | 36 | // hsv2rgb_raw - convert hue, saturation, and value to RGB. 37 | // This 'spectrum' conversion will be more green & blue 38 | // than a real 'rainbow', and the hue is specified just 39 | // in the range 0-191. Together, these result in a 40 | // slightly faster conversion speed, at the expense of 41 | // color balance. 42 | // 43 | // NOTE: Hue is 0-191 only! 44 | // Saturation & value are 0-255 each. 45 | // 46 | 47 | void hsv2rgb_raw(const struct CHSV& hsv, struct CRGB & rgb); 48 | void hsv2rgb_raw(const struct CHSV* phsv, struct CRGB * prgb, int numLeds); 49 | #define HUE_MAX 191 50 | 51 | 52 | // rgb2hsv_approximate - recover _approximate_ HSV values from RGB. 53 | // 54 | // NOTE 1: This function is a long-term work in process; expect 55 | // results to change slightly over time as this function is 56 | // refined and improved. 57 | // 58 | // NOTE 2: This function is most accurate when the input is an 59 | // RGB color that came from a fully-saturated HSV color to start 60 | // with. E.g. CHSV( hue, 255, 255) -> CRGB -> CHSV will give 61 | // best results. 62 | // 63 | // NOTE 3: This function is not nearly as fast as HSV-to-RGB. 64 | // It is provided for those situations when the need for this 65 | // function cannot be avoided, or when extremely high performance 66 | // is not needed. 67 | // 68 | // NOTE 4: Why is this 'only' an "approximation"? 69 | // Not all RGB colors have HSV equivalents! For example, there 70 | // is no HSV value that will ever convert to RGB(255,255,0) using 71 | // the code provided in this library. So if you try to 72 | // convert RGB(255,255,0) 'back' to HSV, you'll necessarily get 73 | // only an approximation. Emphasis has been placed on getting 74 | // the 'hue' as close as usefully possible, but even that's a bit 75 | // of a challenge. The 8-bit HSV and 8-bit RGB color spaces 76 | // are not a "bijection". 77 | // 78 | // Nevertheless, this function does a pretty good job, particularly 79 | // at recovering the 'hue' from fully saturated RGB colors that 80 | // originally came from HSV rainbow colors. So if you start 81 | // with CHSV(hue_in,255,255), and convert that to RGB, and then 82 | // convert it back to HSV using this function, the resulting output 83 | // hue will either exactly the same, or very close (+/-1). 84 | // The more desaturated the original RGB color is, the rougher the 85 | // approximation, and the less accurate the results. 86 | // 87 | CHSV rgb2hsv_approximate( const CRGB& rgb); 88 | 89 | FASTLED_NAMESPACE_END 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/power_mgt.h: -------------------------------------------------------------------------------- 1 | #ifndef POWER_MGT_H 2 | #define POWER_MGT_H 3 | 4 | #include "FastLED.h" 5 | 6 | #include "pixeltypes.h" 7 | 8 | FASTLED_NAMESPACE_BEGIN 9 | 10 | ///@defgroup Power Power management functions 11 | /// functions used to limit the amount of power used by FastLED 12 | ///@{ 13 | 14 | // Power Control setup functions 15 | // 16 | // Example: 17 | // set_max_power_in_volts_and_milliamps( 5, 400); 18 | // 19 | 20 | /// Set the maximum power used in milliamps for a given voltage 21 | /// @deprecated - use FastLED.setMaxPowerInVoltsAndMilliamps() 22 | void set_max_power_in_volts_and_milliamps( uint8_t volts, uint32_t milliamps); 23 | /// Set the maximum power used in watts 24 | void set_max_power_in_milliwatts( uint32_t powerInmW); 25 | 26 | /// Select a ping with an led that will be flashed to indicate that power management 27 | /// is pulling down the brightness 28 | /// @deprecated - use FastLED.setMaxPowerInMilliWatts 29 | void set_max_power_indicator_LED( uint8_t pinNumber); // zero = no indicator LED 30 | 31 | 32 | // Power Control 'show' and 'delay' functions 33 | // 34 | // These are drop-in replacements for FastLED.show() and FastLED.delay() 35 | // In order to use these, you have to actually replace your calls to 36 | // FastLED.show() and FastLED.delay() with these two functions. 37 | // 38 | // Example: 39 | // // was: FastLED.show(); 40 | // // now is: 41 | // show_at_max_brightness_for_power(); 42 | // 43 | 44 | /// Similar to FastLED.show, but pre-adjusts brightness to keep below the power 45 | /// threshold. 46 | /// @deprecated this has now been moved to FastLED.show(); 47 | void show_at_max_brightness_for_power(); 48 | /// Similar to FastLED.delay, but pre-adjusts brightness to keep below the power 49 | /// threshold. 50 | /// @deprecated this has now been rolled into FastLED.delay(); 51 | void delay_at_max_brightness_for_power( uint16_t ms); 52 | 53 | 54 | // Power Control internal helper functions 55 | 56 | /// calculate_unscaled_power_mW tells you how many milliwatts the current 57 | /// LED data would draw at brightness = 255. 58 | /// 59 | uint32_t calculate_unscaled_power_mW( const CRGB* ledbuffer, uint16_t numLeds); 60 | 61 | /// calculate_max_brightness_for_power_mW tells you the highest brightness 62 | /// level you can use and still stay under the specified power budget for 63 | /// a given set of leds. It takes a pointer to an array of CRGB objects, a 64 | /// count, a 'target brightness' which is the brightness you'd ideally like 65 | /// to use, and the max power draw desired in milliwatts. The result from 66 | /// this function will be no higher than the target_brightess you supply, but may be lower. 67 | uint8_t calculate_max_brightness_for_power_mW(const CRGB* ledbuffer, uint16_t numLeds, uint8_t target_brightness, uint32_t max_power_mW); 68 | 69 | /// calculate_max_brightness_for_power_mW tells you the highest brightness 70 | /// level you can use and still stay under the specified power budget for 71 | /// a given set of leds. It takes a pointer to an array of CRGB objects, a 72 | /// count, a 'target brightness' which is the brightness you'd ideally like 73 | /// to use, and the max power in volts and milliamps. The result from this 74 | /// function will be no higher than the target_brightess you supply, but may be lower. 75 | uint8_t calculate_max_brightness_for_power_vmA(const CRGB* ledbuffer, uint16_t numLeds, uint8_t target_brightness, uint32_t max_power_V, uint32_t max_power_mA); 76 | 77 | /// calculate_max_brightness_for_power_mW tells you the highest brightness 78 | /// level you can use and still stay under the specified power budget. It 79 | /// takes a 'target brightness' which is the brightness you'd ideally like 80 | /// to use. The result from this function will be no higher than the 81 | /// target_brightess you supply, but may be lower. 82 | uint8_t calculate_max_brightness_for_power_mW( uint8_t target_brightness, uint32_t max_power_mW); 83 | 84 | FASTLED_NAMESPACE_END 85 | ///@} 86 | // POWER_MGT_H 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/esp/8266/clockless_esp8266.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | FASTLED_NAMESPACE_BEGIN 4 | 5 | #ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES 6 | extern uint32_t _frame_cnt; 7 | extern uint32_t _retry_cnt; 8 | #endif 9 | 10 | // Info on reading cycle counter from https://github.com/kbeckmann/nodemcu-firmware/blob/ws2812-dual/app/modules/ws2812.c 11 | __attribute__ ((always_inline)) inline static uint32_t __clock_cycles() { 12 | uint32_t cyc; 13 | __asm__ __volatile__ ("rsr %0,ccount":"=a" (cyc)); 14 | return cyc; 15 | } 16 | 17 | #define FASTLED_HAS_CLOCKLESS 1 18 | 19 | template 20 | class ClocklessController : public CPixelLEDController { 21 | typedef typename FastPin::port_ptr_t data_ptr_t; 22 | typedef typename FastPin::port_t data_t; 23 | 24 | data_t mPinMask; 25 | data_ptr_t mPort; 26 | CMinWait mWait; 27 | public: 28 | virtual void init() { 29 | FastPin::setOutput(); 30 | mPinMask = FastPin::mask(); 31 | mPort = FastPin::port(); 32 | } 33 | 34 | virtual uint16_t getMaxRefreshRate() const { return 400; } 35 | 36 | protected: 37 | 38 | virtual void showPixels(PixelController & pixels) { 39 | // mWait.wait(); 40 | int cnt = FASTLED_INTERRUPT_RETRY_COUNT; 41 | while((showRGBInternal(pixels)==0) && cnt--) { 42 | #ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES 43 | _retry_cnt++; 44 | #endif 45 | os_intr_unlock(); 46 | delayMicroseconds(WAIT_TIME); 47 | os_intr_lock(); 48 | } 49 | // mWait.mark(); 50 | } 51 | 52 | #define _ESP_ADJ (0) 53 | #define _ESP_ADJ2 (0) 54 | 55 | template __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & last_mark, register uint32_t b) { 56 | b <<= 24; b = ~b; 57 | for(register uint32_t i = BITS; i > 0; i--) { 58 | while((__clock_cycles() - last_mark) < (T1+T2+T3)); 59 | last_mark = __clock_cycles(); 60 | FastPin::hi(); 61 | 62 | while((__clock_cycles() - last_mark) < T1); 63 | if(b & 0x80000000L) { FastPin::lo(); } 64 | b <<= 1; 65 | 66 | while((__clock_cycles() - last_mark) < (T1+T2)); 67 | FastPin::lo(); 68 | } 69 | } 70 | 71 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 72 | // gcc will use register Y for the this pointer. 73 | static uint32_t ICACHE_RAM_ATTR showRGBInternal(PixelController pixels) { 74 | // Setup the pixel controller and load/scale the first byte 75 | pixels.preStepFirstByteDithering(); 76 | register uint32_t b = pixels.loadAndScale0(); 77 | pixels.preStepFirstByteDithering(); 78 | os_intr_lock(); 79 | uint32_t start = __clock_cycles(); 80 | uint32_t last_mark = start; 81 | while(pixels.has(1)) { 82 | // Write first byte, read next byte 83 | writeBits<8+XTRA0>(last_mark, b); 84 | b = pixels.loadAndScale1(); 85 | 86 | // Write second byte, read 3rd byte 87 | writeBits<8+XTRA0>(last_mark, b); 88 | b = pixels.loadAndScale2(); 89 | 90 | // Write third byte, read 1st byte of next pixel 91 | writeBits<8+XTRA0>(last_mark, b); 92 | b = pixels.advanceAndLoadAndScale0(); 93 | 94 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 95 | os_intr_unlock(); 96 | #endif 97 | 98 | pixels.stepDithering(); 99 | 100 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 101 | os_intr_lock(); 102 | // if interrupts took longer than 45µs, punt on the current frame 103 | if((int32_t)(__clock_cycles()-last_mark) > 0) { 104 | if((int32_t)(__clock_cycles()-last_mark) > (T1+T2+T3+((WAIT_TIME-INTERRUPT_THRESHOLD)*CLKS_PER_US))) { sei(); return 0; } 105 | } 106 | #endif 107 | }; 108 | 109 | os_intr_unlock(); 110 | #ifdef FASTLED_DEBUG_COUNT_FRAME_RETRIES 111 | _frame_cnt++; 112 | #endif 113 | return __clock_cycles() - start; 114 | } 115 | }; 116 | 117 | FASTLED_NAMESPACE_END 118 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/esp/32/fastpin_esp32.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | FASTLED_NAMESPACE_BEGIN 4 | 5 | template class _ESPPIN { 6 | 7 | public: 8 | typedef volatile uint32_t * port_ptr_t; 9 | typedef uint32_t port_t; 10 | 11 | inline static void setOutput() { pinMode(PIN, OUTPUT); } 12 | inline static void setInput() { pinMode(PIN, INPUT); } 13 | 14 | inline static void hi() __attribute__ ((always_inline)) { 15 | if (PIN < 32) GPIO.out_w1ts = MASK; 16 | else GPIO.out1_w1ts.val = MASK; 17 | } 18 | 19 | inline static void lo() __attribute__ ((always_inline)) { 20 | if (PIN < 32) GPIO.out_w1tc = MASK; 21 | else GPIO.out1_w1tc.val = MASK; 22 | } 23 | 24 | inline static void set(register port_t val) __attribute__ ((always_inline)) { 25 | if (PIN < 32) GPIO.out = val; 26 | else GPIO.out1.val = val; 27 | } 28 | 29 | inline static void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); } 30 | 31 | inline static void toggle() __attribute__ ((always_inline)) { 32 | if(PIN < 32) { GPIO.out ^= MASK; } 33 | else { GPIO.out1.val ^=MASK; } 34 | } 35 | 36 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { hi(); } 37 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { lo(); } 38 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } 39 | 40 | inline static port_t hival() __attribute__ ((always_inline)) { 41 | if (PIN < 32) return GPIO.out | MASK; 42 | else return GPIO.out1.val | MASK; 43 | } 44 | 45 | inline static port_t loval() __attribute__ ((always_inline)) { 46 | if (PIN < 32) return GPIO.out & ~MASK; 47 | else return GPIO.out1.val & ~MASK; 48 | } 49 | 50 | inline static port_ptr_t port() __attribute__ ((always_inline)) { 51 | if (PIN < 32) return &GPIO.out; 52 | else return &GPIO.out1.val; 53 | } 54 | 55 | inline static port_ptr_t sport() __attribute__ ((always_inline)) { 56 | if (PIN < 32) return &GPIO.out_w1ts; 57 | else return &GPIO.out1_w1ts.val; 58 | } 59 | 60 | inline static port_ptr_t cport() __attribute__ ((always_inline)) { 61 | if (PIN < 32) return &GPIO.out_w1tc; 62 | else return &GPIO.out1_w1tc.val; 63 | } 64 | 65 | inline static port_t mask() __attribute__ ((always_inline)) { return MASK; } 66 | 67 | inline static bool isset() __attribute__ ((always_inline)) { 68 | if (PIN < 32) return GPIO.out & MASK; 69 | else return GPIO.out1.val & MASK; 70 | } 71 | }; 72 | 73 | #define _DEFPIN_ESP32(PIN) template<> class FastPin : public _ESPPIN {}; 74 | #define _DEFPIN_32_33_ESP32(PIN) template<> class FastPin : public _ESPPIN {}; 75 | 76 | _DEFPIN_ESP32(0); 77 | _DEFPIN_ESP32(1); // WARNING: Using TX causes flashiness when uploading 78 | _DEFPIN_ESP32(2); 79 | _DEFPIN_ESP32(3); // WARNING: Using RX causes flashiness when uploading 80 | _DEFPIN_ESP32(4); 81 | _DEFPIN_ESP32(5); 82 | 83 | // -- These pins are not safe to use: 84 | // _DEFPIN_ESP32(6,6); _DEFPIN_ESP32(7,7); _DEFPIN_ESP32(8,8); 85 | // _DEFPIN_ESP32(9,9); _DEFPIN_ESP32(10,10); _DEFPIN_ESP32(11,11); 86 | 87 | _DEFPIN_ESP32(12); 88 | _DEFPIN_ESP32(13); 89 | _DEFPIN_ESP32(14); 90 | _DEFPIN_ESP32(15); 91 | _DEFPIN_ESP32(16); 92 | _DEFPIN_ESP32(17); 93 | _DEFPIN_ESP32(18); 94 | _DEFPIN_ESP32(19); 95 | 96 | // No pin 20 : _DEFPIN_ESP32(20,20); 97 | 98 | _DEFPIN_ESP32(21); // Works, but note that GPIO21 is I2C SDA 99 | _DEFPIN_ESP32(22); // Works, but note that GPIO22 is I2C SCL 100 | _DEFPIN_ESP32(23); 101 | 102 | // No pin 24 : _DEFPIN_ESP32(24,24); 103 | 104 | _DEFPIN_ESP32(25); 105 | _DEFPIN_ESP32(26); 106 | _DEFPIN_ESP32(27); 107 | 108 | // No pin 28-31: _DEFPIN_ESP32(28,28); _DEFPIN_ESP32(29,29); _DEFPIN_ESP32(30,30); _DEFPIN_ESP32(31,31); 109 | 110 | // Need special handling for pins > 31 111 | _DEFPIN_32_33_ESP32(32); 112 | _DEFPIN_32_33_ESP32(33); 113 | 114 | #define HAS_HARDWARE_PIN_SUPPORT 115 | 116 | FASTLED_NAMESPACE_END 117 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/DemoReel100/DemoReel100.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | FASTLED_USING_NAMESPACE 4 | 5 | // FastLED "100-lines-of-code" demo reel, showing just a few 6 | // of the kinds of animation patterns you can quickly and easily 7 | // compose using FastLED. 8 | // 9 | // This example also shows one easy way to define multiple 10 | // animations patterns and have them automatically rotate. 11 | // 12 | // -Mark Kriegsman, December 2014 13 | 14 | #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000) 15 | #warning "Requires FastLED 3.1 or later; check github for latest code." 16 | #endif 17 | 18 | #define DATA_PIN 3 19 | //#define CLK_PIN 4 20 | #define LED_TYPE WS2811 21 | #define COLOR_ORDER GRB 22 | #define NUM_LEDS 64 23 | CRGB leds[NUM_LEDS]; 24 | 25 | #define BRIGHTNESS 96 26 | #define FRAMES_PER_SECOND 120 27 | 28 | void setup() { 29 | delay(3000); // 3 second delay for recovery 30 | 31 | // tell FastLED about the LED strip configuration 32 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); 33 | //FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); 34 | 35 | // set master brightness control 36 | FastLED.setBrightness(BRIGHTNESS); 37 | } 38 | 39 | 40 | // List of patterns to cycle through. Each is defined as a separate function below. 41 | typedef void (*SimplePatternList[])(); 42 | SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm }; 43 | 44 | uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current 45 | uint8_t gHue = 0; // rotating "base color" used by many of the patterns 46 | 47 | void loop() 48 | { 49 | // Call the current pattern function once, updating the 'leds' array 50 | gPatterns[gCurrentPatternNumber](); 51 | 52 | // send the 'leds' array out to the actual LED strip 53 | FastLED.show(); 54 | // insert a delay to keep the framerate modest 55 | FastLED.delay(1000/FRAMES_PER_SECOND); 56 | 57 | // do some periodic updates 58 | EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow 59 | EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically 60 | } 61 | 62 | #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) 63 | 64 | void nextPattern() 65 | { 66 | // add one to the current pattern number, and wrap around at the end 67 | gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns); 68 | } 69 | 70 | void rainbow() 71 | { 72 | // FastLED's built-in rainbow generator 73 | fill_rainbow( leds, NUM_LEDS, gHue, 7); 74 | } 75 | 76 | void rainbowWithGlitter() 77 | { 78 | // built-in FastLED rainbow, plus some random sparkly glitter 79 | rainbow(); 80 | addGlitter(80); 81 | } 82 | 83 | void addGlitter( fract8 chanceOfGlitter) 84 | { 85 | if( random8() < chanceOfGlitter) { 86 | leds[ random16(NUM_LEDS) ] += CRGB::White; 87 | } 88 | } 89 | 90 | void confetti() 91 | { 92 | // random colored speckles that blink in and fade smoothly 93 | fadeToBlackBy( leds, NUM_LEDS, 10); 94 | int pos = random16(NUM_LEDS); 95 | leds[pos] += CHSV( gHue + random8(64), 200, 255); 96 | } 97 | 98 | void sinelon() 99 | { 100 | // a colored dot sweeping back and forth, with fading trails 101 | fadeToBlackBy( leds, NUM_LEDS, 20); 102 | int pos = beatsin16( 13, 0, NUM_LEDS-1 ); 103 | leds[pos] += CHSV( gHue, 255, 192); 104 | } 105 | 106 | void bpm() 107 | { 108 | // colored stripes pulsing at a defined Beats-Per-Minute (BPM) 109 | uint8_t BeatsPerMinute = 62; 110 | CRGBPalette16 palette = PartyColors_p; 111 | uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); 112 | for( int i = 0; i < NUM_LEDS; i++) { //9948 113 | leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); 114 | } 115 | } 116 | 117 | void juggle() { 118 | // eight colored dots, weaving in and out of sync with each other 119 | fadeToBlackBy( leds, NUM_LEDS, 20); 120 | byte dothue = 0; 121 | for( int i = 0; i < 8; i++) { 122 | leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255); 123 | dothue += 32; 124 | } 125 | } 126 | 127 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/SmartMatrix/SmartMatrix.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define kMatrixWidth 32 5 | #define kMatrixHeight 32 6 | const bool kMatrixSerpentineLayout = false; 7 | 8 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 9 | 10 | CRGB leds[kMatrixWidth * kMatrixHeight]; 11 | 12 | 13 | uint16_t XY( uint8_t x, uint8_t y) 14 | { 15 | uint16_t i; 16 | 17 | if( kMatrixSerpentineLayout == false) { 18 | i = (y * kMatrixWidth) + x; 19 | } 20 | 21 | if( kMatrixSerpentineLayout == true) { 22 | if( y & 0x01) { 23 | // Odd rows run backwards 24 | uint8_t reverseX = (kMatrixWidth - 1) - x; 25 | i = (y * kMatrixWidth) + reverseX; 26 | } else { 27 | // Even rows run forwards 28 | i = (y * kMatrixWidth) + x; 29 | } 30 | } 31 | 32 | return i; 33 | } 34 | 35 | // The 32bit version of our coordinates 36 | static uint16_t x; 37 | static uint16_t y; 38 | static uint16_t z; 39 | 40 | // We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll 41 | // use the z-axis for "time". speed determines how fast time moves forward. Try 42 | // 1 for a very slow moving effect, or 60 for something that ends up looking like 43 | // water. 44 | // uint16_t speed = 1; // almost looks like a painting, moves very slowly 45 | uint16_t speed = 20; // a nice starting speed, mixes well with a scale of 100 46 | // uint16_t speed = 33; 47 | // uint16_t speed = 100; // wicked fast! 48 | 49 | // Scale determines how far apart the pixels in our noise matrix are. Try 50 | // changing these values around to see how it affects the motion of the display. The 51 | // higher the value of scale, the more "zoomed out" the noise iwll be. A value 52 | // of 1 will be so zoomed in, you'll mostly see solid colors. 53 | 54 | // uint16_t scale = 1; // mostly just solid colors 55 | // uint16_t scale = 4011; // very zoomed out and shimmery 56 | uint16_t scale = 31; 57 | 58 | // This is the array that we keep our computed noise values in 59 | uint8_t noise[kMatrixWidth][kMatrixHeight]; 60 | 61 | void setup() { 62 | // uncomment the following lines if you want to see FPS count information 63 | // Serial.begin(38400); 64 | // Serial.println("resetting!"); 65 | delay(3000); 66 | LEDS.addLeds(leds,NUM_LEDS); 67 | LEDS.setBrightness(96); 68 | 69 | // Initialize our coordinates to some random values 70 | x = random16(); 71 | y = random16(); 72 | z = random16(); 73 | 74 | // Show off smart matrix scrolling text 75 | pSmartMatrix->setScrollMode(wrapForward); 76 | pSmartMatrix->setScrollColor({0xff, 0xff, 0xff}); 77 | pSmartMatrix->setScrollSpeed(15); 78 | pSmartMatrix->setScrollFont(font6x10); 79 | pSmartMatrix->scrollText("Smart Matrix & FastLED", -1); 80 | pSmartMatrix->setScrollOffsetFromEdge(10); 81 | } 82 | 83 | // Fill the x/y array of 8-bit noise values using the inoise8 function. 84 | void fillnoise8() { 85 | for(int i = 0; i < kMatrixWidth; i++) { 86 | int ioffset = scale * i; 87 | for(int j = 0; j < kMatrixHeight; j++) { 88 | int joffset = scale * j; 89 | noise[i][j] = inoise8(x + ioffset,y + joffset,z); 90 | } 91 | } 92 | z += speed; 93 | } 94 | 95 | 96 | void loop() { 97 | static uint8_t circlex = 0; 98 | static uint8_t circley = 0; 99 | 100 | static uint8_t ihue=0; 101 | fillnoise8(); 102 | for(int i = 0; i < kMatrixWidth; i++) { 103 | for(int j = 0; j < kMatrixHeight; j++) { 104 | // We use the value at the (i,j) coordinate in the noise 105 | // array for our brightness, and the flipped value from (j,i) 106 | // for our pixel's hue. 107 | leds[XY(i,j)] = CHSV(noise[j][i],255,noise[i][j]); 108 | 109 | // You can also explore other ways to constrain the hue used, like below 110 | // leds[XY(i,j)] = CHSV(ihue + (noise[j][i]>>2),255,noise[i][j]); 111 | } 112 | } 113 | ihue+=1; 114 | 115 | // N.B. this requires SmartMatrix modified w/triple buffering support 116 | pSmartMatrix->fillCircle(circlex % 32,circley % 32,6,CRGB(CHSV(ihue+128,255,255))); 117 | circlex += random16(2); 118 | circley += random16(2); 119 | LEDS.show(); 120 | // delay(10); 121 | } 122 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/sam/clockless_arm_sam.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_SAM_H 2 | #define __INC_CLOCKLESS_ARM_SAM_H 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | // Definition for a single channel clockless controller for the sam family of arm chips, like that used in the due and rfduino 7 | // See clockless.h for detailed info on how the template parameters are used. 8 | 9 | #if defined(__SAM3X8E__) 10 | 11 | 12 | #define TADJUST 0 13 | #define TOTAL ( (T1+TADJUST) + (T2+TADJUST) + (T3+TADJUST) ) 14 | 15 | #define FASTLED_HAS_CLOCKLESS 1 16 | 17 | template 18 | class ClocklessController : public CPixelLEDController { 19 | typedef typename FastPinBB::port_ptr_t data_ptr_t; 20 | typedef typename FastPinBB::port_t data_t; 21 | 22 | data_t mPinMask; 23 | data_ptr_t mPort; 24 | CMinWait mWait; 25 | public: 26 | virtual void init() { 27 | FastPinBB::setOutput(); 28 | mPinMask = FastPinBB::mask(); 29 | mPort = FastPinBB::port(); 30 | } 31 | 32 | virtual uint16_t getMaxRefreshRate() const { return 400; } 33 | 34 | protected: 35 | 36 | virtual void showPixels(PixelController & pixels) { 37 | mWait.wait(); 38 | if(!showRGBInternal(pixels)) { 39 | sei(); delayMicroseconds(WAIT_TIME); cli(); 40 | showRGBInternal(pixels); 41 | } 42 | mWait.mark(); 43 | } 44 | 45 | template __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & next_mark, register data_ptr_t port, register uint8_t & b) { 46 | // Make sure we don't slot into a wrapping spot, this will delay up to 12.5µs for WS2812 47 | // bool bShift=0; 48 | // while(VAL < (TOTAL*10)) { bShift=true; } 49 | // if(bShift) { next_mark = (VAL-TOTAL); }; 50 | 51 | for(register uint32_t i = BITS; i > 0; i--) { 52 | // wait to start the bit, then set the pin high 53 | while(DUE_TIMER_VAL < next_mark); 54 | next_mark = (DUE_TIMER_VAL+TOTAL); 55 | *port = 1; 56 | 57 | // how long we want to wait next depends on whether or not our bit is set to 1 or 0 58 | if(b&0x80) { 59 | // we're a 1, wait until there's less than T3 clocks left 60 | while((next_mark - DUE_TIMER_VAL) > (T3)); 61 | } else { 62 | // we're a 0, wait until there's less than (T2+T3+slop) clocks left in this bit 63 | while((next_mark - DUE_TIMER_VAL) > (T2+T3+6+TADJUST+TADJUST)); 64 | } 65 | *port=0; 66 | b <<= 1; 67 | } 68 | } 69 | 70 | #define FORCE_REFERENCE(var) asm volatile( "" : : "r" (var) ) 71 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 72 | // gcc will use register Y for the this pointer. 73 | static uint32_t showRGBInternal(PixelController pixels) { 74 | // Setup and start the clock 75 | TC_Configure(DUE_TIMER,DUE_TIMER_CHANNEL,TC_CMR_TCCLKS_TIMER_CLOCK1); 76 | pmc_enable_periph_clk(DUE_TIMER_ID); 77 | TC_Start(DUE_TIMER,DUE_TIMER_CHANNEL); 78 | 79 | register data_ptr_t port asm("r7") = FastPinBB::port(); FORCE_REFERENCE(port); 80 | *port = 0; 81 | 82 | // Setup the pixel controller and load/scale the first byte 83 | pixels.preStepFirstByteDithering(); 84 | uint8_t b = pixels.loadAndScale0(); 85 | 86 | uint32_t next_mark = (DUE_TIMER_VAL + (TOTAL)); 87 | while(pixels.has(1)) { 88 | pixels.stepDithering(); 89 | 90 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 91 | cli(); 92 | if(DUE_TIMER_VAL > next_mark) { 93 | if((DUE_TIMER_VAL - next_mark) > ((WAIT_TIME-INTERRUPT_THRESHOLD)*CLKS_PER_US)) { sei(); TC_Stop(DUE_TIMER,DUE_TIMER_CHANNEL); return 0; } 94 | } 95 | #endif 96 | 97 | writeBits<8+XTRA0>(next_mark, port, b); 98 | 99 | b = pixels.loadAndScale1(); 100 | writeBits<8+XTRA0>(next_mark, port,b); 101 | 102 | b = pixels.loadAndScale2(); 103 | writeBits<8+XTRA0>(next_mark, port,b); 104 | 105 | b = pixels.advanceAndLoadAndScale0(); 106 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 107 | sei(); 108 | #endif 109 | }; 110 | 111 | TC_Stop(DUE_TIMER,DUE_TIMER_CHANNEL); 112 | return DUE_TIMER_VAL; 113 | } 114 | }; 115 | 116 | #endif 117 | 118 | FASTLED_NAMESPACE_END 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/stm32/cm3_regs.h: -------------------------------------------------------------------------------- 1 | #ifndef __CM3_REGS 2 | #define __CM3_REGS 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | #define __I volatile /*!< Defines 'read only' permissions */ 8 | #else 9 | #define __I volatile const /*!< Defines 'read only' permissions */ 10 | #endif 11 | #define __O volatile /*!< Defines 'write only' permissions */ 12 | #define __IO volatile /*!< Defines 'read / write' permissions */ 13 | 14 | 15 | typedef struct 16 | { 17 | __IO uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ 18 | __O uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ 19 | __IO uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ 20 | __IO uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ 21 | } CoreDebug_Type; 22 | 23 | #define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ 24 | #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ 25 | 26 | #define CoreDebug_DEMCR_TRCENA_Pos 24 /*!< CoreDebug DEMCR: TRCENA Position */ 27 | #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ 28 | 29 | typedef struct 30 | { 31 | __IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ 32 | __IO uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ 33 | __IO uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ 34 | __IO uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ 35 | __IO uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ 36 | __IO uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ 37 | __IO uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ 38 | __I uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ 39 | __IO uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ 40 | __IO uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ 41 | __IO uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ 42 | uint32_t RESERVED0[1]; 43 | __IO uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ 44 | __IO uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ 45 | __IO uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ 46 | uint32_t RESERVED1[1]; 47 | __IO uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ 48 | __IO uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ 49 | __IO uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ 50 | uint32_t RESERVED2[1]; 51 | __IO uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ 52 | __IO uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ 53 | __IO uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ 54 | } DWT_Type; 55 | 56 | 57 | #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ 58 | #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ 59 | 60 | #define DWT_CTRL_CYCCNTENA_Pos 0 /*!< DWT CTRL: CYCCNTENA Position */ 61 | #define DWT_CTRL_CYCCNTENA_Msk (0x1UL << DWT_CTRL_CYCCNTENA_Pos) /*!< DWT CTRL: CYCCNTENA Mask */ 62 | 63 | #endif // __CM3_REGS 64 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/esp/8266/fastpin_esp8266.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | FASTLED_NAMESPACE_BEGIN 4 | 5 | struct FASTLED_ESP_IO { 6 | volatile uint32_t _GPO; 7 | volatile uint32_t _GPOS; 8 | volatile uint32_t _GPOC; 9 | }; 10 | 11 | #define _GPB (*(FASTLED_ESP_IO*)(0x60000000+(0x300))) 12 | 13 | 14 | template class _ESPPIN { 15 | 16 | public: 17 | typedef volatile uint32_t * port_ptr_t; 18 | typedef uint32_t port_t; 19 | 20 | inline static void setOutput() { pinMode(PIN, OUTPUT); } 21 | inline static void setInput() { pinMode(PIN, INPUT); } 22 | 23 | inline static void hi() __attribute__ ((always_inline)) { if(PIN < 16) { _GPB._GPOS = MASK; } else { GP16O |= MASK; } } 24 | inline static void lo() __attribute__ ((always_inline)) { if(PIN < 16) { _GPB._GPOC = MASK; } else { GP16O &= ~MASK; } } 25 | inline static void set(register port_t val) __attribute__ ((always_inline)) { if(PIN < 16) { _GPB._GPO = val; } else { GP16O = val; }} 26 | 27 | inline static void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); } 28 | 29 | inline static void toggle() __attribute__ ((always_inline)) { if(PIN < 16) { _GPB._GPO ^= MASK; } else { GP16O ^= MASK; } } 30 | 31 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { hi(); } 32 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { lo(); } 33 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } 34 | 35 | inline static port_t hival() __attribute__ ((always_inline)) { if (PIN<16) { return GPO | MASK; } else { return GP16O | MASK; } } 36 | inline static port_t loval() __attribute__ ((always_inline)) { if (PIN<16) { return GPO & ~MASK; } else { return GP16O & ~MASK; } } 37 | inline static port_ptr_t port() __attribute__ ((always_inline)) { if(PIN<16) { return &_GPB._GPO; } else { return &GP16O; } } 38 | inline static port_ptr_t sport() __attribute__ ((always_inline)) { return &_GPB._GPOS; } // there is no GP160 support for this 39 | inline static port_ptr_t cport() __attribute__ ((always_inline)) { return &_GPB._GPOC; } 40 | inline static port_t mask() __attribute__ ((always_inline)) { return MASK; } 41 | 42 | inline static bool isset() __attribute__ ((always_inline)) { return (PIN < 16) ? (GPO & MASK) : (GP16O & MASK); } 43 | }; 44 | 45 | #define _DEFPIN_ESP8266(PIN, REAL_PIN) template<> class FastPin : public _ESPPIN {}; 46 | 47 | 48 | #ifdef FASTLED_ESP8266_RAW_PIN_ORDER 49 | #define MAX_PIN 16 50 | _DEFPIN_ESP8266(0,0); _DEFPIN_ESP8266(1,1); _DEFPIN_ESP8266(2,2); _DEFPIN_ESP8266(3,3); 51 | _DEFPIN_ESP8266(4,4); _DEFPIN_ESP8266(5,5); 52 | 53 | // These pins should be disabled, as they always cause WDT resets 54 | // _DEFPIN_ESP8266(6,6); _DEFPIN_ESP8266(7,7); 55 | // _DEFPIN_ESP8266(8,8); _DEFPIN_ESP8266(9,9); _DEFPIN_ESP8266(10,10); _DEFPIN_ESP8266(11,11); 56 | 57 | _DEFPIN_ESP8266(12,12); _DEFPIN_ESP8266(13,13); _DEFPIN_ESP8266(14,14); _DEFPIN_ESP8266(15,15); 58 | _DEFPIN_ESP8266(16,16); 59 | 60 | #define PORTA_FIRST_PIN 12 61 | #elif defined(FASTLED_ESP8266_D1_PIN_ORDER) 62 | #define MAX_PIN 15 63 | _DEFPIN_ESP8266(0,3); 64 | _DEFPIN_ESP8266(1,1); 65 | _DEFPIN_ESP8266(2,16); 66 | _DEFPIN_ESP8266(3,5); 67 | _DEFPIN_ESP8266(4,4); 68 | _DEFPIN_ESP8266(5,14); 69 | _DEFPIN_ESP8266(6,12); 70 | _DEFPIN_ESP8266(7,13); 71 | _DEFPIN_ESP8266(8,0); 72 | _DEFPIN_ESP8266(9,2); 73 | _DEFPIN_ESP8266(10,15); 74 | _DEFPIN_ESP8266(11,13); 75 | _DEFPIN_ESP8266(12,12); 76 | _DEFPIN_ESP8266(13,14); 77 | _DEFPIN_ESP8266(14,4); 78 | _DEFPIN_ESP8266(15,5); 79 | 80 | #define PORTA_FIRST_PIN 12 81 | 82 | #else // if defined(FASTLED_ESP8266_NODEMCU_PIN_ORDER) 83 | #define MAX_PIN 10 84 | 85 | // This seems to be the standard Dxx pin mapping on most of the esp boards that i've found 86 | _DEFPIN_ESP8266(0,16); _DEFPIN_ESP8266(1,5); _DEFPIN_ESP8266(2,4); _DEFPIN_ESP8266(3,0); 87 | _DEFPIN_ESP8266(4,2); _DEFPIN_ESP8266(5,14); _DEFPIN_ESP8266(6,12); _DEFPIN_ESP8266(7,13); 88 | _DEFPIN_ESP8266(8,15); _DEFPIN_ESP8266(9,3); _DEFPIN_ESP8266(10,1); 89 | 90 | #define PORTA_FIRST_PIN 6 91 | 92 | // The rest of the pins - these are generally not available 93 | // _DEFPIN_ESP8266(11,6); 94 | // _DEFPIN_ESP8266(12,7); _DEFPIN_ESP8266(13,8); _DEFPIN_ESP8266(14,9); _DEFPIN_ESP8266(15,10); 95 | // _DEFPIN_ESP8266(16,11); 96 | 97 | #endif 98 | 99 | #define HAS_HARDWARE_PIN_SUPPORT 100 | 101 | #define FASTLED_NAMESPACE_END 102 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k66/clockless_arm_k66.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_K66_H 2 | #define __INC_CLOCKLESS_ARM_K66_H 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | // Definition for a single channel clockless controller for the k66 family of chips, like that used in the teensy 3.6 7 | // See clockless.h for detailed info on how the template parameters are used. 8 | #if defined(FASTLED_TEENSY3) 9 | 10 | #define FASTLED_HAS_CLOCKLESS 1 11 | 12 | template 13 | class ClocklessController : public CPixelLEDController { 14 | typedef typename FastPin::port_ptr_t data_ptr_t; 15 | typedef typename FastPin::port_t data_t; 16 | 17 | data_t mPinMask; 18 | data_ptr_t mPort; 19 | CMinWait mWait; 20 | public: 21 | virtual void init() { 22 | FastPin::setOutput(); 23 | mPinMask = FastPin::mask(); 24 | mPort = FastPin::port(); 25 | } 26 | 27 | virtual uint16_t getMaxRefreshRate() const { return 400; } 28 | 29 | protected: 30 | 31 | virtual void showPixels(PixelController & pixels) { 32 | mWait.wait(); 33 | if(!showRGBInternal(pixels)) { 34 | sei(); delayMicroseconds(WAIT_TIME); cli(); 35 | showRGBInternal(pixels); 36 | } 37 | mWait.mark(); 38 | } 39 | 40 | template __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & next_mark, register data_ptr_t port, register data_t hi, register data_t lo, register uint8_t & b) { 41 | for(register uint32_t i = BITS-1; i > 0; i--) { 42 | while(ARM_DWT_CYCCNT < next_mark); 43 | next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 44 | FastPin::fastset(port, hi); 45 | if(b&0x80) { 46 | while((next_mark - ARM_DWT_CYCCNT) > (T3+(2*(F_CPU/24000000)))); 47 | FastPin::fastset(port, lo); 48 | } else { 49 | while((next_mark - ARM_DWT_CYCCNT) > (T2+T3+(2*(F_CPU/24000000)))); 50 | FastPin::fastset(port, lo); 51 | } 52 | b <<= 1; 53 | } 54 | 55 | while(ARM_DWT_CYCCNT < next_mark); 56 | next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 57 | FastPin::fastset(port, hi); 58 | 59 | if(b&0x80) { 60 | while((next_mark - ARM_DWT_CYCCNT) > (T3+(2*(F_CPU/24000000)))); 61 | FastPin::fastset(port, lo); 62 | } else { 63 | while((next_mark - ARM_DWT_CYCCNT) > (T2+T3+(2*(F_CPU/24000000)))); 64 | FastPin::fastset(port, lo); 65 | } 66 | } 67 | 68 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 69 | // gcc will use register Y for the this pointer. 70 | static uint32_t showRGBInternal(PixelController pixels) { 71 | // Get access to the clock 72 | ARM_DEMCR |= ARM_DEMCR_TRCENA; 73 | ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA; 74 | ARM_DWT_CYCCNT = 0; 75 | 76 | register data_ptr_t port = FastPin::port(); 77 | register data_t hi = *port | FastPin::mask();; 78 | register data_t lo = *port & ~FastPin::mask();; 79 | *port = lo; 80 | 81 | // Setup the pixel controller and load/scale the first byte 82 | pixels.preStepFirstByteDithering(); 83 | register uint8_t b = pixels.loadAndScale0(); 84 | 85 | cli(); 86 | uint32_t next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 87 | 88 | while(pixels.has(1)) { 89 | pixels.stepDithering(); 90 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 91 | cli(); 92 | // if interrupts took longer than 45µs, punt on the current frame 93 | if(ARM_DWT_CYCCNT > next_mark) { 94 | if((ARM_DWT_CYCCNT-next_mark) > ((WAIT_TIME-INTERRUPT_THRESHOLD)*CLKS_PER_US)) { sei(); return 0; } 95 | } 96 | 97 | hi = *port | FastPin::mask(); 98 | lo = *port & ~FastPin::mask(); 99 | #endif 100 | // Write first byte, read next byte 101 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 102 | b = pixels.loadAndScale1(); 103 | 104 | // Write second byte, read 3rd byte 105 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 106 | b = pixels.loadAndScale2(); 107 | 108 | // Write third byte, read 1st byte of next pixel 109 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 110 | b = pixels.advanceAndLoadAndScale0(); 111 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 112 | sei(); 113 | #endif 114 | }; 115 | 116 | sei(); 117 | return ARM_DWT_CYCCNT; 118 | } 119 | }; 120 | #endif 121 | 122 | FASTLED_NAMESPACE_END 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/k20/clockless_arm_k20.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_K20_H 2 | #define __INC_CLOCKLESS_ARM_K20_H 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | // Definition for a single channel clockless controller for the k20 family of chips, like that used in the teensy 3.0/3.1 7 | // See clockless.h for detailed info on how the template parameters are used. 8 | #if defined(FASTLED_TEENSY3) 9 | 10 | #define FASTLED_HAS_CLOCKLESS 1 11 | 12 | template 13 | class ClocklessController : public CPixelLEDController { 14 | typedef typename FastPin::port_ptr_t data_ptr_t; 15 | typedef typename FastPin::port_t data_t; 16 | 17 | data_t mPinMask; 18 | data_ptr_t mPort; 19 | CMinWait mWait; 20 | public: 21 | virtual void init() { 22 | FastPin::setOutput(); 23 | mPinMask = FastPin::mask(); 24 | mPort = FastPin::port(); 25 | } 26 | 27 | virtual uint16_t getMaxRefreshRate() const { return 400; } 28 | 29 | protected: 30 | 31 | virtual void showPixels(PixelController & pixels) { 32 | mWait.wait(); 33 | if(!showRGBInternal(pixels)) { 34 | sei(); delayMicroseconds(WAIT_TIME); cli(); 35 | showRGBInternal(pixels); 36 | } 37 | mWait.mark(); 38 | } 39 | 40 | template __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & next_mark, register data_ptr_t port, register data_t hi, register data_t lo, register uint8_t & b) { 41 | for(register uint32_t i = BITS-1; i > 0; i--) { 42 | while(ARM_DWT_CYCCNT < next_mark); 43 | next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 44 | FastPin::fastset(port, hi); 45 | if(b&0x80) { 46 | while((next_mark - ARM_DWT_CYCCNT) > (T3+(2*(F_CPU/24000000)))); 47 | FastPin::fastset(port, lo); 48 | } else { 49 | while((next_mark - ARM_DWT_CYCCNT) > (T2+T3+(2*(F_CPU/24000000)))); 50 | FastPin::fastset(port, lo); 51 | } 52 | b <<= 1; 53 | } 54 | 55 | while(ARM_DWT_CYCCNT < next_mark); 56 | next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 57 | FastPin::fastset(port, hi); 58 | 59 | if(b&0x80) { 60 | while((next_mark - ARM_DWT_CYCCNT) > (T3+(2*(F_CPU/24000000)))); 61 | FastPin::fastset(port, lo); 62 | } else { 63 | while((next_mark - ARM_DWT_CYCCNT) > (T2+T3+(2*(F_CPU/24000000)))); 64 | FastPin::fastset(port, lo); 65 | } 66 | } 67 | 68 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 69 | // gcc will use register Y for the this pointer. 70 | static uint32_t showRGBInternal(PixelController pixels) { 71 | // Get access to the clock 72 | ARM_DEMCR |= ARM_DEMCR_TRCENA; 73 | ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA; 74 | ARM_DWT_CYCCNT = 0; 75 | 76 | register data_ptr_t port = FastPin::port(); 77 | register data_t hi = *port | FastPin::mask();; 78 | register data_t lo = *port & ~FastPin::mask();; 79 | *port = lo; 80 | 81 | // Setup the pixel controller and load/scale the first byte 82 | pixels.preStepFirstByteDithering(); 83 | register uint8_t b = pixels.loadAndScale0(); 84 | 85 | cli(); 86 | uint32_t next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 87 | 88 | while(pixels.has(1)) { 89 | pixels.stepDithering(); 90 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 91 | cli(); 92 | // if interrupts took longer than 45µs, punt on the current frame 93 | if(ARM_DWT_CYCCNT > next_mark) { 94 | if((ARM_DWT_CYCCNT-next_mark) > ((WAIT_TIME-INTERRUPT_THRESHOLD)*CLKS_PER_US)) { sei(); return 0; } 95 | } 96 | 97 | hi = *port | FastPin::mask(); 98 | lo = *port & ~FastPin::mask(); 99 | #endif 100 | // Write first byte, read next byte 101 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 102 | b = pixels.loadAndScale1(); 103 | 104 | // Write second byte, read 3rd byte 105 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 106 | b = pixels.loadAndScale2(); 107 | 108 | // Write third byte, read 1st byte of next pixel 109 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 110 | b = pixels.advanceAndLoadAndScale0(); 111 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 112 | sei(); 113 | #endif 114 | }; 115 | 116 | sei(); 117 | return ARM_DWT_CYCCNT; 118 | } 119 | }; 120 | #endif 121 | 122 | FASTLED_NAMESPACE_END 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/stm32/clockless_arm_stm32.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_STM32_H 2 | #define __INC_CLOCKLESS_ARM_STM32_H 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | // Definition for a single channel clockless controller for the stm32 family of chips, like that used in the spark core 6 | // See clockless.h for detailed info on how the template parameters are used. 7 | 8 | #define FASTLED_HAS_CLOCKLESS 1 9 | 10 | template 11 | class ClocklessController : public CPixelLEDController { 12 | typedef typename FastPin::port_ptr_t data_ptr_t; 13 | typedef typename FastPin::port_t data_t; 14 | 15 | data_t mPinMask; 16 | data_ptr_t mPort; 17 | CMinWait mWait; 18 | public: 19 | virtual void init() { 20 | FastPin::setOutput(); 21 | mPinMask = FastPin::mask(); 22 | mPort = FastPin::port(); 23 | } 24 | 25 | virtual uint16_t getMaxRefreshRate() const { return 400; } 26 | 27 | protected: 28 | 29 | virtual void showPixels(PixelController & pixels) { 30 | mWait.wait(); 31 | if(!showRGBInternal(pixels)) { 32 | sei(); delayMicroseconds(WAIT_TIME); cli(); 33 | showRGBInternal(pixels); 34 | } 35 | mWait.mark(); 36 | } 37 | 38 | #define _CYCCNT (*(volatile uint32_t*)(0xE0001004UL)) 39 | 40 | template __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & next_mark, register data_ptr_t port, register data_t hi, register data_t lo, register uint8_t & b) { 41 | for(register uint32_t i = BITS-1; i > 0; i--) { 42 | while(_CYCCNT < (T1+T2+T3-20)); 43 | FastPin::fastset(port, hi); 44 | _CYCCNT = 4; 45 | if(b&0x80) { 46 | while(_CYCCNT < (T1+T2-20)); 47 | FastPin::fastset(port, lo); 48 | } else { 49 | while(_CYCCNT < (T1-10)); 50 | FastPin::fastset(port, lo); 51 | } 52 | b <<= 1; 53 | } 54 | 55 | while(_CYCCNT < (T1+T2+T3-20)); 56 | FastPin::fastset(port, hi); 57 | _CYCCNT = 4; 58 | 59 | if(b&0x80) { 60 | while(_CYCCNT < (T1+T2-20)); 61 | FastPin::fastset(port, lo); 62 | } else { 63 | while(_CYCCNT < (T1-10)); 64 | FastPin::fastset(port, lo); 65 | } 66 | } 67 | 68 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 69 | // gcc will use register Y for the this pointer. 70 | static uint32_t showRGBInternal(PixelController pixels) { 71 | // Get access to the clock 72 | CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; 73 | DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; 74 | DWT->CYCCNT = 0; 75 | 76 | register data_ptr_t port = FastPin::port(); 77 | register data_t hi = *port | FastPin::mask();; 78 | register data_t lo = *port & ~FastPin::mask();; 79 | *port = lo; 80 | 81 | // Setup the pixel controller and load/scale the first byte 82 | pixels.preStepFirstByteDithering(); 83 | register uint8_t b = pixels.loadAndScale0(); 84 | 85 | cli(); 86 | 87 | uint32_t next_mark = (T1+T2+T3); 88 | 89 | DWT->CYCCNT = 0; 90 | while(pixels.has(1)) { 91 | pixels.stepDithering(); 92 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 93 | cli(); 94 | // if interrupts took longer than 45µs, punt on the current frame 95 | if(DWT->CYCCNT > next_mark) { 96 | if((DWT->CYCCNT-next_mark) > ((WAIT_TIME-INTERRUPT_THRESHOLD)*CLKS_PER_US)) { sei(); return 0; } 97 | } 98 | 99 | hi = *port | FastPin::mask(); 100 | lo = *port & ~FastPin::mask(); 101 | #endif 102 | 103 | // Write first byte, read next byte 104 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 105 | b = pixels.loadAndScale1(); 106 | 107 | // Write second byte, read 3rd byte 108 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 109 | b = pixels.loadAndScale2(); 110 | 111 | // Write third byte, read 1st byte of next pixel 112 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 113 | b = pixels.advanceAndLoadAndScale0(); 114 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 115 | sei(); 116 | #endif 117 | }; 118 | 119 | sei(); 120 | return DWT->CYCCNT; 121 | } 122 | }; 123 | 124 | FASTLED_NAMESPACE_END 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/nrf52/arbiter_nrf52.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_ARBITER_NRF52 2 | #define __INC_ARBITER_NRF52 3 | 4 | #if defined(NRF52_SERIES) 5 | 6 | #include "led_sysdefs_arm_nrf52.h" 7 | 8 | //FASTLED_NAMESPACE_BEGIN 9 | 10 | typedef void (*FASTLED_NRF52_PWM_INTERRUPT_HANDLER)(); 11 | 12 | // a trick learned from other embedded projects .. 13 | // use the enum as an index to a statically-allocated array 14 | // to store unique information for that instance. 15 | // also provides a count of how many instances were enabled. 16 | // 17 | // See led_sysdefs_arm_nrf52.h for selection.... 18 | // 19 | typedef enum _FASTLED_NRF52_ENABLED_PWM_INSTANCE { 20 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE0) 21 | FASTLED_NRF52_PWM0_INSTANCE_IDX, 22 | #endif 23 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE1) 24 | FASTLED_NRF52_PWM1_INSTANCE_IDX, 25 | #endif 26 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE2) 27 | FASTLED_NRF52_PWM2_INSTANCE_IDX, 28 | #endif 29 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE3) 30 | FASTLED_NRF52_PWM3_INSTANCE_IDX, 31 | #endif 32 | FASTLED_NRF52_PWM_INSTANCE_COUNT 33 | } FASTLED_NRF52_ENABLED_PWM_INSTANCES; 34 | 35 | static_assert(FASTLED_NRF52_PWM_INSTANCE_COUNT > 0, "Instance count must be greater than zero -- define FASTLED_NRF52_ENABLE_PWM_INSTNACE[n] (replace `[n]` with digit)"); 36 | 37 | template 38 | class PWM_Arbiter { 39 | 40 | private: 41 | static_assert(_PWM_ID < 32, "PWM_ID over 31 breaks current arbitration bitmask"); 42 | //const uint32_t _ACQUIRE_MASK = (1u << _PWM_ID) ; 43 | //const uint32_t _CLEAR_MASK = ~((uint32_t)(1u << _PWM_ID)); 44 | static uint32_t s_PwmInUse; 45 | static NRF_PWM_Type * const s_PWM; 46 | static IRQn_Type const s_PWM_IRQ; 47 | static FASTLED_NRF52_PWM_INTERRUPT_HANDLER volatile s_Isr; 48 | 49 | public: 50 | static void isr_handler() { 51 | return s_Isr(); 52 | } 53 | FASTLED_NRF52_INLINE_ATTRIBUTE static bool isAcquired() { 54 | return (0u != (s_PwmInUse & 1u)); // _ACQUIRE_MASK 55 | } 56 | FASTLED_NRF52_INLINE_ATTRIBUTE static void acquire(FASTLED_NRF52_PWM_INTERRUPT_HANDLER isr) { 57 | while (!tryAcquire(isr)); 58 | } 59 | FASTLED_NRF52_INLINE_ATTRIBUTE static bool tryAcquire(FASTLED_NRF52_PWM_INTERRUPT_HANDLER isr) { 60 | uint32_t oldValue = __sync_fetch_and_or(&s_PwmInUse, 1u); // _ACQUIRE_MASK 61 | if (0u == (oldValue & 1u)) { // _ACQUIRE_MASK 62 | s_Isr = isr; 63 | return true; 64 | } 65 | return false; 66 | } 67 | FASTLED_NRF52_INLINE_ATTRIBUTE static void releaseFromIsr() { 68 | uint32_t oldValue = __sync_fetch_and_and(&s_PwmInUse, ~1u); // _CLEAR_MASK 69 | if (0u == (oldValue & 1u)) { // _ACQUIRE_MASK 70 | // TODO: This should never be true... indicates was not held. 71 | // Assert here? 72 | (void)oldValue; 73 | } 74 | return; 75 | } 76 | FASTLED_NRF52_INLINE_ATTRIBUTE static NRF_PWM_Type * getPWM() { 77 | return s_PWM; 78 | } 79 | FASTLED_NRF52_INLINE_ATTRIBUTE static IRQn_Type getIRQn() { return s_PWM_IRQ; } 80 | }; 81 | template NRF_PWM_Type * const PWM_Arbiter<_PWM_ID>::s_PWM = 82 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE0) 83 | (_PWM_ID == 0 ? NRF_PWM0 : 84 | #endif 85 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE1) 86 | (_PWM_ID == 1 ? NRF_PWM1 : 87 | #endif 88 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE2) 89 | (_PWM_ID == 2 ? NRF_PWM2 : 90 | #endif 91 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE3) 92 | (_PWM_ID == 3 ? NRF_PWM3 : 93 | #endif 94 | (NRF_PWM_Type*)-1 95 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE0) 96 | ) 97 | #endif 98 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE1) 99 | ) 100 | #endif 101 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE2) 102 | ) 103 | #endif 104 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE3) 105 | ) 106 | #endif 107 | ; 108 | template IRQn_Type const PWM_Arbiter<_PWM_ID>::s_PWM_IRQ = ((IRQn_Type)((uint8_t)((uint32_t)(s_PWM) >> 12))); 109 | template uint32_t PWM_Arbiter<_PWM_ID>::s_PwmInUse = 0; 110 | template FASTLED_NRF52_PWM_INTERRUPT_HANDLER volatile PWM_Arbiter<_PWM_ID>::s_Isr = NULL; 111 | 112 | //FASTLED_NAMESPACE_END 113 | 114 | #endif // NRF52_SERIES 115 | #endif // __INC_ARBITER_NRF52 -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/d51/clockless_arm_d51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_D51 2 | #define __INC_CLOCKLESS_ARM_D51 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | // Definition for a single channel clockless controller for SAMD51 7 | // See clockless.h for detailed info on how the template parameters are used. 8 | #define ARM_DEMCR (*(volatile uint32_t *)0xE000EDFC) // Debug Exception and Monitor Control 9 | #define ARM_DEMCR_TRCENA (1 << 24) // Enable debugging & monitoring blocks 10 | #define ARM_DWT_CTRL (*(volatile uint32_t *)0xE0001000) // DWT control register 11 | #define ARM_DWT_CTRL_CYCCNTENA (1 << 0) // Enable cycle count 12 | #define ARM_DWT_CYCCNT (*(volatile uint32_t *)0xE0001004) // Cycle count register 13 | 14 | 15 | #define FASTLED_HAS_CLOCKLESS 1 16 | 17 | template 18 | class ClocklessController : public CPixelLEDController { 19 | typedef typename FastPin::port_ptr_t data_ptr_t; 20 | typedef typename FastPin::port_t data_t; 21 | 22 | data_t mPinMask; 23 | data_ptr_t mPort; 24 | CMinWait mWait; 25 | public: 26 | virtual void init() { 27 | FastPin::setOutput(); 28 | mPinMask = FastPin::mask(); 29 | mPort = FastPin::port(); 30 | } 31 | 32 | virtual uint16_t getMaxRefreshRate() const { return 400; } 33 | 34 | protected: 35 | 36 | virtual void showPixels(PixelController & pixels) { 37 | mWait.wait(); 38 | if(!showRGBInternal(pixels)) { 39 | sei(); delayMicroseconds(WAIT_TIME); cli(); 40 | showRGBInternal(pixels); 41 | } 42 | mWait.mark(); 43 | } 44 | 45 | template __attribute__ ((always_inline)) inline static void writeBits(register uint32_t & next_mark, register data_ptr_t port, register data_t hi, register data_t lo, register uint8_t & b) { 46 | for(register uint32_t i = BITS-1; i > 0; i--) { 47 | while(ARM_DWT_CYCCNT < next_mark); 48 | next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 49 | FastPin::fastset(port, hi); 50 | if(b&0x80) { 51 | while((next_mark - ARM_DWT_CYCCNT) > (T3+(2*(F_CPU/24000000)))); 52 | FastPin::fastset(port, lo); 53 | } else { 54 | while((next_mark - ARM_DWT_CYCCNT) > (T2+T3+(2*(F_CPU/24000000)))); 55 | FastPin::fastset(port, lo); 56 | } 57 | b <<= 1; 58 | } 59 | 60 | while(ARM_DWT_CYCCNT < next_mark); 61 | next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 62 | FastPin::fastset(port, hi); 63 | 64 | if(b&0x80) { 65 | while((next_mark - ARM_DWT_CYCCNT) > (T3+(2*(F_CPU/24000000)))); 66 | FastPin::fastset(port, lo); 67 | } else { 68 | while((next_mark - ARM_DWT_CYCCNT) > (T2+T3+(2*(F_CPU/24000000)))); 69 | FastPin::fastset(port, lo); 70 | } 71 | } 72 | 73 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 74 | // gcc will use register Y for the this pointer. 75 | static uint32_t showRGBInternal(PixelController pixels) { 76 | // Get access to the clock 77 | ARM_DEMCR |= ARM_DEMCR_TRCENA; 78 | ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA; 79 | ARM_DWT_CYCCNT = 0; 80 | 81 | register data_ptr_t port = FastPin::port(); 82 | register data_t hi = *port | FastPin::mask();; 83 | register data_t lo = *port & ~FastPin::mask();; 84 | *port = lo; 85 | 86 | // Setup the pixel controller and load/scale the first byte 87 | pixels.preStepFirstByteDithering(); 88 | register uint8_t b = pixels.loadAndScale0(); 89 | 90 | cli(); 91 | uint32_t next_mark = ARM_DWT_CYCCNT + (T1+T2+T3); 92 | 93 | while(pixels.has(1)) { 94 | pixels.stepDithering(); 95 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 96 | cli(); 97 | // if interrupts took longer than 45µs, punt on the current frame 98 | if(ARM_DWT_CYCCNT > next_mark) { 99 | if((ARM_DWT_CYCCNT-next_mark) > ((WAIT_TIME-INTERRUPT_THRESHOLD)*CLKS_PER_US)) { sei(); return 0; } 100 | } 101 | 102 | hi = *port | FastPin::mask(); 103 | lo = *port & ~FastPin::mask(); 104 | #endif 105 | // Write first byte, read next byte 106 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 107 | b = pixels.loadAndScale1(); 108 | 109 | // Write second byte, read 3rd byte 110 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 111 | b = pixels.loadAndScale2(); 112 | 113 | // Write third byte, read 1st byte of next pixel 114 | writeBits<8+XTRA0>(next_mark, port, hi, lo, b); 115 | b = pixels.advanceAndLoadAndScale0(); 116 | #if (FASTLED_ALLOW_INTERRUPTS == 1) 117 | sei(); 118 | #endif 119 | }; 120 | 121 | sei(); 122 | return ARM_DWT_CYCCNT; 123 | } 124 | }; 125 | 126 | FASTLED_NAMESPACE_END 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/examples/Ports/PJRCSpectrumAnalyzer/PJRCSpectrumAnalyzer.ino: -------------------------------------------------------------------------------- 1 | // LED Audio Spectrum Analyzer Display 2 | // 3 | // Creates an impressive LED light show to music input 4 | // using Teensy 3.1 with the OctoWS2811 adaptor board 5 | // http://www.pjrc.com/store/teensy31.html 6 | // http://www.pjrc.com/store/octo28_adaptor.html 7 | // 8 | // Line Level Audio Input connects to analog pin A3 9 | // Recommended input circuit: 10 | // http://www.pjrc.com/teensy/gui/?info=AudioInputAnalog 11 | // 12 | // This example code is in the public domain. 13 | 14 | #define USE_OCTOWS2811 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | // The display size and color to use 23 | const unsigned int matrix_width = 60; 24 | const unsigned int matrix_height = 32; 25 | const unsigned int myColor = 0x400020; 26 | 27 | // These parameters adjust the vertical thresholds 28 | const float maxLevel = 0.5; // 1.0 = max, lower is more "sensitive" 29 | const float dynamicRange = 40.0; // total range to display, in decibels 30 | const float linearBlend = 0.3; // useful range is 0 to 0.7 31 | 32 | CRGB leds[matrix_width * matrix_height]; 33 | 34 | // Audio library objects 35 | AudioInputAnalog adc1(A3); //xy=99,55 36 | AudioAnalyzeFFT1024 fft; //xy=265,75 37 | AudioConnection patchCord1(adc1, fft); 38 | 39 | 40 | // This array holds the volume level (0 to 1.0) for each 41 | // vertical pixel to turn on. Computed in setup() using 42 | // the 3 parameters above. 43 | float thresholdVertical[matrix_height]; 44 | 45 | // This array specifies how many of the FFT frequency bin 46 | // to use for each horizontal pixel. Because humans hear 47 | // in octaves and FFT bins are linear, the low frequencies 48 | // use a small number of bins, higher frequencies use more. 49 | int frequencyBinsHorizontal[matrix_width] = { 50 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 51 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 52 | 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 53 | 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 54 | 9, 9, 10, 10, 11, 12, 12, 13, 14, 15, 55 | 15, 16, 17, 18, 19, 20, 22, 23, 24, 25 56 | }; 57 | 58 | 59 | 60 | // Run setup once 61 | void setup() { 62 | // the audio library needs to be given memory to start working 63 | AudioMemory(12); 64 | 65 | // compute the vertical thresholds before starting 66 | computeVerticalLevels(); 67 | 68 | // turn on the display 69 | FastLED.addLeds(leds,(matrix_width * matrix_height) / 8); 70 | } 71 | 72 | // A simple xy() function to turn display matrix coordinates 73 | // into the index numbers OctoWS2811 requires. If your LEDs 74 | // are arranged differently, edit this code... 75 | unsigned int xy(unsigned int x, unsigned int y) { 76 | if ((y & 1) == 0) { 77 | // even numbered rows (0, 2, 4...) are left to right 78 | return y * matrix_width + x; 79 | } else { 80 | // odd numbered rows (1, 3, 5...) are right to left 81 | return y * matrix_width + matrix_width - 1 - x; 82 | } 83 | } 84 | 85 | // Run repetitively 86 | void loop() { 87 | unsigned int x, y, freqBin; 88 | float level; 89 | 90 | if (fft.available()) { 91 | // freqBin counts which FFT frequency data has been used, 92 | // starting at low frequency 93 | freqBin = 0; 94 | 95 | for (x=0; x < matrix_width; x++) { 96 | // get the volume for each horizontal pixel position 97 | level = fft.read(freqBin, freqBin + frequencyBinsHorizontal[x] - 1); 98 | 99 | // uncomment to see the spectrum in Arduino's Serial Monitor 100 | // Serial.print(level); 101 | // Serial.print(" "); 102 | 103 | for (y=0; y < matrix_height; y++) { 104 | // for each vertical pixel, check if above the threshold 105 | // and turn the LED on or off 106 | if (level >= thresholdVertical[y]) { 107 | leds[xy(x,y)] = CRGB(myColor); 108 | } else { 109 | leds[xy(x,y)] = CRGB::Black; 110 | } 111 | } 112 | // increment the frequency bin count, so we display 113 | // low to higher frequency from left to right 114 | freqBin = freqBin + frequencyBinsHorizontal[x]; 115 | } 116 | // after all pixels set, show them all at the same instant 117 | FastLED.show(); 118 | // Serial.println(); 119 | } 120 | } 121 | 122 | 123 | // Run once from setup, the compute the vertical levels 124 | void computeVerticalLevels() { 125 | unsigned int y; 126 | float n, logLevel, linearLevel; 127 | 128 | for (y=0; y < matrix_height; y++) { 129 | n = (float)y / (float)(matrix_height - 1); 130 | logLevel = pow10f(n * -1.0 * (dynamicRange / 20.0)); 131 | linearLevel = 1.0 - n; 132 | linearLevel = linearLevel * linearBlend; 133 | logLevel = logLevel * (1.0 - linearBlend); 134 | thresholdVertical[y] = (logLevel + linearLevel) * maxLevel; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/platforms/arm/kl26/fastpin_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __FASTPIN_ARM_KL26_H 2 | #define __FASTPIN_ARM_KL26_H 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | #if defined(FASTLED_FORCE_SOFTWARE_PINS) 7 | #warning "Software pin support forced, pin access will be sloightly slower." 8 | #define NO_HARDWARE_PIN_SUPPORT 9 | #undef HAS_HARDWARE_PIN_SUPPORT 10 | 11 | #else 12 | 13 | 14 | /// Template definition for teensy LC style ARM pins, providing direct access to the various GPIO registers. Note that this 15 | /// uses the full port GPIO registers. In theory, in some way, bit-band register access -should- be faster, however I have found 16 | /// that something about the way gcc does register allocation results in the bit-band code being slower. It will need more fine tuning. 17 | /// The registers are data output, set output, clear output, toggle output, input, and direction 18 | template class _ARMPIN { 19 | public: 20 | typedef volatile uint32_t * port_ptr_t; 21 | typedef uint32_t port_t; 22 | 23 | inline static void setOutput() { pinMode(PIN, OUTPUT); } // TODO: perform MUX config { _PDDR::r() |= _MASK; } 24 | inline static void setInput() { pinMode(PIN, INPUT); } // TODO: preform MUX config { _PDDR::r() &= ~_MASK; } 25 | 26 | inline static void hi() __attribute__ ((always_inline)) { _PSOR::r() = _MASK; } 27 | inline static void lo() __attribute__ ((always_inline)) { _PCOR::r() = _MASK; } 28 | inline static void set(register port_t val) __attribute__ ((always_inline)) { _PDOR::r() = val; } 29 | 30 | inline static void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); } 31 | 32 | inline static void toggle() __attribute__ ((always_inline)) { _PTOR::r() = _MASK; } 33 | 34 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { hi(); } 35 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { lo(); } 36 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } 37 | 38 | inline static port_t hival() __attribute__ ((always_inline)) { return _PDOR::r() | _MASK; } 39 | inline static port_t loval() __attribute__ ((always_inline)) { return _PDOR::r() & ~_MASK; } 40 | inline static port_ptr_t port() __attribute__ ((always_inline)) { return &_PDOR::r(); } 41 | inline static port_ptr_t sport() __attribute__ ((always_inline)) { return &_PSOR::r(); } 42 | inline static port_ptr_t cport() __attribute__ ((always_inline)) { return &_PCOR::r(); } 43 | inline static port_t mask() __attribute__ ((always_inline)) { return _MASK; } 44 | }; 45 | 46 | // Macros for kl26 pin access/definition 47 | #define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000) 48 | #define GPIO_BITBAND_PTR(reg, bit) ((uint32_t *)GPIO_BITBAND_ADDR((reg), (bit))) 49 | 50 | #define _R(T) struct __gen_struct_ ## T 51 | #define _RD32(T) struct __gen_struct_ ## T { static __attribute__((always_inline)) inline reg32_t r() { return T; } \ 52 | template static __attribute__((always_inline)) inline ptr_reg32_t rx() { return GPIO_BITBAND_PTR(T, BIT); } }; 53 | #define _IO32(L) _RD32(FGPIO ## L ## _PDOR); _RD32(FGPIO ## L ## _PSOR); _RD32(FGPIO ## L ## _PCOR); _RD32(GPIO ## L ## _PTOR); _RD32(FGPIO ## L ## _PDIR); _RD32(FGPIO ## L ## _PDDR); 54 | 55 | #define _DEFPIN_ARM(PIN, BIT, L) template<> class FastPin : public _ARMPIN {}; \ 57 | /* template<> class FastPinBB : public _ARMPIN_BITBAND {}; */ 59 | 60 | // Actual pin definitions 61 | #if defined(FASTLED_TEENSYLC) && defined(CORE_TEENSY) 62 | 63 | _IO32(A); _IO32(B); _IO32(C); _IO32(D); _IO32(E); 64 | 65 | #define MAX_PIN 26 66 | _DEFPIN_ARM(0, 16, B); _DEFPIN_ARM(1, 17, B); _DEFPIN_ARM(2, 0, D); _DEFPIN_ARM(3, 1, A); 67 | _DEFPIN_ARM(4, 2, A); _DEFPIN_ARM(5, 7, D); _DEFPIN_ARM(6, 4, D); _DEFPIN_ARM(7, 2, D); 68 | _DEFPIN_ARM(8, 3, D); _DEFPIN_ARM(9, 3, C); _DEFPIN_ARM(10, 4, C); _DEFPIN_ARM(11, 6, C); 69 | _DEFPIN_ARM(12, 7, C); _DEFPIN_ARM(13, 5, C); _DEFPIN_ARM(14, 1, D); _DEFPIN_ARM(15, 0, C); 70 | _DEFPIN_ARM(16, 0, B); _DEFPIN_ARM(17, 1, B); _DEFPIN_ARM(18, 3, B); _DEFPIN_ARM(19, 2, B); 71 | _DEFPIN_ARM(20, 5, D); _DEFPIN_ARM(21, 6, D); _DEFPIN_ARM(22, 1, C); _DEFPIN_ARM(23, 2, C); 72 | _DEFPIN_ARM(24, 20, E); _DEFPIN_ARM(25, 21, E); _DEFPIN_ARM(26, 30, E); 73 | 74 | #define SPI_DATA 11 75 | #define SPI_CLOCK 13 76 | // #define SPI1 (*(SPI_t *)0x4002D000) 77 | 78 | #define SPI2_DATA 0 79 | #define SPI2_CLOCK 20 80 | 81 | #define HAS_HARDWARE_PIN_SUPPORT 82 | #endif 83 | 84 | #endif // FASTLED_FORCE_SOFTWARE_PINS 85 | 86 | FASTLED_NAMESPACE_END 87 | 88 | #endif // __INC_FASTPIN_ARM_K20 89 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/noise.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_NOISE_H 2 | #define __INC_NOISE_H 3 | 4 | #include "FastLED.h" 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | ///@file noise.h 9 | /// Noise functions provided by the library. 10 | 11 | ///@defgroup Noise Noise functions 12 | ///Simplex noise function definitions 13 | ///@{ 14 | /// @name scaled 16 bit noise functions 15 | ///@{ 16 | /// 16 bit, fixed point implementation of perlin's Simplex Noise. Coordinates are 17 | /// 16.16 fixed point values, 32 bit integers with integral coordinates in the high 16 18 | /// bits and fractional in the low 16 bits, and the function takes 1d, 2d, and 3d coordinate 19 | /// values. These functions are scaled to return 0-65535 20 | 21 | extern uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z); 22 | extern uint16_t inoise16(uint32_t x, uint32_t y); 23 | extern uint16_t inoise16(uint32_t x); 24 | ///@} 25 | 26 | /// @name raw 16 bit noise functions 27 | //@{ 28 | /// 16 bit raw versions of the noise functions. These values are not scaled/altered and have 29 | /// output values roughly in the range (-18k,18k) 30 | extern int16_t inoise16_raw(uint32_t x, uint32_t y, uint32_t z); 31 | extern int16_t inoise16_raw(uint32_t x, uint32_t y); 32 | extern int16_t inoise16_raw(uint32_t x); 33 | ///@} 34 | 35 | /// @name 8 bit scaled noise functions 36 | ///@{ 37 | /// 8 bit, fixed point implementation of perlin's Simplex Noise. Coordinates are 38 | /// 8.8 fixed point values, 16 bit integers with integral coordinates in the high 8 39 | /// bits and fractional in the low 8 bits, and the function takes 1d, 2d, and 3d coordinate 40 | /// values. These functions are scaled to return 0-255 41 | extern uint8_t inoise8(uint16_t x, uint16_t y, uint16_t z); 42 | extern uint8_t inoise8(uint16_t x, uint16_t y); 43 | extern uint8_t inoise8(uint16_t x); 44 | ///@} 45 | 46 | /// @name 8 bit raw noise functions 47 | ///@{ 48 | /// 8 bit raw versions of the noise functions. These values are not scaled/altered and have 49 | /// output values roughly in the range (-70,70) 50 | extern int8_t inoise8_raw(uint16_t x, uint16_t y, uint16_t z); 51 | extern int8_t inoise8_raw(uint16_t x, uint16_t y); 52 | extern int8_t inoise8_raw(uint16_t x); 53 | ///@} 54 | 55 | ///@name raw fill functions 56 | ///@{ 57 | /// Raw noise fill functions - fill into a 1d or 2d array of 8-bit values using either 8-bit noise or 16-bit noise 58 | /// functions. 59 | ///@param pData the array of data to write into 60 | ///@param num_points the number of points of noise to compute 61 | ///@param octaves the number of octaves to use for noise 62 | ///@param x the x position in the noise field 63 | ///@param y the y position in the noise field for 2d functions 64 | ///@param scalex the scale (distance) between x points when filling in noise 65 | ///@param scaley the scale (distance) between y points when filling in noise 66 | ///@param time the time position for the noise field 67 | void fill_raw_noise8(uint8_t *pData, uint8_t num_points, uint8_t octaves, uint16_t x, int scalex, uint16_t time); 68 | void fill_raw_noise16into8(uint8_t *pData, uint8_t num_points, uint8_t octaves, uint32_t x, int scalex, uint32_t time); 69 | void fill_raw_2dnoise8(uint8_t *pData, int width, int height, uint8_t octaves, uint16_t x, int scalex, uint16_t y, int scaley, uint16_t time); 70 | void fill_raw_2dnoise16into8(uint8_t *pData, int width, int height, uint8_t octaves, uint32_t x, int scalex, uint32_t y, int scaley, uint32_t time); 71 | 72 | void fill_raw_2dnoise16(uint16_t *pData, int width, int height, uint8_t octaves, q88 freq88, fract16 amplitude, int skip, uint32_t x, int scalex, uint32_t y, int scaley, uint32_t time); 73 | void fill_raw_2dnoise16into8(uint8_t *pData, int width, int height, uint8_t octaves, q44 freq44, fract8 amplitude, int skip, uint32_t x, int scalex, uint32_t y, int scaley, uint32_t time); 74 | ///@} 75 | 76 | ///@name fill functions 77 | ///@{ 78 | /// fill functions to fill leds with values based on noise functions. These functions use the fill_raw_* functions as appropriate. 79 | void fill_noise8(CRGB *leds, int num_leds, 80 | uint8_t octaves, uint16_t x, int scale, 81 | uint8_t hue_octaves, uint16_t hue_x, int hue_scale, 82 | uint16_t time); 83 | void fill_noise16(CRGB *leds, int num_leds, 84 | uint8_t octaves, uint16_t x, int scale, 85 | uint8_t hue_octaves, uint16_t hue_x, int hue_scale, 86 | uint16_t time, uint8_t hue_shift=0); 87 | void fill_2dnoise8(CRGB *leds, int width, int height, bool serpentine, 88 | uint8_t octaves, uint16_t x, int xscale, uint16_t y, int yscale, uint16_t time, 89 | uint8_t hue_octaves, uint16_t hue_x, int hue_xscale, uint16_t hue_y, uint16_t hue_yscale,uint16_t hue_time,bool blend); 90 | void fill_2dnoise16(CRGB *leds, int width, int height, bool serpentine, 91 | uint8_t octaves, uint32_t x, int xscale, uint32_t y, int yscale, uint32_t time, 92 | uint8_t hue_octaves, uint16_t hue_x, int hue_xscale, uint16_t hue_y, uint16_t hue_yscale,uint16_t hue_time, bool blend, uint16_t hue_shift=0); 93 | 94 | FASTLED_NAMESPACE_END 95 | ///@} 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/colorpalettes.cpp: -------------------------------------------------------------------------------- 1 | #ifndef __INC_COLORPALETTES_H 2 | #define __INC_COLORPALETTES_H 3 | #define FASTLED_INTERNAL 4 | #include "FastLED.h" 5 | #include "colorutils.h" 6 | #include "colorpalettes.h" 7 | 8 | FASTLED_USING_NAMESPACE 9 | 10 | 11 | // Preset color schemes, such as they are. 12 | 13 | // These schemes are all declared as "PROGMEM", meaning 14 | // that they won't take up SRAM on AVR chips until used. 15 | // Furthermore, the compiler won't even include these 16 | // in your PROGMEM (flash) storage unless you specifically 17 | // use each one, so you only 'pay for' those you actually use. 18 | 19 | 20 | extern const TProgmemRGBPalette16 CloudColors_p FL_PROGMEM = 21 | { 22 | CRGB::Blue, 23 | CRGB::DarkBlue, 24 | CRGB::DarkBlue, 25 | CRGB::DarkBlue, 26 | 27 | CRGB::DarkBlue, 28 | CRGB::DarkBlue, 29 | CRGB::DarkBlue, 30 | CRGB::DarkBlue, 31 | 32 | CRGB::Blue, 33 | CRGB::DarkBlue, 34 | CRGB::SkyBlue, 35 | CRGB::SkyBlue, 36 | 37 | CRGB::LightBlue, 38 | CRGB::White, 39 | CRGB::LightBlue, 40 | CRGB::SkyBlue 41 | }; 42 | 43 | extern const TProgmemRGBPalette16 LavaColors_p FL_PROGMEM = 44 | { 45 | CRGB::Black, 46 | CRGB::Maroon, 47 | CRGB::Black, 48 | CRGB::Maroon, 49 | 50 | CRGB::DarkRed, 51 | CRGB::Maroon, 52 | CRGB::DarkRed, 53 | 54 | CRGB::DarkRed, 55 | CRGB::DarkRed, 56 | CRGB::Red, 57 | CRGB::Orange, 58 | 59 | CRGB::White, 60 | CRGB::Orange, 61 | CRGB::Red, 62 | CRGB::DarkRed 63 | }; 64 | 65 | 66 | extern const TProgmemRGBPalette16 OceanColors_p FL_PROGMEM = 67 | { 68 | CRGB::MidnightBlue, 69 | CRGB::DarkBlue, 70 | CRGB::MidnightBlue, 71 | CRGB::Navy, 72 | 73 | CRGB::DarkBlue, 74 | CRGB::MediumBlue, 75 | CRGB::SeaGreen, 76 | CRGB::Teal, 77 | 78 | CRGB::CadetBlue, 79 | CRGB::Blue, 80 | CRGB::DarkCyan, 81 | CRGB::CornflowerBlue, 82 | 83 | CRGB::Aquamarine, 84 | CRGB::SeaGreen, 85 | CRGB::Aqua, 86 | CRGB::LightSkyBlue 87 | }; 88 | 89 | extern const TProgmemRGBPalette16 ForestColors_p FL_PROGMEM = 90 | { 91 | CRGB::DarkGreen, 92 | CRGB::DarkGreen, 93 | CRGB::DarkOliveGreen, 94 | CRGB::DarkGreen, 95 | 96 | CRGB::Green, 97 | CRGB::ForestGreen, 98 | CRGB::OliveDrab, 99 | CRGB::Green, 100 | 101 | CRGB::SeaGreen, 102 | CRGB::MediumAquamarine, 103 | CRGB::LimeGreen, 104 | CRGB::YellowGreen, 105 | 106 | CRGB::LightGreen, 107 | CRGB::LawnGreen, 108 | CRGB::MediumAquamarine, 109 | CRGB::ForestGreen 110 | }; 111 | 112 | /// HSV Rainbow 113 | extern const TProgmemRGBPalette16 RainbowColors_p FL_PROGMEM = 114 | { 115 | 0xFF0000, 0xD52A00, 0xAB5500, 0xAB7F00, 116 | 0xABAB00, 0x56D500, 0x00FF00, 0x00D52A, 117 | 0x00AB55, 0x0056AA, 0x0000FF, 0x2A00D5, 118 | 0x5500AB, 0x7F0081, 0xAB0055, 0xD5002B 119 | }; 120 | 121 | /// HSV Rainbow colors with alternatating stripes of black 122 | #define RainbowStripesColors_p RainbowStripeColors_p 123 | extern const TProgmemRGBPalette16 RainbowStripeColors_p FL_PROGMEM = 124 | { 125 | 0xFF0000, 0x000000, 0xAB5500, 0x000000, 126 | 0xABAB00, 0x000000, 0x00FF00, 0x000000, 127 | 0x00AB55, 0x000000, 0x0000FF, 0x000000, 128 | 0x5500AB, 0x000000, 0xAB0055, 0x000000 129 | }; 130 | 131 | /// HSV color ramp: blue purple ping red orange yellow (and back) 132 | /// Basically, everything but the greens, which tend to make 133 | /// people's skin look unhealthy. This palette is good for 134 | /// lighting at a club or party, where it'll be shining on people. 135 | extern const TProgmemRGBPalette16 PartyColors_p FL_PROGMEM = 136 | { 137 | 0x5500AB, 0x84007C, 0xB5004B, 0xE5001B, 138 | 0xE81700, 0xB84700, 0xAB7700, 0xABAB00, 139 | 0xAB5500, 0xDD2200, 0xF2000E, 0xC2003E, 140 | 0x8F0071, 0x5F00A1, 0x2F00D0, 0x0007F9 141 | }; 142 | 143 | /// Approximate "black body radiation" palette, akin to 144 | /// the FastLED 'HeatColor' function. 145 | /// Recommend that you use values 0-240 rather than 146 | /// the usual 0-255, as the last 15 colors will be 147 | /// 'wrapping around' from the hot end to the cold end, 148 | /// which looks wrong. 149 | extern const TProgmemRGBPalette16 HeatColors_p FL_PROGMEM = 150 | { 151 | 0x000000, 152 | 0x330000, 0x660000, 0x990000, 0xCC0000, 0xFF0000, 153 | 0xFF3300, 0xFF6600, 0xFF9900, 0xFFCC00, 0xFFFF00, 154 | 0xFFFF33, 0xFFFF66, 0xFFFF99, 0xFFFFCC, 0xFFFFFF 155 | }; 156 | 157 | 158 | // Gradient palette "Rainbow_gp", 159 | // provided for situations where you're going 160 | // to use a number of other gradient palettes, AND 161 | // you want a 'standard' FastLED rainbow as well. 162 | 163 | DEFINE_GRADIENT_PALETTE( Rainbow_gp ) { 164 | 0, 255, 0, 0, // Red 165 | 32, 171, 85, 0, // Orange 166 | 64, 171,171, 0, // Yellow 167 | 96, 0,255, 0, // Green 168 | 128, 0,171, 85, // Aqua 169 | 160, 0, 0,255, // Blue 170 | 192, 85, 0,171, // Purple 171 | 224, 171, 0, 85, // Pink 172 | 255, 255, 0, 0};// and back to Red 173 | 174 | #endif 175 | -------------------------------------------------------------------------------- /firmware/HyperGyver/HyperGyver.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Скетч к проекту "Гиперкуб" 3 | Страница проекта (схемы, описания): https://alexgyver.ru/hypergyver/ 4 | Исходники на GitHub: https://github.com/AlexGyver/hypergyver/ 5 | Нравится, как написан и закомментирован код? Поддержи автора! https://alexgyver.ru/support_alex/ 6 | Автор: AlexGyver Technologies, 2020 7 | http://AlexGyver.ru/ 8 | */ 9 | 10 | // ===== НАСТРОЙКИ ===== 11 | #define EDGE_LEDS 11 // кол-во диодов на ребре куба 12 | #define LED_DI 2 // пин подключения 13 | #define BRIGHT 250 // яркость 14 | #define CHANGE_PRD 10 // смена режима, секунд 15 | #define CUR_LIMIT 2000 // лимит тока в мА (0 - выкл) 16 | 17 | // ===== ДЛЯ РАЗРАБОВ ===== 18 | const int NUM_LEDS = (EDGE_LEDS * 24); 19 | #define USE_MICROLED 0 20 | #include 21 | CRGBPalette16 currentPalette; 22 | const int FACE_SIZE = EDGE_LEDS * 4; 23 | const int LINE_SIZE = EDGE_LEDS; 24 | #define PAL_STEP 30 25 | CRGB leds[NUM_LEDS]; 26 | 27 | int perlinPoint; 28 | int curBright = BRIGHT; 29 | bool fadeFlag = false; 30 | bool mode = true; 31 | bool colorMode = true; 32 | uint16_t counter = 0; 33 | byte speed = 15; 34 | uint32_t tmrDraw, tmrColor, tmrFade; 35 | 36 | #define DEBUG(x) //Serial.println(x) 37 | 38 | uint32_t getPixColor(CRGB color) { 39 | return (((uint32_t)color.r << 16) | (color.g << 8) | color.b); 40 | } 41 | 42 | void setup() { 43 | Serial.begin(9600); 44 | 45 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); 46 | if (CUR_LIMIT > 0) FastLED.setMaxPowerInVoltsAndMilliamps(5, CUR_LIMIT); 47 | FastLED.setBrightness(BRIGHT); 48 | FastLED.clear(); 49 | random16_set_seed(getEntropy(A0)); // My system's in decline, EMBRACING ENTROPY! 50 | perlinPoint = random16(); 51 | fadeFlag = true; // сразу флаг на смену режима 52 | } 53 | 54 | void loop() { 55 | // отрисовка 56 | if (millis() - tmrDraw >= 40) { 57 | tmrDraw = millis(); 58 | for (int i = 0; i < FACE_SIZE; i++) { 59 | if (mode) fillSimple(i, ColorFromPalette(currentPalette, getMaxNoise(i * PAL_STEP + counter, counter), 255, LINEARBLEND)); 60 | else fillVertex(i, ColorFromPalette(currentPalette, getMaxNoise(i * PAL_STEP / 4 + counter, counter), 255, LINEARBLEND)); 61 | } 62 | FastLED.show(); 63 | counter += speed; 64 | } 65 | 66 | // смена режима и цвета 67 | if (millis() - tmrColor >= CHANGE_PRD * 1000L) { 68 | tmrColor = millis(); 69 | fadeFlag = true; 70 | } 71 | 72 | // фейдер для смены через чёрный 73 | if (fadeFlag && millis() - tmrFade >= 30) { 74 | static int8_t fadeDir = -1; 75 | tmrFade = millis(); 76 | if (fadeFlag) { 77 | curBright += 5 * fadeDir; 78 | 79 | if (curBright < 5) { 80 | curBright = 5; 81 | fadeDir = 1; 82 | changeMode(); 83 | } 84 | if (curBright > BRIGHT) { 85 | curBright = BRIGHT; 86 | fadeDir = -1; 87 | fadeFlag = false; 88 | } 89 | FastLED.setBrightness(curBright); 90 | } 91 | } 92 | } // луп 93 | 94 | void changeMode() { 95 | if (!random(3)) mode = !mode; 96 | speed = constrain(random8(), 4, 12); 97 | colorMode = !colorMode; 98 | int thisDebth = random16(); 99 | byte thisStep = random(2, 7) * 5; 100 | bool sparkles = !random(5); 101 | 102 | if (colorMode) { 103 | for (int i = 0; i < 16; i++) { 104 | currentPalette[i] = CHSV(getMaxNoise(thisDebth + i * thisStep, thisDebth), 105 | sparkles ? (!random(9) ? 30 : 255) : 255, 106 | constrain((i + 7) * (i + 7), 0, 255)); 107 | } 108 | } else { 109 | for (int i = 0; i < 4; i++) { 110 | CHSV color = CHSV(random8(), random8(), (uint8_t)(i + 1) * 64 - 1); 111 | for (byte j = 0; j < 4; j++) { 112 | currentPalette[i * 4 + j] = color; 113 | } 114 | } 115 | } 116 | } 117 | 118 | byte getMaxNoise(uint16_t x, uint16_t y) { 119 | return constrain(map(inoise8(x, y), 50, 200, 0, 255), 0, 255); 120 | } 121 | 122 | 123 | // заливка всех 6 граней в одинаковом порядке 124 | void fillSimple(int num, CRGB color) { // num 0-NUM_LEDS / 6 125 | for (byte i = 0; i < 6; i++) { 126 | leds[i * FACE_SIZE + num] = color; 127 | } 128 | } 129 | 130 | // заливка из четырёх вершин 131 | void fillVertex(int num, CRGB color) { // num 0-NUM_LEDS / 6 132 | num /= 4; 133 | byte thisRow = 0; 134 | for (byte i = 0; i < 3; i++) { 135 | leds[LINE_SIZE * thisRow + num] = color; 136 | thisRow += 2; 137 | leds[LINE_SIZE * thisRow - num - 1] = color; 138 | leds[LINE_SIZE * thisRow + num] = color; 139 | thisRow += 2; 140 | leds[LINE_SIZE * thisRow - num - 1] = color; 141 | } 142 | thisRow = 13; 143 | for (byte i = 0; i < 3; i++) { 144 | leds[LINE_SIZE * thisRow - num - 1] = color; 145 | leds[LINE_SIZE * thisRow + num] = color; 146 | thisRow += 2; 147 | leds[LINE_SIZE * thisRow - num - 1] = color; 148 | leds[LINE_SIZE * thisRow + num] = color; 149 | thisRow += 2; 150 | } 151 | } 152 | 153 | // рандом сид из сырого аналога 154 | uint32_t getEntropy(byte pin) { 155 | unsigned long seed = 0; 156 | for (int i = 0; i < 400; i++) { 157 | seed = 1; 158 | for (byte j = 0; j < 16; j++) { 159 | seed *= 4; 160 | seed += analogRead(pin) & 3; 161 | } 162 | } 163 | return seed; 164 | } 165 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/fastled_delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FL_DELAY_H 2 | #define __INC_FL_DELAY_H 3 | 4 | #include "FastLED.h" 5 | 6 | ///@file fastled_delay.h 7 | ///Utility functions and classes for managing delaycycles 8 | 9 | FASTLED_NAMESPACE_BEGIN 10 | 11 | /// Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not enough time has passed yet 12 | /// this should make sure that chipsets that have 13 | template class CMinWait { 14 | uint16_t mLastMicros; 15 | public: 16 | CMinWait() { mLastMicros = 0; } 17 | 18 | void wait() { 19 | uint16_t diff; 20 | do { 21 | diff = (micros() & 0xFFFF) - mLastMicros; 22 | } while(diff < WAIT); 23 | } 24 | 25 | void mark() { mLastMicros = micros() & 0xFFFF; } 26 | }; 27 | 28 | 29 | //////////////////////////////////////////////////////////////////////////////////////////// 30 | // 31 | // Clock cycle counted delay loop 32 | // 33 | //////////////////////////////////////////////////////////////////////////////////////////// 34 | 35 | // Default is now just 'nop', with special case for AVR 36 | 37 | // ESP32 core has it's own definition of NOP, so undef it first 38 | #ifdef ESP32 39 | #undef NOP 40 | #undef NOP2 41 | #endif 42 | 43 | #if defined(__AVR__) 44 | # define FL_NOP __asm__ __volatile__ ("cp r0,r0\n"); 45 | # define FL_NOP2 __asm__ __volatile__ ("rjmp .+0"); 46 | #else 47 | # define FL_NOP __asm__ __volatile__ ("nop\n"); 48 | # define FL_NOP2 __asm__ __volatile__ ("nop\n\t nop\n"); 49 | #endif 50 | 51 | // predeclaration to not upset the compiler 52 | template inline void delaycycles(); 53 | template inline void delaycycles_min1() { 54 | delaycycles<1>(); 55 | delaycycles(); 56 | } 57 | 58 | 59 | // TODO: ARM version of _delaycycles_ 60 | 61 | // usable definition 62 | #if defined(FASTLED_AVR) 63 | // worker template - this will nop for LOOP * 3 + PAD cycles total 64 | template inline void _delaycycles_AVR() { 65 | delaycycles(); 66 | // the loop below is 3 cycles * LOOP. the LDI is one cycle, 67 | // the DEC is 1 cycle, the BRNE is 2 cycles if looping back and 68 | // 1 if not (the LDI balances out the BRNE being 1 cycle on exit) 69 | __asm__ __volatile__ ( 70 | " LDI R16, %0\n" 71 | "L_%=: DEC R16\n" 72 | " BRNE L_%=\n" 73 | : /* no outputs */ 74 | : "M" (LOOP) 75 | : "r16" 76 | ); 77 | } 78 | 79 | template __attribute__((always_inline)) inline void delaycycles() { 80 | _delaycycles_AVR(); 81 | } 82 | #else 83 | // template inline void _delaycycles_ARM() { 84 | // delaycycles(); 85 | // // the loop below is 3 cycles * LOOP. the LDI is one cycle, 86 | // // the DEC is 1 cycle, the BRNE is 2 cycles if looping back and 87 | // // 1 if not (the LDI balances out the BRNE being 1 cycle on exit) 88 | // __asm__ __volatile__ ( 89 | // " mov.w r9, %0\n" 90 | // "L_%=: subs.w r9, r9, #1\n" 91 | // " bne.n L_%=\n" 92 | // : /* no outputs */ 93 | // : "M" (LOOP) 94 | // : "r9" 95 | // ); 96 | // } 97 | 98 | 99 | template __attribute__((always_inline)) inline void delaycycles() { 100 | // _delaycycles_ARM(); 101 | FL_NOP; delaycycles(); 102 | } 103 | #endif 104 | 105 | // pre-instantiations for values small enough to not need the loop, as well as sanity holders 106 | // for some negative values. 107 | template<> __attribute__((always_inline)) inline void delaycycles<-10>() {} 108 | template<> __attribute__((always_inline)) inline void delaycycles<-9>() {} 109 | template<> __attribute__((always_inline)) inline void delaycycles<-8>() {} 110 | template<> __attribute__((always_inline)) inline void delaycycles<-7>() {} 111 | template<> __attribute__((always_inline)) inline void delaycycles<-6>() {} 112 | template<> __attribute__((always_inline)) inline void delaycycles<-5>() {} 113 | template<> __attribute__((always_inline)) inline void delaycycles<-4>() {} 114 | template<> __attribute__((always_inline)) inline void delaycycles<-3>() {} 115 | template<> __attribute__((always_inline)) inline void delaycycles<-2>() {} 116 | template<> __attribute__((always_inline)) inline void delaycycles<-1>() {} 117 | template<> __attribute__((always_inline)) inline void delaycycles<0>() {} 118 | template<> __attribute__((always_inline)) inline void delaycycles<1>() {FL_NOP;} 119 | template<> __attribute__((always_inline)) inline void delaycycles<2>() {FL_NOP2;} 120 | template<> __attribute__((always_inline)) inline void delaycycles<3>() {FL_NOP;FL_NOP2;} 121 | template<> __attribute__((always_inline)) inline void delaycycles<4>() {FL_NOP2;FL_NOP2;} 122 | template<> __attribute__((always_inline)) inline void delaycycles<5>() {FL_NOP2;FL_NOP2;FL_NOP;} 123 | 124 | // Some timing related macros/definitions 125 | 126 | // Macro to convert from nano-seconds to clocks and clocks to nano-seconds 127 | // #define NS(_NS) (_NS / (1000 / (F_CPU / 1000000L))) 128 | #define F_CPU_MHZ (F_CPU / 1000000L) 129 | 130 | // #define NS(_NS) ( (_NS * (F_CPU / 1000000L))) / 1000 131 | #define NS(_NS) (((_NS * F_CPU_MHZ) + 999) / 1000) 132 | #define CLKS_TO_MICROS(_CLKS) ((long)(_CLKS)) / (F_CPU / 1000000L) 133 | 134 | // Macro for making sure there's enough time available 135 | #define NO_TIME(A, B, C) (NS(A) < 3 || NS(B) < 3 || NS(C) < 6) 136 | 137 | FASTLED_NAMESPACE_END 138 | 139 | #endif 140 | -------------------------------------------------------------------------------- /firmware/HyperGyver_v1.1/HyperGyver_v1.1.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Скетч к проекту "Гиперкуб" 3 | Страница проекта (схемы, описания): https://alexgyver.ru/hypergyver/ 4 | Исходники на GitHub: https://github.com/AlexGyver/hypergyver/ 5 | Нравится, как написан и закомментирован код? Поддержи автора! https://alexgyver.ru/support_alex/ 6 | Автор: AlexGyver Technologies, 2020 7 | http://AlexGyver.ru/ 8 | */ 9 | 10 | // Версия 1.1: исправлен случайный глюк. Виноваты random функции из либы FastLED!!! 11 | 12 | // ===== НАСТРОЙКИ ===== 13 | #define EDGE_LEDS 11 // кол-во диодов на ребре куба 14 | #define LED_DI 2 // пин подключения 15 | #define BRIGHT 255 // яркость 16 | #define CHANGE_PRD 10 // смена режима, секунд 17 | #define CUR_LIMIT 2000 // лимит тока в мА (0 - выкл) 18 | 19 | // ===== ДЛЯ РАЗРАБОВ ===== 20 | const int NUM_LEDS = (EDGE_LEDS * 24); 21 | #define USE_MICROLED 0 22 | #include 23 | CRGBPalette16 currentPalette; 24 | const int FACE_SIZE = EDGE_LEDS * 4; 25 | const int LINE_SIZE = EDGE_LEDS; 26 | #define PAL_STEP 30 27 | CRGB leds[NUM_LEDS]; 28 | 29 | int perlinPoint; 30 | int curBright = BRIGHT; 31 | bool fadeFlag = false; 32 | bool mode = true; 33 | bool colorMode = true; 34 | uint16_t counter = 0; 35 | byte speed = 15; 36 | uint32_t tmrDraw, tmrColor, tmrFade; 37 | 38 | #define DEBUG(x) //Serial.println(x) 39 | 40 | uint32_t getPixColor(CRGB color) { 41 | return (((uint32_t)color.r << 16) | (color.g << 8) | color.b); 42 | } 43 | 44 | void setup() { 45 | Serial.begin(9600); 46 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); 47 | if (CUR_LIMIT > 0) FastLED.setMaxPowerInVoltsAndMilliamps(5, CUR_LIMIT); 48 | FastLED.setBrightness(BRIGHT); 49 | FastLED.clear(); 50 | 51 | randomSeed(getEntropy(A0)); // My system's in decline, EMBRACING ENTROPY! 52 | perlinPoint = random(0, 32768); 53 | fadeFlag = true; // сразу флаг на смену режима 54 | } 55 | 56 | void loop() { 57 | // отрисовка 58 | if (millis() - tmrDraw >= 40) { 59 | tmrDraw = millis(); 60 | for (int i = 0; i < FACE_SIZE; i++) { 61 | if (mode) fillSimple(i, ColorFromPalette(currentPalette, getMaxNoise(i * PAL_STEP + counter, counter), 255, LINEARBLEND)); 62 | else fillVertex(i, ColorFromPalette(currentPalette, getMaxNoise(i * PAL_STEP / 4 + counter, counter), 255, LINEARBLEND)); 63 | } 64 | FastLED.show(); 65 | counter += speed; 66 | } 67 | 68 | // смена режима и цвета 69 | if (millis() - tmrColor >= CHANGE_PRD * 1000L) { 70 | tmrColor = millis(); 71 | fadeFlag = true; 72 | } 73 | 74 | // фейдер для смены через чёрный 75 | if (fadeFlag && millis() - tmrFade >= 30) { 76 | static int8_t fadeDir = -1; 77 | tmrFade = millis(); 78 | if (fadeFlag) { 79 | curBright += 5 * fadeDir; 80 | 81 | if (curBright < 5) { 82 | curBright = 5; 83 | fadeDir = 1; 84 | changeMode(); 85 | } 86 | if (curBright > BRIGHT) { 87 | curBright = BRIGHT; 88 | fadeDir = -1; 89 | fadeFlag = false; 90 | } 91 | FastLED.setBrightness(curBright); 92 | } 93 | } 94 | } // луп 95 | 96 | void changeMode() { 97 | if (!random(3)) mode = !mode; 98 | speed = random(4, 12); 99 | colorMode = !colorMode; 100 | int thisDebth = random(0, 32768); 101 | byte thisStep = random(2, 7) * 5; 102 | bool sparkles = !random(5); 103 | 104 | if (colorMode) { 105 | for (int i = 0; i < 16; i++) { 106 | currentPalette[i] = CHSV(getMaxNoise(thisDebth + i * thisStep, thisDebth), 107 | sparkles ? (!random(9) ? 30 : 255) : 255, 108 | constrain((i + 7) * (i + 7), 0, 255)); 109 | } 110 | } else { 111 | for (int i = 0; i < 4; i++) { 112 | CHSV color = CHSV(random(0, 256), random(0, 256), (uint8_t)(i + 1) * 64 - 1); 113 | for (byte j = 0; j < 4; j++) { 114 | currentPalette[i * 4 + j] = color; 115 | } 116 | } 117 | } 118 | } 119 | 120 | // масштабируем шум 121 | byte getMaxNoise(uint16_t x, uint16_t y) { 122 | return constrain(map(inoise8(x, y), 50, 200, 0, 255), 0, 255); 123 | } 124 | 125 | // заливка всех 6 граней в одинаковом порядке 126 | void fillSimple(int num, CRGB color) { // num 0-NUM_LEDS / 6 127 | for (byte i = 0; i < 6; i++) { 128 | leds[i * FACE_SIZE + num] = color; 129 | } 130 | } 131 | 132 | // заливка из четырёх вершин 133 | void fillVertex(int num, CRGB color) { // num 0-NUM_LEDS / 6 134 | num /= 4; 135 | byte thisRow = 0; 136 | for (byte i = 0; i < 3; i++) { 137 | leds[LINE_SIZE * thisRow + num] = color; 138 | thisRow += 2; 139 | leds[LINE_SIZE * thisRow - num - 1] = color; 140 | leds[LINE_SIZE * thisRow + num] = color; 141 | thisRow += 2; 142 | leds[LINE_SIZE * thisRow - num - 1] = color; 143 | } 144 | thisRow = 13; 145 | for (byte i = 0; i < 3; i++) { 146 | leds[LINE_SIZE * thisRow - num - 1] = color; 147 | leds[LINE_SIZE * thisRow + num] = color; 148 | thisRow += 2; 149 | leds[LINE_SIZE * thisRow - num - 1] = color; 150 | leds[LINE_SIZE * thisRow + num] = color; 151 | thisRow += 2; 152 | } 153 | } 154 | 155 | // рандом сид из сырого аналога 156 | uint32_t getEntropy(byte pin) { 157 | unsigned long seed = 0; 158 | for (int i = 0; i < 400; i++) { 159 | seed = 1; 160 | for (byte j = 0; j < 16; j++) { 161 | seed *= 4; 162 | seed += analogRead(pin) & 3; 163 | } 164 | } 165 | return seed; 166 | } 167 | -------------------------------------------------------------------------------- /libraries/FastLED-3.2.9/fastspi.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTSPI_H 2 | #define __INC_FASTSPI_H 3 | 4 | #include "FastLED.h" 5 | 6 | #include "controller.h" 7 | #include "lib8tion.h" 8 | 9 | #include "fastspi_bitbang.h" 10 | 11 | FASTLED_NAMESPACE_BEGIN 12 | 13 | #if defined(FASTLED_TEENSY3) && (F_CPU > 48000000) 14 | #define DATA_RATE_MHZ(X) (((48000000L / 1000000L) / X)) 15 | #define DATA_RATE_KHZ(X) (((48000000L / 1000L) / X)) 16 | #else 17 | #define DATA_RATE_MHZ(X) ((F_CPU / 1000000L) / X) 18 | #define DATA_RATE_KHZ(X) ((F_CPU / 1000L) / X) 19 | #endif 20 | 21 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 22 | // 23 | // External SPI template definition with partial instantiation(s) to map to hardware SPI ports on platforms/builds where the pin 24 | // mappings are known at compile time. 25 | // 26 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 27 | 28 | #if !defined(FASTLED_ALL_PINS_HARDWARE_SPI) 29 | template 30 | class SPIOutput : public AVRSoftwareSPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER> {}; 31 | #endif 32 | 33 | template 34 | class SoftwareSPIOutput : public AVRSoftwareSPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER> {}; 35 | 36 | #ifndef FASTLED_FORCE_SOFTWARE_SPI 37 | 38 | #if defined(NRF51) && defined(FASTLED_ALL_PINS_HARDWARE_SPI) 39 | template 40 | class SPIOutput : public NRF51SPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER> {}; 41 | #endif 42 | 43 | #if defined(NRF52_SERIES) && defined(FASTLED_ALL_PINS_HARDWARE_SPI) 44 | template 45 | class SPIOutput : public NRF52SPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER> {}; 46 | #endif 47 | 48 | #if defined(SPI_DATA) && defined(SPI_CLOCK) 49 | 50 | #if defined(FASTLED_TEENSY3) && defined(ARM_HARDWARE_SPI) 51 | 52 | template 53 | class SPIOutput : public ARMHardwareSPIOutput {}; 54 | 55 | #if defined(SPI2_DATA) 56 | 57 | template 58 | class SPIOutput : public ARMHardwareSPIOutput {}; 59 | 60 | template 61 | class SPIOutput : public ARMHardwareSPIOutput {}; 62 | 63 | template 64 | class SPIOutput : public ARMHardwareSPIOutput {}; 65 | #endif 66 | 67 | #elif defined(FASTLED_TEENSYLC) && defined(ARM_HARDWARE_SPI) 68 | 69 | #define DECLARE_SPI0(__DATA,__CLOCK) template\ 70 | class SPIOutput<__DATA, __CLOCK, SPI_SPEED> : public ARMHardwareSPIOutput<__DATA, __CLOCK, SPI_SPEED, 0x40076000> {}; 71 | #define DECLARE_SPI1(__DATA,__CLOCK) template\ 72 | class SPIOutput<__DATA, __CLOCK, SPI_SPEED> : public ARMHardwareSPIOutput<__DATA, __CLOCK, SPI_SPEED, 0x40077000> {}; 73 | 74 | DECLARE_SPI0(7,13); 75 | DECLARE_SPI0(8,13); 76 | DECLARE_SPI0(11,13); 77 | DECLARE_SPI0(12,13); 78 | DECLARE_SPI0(7,14); 79 | DECLARE_SPI0(8,14); 80 | DECLARE_SPI0(11,14); 81 | DECLARE_SPI0(12,14); 82 | DECLARE_SPI1(0,20); 83 | DECLARE_SPI1(1,20); 84 | DECLARE_SPI1(21,20); 85 | 86 | #elif defined(__SAM3X8E__) 87 | 88 | template 89 | class SPIOutput : public SAMHardwareSPIOutput {}; 90 | 91 | #elif defined(AVR_HARDWARE_SPI) 92 | 93 | template 94 | class SPIOutput : public AVRHardwareSPIOutput {}; 95 | 96 | #if defined(SPI_UART0_DATA) 97 | 98 | template 99 | class SPIOutput : public AVRUSART0SPIOutput {}; 100 | 101 | #endif 102 | 103 | #if defined(SPI_UART1_DATA) 104 | 105 | template 106 | class SPIOutput : public AVRUSART1SPIOutput {}; 107 | 108 | #endif 109 | 110 | #endif 111 | 112 | #else 113 | # if !defined(FASTLED_INTERNAL) && !defined(FASTLED_ALL_PINS_HARDWARE_SPI) 114 | # ifdef FASTLED_HAS_PRAGMA_MESSAGE 115 | # pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output" 116 | # else 117 | # warning "No hardware SPI pins defined. All SPI access will default to bitbanged output" 118 | # endif 119 | # endif 120 | #endif 121 | 122 | // #if defined(USART_DATA) && defined(USART_CLOCK) 123 | // template 124 | // class AVRSPIOutput : public AVRUSARTSPIOutput {}; 125 | // #endif 126 | 127 | #else 128 | # if !defined(FASTLED_INTERNAL) && !defined(FASTLED_ALL_PINS_HARDWARE_SPI) 129 | # ifdef FASTLED_HAS_PRAGMA_MESSAGE 130 | # pragma message "Forcing software SPI - no hardware SPI for you!" 131 | # else 132 | # warning "Forcing software SPI - no hardware SPI for you!" 133 | # endif 134 | # endif 135 | #endif 136 | 137 | FASTLED_NAMESPACE_END 138 | 139 | #endif 140 | --------------------------------------------------------------------------------