PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 3 gadiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include "FastLED.h"
  2. // Pride2015
  3. // Animated, ever-changing rainbows.
  4. // by Mark Kriegsman
  5. #if FASTLED_VERSION < 3001000
  6. #error "Requires FastLED 3.1 or later; check github for latest code."
  7. #endif
  8. #define DATA_PIN 3
  9. //#define CLK_PIN 4
  10. #define LED_TYPE WS2811
  11. #define COLOR_ORDER GRB
  12. #define NUM_LEDS 200
  13. #define BRIGHTNESS 255
  14. CRGB leds[NUM_LEDS];
  15. void setup() {
  16. delay(3000); // 3 second delay for recovery
  17. // tell FastLED about the LED strip configuration
  18. FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
  19. .setCorrection(TypicalLEDStrip)
  20. .setDither(BRIGHTNESS < 255);
  21. // set master brightness control
  22. FastLED.setBrightness(BRIGHTNESS);
  23. }
  24. void loop()
  25. {
  26. pride();
  27. FastLED.show();
  28. }
  29. // This function draws rainbows with an ever-changing,
  30. // widely-varying set of parameters.
  31. void pride()
  32. {
  33. static uint16_t sPseudotime = 0;
  34. static uint16_t sLastMillis = 0;
  35. static uint16_t sHue16 = 0;
  36. uint8_t sat8 = beatsin88( 87, 220, 250);
  37. uint8_t brightdepth = beatsin88( 341, 96, 224);
  38. uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
  39. uint8_t msmultiplier = beatsin88(147, 23, 60);
  40. uint16_t hue16 = sHue16;//gHue * 256;
  41. uint16_t hueinc16 = beatsin88(113, 1, 3000);
  42. uint16_t ms = millis();
  43. uint16_t deltams = ms - sLastMillis ;
  44. sLastMillis = ms;
  45. sPseudotime += deltams * msmultiplier;
  46. sHue16 += deltams * beatsin88( 400, 5,9);
  47. uint16_t brightnesstheta16 = sPseudotime;
  48. for( uint16_t i = 0 ; i < NUM_LEDS; i++) {
  49. hue16 += hueinc16;
  50. uint8_t hue8 = hue16 / 256;
  51. brightnesstheta16 += brightnessthetainc16;
  52. uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
  53. uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
  54. uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
  55. bri8 += (255 - brightdepth);
  56. CRGB newcolor = CHSV( hue8, sat8, bri8);
  57. uint16_t pixelnumber = i;
  58. pixelnumber = (NUM_LEDS-1) - pixelnumber;
  59. nblend( leds[pixelnumber], newcolor, 64);
  60. }
  61. }