ESPectro32 Library
Library for using ESPectro32 board
 All Classes Functions Variables Enumerations Enumerator Pages
ex_leds_anim.hpp
1 /*
2  * ex_leds_anim.hpp
3  *
4  * Created on: Aug 22, 2017
5  * Author: andri
6  */
7 
8 #ifndef COMPONENTS_ESPECTRO32_EXAMPLES_IDF_EX_LEDS_ANIM_HPP_
9 #define COMPONENTS_ESPECTRO32_EXAMPLES_IDF_EX_LEDS_ANIM_HPP_
10 
11 #include <ESPectro32_Board.h>
12 #include <ESPectro32_RGBLED_Animation.h>
13 
14 RgbLedColor_t aCol(200, 0, 80);
15 ESPectro32_RGBLED_GlowingAnimation glowAnim(ESPectro32.RgbLed(), aCol);
16 
17 #include <ESPectro32_LedMatrix_Animation.h>
18 ESPectro32_LedMatrix_Animation ledMatrixAnim;
19 
20 static void load_ex_leds_anim() {
21  //Turn on/off LED once
22  // ESPectro32.turnOnLED();
23  // delay(1000);
24  // ESPectro32.turnOffLED();
25 
26  //Single color LED animation
27  ESPectro32.LED().setAnimation(ESPectro_LED_Animation_Fading, 3000, 3);
28  //ESPectro32.LED().blink(1000, 3);
29 
30 
31 // ESPectro32.RgbLed().setPixel(0, 120, 128, 7);
32 // ESPectro32.RgbLed().show();
33 // delay(1000);
34 // ESPectro32.RgbLed().clear();
35 // ESPectro32.RgbLed().show();
36 
37  //RGB LED Animation, glowing LED for 3 times, 3 seconds each
38  glowAnim.start(3000, 3);
39 
40  /*
41  fadeAnim.start([](const WS2812Animator::AnimationParam param) {
42 
43  //Triangle function
44  //y = (A/P) * (P - abs(x % (2*P) - P))
45  float x = param.progress * 100;
46  float P = 100/2;
47  float b = (100/P) * (P - abs(((int)x % (int)(2*P)) - P));
48 
49  //float b = sin(param.progress * PI) * 100;
50 // ESP_LOGI(TAG, "Progress %f", b);
51 
52  for (uint8_t pixNum = 0; pixNum < fadeAnim.RgbLed().getPixelCount(); pixNum++) {
53  fadeAnim.RgbLed().setBrightnessPercent(pixNum, b);
54  }
55 
56  fadeAnim.RgbLed().show();
57 
58  }, []() {
59 
60  ESP_LOGI(TAG, "Animation DONE");
61 
62  }, 1000, 10);*/
63 
64 
65  //LED Matrix animation (only support 8 frames)
66  ledMatrixAnim.setLedMatrix(ESPectro32.LedMatrix());
67 
68  ledMatrixAnim.addFrameWithData((uint8_t*)LED_MATRIX_ICON_HEART);
69  ledMatrixAnim.addFrameWithData((uint8_t*)LED_MATRIX_ICON_HEART_OUTLINE);
70  ledMatrixAnim.addFrameWithData((uint8_t*)LED_MATRIX_ICON_HEART);
71  ledMatrixAnim.addFrameWithData((uint8_t*)LED_MATRIX_ICON_HEART_OUTLINE);
72  ledMatrixAnim.addFrameWithDataCallback([](ESPectro32_LedMatrix &ledM) {
73  ledM.drawCircle(3, 3, 3, 200);
74  });
75  ledMatrixAnim.addFrameWithDataCallback([](ESPectro32_LedMatrix &ledM) {
76  ledM.fillCircle(3, 3, 3, 200);
77  });
78 
79  ledMatrixAnim.start(3000);
80 }
81 
82 #endif /* COMPONENTS_ESPECTRO32_EXAMPLES_IDF_EX_LEDS_ANIM_HPP_ */
Base class of Led Matrix animation.
Definition: ESPectro32_LedMatrix_Animation.h:28
A class of Neopixel RGB LED glowing animation.
Definition: ESPectro32_RGBLED_Animation.h:83
ESPectro32_RGBLED & RgbLed()
Get RGB LED object of the ESPectro32 board.
Definition: ESPectro32_Board.cpp:53
ESPectro32_LedMatrix & LedMatrix()
Get Led Matrix object.
Definition: ESPectro32_Board.cpp:149
The class represents Led Matrix.
Definition: ESPectro32_LedMatrix.h:76
Definition: RgbLedColor.h:25
ESPectro32_LED & LED()
Get LED object.
Definition: ESPectro32_Board.cpp:105
void start(uint16_t duration=0, uint16_t count=0)
Start the animation.
Definition: ESPectro32_RGBLED_Animation.cpp:138