PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

74 lines
1.9KB

  1. #include <FastLED.h>
  2. #define kMatrixWidth 16
  3. #define kMatrixHeight 16
  4. #define NUM_LEDS (kMatrixWidth * kMatrixHeight)
  5. // Param for different pixel layouts
  6. #define kMatrixSerpentineLayout true
  7. // led array
  8. CRGB leds[kMatrixWidth * kMatrixHeight];
  9. // x,y, & time values
  10. uint32_t x,y,v_time,hue_time,hxy;
  11. // Play with the values of the variables below and see what kinds of effects they
  12. // have! More octaves will make things slower.
  13. // how many octaves to use for the brightness and hue functions
  14. uint8_t octaves=1;
  15. uint8_t hue_octaves=3;
  16. // the 'distance' between points on the x and y axis
  17. int xscale=57771;
  18. int yscale=57771;
  19. // the 'distance' between x/y points for the hue noise
  20. int hue_scale=1;
  21. // how fast we move through time & hue noise
  22. int time_speed=1111;
  23. int hue_speed=31;
  24. // adjust these values to move along the x or y axis between frames
  25. int x_speed=331;
  26. int y_speed=1111;
  27. void loop() {
  28. // fill the led array 2/16-bit noise values
  29. fill_2dnoise16(LEDS.leds(), kMatrixWidth, kMatrixHeight, kMatrixSerpentineLayout,
  30. octaves,x,xscale,y,yscale,v_time,
  31. hue_octaves,hxy,hue_scale,hxy,hue_scale,hue_time, false);
  32. LEDS.show();
  33. // adjust the intra-frame time values
  34. x += x_speed;
  35. y += y_speed;
  36. v_time += time_speed;
  37. hue_time += hue_speed;
  38. // delay(50);
  39. }
  40. void setup() {
  41. // initialize the x/y and time values
  42. random16_set_seed(8934);
  43. random16_add_entropy(analogRead(3));
  44. Serial.begin(57600);
  45. Serial.println("resetting!");
  46. delay(3000);
  47. LEDS.addLeds<WS2811,6,GRB>(leds,NUM_LEDS);
  48. LEDS.setBrightness(96);
  49. hxy = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
  50. x = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
  51. y = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
  52. v_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
  53. hue_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
  54. }