ESPectro32 Library
Library for using ESPectro32 board
 All Classes Functions Variables Enumerations Enumerator Pages
ESPectro32_LedMatrix_Animation.h
1 /*
2  * ESPectro32_LedMatrix_Animation.h
3  *
4  * Created on: Aug 20, 2017
5  * Author: andri
6  */
7 
8 #ifndef COMPONENTS_ESPECTRO32_SRC_ESPECTRO32_LEDMATRIX_ANIMATION_H_
9 #define COMPONENTS_ESPECTRO32_SRC_ESPECTRO32_LEDMATRIX_ANIMATION_H_
10 
11 #include <Animator.h>
12 #include "ESPectro32_LedMatrix.h"
13 
14 #define ESPECTRO32_LEDMATRIX_MAX_FRAME_COUNT 8
15 
29 public:
30 
31  typedef std::function<void(ESPectro32_LedMatrix &ledMatrix)> FrameDataCallback;
32 
35 
36  void setLedMatrix(ESPectro32_LedMatrix &ledM) {
37  ledMatrix_ = &ledM;
38  }
39 
40  ESPectro32_LedMatrix &LedMatrix() {
41  return *ledMatrix_;
42  }
43 
44  void onAnimationCompleted(Animator::AnimationFinishedCallback cb) {
45  animCompletedCb_ = cb;
46  }
47 
48  void addFrameWithData(uint8_t *data, uint16_t color = 255);
49  void addFrameWithDataCallback(ESPectro32_LedMatrix_Animation::FrameDataCallback cb);
50  void setFrameWithData(uint8_t frameNo, uint8_t *data, uint16_t color = 255);
51  void setFrameWithDataCallback(uint8_t frameNo, ESPectro32_LedMatrix_Animation::FrameDataCallback cb);
52 
53  void start(Animator::AnimationUpdateCallback animUpdateCallback, Animator::AnimationFinishedCallback animFinishedCallback,
54  uint16_t duration = 0, uint16_t updateInterval = 0);
55  void start(uint16_t duration = 0, bool repeat = false);
56  void stop();
57  void run();
58 
59 protected:
60  ESPectro32_LedMatrix *ledMatrix_ = NULL;
61  uint8_t frameCount_ = 0;
62  bool forceStop_ = false;
63 
64  Animator::AnimationFinishedCallback animCompletedCb_ = NULL;
65  Animator *animator_ = NULL;
66  Animator *getAnimatorPtr();
67 };
68 
70 public:
73 
74  void scrollText(const char *text, uint16_t duration = 0, bool repeat = false);
75 private:
76  char *scrolledText_ = NULL;
77 };
78 
79 #endif /* COMPONENTS_ESPECTRO32_SRC_ESPECTRO32_LEDMATRIX_ANIMATION_H_ */
Base class of Led Matrix animation.
Definition: ESPectro32_LedMatrix_Animation.h:28
Definition: ESPectro32_LedMatrix_Animation.h:69
The class represents Led Matrix.
Definition: ESPectro32_LedMatrix.h:76
Definition: Animator.h:15