├── .gitattributes ├── README.md ├── firmware └── notamesh4_gyver_v1.1 │ ├── 1main.ino │ ├── IRremote.h │ ├── addings.h │ ├── blendwave.h │ ├── candles.h │ ├── colorwave.h │ ├── commands.h │ ├── confetti_pal.h │ ├── fire.h │ ├── getirl.h │ ├── gradient_palettes.h │ ├── juggle_pal.h │ ├── matrix_pal.h │ ├── noise16_pal.h │ ├── noise8_pal.h │ ├── notamesh4_gyver_v1.1.ino │ ├── one_sin_pal.h │ ├── plasma.h │ ├── rainbow_beat.h │ ├── rainbow_march.h │ ├── serendipitous_pal.h │ ├── three_sin_pal.h │ └── two_sin.h ├── libraries ├── FastLED-3.2.9 │ ├── FastLED.cpp │ ├── FastLED.h │ ├── LICENSE │ ├── PORTING.md │ ├── README.md │ ├── bitswap.cpp │ ├── bitswap.h │ ├── chipsets.h │ ├── color.h │ ├── colorpalettes.cpp │ ├── colorpalettes.h │ ├── colorutils.cpp │ ├── colorutils.h │ ├── component.mk │ ├── controller.h │ ├── cpp_compat.h │ ├── dmx.h │ ├── docs │ │ ├── Doxyfile │ │ └── mainpage.dox │ ├── examples │ │ ├── AnalogOutput │ │ │ └── AnalogOutput.ino │ │ ├── Blink │ │ │ └── Blink.ino │ │ ├── ColorPalette │ │ │ └── ColorPalette.ino │ │ ├── ColorTemperature │ │ │ └── ColorTemperature.ino │ │ ├── Cylon │ │ │ └── Cylon.ino │ │ ├── DemoReel100 │ │ │ └── DemoReel100.ino │ │ ├── Fire2012 │ │ │ └── Fire2012.ino │ │ ├── Fire2012WithPalette │ │ │ └── Fire2012WithPalette.ino │ │ ├── FirstLight │ │ │ └── FirstLight.ino │ │ ├── Multiple │ │ │ ├── ArrayOfLedArrays │ │ │ │ └── ArrayOfLedArrays.ino │ │ │ ├── MirroringSample │ │ │ │ └── MirroringSample.ino │ │ │ ├── MultiArrays │ │ │ │ └── MultiArrays.ino │ │ │ ├── MultipleStripsInOneArray │ │ │ │ └── MultipleStripsInOneArray.ino │ │ │ ├── OctoWS2811Demo │ │ │ │ └── OctoWS2811Demo.ino │ │ │ └── ParallelOutputDemo │ │ │ │ └── ParallelOutputDemo.ino │ │ ├── Noise │ │ │ └── Noise.ino │ │ ├── NoisePlayground │ │ │ └── NoisePlayground.ino │ │ ├── NoisePlusPalette │ │ │ └── NoisePlusPalette.ino │ │ ├── Pintest │ │ │ └── Pintest.ino │ │ ├── Ports │ │ │ └── PJRCSpectrumAnalyzer │ │ │ │ └── PJRCSpectrumAnalyzer.ino │ │ ├── RGBCalibrate │ │ │ └── RGBCalibrate.ino │ │ ├── RGBSetDemo │ │ │ └── RGBSetDemo.ino │ │ ├── SmartMatrix │ │ │ └── SmartMatrix.ino │ │ └── XYMatrix │ │ │ └── XYMatrix.ino │ ├── extras │ │ ├── AppleII.s65 │ │ ├── FastLED6502.s65 │ │ ├── RainbowDemo.bin.zip │ │ └── RainbowDemo.s65 │ ├── fastled_config.h │ ├── fastled_delay.h │ ├── fastled_progmem.h │ ├── fastpin.h │ ├── fastspi.h │ ├── fastspi_bitbang.h │ ├── fastspi_dma.h │ ├── fastspi_nop.h │ ├── fastspi_ref.h │ ├── fastspi_types.h │ ├── hsv2rgb.cpp │ ├── hsv2rgb.h │ ├── keywords.txt │ ├── led_sysdefs.h │ ├── lib8tion.cpp │ ├── lib8tion.h │ ├── lib8tion │ │ ├── math8.h │ │ ├── random8.h │ │ ├── scale8.h │ │ └── trig8.h │ ├── library.json │ ├── library.properties │ ├── noise.cpp │ ├── noise.h │ ├── pixelset.h │ ├── pixeltypes.h │ ├── platforms.cpp │ ├── platforms.h │ ├── platforms │ │ ├── arm │ │ │ ├── common │ │ │ │ └── m0clockless.h │ │ │ ├── d21 │ │ │ │ ├── clockless_arm_d21.h │ │ │ │ ├── fastled_arm_d21.h │ │ │ │ ├── fastpin_arm_d21.h │ │ │ │ └── led_sysdefs_arm_d21.h │ │ │ ├── d51 │ │ │ │ ├── README.txt │ │ │ │ ├── clockless_arm_d51.h │ │ │ │ ├── fastled_arm_d51.h │ │ │ │ ├── fastpin_arm_d51.h │ │ │ │ └── led_sysdefs_arm_d51.h │ │ │ ├── k20 │ │ │ │ ├── clockless_arm_k20.h │ │ │ │ ├── clockless_block_arm_k20.h │ │ │ │ ├── fastled_arm_k20.h │ │ │ │ ├── fastpin_arm_k20.h │ │ │ │ ├── fastspi_arm_k20.h │ │ │ │ ├── led_sysdefs_arm_k20.h │ │ │ │ ├── octows2811_controller.h │ │ │ │ ├── smartmatrix_t3.h │ │ │ │ └── ws2812serial_controller.h │ │ │ ├── k66 │ │ │ │ ├── clockless_arm_k66.h │ │ │ │ ├── clockless_block_arm_k66.h │ │ │ │ ├── fastled_arm_k66.h │ │ │ │ ├── fastpin_arm_k66.h │ │ │ │ ├── fastspi_arm_k66.h │ │ │ │ └── led_sysdefs_arm_k66.h │ │ │ ├── kl26 │ │ │ │ ├── clockless_arm_kl26.h │ │ │ │ ├── fastled_arm_kl26.h │ │ │ │ ├── fastpin_arm_kl26.h │ │ │ │ ├── fastspi_arm_kl26.h │ │ │ │ └── led_sysdefs_arm_kl26.h │ │ │ ├── nrf51 │ │ │ │ ├── clockless_arm_nrf51.h │ │ │ │ ├── fastled_arm_nrf51.h │ │ │ │ ├── fastpin_arm_nrf51.h │ │ │ │ ├── fastspi_arm_nrf51.h │ │ │ │ └── led_sysdefs_arm_nrf51.h │ │ │ ├── nrf52 │ │ │ │ ├── arbiter_nrf52.h │ │ │ │ ├── clockless_arm_nrf52.h │ │ │ │ ├── fastled_arm_nrf52.h │ │ │ │ ├── fastpin_arm_nrf52.h │ │ │ │ ├── fastpin_arm_nrf52_variants.h │ │ │ │ ├── fastspi_arm_nrf52.h │ │ │ │ └── led_sysdefs_arm_nrf52.h │ │ │ ├── sam │ │ │ │ ├── clockless_arm_sam.h │ │ │ │ ├── clockless_block_arm_sam.h │ │ │ │ ├── fastled_arm_sam.h │ │ │ │ ├── fastpin_arm_sam.h │ │ │ │ ├── fastspi_arm_sam.h │ │ │ │ └── led_sysdefs_arm_sam.h │ │ │ └── stm32 │ │ │ │ ├── clockless_arm_stm32.h │ │ │ │ ├── cm3_regs.h │ │ │ │ ├── fastled_arm_stm32.h │ │ │ │ ├── fastpin_arm_stm32.h │ │ │ │ └── led_sysdefs_arm_stm32.h │ │ ├── avr │ │ │ ├── clockless_trinket.h │ │ │ ├── fastled_avr.h │ │ │ ├── fastpin_avr.h │ │ │ ├── fastspi_avr.h │ │ │ └── led_sysdefs_avr.h │ │ └── esp │ │ │ ├── 32 │ │ │ ├── clockless_block_esp32.h │ │ │ ├── clockless_esp32.h.orig │ │ │ ├── clockless_i2s_esp32.h │ │ │ ├── clockless_rmt_esp32.h │ │ │ ├── fastled_esp32.h │ │ │ ├── fastpin_esp32.h │ │ │ └── led_sysdefs_esp32.h │ │ │ └── 8266 │ │ │ ├── clockless_block_esp8266.h │ │ │ ├── clockless_esp8266.h │ │ │ ├── fastled_esp8266.h │ │ │ ├── fastpin_esp8266.h │ │ │ └── led_sysdefs_esp8266.h │ ├── power_mgt.cpp │ ├── power_mgt.h │ ├── preview_changes.txt │ ├── release_notes.md │ └── wiring.cpp └── GyverButton │ ├── GyverButton.cpp │ ├── GyverButton.h │ ├── examples │ ├── Gbutton_demo │ │ └── Gbutton_demo.ino │ ├── Gbutton_example_auto │ │ └── Gbutton_example_auto.ino │ ├── Gbutton_interrupt │ │ └── Gbutton_interrupt.ino │ ├── Gbutton_timer_interrupt │ │ └── Gbutton_timer_interrupt.ino │ ├── _1-2-3-click │ │ └── _1-2-3-click.ino │ ├── _5_buttons │ │ └── _5_buttons.ino │ ├── _5_buttons_auto │ │ └── _5_buttons_auto.ino │ ├── analogKeyboard │ │ ├── analogBtns.jpg │ │ └── analogKeyboard.ino │ ├── btn_pinChangeInt │ │ └── btn_pinChangeInt.ino │ ├── clicks_step │ │ └── clicks_step.ino │ ├── increment │ │ └── increment.ino │ └── many_clicks │ │ └── many_clicks.ino │ ├── keywords.txt │ └── library.properties └── schemes └── scheme.jpg /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ChristmasLights 2 | Гирлянда на адресной ленте и Arduino 3 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/addings.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDINGS_H 2 | #define ADDINGS_H 3 | 4 | #if CANDLE_KOL >0 5 | ////////////////////////////////////////////////////////////// Свечи 6 | DEFINE_GRADIENT_PALETTE( candle_Pal ) { 7 | 0, 255, 0, 0, //red 8 | 90, 255, 255, 255, //full white 9 | 180, 255, 255, 0, //bright yellow 10 | 255, 255, 255, 255 11 | }; //full white 12 | 13 | uint8_t PolCandle = 1; //Положение свечи 14 | 15 | void addcandle() 16 | { 17 | uint16_t poz = PolCandle; 18 | CRGBPalette16 myPal = candle_Pal; 19 | 20 | if (NUM_LEDS > 5) 21 | { 22 | uint8_t kol = NUM_LEDS / 10; //Количество свечей 23 | 24 | for ( uint8_t x = 0; x < kol; x++) 25 | { 26 | leds[ poz ] = ColorFromPalette( myPal, random8(255)); 27 | poz += CANDLE_KOL; 28 | } 29 | } 30 | } 31 | #endif 32 | 33 | ///////////////////////////////////////////////////////////////// Черный фон 34 | void addbackground() 35 | { 36 | #if MAX_LEDS < 255 37 | uint8_t i; 38 | #else 39 | uint16_t i; 40 | #endif 41 | 42 | for (i = 0; i < NUM_LEDS ; i++ ) 43 | if ( (leds[i].r < 5) && 44 | (leds[i].g < 5) && 45 | (leds[i].b < 5) ) 46 | leds[i].b += CRGB(5, 5, 5); 47 | 48 | } 49 | 50 | ////////////////////////////////////////////////////////////////// Блеск 51 | void addglitter( fract8 chanceOfGlitter) 52 | { 53 | if ( random8() < chanceOfGlitter) { 54 | #if MAX_LEDS < 255 55 | leds[ random8(NUM_LEDS) ] += CRGB::White; 56 | #else 57 | leds[ random16(NUM_LEDS) ] += CRGB::White; 58 | #endif 59 | } 60 | } 61 | 62 | ////////////////////////////////////////////////////////////////// Бенгальский огонь 63 | void sparkler(uint8_t n) //Бенгальский огонь 64 | // 0 - нет эффектов 65 | // 1 - Бенгальский огонь 66 | // 2 - 1 яркий светодиод 67 | // 3 - метеорит 68 | // 4 - случайный эффект 69 | { uint8_t kol = 3; 70 | 71 | if ( KolLed < 10 ) kol = KolLed / 3; 72 | if (kol >= 2) 73 | { uint8_t nn = n; 74 | switch (nn) { 75 | case 1 : for ( uint8_t x = 0; x < kol; x++) leds[ KolLed - random8(kol * 2) ] = CRGB::White; break; //Бенгальский 76 | case 2 : leds[KolLed - 1] = CRGB::White; break; //1 яркий 77 | case 3 : leds[KolLed] = CRGB::White; leds[KolLed - 1] = CRGB::Red; leds[KolLed - 2] = CRGB::Violet; break; //Метеорит 78 | } 79 | } 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/blendwave.h: -------------------------------------------------------------------------------- 1 | #ifndef BLENDWARE_H 2 | #define BLENDWARE_H 3 | 4 | void blendwave() { 5 | CRGB clr1; 6 | CRGB clr2; 7 | uint8_t speed; 8 | uint8_t loc1; 9 | 10 | if (KolLed >= 10) { 11 | 12 | speed = beatsin8(6, 0, 255); 13 | 14 | clr1 = blend(CHSV(beatsin8(3, 0, 255), 255, 255), CHSV(beatsin8(4, 0, 255), 255, 255), speed); 15 | clr2 = blend(CHSV(beatsin8(4, 0, 255), 255, 255), CHSV(beatsin8(3, 0, 255), 255, 255), speed); 16 | 17 | #if MAX_LEDS < 255 18 | loc1 = beatsin8(10, 0, KolLed - 1); 19 | #else 20 | loc1 = beatsin16(10, 0, KolLed - 1); 21 | #endif 22 | 23 | fill_gradient_RGB(leds, 0, clr2, loc1, clr1); 24 | fill_gradient_RGB(leds, loc1, clr2, KolLed - 1, clr1); 25 | } 26 | } // blendwave() 27 | 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/candles.h: -------------------------------------------------------------------------------- 1 | #ifndef CANDLES_H 2 | #define CANDLES_H 3 | 4 | void candles() { 5 | if (KolLed >= 10) { 6 | 7 | #if MAX_LEDS < 255 8 | uint8_t x; 9 | #else 10 | uint16_t x; 11 | #endif 12 | 13 | for (x = 0; x < KolLed; x++) 14 | { 15 | #if CANDLE_40 == 1 16 | //Вариант efimova1969 17 | uint8_t flicker = random8(1, 80); 18 | leds[x] = CRGB(255 - flicker * 2, 150 - flicker, flicker / 2); 19 | #else 20 | uint8_t flicker = random8(1, 15); 21 | leds[x] = CRGB(255 - flicker * 2, 63 - flicker, flicker / 2); 22 | #endif 23 | } 24 | } 25 | } // candles() 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/colorwave.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORWAVE_H 2 | #define COLORWAVE_H 3 | 4 | // ColorWavesWithPalettes 5 | // Animated shifting color waves, with several cross-fading color palettes. 6 | // by Mark Kriegsman, August 2015 7 | // 8 | // Color palettes courtesy of cpt-city and its contributors: 9 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ 10 | // 11 | // Color palettes converted for FastLED using "PaletteKnife" v1: 12 | // http://fastled.io/tools/paletteknife/ 13 | // 14 | 15 | 16 | // This function draws color waves with an ever-changing, 17 | // widely-varying set of parameters, using a color palette. 18 | 19 | 20 | void colorwaves() 21 | { 22 | static uint16_t sPseudotime = 0; 23 | static uint16_t sLastMillis = 0; 24 | static uint16_t sHue16 = 0; 25 | #if MAX_LEDS < 255 26 | uint8_t i; 27 | #else 28 | uint16_t i; 29 | #endif 30 | 31 | if (KolLed >= 10) { 32 | uint8_t brightdepth = beatsin88( 341, 96, 224); 33 | uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256)); 34 | uint8_t msmultiplier = beatsin88(147, 23, 60); 35 | 36 | uint16_t hue16 = sHue16;//gHue * 256; 37 | uint16_t hueinc16 = beatsin88(113, 300, 1500); 38 | 39 | uint16_t ms = millis(); 40 | uint16_t deltams = ms - sLastMillis ; 41 | sLastMillis = ms; 42 | sPseudotime += deltams * msmultiplier; 43 | sHue16 += deltams * beatsin88( 400, 5, 9); 44 | uint16_t brightnesstheta16 = sPseudotime; 45 | 46 | for ( i = 0 ; i < KolLed; i++) { 47 | hue16 += hueinc16; 48 | uint8_t hue8 = hue16 / 256; 49 | uint16_t h16_128 = hue16 >> 7; 50 | if ( h16_128 & 0x100) { 51 | hue8 = 255 - (h16_128 >> 1); 52 | } else { 53 | hue8 = h16_128 >> 1; 54 | } 55 | 56 | brightnesstheta16 += brightnessthetainc16; 57 | uint16_t b16 = sin16( brightnesstheta16 ) + 32768; 58 | 59 | uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536; 60 | uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536; 61 | bri8 += (255 - brightdepth); 62 | 63 | uint8_t index = hue8; 64 | //index = triwave8( index); 65 | index = scale8( index, 240); 66 | 67 | CRGB newcolor = ColorFromPalette(gCurrentPalette, index, bri8); 68 | if ( thisdir == 1) //направление 69 | nblend( leds[(KolLed - 1) - i], newcolor, 128); 70 | else 71 | nblend( leds[i], newcolor, 128); 72 | 73 | } 74 | } 75 | 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/confetti_pal.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFETTI_PAL_H 2 | #define CONFETTI_PAL_H 3 | 4 | /* This is adapted from the confetti routine created by Mark Kriegsman */ 5 | 6 | /* Usage - confetti_pal(); 7 | 8 | thisfade 9 | thisdelay 10 | currentPalette and targetPalette 11 | thisdiff 12 | thisindex 13 | thisinc 14 | thisbright 15 | */ 16 | 17 | 18 | void confetti_pal() { // random colored speckles that blink in and fade smoothly 19 | if (KolLed >= 10) { 20 | fadeToBlackBy(leds, KolLed, thisfade); //Задухание светодиодов на значение thisfade 21 | #if MAX_LEDS < 255 22 | uint8_t pos = random8(KolLed); 23 | #else 24 | uint16_t pos = random16(KolLed); 25 | #endif 26 | leds[pos] = ColorFromPalette(gCurrentPalette, thisindex + random8(thisdiff) / 4 , 255, currentBlending); // Munge the values and pick a colour from the palette 27 | thisindex = thisindex + thisinc; // base palette counter increments here. 28 | } 29 | } // confetti_pal() 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/fire.h: -------------------------------------------------------------------------------- 1 | #ifndef FIRE_H 2 | #define FIRE_H 3 | 4 | void fire() { // The fill_rainbow call doesn't support brightness levels 5 | if (KolLed >= 10) { 6 | 7 | #if MAX_LEDS < 255 8 | uint8_t x = KolLed / 10; // Координаты 9 | uint8_t k1 = random8(x * 2); //Жар 10 | uint8_t k2 = random8(x * 2) + k1; //Огонь 11 | uint8_t k3 = x * 3 + random8(x * 4); //Пламя 12 | uint8_t k4 = KolLed - 1; //Дым 13 | if ((k4 - k2) < k3) k3 = k4; 14 | else k3 = k3 + k2; 15 | 16 | #else 17 | uint16_t x = KolLed / 10; 18 | uint16_t k1 = random8(x * 2); //Жар 19 | uint16_t k2 = random8(x * 2) + k1; //Огонь 20 | uint16_t k3 = x * 3 + random8(x * 4) + k2; //Пламя 21 | uint16_t k4 = KolLed - 1; //Дым 22 | 23 | #endif 24 | 25 | if ( thisdir == 1) { //направление 26 | fill_gradient_RGB(leds, 0, CRGB::White, k1, CRGB::Yellow); //Градинет 27 | fill_gradient_RGB(leds, k1, CRGB::Yellow, k2, CRGB::Red); 28 | fill_gradient_RGB(leds, k2, CRGB::Red, k3, CRGB::Black); 29 | if ( k3 < k4) 30 | fill_gradient_RGB(leds, k3, CRGB::Black, k4, CRGB::Black); 31 | for (uint8_t y = 0; y < x; y++) leds[random16(k2, KolLed - 1)] = CRGB::Red; 32 | 33 | } 34 | else 35 | { 36 | k1 = KolLed - 1 - k1; //Поворот 37 | k2 = KolLed - 1 - k2; 38 | #if MAX_LEDS < 255 39 | if ((KolLed - 1) < k3) k3 = 0; 40 | else k3 = KolLed - 1 - k3; 41 | #else 42 | k3 = KolLed - 1 - k3; 43 | #endif 44 | 45 | fill_gradient_RGB(leds, k1, CRGB::White, k4, CRGB::Yellow); //Градиент 46 | fill_gradient_RGB(leds, k2, CRGB::Yellow, k1, CRGB::Red); 47 | fill_gradient_RGB(leds, k3, CRGB::Red, k2, CRGB::Black); 48 | if ( k3 > 0) 49 | fill_gradient_RGB(leds, 0, CRGB::Black, k3, CRGB::Black); 50 | for (uint8_t y = 0; y < x; y++) leds[random16(k2)] = CRGB::Red; 51 | 52 | } 53 | } 54 | 55 | } // fire() 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/juggle_pal.h: -------------------------------------------------------------------------------- 1 | #ifndef JUGGLE_PAL_H 2 | #define JUGGLE_PAL_H 3 | 4 | /* This is adapted from a routine created by Mark Kriegsman */ 5 | 6 | /* Usage - juggle_pal(); 7 | 8 | thishue 9 | thisfade 10 | numdots 11 | thisbeat 12 | thisbright 13 | thisdiff 14 | */ 15 | 16 | uint8_t numdots; 17 | 18 | void juggle_pal() { // Several colored dots, weaving in and out of sync with each other 19 | if (KolLed >= 10) { 20 | thisindex = 0; // Reset the hue values. 21 | fadeToBlackBy(leds, KolLed, thisfade); //Затухание к черному 22 | for ( uint8_t i = 0; i < numdots; i++) { 23 | leds[beatsin16(thisbeat + i + numdots, 0, KolLed - 1)] += ColorFromPalette(gCurrentPalette, thisindex , 255, currentBlending); // Munge the values and pick a colour from the palette 24 | thisindex += thisdiff; 25 | } 26 | } 27 | } // juggle_pal() 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/matrix_pal.h: -------------------------------------------------------------------------------- 1 | #ifndef MATRIX_PAL_H 2 | #define MATRIX_PAL_H 3 | 4 | 5 | /* Usage - matrix_pal(); 6 | 7 | This is one of the few routines I have with pixel counting. 8 | 9 | 10 | currentPalette, targetPalette 11 | thisrot 12 | thisindex 13 | bgclr 14 | bgbri 15 | thisdir 16 | thisbright 17 | */ 18 | 19 | void matrix_pal() { // One line matrix 20 | 21 | if (thisrot) thisindex++; // Increase palette index to change colours on the fly 22 | 23 | if (KolLed >= 10) { 24 | 25 | if (random8(90) > 80) { 26 | if (thisdir == -1) 27 | leds[0] = ColorFromPalette(gCurrentPalette, thisindex, 255, currentBlending); // Foreground matrix colour 28 | else 29 | leds[KolLed - 1] = ColorFromPalette(gCurrentPalette, thisindex, 255, currentBlending); 30 | } else { 31 | if (thisdir == -1) 32 | leds[0] = CHSV(bgclr, 255, bgbri); // Background colour 33 | else 34 | leds[KolLed - 1] = CHSV(bgclr, 255, bgbri); 35 | } 36 | 37 | #if MAX_LEDS < 255 38 | uint8_t i; 39 | #else 40 | uint16_t i; 41 | #endif 42 | 43 | if (thisdir == -1) { // Move the foreground colour down the line. 44 | for (i = KolLed - 1; i > 0 ; i-- ) leds[i] = leds[i - 1]; 45 | } else { 46 | for (i = 0; i < KolLed - 1 ; i++ ) leds[i] = leds[i + 1]; 47 | } 48 | } 49 | } // matrix_pal() 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/noise16_pal.h: -------------------------------------------------------------------------------- 1 | #ifndef NOISE16_PAL_H 2 | #define NOISE16_PAL_H 3 | 4 | // noise16 variables ----------------------------------------------------------------------- 5 | 6 | uint32_t x, hue_time; // x & hue_time values 7 | uint8_t octaves = 2; //2 // how many octaves to use for the brightness 8 | uint8_t hue_octaves = 3; //3 // how many octaves to use for the hue 9 | int xscale = 57771; //57771 // the 'distance' between points on the x axis 10 | uint32_t hxy = 43213; //43213 // not sure about this 11 | int hue_scale = 20; //1 // the 'distance' between points for the hue noise 12 | int hue_speed = 1; //31 // how fast we move through hue noise 13 | uint8_t x_speed = 0; //331 // adjust this value to move along the x axis between frames 14 | int8_t hxyinc = 3; //3 15 | 16 | 17 | void noise16_pal() { 18 | if (KolLed >= 10) { 19 | /* if (KolLed<=200) 20 | fill_noise16(leds, KolLed, octaves, x, xscale, hue_octaves, hxy, hue_scale, hue_time); 21 | else 22 | if (KolLed<=400) { 23 | fill_noise16(leds, 200, octaves, x, xscale, hue_octaves, hxy, hue_scale, hue_time); 24 | fill_noise16(&leds[200], KolLed, octaves, x, xscale, hue_octaves, hxy, hue_scale, hue_time); 25 | } 26 | else 27 | */ fill_noise16(leds, KolLed, octaves, x, xscale, hue_octaves, hxy, hue_scale, hue_time); 28 | 29 | hxy += hxyinc * thisdir; 30 | x += x_speed * thisdir; 31 | hue_time += hue_speed * thisdir; 32 | } 33 | } // noise16_pal() 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/noise8_pal.h: -------------------------------------------------------------------------------- 1 | #ifndef NOISE8_PAL_H 2 | #define NOISE8_PAL_H 3 | 4 | /* This is adapted from a routine created by Mark Kriegsman */ 5 | 6 | /* Usage - noise8(); 7 | 8 | */ 9 | 10 | uint16_t dist = 12345; // A random number for our noise generator. 11 | uint8_t scale = 30; // Wouldn't recommend changing this on the fly, or the animation will be really blocky. 12 | 13 | void noise8_pal() { 14 | 15 | #if MAX_LEDS < 255 16 | uint8_t i; 17 | #else 18 | uint16_t i; 19 | #endif 20 | if (KolLed >= 10) { 21 | for ( i = 0; i < KolLed; i++) { // Just ONE loop to fill up the LED array as all of the pixels change. 22 | uint8_t index = inoise8(i * scale, dist + i * scale) % 255; // Get a value from the noise function. I'm using both x and y axis. 23 | leds[i] = ColorFromPalette(gCurrentPalette, index, 255, currentBlending); // With that value, look up the 8 bit colour palette value and assign it to the current LED. 24 | } 25 | dist += beatsin8(10, 1, 4) * thisdir; // Moving along the distance (that random number we started out with). Vary it a bit with a sine wave. 26 | } // In some sketches, I've used millis() instead of an incremented counter. Works a treat. 27 | } // noise8_pal() 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/one_sin_pal.h: -------------------------------------------------------------------------------- 1 | #ifndef ONE_SIN_PAL_H 2 | #define ONE_SIN_PAL_H 3 | 4 | 5 | /* There's lots of values to play with here, as well as selecting your own palettes 6 | 7 | */ 8 | 9 | 10 | /* 11 | Usage - one_sin_pal(); 12 | 13 | allfreq - What is the frequency 14 | bgbri - The background brightness 15 | bgclr - The background colour 16 | startindex - What foreground colour are we starting with? 17 | thisbright - How bright is it? 18 | thiscutoff - If the brightness is lower than this, then brightness=0 19 | thisinc - incrementer to change the starting colour after each pass 20 | thisindex - rotating colours down the strip counter 21 | thisphase - the counter used in conjunction with the frequency to move down the strip 22 | thisrot - How quickly to rotate those colours down the strip 23 | thisspeed - How fast does it whip down the strand 24 | thisdir - Direction. 25 | */ 26 | 27 | 28 | void one_sin_pal() { 29 | 30 | startindex += thisinc; 31 | thisindex = startindex; 32 | thisphase += thisdir; // You can change direction and speed individually. 33 | 34 | #if MAX_LEDS < 255 35 | uint8_t k; 36 | #else 37 | uint16_t k; 38 | #endif 39 | if (KolLed >= 10) { 40 | for (k = 0; k < KolLed; k++) { // For each of the LED's in the strand, set a brightness based on a wave as follows: 41 | int thisbright = qsubd(cubicwave8((k * allfreq) + thisphase), thiscutoff); // qsub sets a minimum value called thiscutoff. If < thiscutoff, then bright = 0. Otherwise, bright = 128 (as defined in qsub).. 42 | leds[k] = CHSV(bgclr, 255, bgbri); // First set a background colour, but fully saturated. 43 | leds[k] += ColorFromPalette(gCurrentPalette, thisindex + k * thisinc, thisbright, currentBlending); 44 | thisindex += thisrot; 45 | } 46 | } 47 | } // one_sin() 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/plasma.h: -------------------------------------------------------------------------------- 1 | #ifndef PLASMA_H 2 | #define PLASMA_H 3 | 4 | /* Usage - plasma(freq1, freq2, phase1, phase2); 5 | 6 | 7 | 8 | */ 9 | 10 | #endif 11 | 12 | 13 | 14 | void plasma(uint8_t freq1, uint8_t freq2, int8_t phase1, int8_t phase2) { // This is the heart of this program. Sure is short. . . and fast. 15 | 16 | int thisPhase = beatsin8(phase1, -64, 64); // Setting phase change for a couple of waves. 17 | int thatPhase = beatsin8(phase2, -64, 64); 18 | 19 | #if MAX_LEDS < 255 20 | uint8_t k; 21 | #else 22 | uint16_t k; 23 | #endif 24 | if (KolLed >= 10) { 25 | 26 | for (k = 0; k < KolLed; k++) { // For each of the LED's in the strand, set a brightness based on a wave as follows: 27 | int colorIndex = cubicwave8((k * freq1) + thisPhase) / 2 + cos8((k * freq2) + thatPhase) / 2; // Create a wave and add a phase change and add another wave with its own phase change.. Hey, you can even change the frequencies if you wish, but don't change on the fly. 28 | int thisBright = qsuba(colorIndex, beatsin8(7, 0, 96)); // qsub gives it a bit of 'black' dead space by setting sets a minimum value. If colorIndex < current value of beatsin8(), then bright = 0. Otherwise, bright = colorIndex.. 29 | leds[k] = ColorFromPalette(gCurrentPalette, colorIndex, thisBright, currentBlending); // Let's now add the foreground colour. 30 | } 31 | } 32 | } // plasma() 33 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/rainbow_beat.h: -------------------------------------------------------------------------------- 1 | #ifndef RAINBOW_BEAT_H 2 | #define RAINBOW_BEAT_H 3 | 4 | // Usage - rainbow_beat(); 5 | 6 | void rainbow_beat() { // The fill_rainbow call doesn't support brightness levels 7 | if (KolLed >= 10) { 8 | uint8_t beatA = beatsin8(17, 0, 255); // Starting hue 9 | uint8_t beatB = beatsin8(13, 0, 255); 10 | fill_rainbow(leds, KolLed, (beatA + beatB) / 2, 8); // Use FastLED's fill_rainbow routine. 11 | } 12 | } // rainbow_beat() 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/rainbow_march.h: -------------------------------------------------------------------------------- 1 | #ifndef RAINBOW_MARCH_H 2 | #define RAINBOW_MARCH_H 3 | 4 | /* Usage - rainbow_march(); 5 | 6 | thisindex 7 | thisdiff 8 | thisrot 9 | thisdir 10 | */ 11 | 12 | 13 | void rainbow_march() { // The fill_rainbow call doesn't support brightness levels 14 | if (KolLed >= 10) { 15 | thisindex += thisrot * thisdir; 16 | fill_rainbow(leds, KolLed, thisindex, thisdiff); // I don't change deltahue on the fly as it's too fast near the end of the strip. 17 | } 18 | } // rainbow_march() 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/serendipitous_pal.h: -------------------------------------------------------------------------------- 1 | #ifndef SERENDIPITOUS_PAL_H 2 | #define SERENDIPITOUS_PAL_H 3 | 4 | /* This is from Serendipitous Circles from the August 1977 and April 1978 issues of Byte Magazine. I didn't do a very good job of it, but am at least getting some animation and the routine is very short. 5 | */ 6 | 7 | 8 | /* Usage - serendipitous_pal(); 9 | 10 | */ 11 | 12 | uint16_t Xorig = 0x013; 13 | uint16_t Yorig = 0x021; 14 | uint16_t X = Xorig; 15 | uint16_t Y = Yorig; 16 | uint16_t Xn; 17 | uint16_t Yn; 18 | 19 | 20 | void serendipitous_pal() { 21 | 22 | EVERY_N_SECONDS(5) { 23 | X = Xorig; 24 | Y = Yorig; 25 | } 26 | 27 | Xn = X - (Y / 2); Yn = Y + (Xn / 2); 28 | // Xn = X-Y/2; Yn = Y+Xn/2; 29 | // Xn = X-(Y/2); Yn = Y+(X/2.1); 30 | // Xn = X-(Y/3); Yn = Y+(X/1.5); 31 | // Xn = X-(2*Y); Yn = Y+(X/1.1); 32 | 33 | X = Xn; 34 | Y = Yn; 35 | if (KolLed >= 10) { 36 | thisindex = (sin8(X) + cos8(Y)) / 2; 37 | leds[X % (KolLed)] = ColorFromPalette(gCurrentPalette, thisindex, 255, currentBlending); 38 | fadeToBlackBy(leds, KolLed, 16); // 8 bit, 1 = slow, 255 = fast 39 | } 40 | } // serendipitous_pal() 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/three_sin_pal.h: -------------------------------------------------------------------------------- 1 | #ifndef THREE_SIN_PAL_H 2 | #define THREE_SIN_PAL_H 3 | 4 | 5 | 6 | // three_sin_pal variables --------------------------------------------------------------------- 7 | 8 | int wave1; 9 | int wave2; 10 | int wave3; 11 | uint8_t mul1; 12 | uint8_t mul2; 13 | uint8_t mul3; 14 | 15 | 16 | void three_sin_pal() { 17 | if (KolLed >= 10) { 18 | 19 | wave1 += beatsin8(10, -4, 4) * thisdir; 20 | wave2 += beatsin8(15, -2, 2) * thisdir; 21 | wave3 += beatsin8(12, -3, 3) * thisdir; 22 | 23 | #if MAX_LEDS < 255 24 | uint8_t k; 25 | #else 26 | uint16_t k; 27 | #endif 28 | 29 | for (k = 0; k < KolLed; k++) { 30 | uint8_t tmp = sin8(mul1 * k + wave1) + sin8(mul1 * k + wave2) + sin8(mul1 * k + wave3); 31 | leds[k] = ColorFromPalette(gCurrentPalette, tmp, 255, currentBlending); 32 | } 33 | } 34 | } // three_sin_pal() 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /firmware/notamesh4_gyver_v1.1/two_sin.h: -------------------------------------------------------------------------------- 1 | #ifndef TWO_SIN_H 2 | #define TWO_SIN_H 3 | 4 | /* Usage - two_sin(); 5 | 6 | Loads of variables to play with 7 | 8 | */ 9 | 10 | 11 | // two_sin variables------------------------------------------------------------------------- 12 | 13 | uint8_t thathue = 140; // You can change the starting hue for other wave. 14 | uint8_t thatrot = 0; // You can change how quickly the hue rotates for the other wave. Currently 0. 15 | int8_t thatspeed = 4; // You can change the speed, and use negative values. 16 | int thatphase = 0; // Phase change value gets calculated. 17 | uint8_t thatcutoff = 192; // You can change the cutoff value to display that wave. Lower value = longer wave. 18 | 19 | 20 | void two_sin() { // This is the heart of this program. Sure is short. 21 | if ( KolLed >= 10) { 22 | thisphase += thisspeed * thisdir; 23 | thatphase += thatspeed * thisdir; 24 | 25 | thishue = thishue + thisrot; // Hue rotation is fun for thiswave. 26 | thathue = thathue + thatrot; // It's also fun for thatwave. 27 | 28 | #if MAX_LEDS < 255 29 | uint8_t k; 30 | #else 31 | uint16_t k; 32 | #endif 33 | 34 | for (k = 0; k < KolLed; k++) { 35 | int thisbright = qsuba(cubicwave8((k * allfreq) + thisphase), thiscutoff); // qsub sets a minimum value called thiscutoff. If < thiscutoff, then bright = 0. Otherwise, bright = 128 (as defined in qsub).. 36 | int thatbright = qsuba(cubicwave8((k * allfreq) + 128 + thatphase), thatcutoff); // This wave is 180 degrees out of phase (with the value of 128). 37 | 38 | leds[k] = ColorFromPalette(gCurrentPalette, thishue, thisbright, currentBlending); 39 | leds[k] += ColorFromPalette(gCurrentPalette, thathue, thatbright, currentBlending); 40 | } 41 | } 42 | } // two_sin() 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := . 2 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/extras/RainbowDemo.bin.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexGyver/ChristmasLights/6ecc5a21f3cccb0a0bffe7e7a185f261f673d9c3/libraries/FastLED-3.2.9/extras/RainbowDemo.bin.zip -------------------------------------------------------------------------------- /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/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/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/fastspi_dma.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexGyver/ChristmasLights/6ecc5a21f3cccb0a0bffe7e7a185f261f673d9c3/libraries/FastLED-3.2.9/fastspi_dma.h -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/GyverButton/examples/Gbutton_demo/Gbutton_demo.ino: -------------------------------------------------------------------------------- 1 | // Пример использования библиотеки GyverButton, все возможности в одном скетче. 2 | 3 | #define BTN_PIN 3 // кнопка подключена сюда (BTN_PIN --- КНОПКА --- GND) 4 | 5 | #include "GyverButton.h" 6 | GButton butt1(BTN_PIN); 7 | 8 | // Варианты инициализации: 9 | // GButton btn; // без привязки к пину (виртуальная кнопка) и без указания типа (по умолч. HIGH_PULL и NORM_OPEN) 10 | // GButton btn(пин); // с привязкой к пину и без указания типа (по умолч. HIGH_PULL и NORM_OPEN) 11 | // GButton btn(пин, тип подключ.); // с привязкой к пину и указанием типа подключения (HIGH_PULL / LOW_PULL) и без указания типа кнопки (по умолч. NORM_OPEN) 12 | // GButton btn(пин, тип подключ., тип кнопки); // с привязкой к пину и указанием типа подключения (HIGH_PULL / LOW_PULL) и типа кнопки (NORM_OPEN / NORM_CLOSE) 13 | // GButton btn(BTN_NO_BTN_PIN, тип подключ., тип кнопки); // без привязки к пину и указанием типа подключения (HIGH_PULL / LOW_PULL) и типа кнопки (NORM_OPEN / NORM_CLOSE) 14 | 15 | int value = 0; 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | 20 | butt1.setDebounce(50); // настройка антидребезга (по умолчанию 80 мс) 21 | butt1.setTimeout(300); // настройка таймаута на удержание (по умолчанию 500 мс) 22 | butt1.setClickTimeout(600); // настройка таймаута между кликами (по умолчанию 300 мс) 23 | 24 | // HIGH_PULL - кнопка подключена к GND, пин подтянут к VCC (BTN_PIN --- КНОПКА --- GND) 25 | // LOW_PULL - кнопка подключена к VCC, пин подтянут к GND 26 | // по умолчанию стоит HIGH_PULL 27 | butt1.setType(HIGH_PULL); 28 | 29 | // NORM_OPEN - нормально-разомкнутая кнопка 30 | // NORM_CLOSE - нормально-замкнутая кнопка 31 | // по умолчанию стоит NORM_OPEN 32 | butt1.setDirection(NORM_OPEN); 33 | } 34 | 35 | void loop() { 36 | butt1.tick(); // обязательная функция отработки. Должна постоянно опрашиваться 37 | 38 | if (butt1.isClick()) Serial.println("Click"); // проверка на один клик 39 | if (butt1.isSingle()) Serial.println("Single"); // проверка на один клик 40 | if (butt1.isDouble()) Serial.println("Double"); // проверка на двойной клик 41 | if (butt1.isTriple()) Serial.println("Triple"); // проверка на тройной клик 42 | 43 | if (butt1.hasClicks()) // проверка на наличие нажатий 44 | Serial.println(butt1.getClicks()); // получить (и вывести) число нажатий 45 | 46 | if (butt1.isPress()) Serial.println("Press"); // нажатие на кнопку (+ дебаунс) 47 | if (butt1.isRelease()) Serial.println("Release"); // отпускание кнопки (+ дебаунс) 48 | if (butt1.isHold()) { // если кнопка удерживается 49 | Serial.print("Holding "); // выводим пока удерживается 50 | Serial.println(butt1.getHoldClicks()); // можно вывести количество кликов перед удержанием! 51 | } 52 | if (butt1.isHold()) Serial.println("Holding"); // проверка на удержание 53 | //if (butt1.state()) Serial.println("Hold"); // возвращает состояние кнопки 54 | 55 | if (butt1.isStep()) { // если кнопка была удержана (это для инкремента) 56 | value++; // увеличивать/уменьшать переменную value с шагом и интервалом 57 | Serial.println(value); // для примера выведем в порт 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/Gbutton_example_auto/Gbutton_example_auto.ino: -------------------------------------------------------------------------------- 1 | // Пример использования библиотеки GyverButton, все возможности в одном скетче. 2 | // автоматический тик 3 | 4 | #define BTN_PIN 3 // кнопка подключена сюда (BTN_PIN --- КНОПКА --- GND) 5 | 6 | #include "GyverButton.h" 7 | GButton butt1(BTN_PIN); 8 | // GButton butt1(BTN_PIN, HIGH_PULL, NORM_OPEN); // можно инициализировать так 9 | 10 | int value = 0; 11 | 12 | void setup() { 13 | Serial.begin(9600); 14 | 15 | butt1.setDebounce(90); // настройка антидребезга (по умолчанию 80 мс) 16 | butt1.setTimeout(300); // настройка таймаута на удержание (по умолчанию 500 мс) 17 | 18 | // HIGH_PULL - кнопка подключена к GND, пин подтянут к VCC (BTN_PIN --- КНОПКА --- GND) 19 | // LOW_PULL - кнопка подключена к VCC, пин подтянут к GND 20 | // по умолчанию стоит HIGH_PULL 21 | butt1.setType(HIGH_PULL); 22 | 23 | // NORM_OPEN - нормально-разомкнутая кнопка 24 | // NORM_CLOSE - нормально-замкнутая кнопка 25 | // по умолчанию стоит NORM_OPEN 26 | butt1.setDirection(NORM_OPEN); 27 | 28 | // MANUAL - нужно вызывать функцию tick() вручную 29 | // AUTO - tick() входит во все остальные функции и опрашивается сама! 30 | butt1.setTickMode(AUTO); 31 | } 32 | 33 | void loop() { 34 | // butt1.tick(); // НЕ НУЖНА, в этом режиме (AUTO) она входит в каждую функцию 35 | 36 | if (butt1.isClick()) Serial.println("Click"); // проверка на один клик 37 | if (butt1.isSingle()) Serial.println("Single"); // проверка на один клик 38 | if (butt1.isDouble()) Serial.println("Double"); // проверка на двойной клик 39 | if (butt1.isTriple()) Serial.println("Triple"); // проверка на тройной клик 40 | 41 | if (butt1.hasClicks()) // проверка на наличие нажатий 42 | Serial.println(butt1.getClicks()); // получить (и вывести) число нажатий 43 | 44 | if (butt1.isPress()) Serial.println("Press"); // нажатие на кнопку (+ дебаунс) 45 | if (butt1.isRelease()) Serial.println("Release"); // отпускание кнопки (+ дебаунс) 46 | if (butt1.isHolded()) Serial.println("Holded"); // проверка на удержание 47 | if (butt1.isHold()) Serial.println("Holding"); // проверка на удержание 48 | //if (butt1.state()) Serial.println("Hold"); // возвращает состояние кнопки 49 | 50 | if (butt1.isStep()) { // если кнопка была удержана (это для инкремента) 51 | value++; // увеличивать/уменьшать переменную value с шагом и интервалом 52 | Serial.println(value); // для примера выведем в порт 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/Gbutton_interrupt/Gbutton_interrupt.ino: -------------------------------------------------------------------------------- 1 | // Пример использования библиотеки GyverButton, все возможности в одном скетче. 2 | // Дополнительный опрос по аппаратному прерыванию 3 | 4 | #define BTN_PIN 3 // кнопка подключена сюда (BTN_PIN --- КНОПКА --- GND) 5 | 6 | #include "GyverButton.h" 7 | GButton butt1(BTN_PIN); 8 | int value = 0; 9 | 10 | void setup() { 11 | Serial.begin(9600); 12 | attachInterrupt(1, isr, CHANGE); 13 | 14 | butt1.setDebounce(80); // настройка антидребезга (по умолчанию 80 мс) 15 | butt1.setTimeout(300); // настройка таймаута на удержание (по умолчанию 500 мс) 16 | } 17 | 18 | void isr() { 19 | butt1.tick(); // опрашиваем в прерывании, чтобы поймать нажатие в любом случае 20 | } 21 | 22 | void loop() { 23 | butt1.tick(); // опрашиваем в скетче, иначе не будут работать проверки по времени! 24 | 25 | if (butt1.isClick()) Serial.println("Click"); // проверка на один клик 26 | if (butt1.isSingle()) Serial.println("Single"); // проверка на один клик 27 | if (butt1.isDouble()) Serial.println("Double"); // проверка на двойной клик 28 | if (butt1.isTriple()) Serial.println("Triple"); // проверка на тройной клик 29 | 30 | if (butt1.hasClicks()) // проверка на наличие нажатий 31 | Serial.println(butt1.getClicks()); // получить (и вывести) число нажатий 32 | 33 | if (butt1.isPress()) Serial.println("Press"); // нажатие на кнопку (+ дебаунс) 34 | if (butt1.isRelease()) Serial.println("Release"); // отпускание кнопки (+ дебаунс) 35 | if (butt1.isHolded()) Serial.println("Holded"); // проверка на удержание 36 | //if (butt1.isHold()) Serial.println("Hold"); // возвращает состояние кнопки 37 | 38 | if (butt1.isStep()) { // если кнопка была удержана (это для инкремента) 39 | value++; // увеличивать/уменьшать переменную value с шагом и интервалом 40 | Serial.println(value); // для примера выведем в порт 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/Gbutton_timer_interrupt/Gbutton_timer_interrupt.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Пример использования библиотеки GyverButton, все возможности в одном скетче 3 | Данный скетч показывает, как быть в сложном "не сквозном" коде с кучей delay и замкнутых циклов 4 | Здесь кнопка опрашивается каждые 10 миллисекунд независимо от того, что происходит у вас в коде 5 | Используется библиотека TimerOne https://github.com/PaulStoffregen/TimerOne 6 | */ 7 | 8 | #define BTN_PIN 3 // кнопка подключена сюда (BTN_PIN --- КНОПКА --- GND) 9 | 10 | #include "GyverButton.h" 11 | #include "TimerOne.h" 12 | GButton butt1(BTN_PIN); 13 | int value = 0; 14 | 15 | void setup() { 16 | Serial.begin(9600); 17 | 18 | Timer1.initialize(10000); // установка таймера на каждые 10000 микросекунд (== 10 мс) 19 | Timer1.attachInterrupt(timerIsr); // запуск таймера 20 | } 21 | 22 | void timerIsr() { // прерывание таймера 23 | butt1.tick(); // отработка теперь находится здесь 24 | } 25 | 26 | void loop() { 27 | if (butt1.isClick()) Serial.println("Click"); // проверка на один клик 28 | if (butt1.isSingle()) Serial.println("Single"); // проверка на один клик 29 | if (butt1.isDouble()) Serial.println("Double"); // проверка на двойной клик 30 | if (butt1.isTriple()) Serial.println("Triple"); // проверка на тройной клик 31 | 32 | if (butt1.hasClicks()) // проверка на наличие нажатий 33 | Serial.println(butt1.getClicks()); // получить (и вывести) число нажатий 34 | 35 | if (butt1.isPress()) Serial.println("Press"); // нажатие на кнопку (+ дебаунс) 36 | if (butt1.isRelease()) Serial.println("Release"); // отпускание кнопки (+ дебаунс) 37 | if (butt1.isHolded()) Serial.println("Holded"); // проверка на удержание 38 | //if (butt1.isHold()) Serial.println("Hold"); // возвращает состояние кнопки 39 | 40 | if (butt1.isStep()) { // если кнопка была удержана (это для инкремента) 41 | value++; // увеличивать/уменьшать переменную value с шагом и интервалом 42 | Serial.println(value); // для примера выведем в порт 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/_1-2-3-click/_1-2-3-click.ino: -------------------------------------------------------------------------------- 1 | // Пример использования библиотеки GyverButton, 1- 2- 3- нажатие 2 | 3 | #define BTN_PIN 3 // кнопка подключена сюда (BTN_PIN --- КНОПКА --- GND) 4 | 5 | #include "GyverButton.h" 6 | GButton butt1(BTN_PIN); 7 | 8 | void setup() { 9 | Serial.begin(9600); 10 | } 11 | 12 | void loop() { 13 | butt1.tick(); // обязательная функция отработки. Должна постоянно опрашиваться 14 | 15 | if (butt1.isSingle()) Serial.println("Single"); // проверка на один клик 16 | if (butt1.isDouble()) Serial.println("Double"); // проверка на двойной клик 17 | if (butt1.isTriple()) Serial.println("Triple"); // проверка на тройной клик 18 | } 19 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/_5_buttons/_5_buttons.ino: -------------------------------------------------------------------------------- 1 | // Пример использования библиотеки GyverButton 2 | // опрос 5 кнопок в ручном режиме 3 | 4 | // кнопки подключены к земле (PIN --- КНОПКА --- GND) 5 | #define BTN1 3 6 | #define BTN2 4 7 | #define BTN3 5 8 | #define BTN4 6 9 | #define BTN5 7 10 | 11 | #include "GyverButton.h" 12 | GButton butt1(BTN1); 13 | GButton butt2(BTN2); 14 | GButton butt3(BTN3); 15 | GButton butt4(BTN4); 16 | GButton butt5(BTN5); 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | } 21 | 22 | void loop() { 23 | // тик в ручном режиме 24 | butt1.tick(); 25 | butt2.tick(); 26 | butt3.tick(); 27 | butt4.tick(); 28 | butt5.tick(); 29 | 30 | // проверяем одиночный клик 31 | if (butt1.isClick()) Serial.println("Button 1"); 32 | if (butt2.isClick()) Serial.println("Button 2"); 33 | if (butt3.isClick()) Serial.println("Button 3"); 34 | if (butt4.isClick()) Serial.println("Button 4"); 35 | if (butt5.isClick()) Serial.println("Button 5"); 36 | } 37 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/_5_buttons_auto/_5_buttons_auto.ino: -------------------------------------------------------------------------------- 1 | // Пример использования библиотеки GyverButton 2 | // опрос 5 кнопок в автоматическом режиме 3 | 4 | // кнопки подключены к земле (PIN --- КНОПКА --- GND) 5 | #define BTN1 3 6 | #define BTN2 4 7 | #define BTN3 5 8 | #define BTN4 6 9 | #define BTN5 7 10 | 11 | #include "GyverButton.h" 12 | GButton butt1(BTN1); 13 | GButton butt2(BTN2); 14 | GButton butt3(BTN3); 15 | GButton butt4(BTN4); 16 | GButton butt5(BTN5); 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | 21 | // устанавливаем опрос на автоматический 22 | butt1.setTickMode(AUTO); 23 | butt2.setTickMode(AUTO); 24 | butt3.setTickMode(AUTO); 25 | butt4.setTickMode(AUTO); 26 | butt5.setTickMode(AUTO); 27 | } 28 | 29 | void loop() { 30 | // проверяем одиночный клик 31 | // tick уже сидит внутри опроса 32 | if (butt1.isClick()) Serial.println("Button 1"); 33 | if (butt2.isClick()) Serial.println("Button 2"); 34 | if (butt3.isClick()) Serial.println("Button 3"); 35 | if (butt4.isClick()) Serial.println("Button 4"); 36 | if (butt5.isClick()) Serial.println("Button 5"); 37 | } 38 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/analogKeyboard/analogBtns.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexGyver/ChristmasLights/6ecc5a21f3cccb0a0bffe7e7a185f261f673d9c3/libraries/GyverButton/examples/analogKeyboard/analogBtns.jpg -------------------------------------------------------------------------------- /libraries/GyverButton/examples/analogKeyboard/analogKeyboard.ino: -------------------------------------------------------------------------------- 1 | // Пример использования библиотеки GyverButton с аналоговой клавиатурой 2 | // аналоговая клавиатура подключена на А7 3 | // Схему смотри на странице библиотеки https://alexgyver.ru/gyverbutton/ 4 | // также она есть в папке с примером 5 | 6 | #include "GyverButton.h" 7 | 8 | // создаём кнопки без привязки к пину 9 | GButton myButt1; 10 | GButton myButt2; 11 | GButton myButt3; 12 | 13 | void setup() { 14 | Serial.begin(9600); 15 | // меняем тип на LOW_PULL, потому что по умолчанию стоит HIGH_PULL 16 | myButt1.setType(LOW_PULL); 17 | myButt2.setType(LOW_PULL); 18 | myButt3.setType(LOW_PULL); 19 | } 20 | 21 | void loop() { 22 | // читаем значение 23 | int analog = analogRead(7); 24 | 25 | // для начала нужно вывести и запомнить значение для каждой кнопки 26 | //Serial.println(analog); 27 | 28 | // проверяем у каждой кнопки свой диапазон (+- 20 от полученного значения) 29 | myButt1.tick(analog < 860 && analog > 820); 30 | myButt2.tick(analog < 740 && analog > 700); 31 | myButt3.tick(analog < 650 && analog > 600); 32 | 33 | // проверка на удержание, например 34 | if (myButt1.isHolded()) { 35 | Serial.println("hold 1"); 36 | } 37 | if (myButt2.isHolded()) { 38 | Serial.println("hold 2"); 39 | } 40 | if (myButt3.isHolded()) { 41 | Serial.println("hold 3"); 42 | } 43 | 44 | delay(10); // задержка тут не нужна, чисто для вывода 45 | } 46 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/btn_pinChangeInt/btn_pinChangeInt.ino: -------------------------------------------------------------------------------- 1 | // пример с прерываниями pinChangeInterrupt (прерывания на любом пине) 2 | // только для ATmega328 (UNO, Nano, Pro Mini) 3 | 4 | #define BTN_PIN 3 5 | 6 | #include "GyverButton.h" 7 | GButton butt1(BTN_PIN); 8 | 9 | void setup() { 10 | Serial.begin(9600); 11 | 12 | // настроить PCINT 13 | attachPCINT(BTN_PIN); 14 | } 15 | 16 | void loop() { 17 | butt1.tick(); // обязательно нужен отработчик ещё и в loop, чтобы работали таймауты 18 | 19 | if (butt1.isClick()) Serial.println("Click"); // проверка на один клик 20 | if (butt1.isSingle()) Serial.println("Single"); // проверка на один клик 21 | if (butt1.isDouble()) Serial.println("Double"); // проверка на двойной клик 22 | if (butt1.isTriple()) Serial.println("Triple"); // проверка на тройной клик 23 | } 24 | 25 | // функция для настройки PCINT для ATmega328 (UNO, Nano, Pro Mini) 26 | uint8_t attachPCINT(uint8_t pin) { 27 | if (pin < 8) { // D0-D7 // PCINT2 28 | PCICR |= (1 << PCIE2); 29 | PCMSK2 |= (1 << pin); 30 | return 2; 31 | } 32 | else if (pin > 13) { //A0-A5 // PCINT1 33 | PCICR |= (1 << PCIE1); 34 | PCMSK1 |= (1 << pin - 14); 35 | return 1; 36 | } 37 | else { // D8-D13 // PCINT0 38 | PCICR |= (1 << PCIE0); 39 | PCMSK0 |= (1 << pin - 8); 40 | return 0; 41 | } 42 | } 43 | 44 | // Векторы PCINT, нужно кинуть сюда тики 45 | // не обязательно в каждый вектор, достаточно в тот, который задействован 46 | // пины 0-7: PCINT2 47 | // пины 8-13: PCINT0 48 | // пины A0-A5: PCINT1 49 | ISR(PCINT0_vect) { 50 | //butt1.tick(); 51 | } 52 | ISR(PCINT1_vect) { 53 | //butt1.tick(); 54 | } 55 | ISR(PCINT2_vect) { 56 | butt1.tick(); 57 | } 58 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/clicks_step/clicks_step.ino: -------------------------------------------------------------------------------- 1 | // ловим степ с накликиванием 2 | #define BTN_PIN 0 // кнопка подключена сюда (BTN_PIN --- КНОПКА --- GND) 3 | #include "GyverButton.h" 4 | GButton butt1(BTN_PIN); 5 | 6 | void setup() { 7 | Serial.begin(9600); 8 | } 9 | 10 | void loop() { 11 | butt1.tick(); 12 | 13 | // удержание 14 | if (butt1.isStep()) { 15 | Serial.println("0x"); 16 | } 17 | 18 | // один клик + удержание 19 | if (butt1.isStep(1)) { 20 | Serial.println("1x"); 21 | } 22 | 23 | // два клика + удержание 24 | if (butt1.isStep(2)) { 25 | Serial.println("2x"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/increment/increment.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Пример использования библиотеки GyverButton, управляем переменной value при помощи двух кнопок 3 | Конструкция с isIncr делает увеличение/уменьшение переменной при нажатой кнопке с шагом по времени 4 | */ 5 | 6 | #define BTN1 2 // кнопка подключена сюда (PIN --- КНОПКА --- GND) 7 | #define BTN2 3 // кнопка подключена сюда (PIN --- КНОПКА --- GND) 8 | 9 | #include "GyverButton.h" 10 | GButton butt1(BTN1); 11 | GButton butt2(BTN2); 12 | int value = 0; 13 | 14 | void setup() { 15 | Serial.begin(9600); 16 | } 17 | 18 | void loop() { 19 | butt1.tick(); // обязательная функция отработки. Должна постоянно опрашиваться 20 | butt2.tick(); // обязательная функция отработки. Должна постоянно опрашиваться 21 | 22 | if (butt1.isClick()) { // одиночное нажатие 23 | value++; // инкремент 24 | Serial.println(value); // для примера выведем в порт 25 | } 26 | 27 | if (butt2.isClick()) { // одиночное нажатие 28 | value--; // декремент 29 | Serial.println(value); // для примера выведем в порт 30 | } 31 | 32 | if (butt1.isStep()) { // обработчик удержания с шагами 33 | value++; // увеличивать/уменьшать переменную value с шагом и интервалом! 34 | Serial.println(value); // для примера выведем в порт 35 | } 36 | 37 | if (butt2.isStep()) { // обработчик удержания с шагами 38 | value--; // увеличивать/уменьшать переменную value с шагом и интервалом! 39 | Serial.println(value); // для примера выведем в порт 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /libraries/GyverButton/examples/many_clicks/many_clicks.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Пример использования библиотеки GyverButton, отработка любого количества нажатий 3 | */ 4 | 5 | #define BTN_PIN 3 // кнопка подключена сюда (BTN_PIN --- КНОПКА --- GND) 6 | #include "GyverButton.h" 7 | GButton butt1(BTN_PIN); 8 | 9 | void setup() { 10 | Serial.begin(9600); 11 | butt1.setTimeout(400); // настройка таймаута на удержание и второй клик (по умолчанию 500 мс) 12 | } 13 | 14 | void loop() { 15 | butt1.tick(); // обязательная функция отработки. Должна постоянно опрашиваться 16 | 17 | if (butt1.hasClicks()) // проверка на наличие нажатий 18 | Serial.println(butt1.getClicks()); // получить (и вывести) число нажатий 19 | } 20 | -------------------------------------------------------------------------------- /libraries/GyverButton/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For GyverButton 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | GButton KEYWORD1 10 | GyverButton KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | 16 | setDebounce KEYWORD2 17 | setTimeout KEYWORD2 18 | setStepTimeout KEYWORD2 19 | setClickTimeout KEYWORD2 20 | setType KEYWORD2 21 | setDirection KEYWORD2 22 | setTickMode KEYWORD2 23 | 24 | tick KEYWORD2 25 | isPress KEYWORD2 26 | isRelease KEYWORD2 27 | isClick KEYWORD2 28 | isHolded KEYWORD2 29 | isHold KEYWORD2 30 | state KEYWORD2 31 | 32 | hasClicks KEYWORD2 33 | getClicks KEYWORD2 34 | getHoldClicks KEYWORD2 35 | isSingle KEYWORD2 36 | isDouble KEYWORD2 37 | isTriple KEYWORD2 38 | isStep KEYWORD2 39 | 40 | ####################################### 41 | # Constants (LITERAL1) 42 | ####################################### 43 | 44 | HIGH_PULL LITERAL1 45 | LOW_PULL LITERAL1 46 | NORM_OPEN LITERAL1 47 | NORM_CLOSE LITERAL1 48 | MANUAL LITERAL1 49 | AUTO LITERAL1 -------------------------------------------------------------------------------- /libraries/GyverButton/library.properties: -------------------------------------------------------------------------------- 1 | name=GyverButton 2 | version=3.2 3 | author=AlexGyver 4 | maintainer=AlexGyver 5 | sentence=Advanced library for button. 6 | paragraph=Allows to get maximum uses of single button: clicks, holds and many more. 7 | category=Sensors 8 | url=https://github.com/AlexGyver/GyverLibs 9 | architectures=* -------------------------------------------------------------------------------- /schemes/scheme.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexGyver/ChristmasLights/6ecc5a21f3cccb0a0bffe7e7a185f261f673d9c3/schemes/scheme.jpg --------------------------------------------------------------------------------