【花雕体验】19 合宙ESP32_C3点亮WS2812B硬屏-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

123
返回列表 发新帖
楼主: eagler8

【花雕体验】19 合宙ESP32_C3点亮WS2812B硬屏

[复制链接]
 楼主| 发表于 2022-7-12 16:03 | 显示全部楼层
  【花雕体验】19 合宙ESP32_C3点亮WS2812B硬屏
  实验程序六:FastLED“100行代码”演示卷轴动画效果

  1. /*
  2.   【花雕体验】19 合宙ESP32_C3点亮WS2812B硬屏
  3.   实验程序六:FastLED“100行代码”演示卷轴动画效果
  4. */

  5. #include <FastLED.h>

  6. FASTLED_USING_NAMESPACE

  7. // FastLED "100-lines-of-code" demo reel, showing just a few
  8. // of the kinds of animation patterns you can quickly and easily
  9. // compose using FastLED.
  10. //
  11. // This example also shows one easy way to define multiple
  12. // animations patterns and have them automatically rotate.
  13. //
  14. // -Mark Kriegsman, December 2014


  15. #define DATA_PIN    9
  16. //#define CLK_PIN   4
  17. #define LED_TYPE    WS2811
  18. #define COLOR_ORDER GRB
  19. #define NUM_LEDS    256
  20. CRGB leds[NUM_LEDS];

  21. #define BRIGHTNESS          22
  22. #define FRAMES_PER_SECOND  120

  23. void setup() {
  24.   delay(1000); // 3 second delay for recovery

  25.   // tell FastLED about the LED strip configuration
  26.   FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  27.   //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

  28.   // set master brightness control
  29.   FastLED.setBrightness(BRIGHTNESS);
  30. }


  31. // List of patterns to cycle through.  Each is defined as a separate function below.
  32. typedef void (*SimplePatternList[])();
  33. SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };

  34. uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
  35. uint8_t gHue = 0; // rotating "base color" used by many of the patterns

  36. void loop()
  37. {
  38.   // Call the current pattern function once, updating the 'leds' array
  39.   gPatterns[gCurrentPatternNumber]();

  40.   // send the 'leds' array out to the actual LED strip
  41.   FastLED.show();
  42.   // insert a delay to keep the framerate modest
  43.   FastLED.delay(1000 / FRAMES_PER_SECOND);

  44.   // do some periodic updates
  45.   EVERY_N_MILLISECONDS( 20 ) {
  46.     gHue++;  // slowly cycle the "base color" through the rainbow
  47.   }
  48.   EVERY_N_SECONDS( 10 ) {
  49.     nextPattern();  // change patterns periodically
  50.   }
  51. }

  52. #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

  53. void nextPattern()
  54. {
  55.   // add one to the current pattern number, and wrap around at the end
  56.   gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
  57. }

  58. void rainbow()
  59. {
  60.   // FastLED's built-in rainbow generator
  61.   fill_rainbow( leds, NUM_LEDS, gHue, 7);
  62. }

  63. void rainbowWithGlitter()
  64. {
  65.   // built-in FastLED rainbow, plus some random sparkly glitter
  66.   rainbow();
  67.   addGlitter(80);
  68. }

  69. void addGlitter( fract8 chanceOfGlitter)
  70. {
  71.   if ( random8() < chanceOfGlitter) {
  72.     leds[ random16(NUM_LEDS) ] += CRGB::White;
  73.   }
  74. }

  75. void confetti()
  76. {
  77.   // random colored speckles that blink in and fade smoothly
  78.   fadeToBlackBy( leds, NUM_LEDS, 10);
  79.   int pos = random16(NUM_LEDS);
  80.   leds[pos] += CHSV( gHue + random8(64), 200, 255);
  81. }

  82. void sinelon()
  83. {
  84.   // a colored dot sweeping back and forth, with fading trails
  85.   fadeToBlackBy( leds, NUM_LEDS, 20);
  86.   int pos = beatsin16( 13, 0, NUM_LEDS - 1 );
  87.   leds[pos] += CHSV( gHue, 255, 192);
  88. }

  89. void bpm()
  90. {
  91.   // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  92.   uint8_t BeatsPerMinute = 62;
  93.   CRGBPalette16 palette = PartyColors_p;
  94.   uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  95.   for ( int i = 0; i < NUM_LEDS; i++) { //9948
  96.     leds[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
  97.   }
  98. }

  99. void juggle() {
  100.   // eight colored dots, weaving in and out of sync with each other
  101.   fadeToBlackBy( leds, NUM_LEDS, 20);
  102.   uint8_t dothue = 0;
  103.   for ( int i = 0; i < 8; i++) {
  104.     leds[beatsin16( i + 7, 0, NUM_LEDS - 1 )] |= CHSV(dothue, 200, 255);
  105.     dothue += 32;
  106.   }
  107. }
复制代码


 楼主| 发表于 2022-7-12 16:13 | 显示全部楼层
实验场景图  动态图
 楼主| 发表于 2022-7-12 16:16 | 显示全部楼层


实验的视频记录

https://v.youku.com/v_show/id_XN ... hcb.playlsit.page.1


发表于 2022-7-15 10:56 | 显示全部楼层
请问简约版的合宙ESP32C3没有办法进行程序烧录,一烧录就报错。
 楼主| 发表于 2022-7-15 11:12 | 显示全部楼层
SmallLion_114 发表于 2022-7-15 10:56
请问简约版的合宙ESP32C3没有办法进行程序烧录,一烧录就报错。

我收的C3都是经典版,可能使用简单些,反正价格都一样9.9,估计简约版适合有一定技术基础的和批量使用......
发表于 2022-7-15 13:53 | 显示全部楼层
eagler8 发表于 2022-7-15 11:12
我收的C3都是经典版,可能使用简单些,反正价格都一样9.9,估计简约版适合有一定技术基础的和批量使用... ...

经典版的没问题,但是简约版确实有问题,谢谢您的回复
 楼主| 发表于 2022-7-15 15:50 | 显示全部楼层
SmallLion_114 发表于 2022-7-15 13:53
经典版的没问题,但是简约版确实有问题,谢谢您的回复

不客气,多交流
发表于 2022-7-16 17:30 | 显示全部楼层
好炫啊
可以自娱自乐
也可以做招牌广告呵
 楼主| 发表于 2022-7-16 19:03 | 显示全部楼层
西米 发表于 2022-7-16 17:30
好炫啊
可以自娱自乐
也可以做招牌广告呵

谢谢鼓励
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 10:44 , Processed in 0.254159 second(s), 13 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表