FastLED 3.9.7
Loading...
Searching...
No Matches
LedRopeTCL.h
1// Copyleft (c) 2012, Zach Vorhies
2// Public domain, no rights reserved.
3// This object holds a frame buffer and effects can be applied. This is a higher level
4// object than the TCL class which this object uses for drawing.
5
6#ifndef LED_REPE_TCL_H_
7#define LED_REPE_TCL_H_
8
9#include <Arduino.h>
10#include "../shared/color.h"
11#include "../shared/framebuffer.h"
12#include "../shared/led_rope_interface.h"
13
14#include "fl/vector.h"
15#include "crgb.h"
16#include "fl/screenmap.h"
17
18// LedRopeTCL is a C++ wrapper around the Total Control Lighting LED rope
19// device driver (TCL.h). This wrapper includes automatic setup of the LED
20// rope and allows the user to use a graphics-state like interface for
21// talking to the rope. A copy of the rope led state is held in this class
22// which makes blending operations easier. After all changes by the user
23// are applied to the rope, the hardware is updated via an explicit Draw()
24// command.
25//
26// Whole-rope blink Example:
27// #include <SPI.h>
28// #include <TCL.h> // From CoolNeon (https://bitbucket.org/devries/arduino-tcl)
29// #include "LedRopeTCL.h"
30// LedRopeTCL led_rope(100); // 100 led-strand.
31//
32// void setup() {} // No setup necessary for Led rope.
33// void loop() {
34// led_rope.FillColor(LedRopeTCL::Color3i::Black());
35// led_rope.Draw();
36// delay(1000);
37// led_rope.FillColor(LedRopeTCL::Color3i::White());
38// led_rope.Draw();
39// delay(1000);
40// }
41
42
44 public:
45 LedRopeTCL(int n_pixels);
46 virtual ~LedRopeTCL();
47
48 void Draw();
49 void DrawSequentialRepeat(int repeat);
50 void DrawRepeat(const int* value_array, int array_length);
51 void set_draw_offset(int val);
52
53 virtual void Set(int i, const Color3i& c) {
54 frame_buffer_.Set(i, c);
55 }
56
57 Color3i* GetIterator(int i) {
58 return frame_buffer_.GetIterator(i);
59 }
60
61 int length() const { return frame_buffer_.length(); }
62
63 void RawBeginDraw();
64 void RawDrawPixel(const Color3i& c);
65 void RawDrawPixels(const Color3i& c, int n);
66 void RawDrawPixel(uint8_t r, uint8_t g, uint8_t b);
67 void RawCommitDraw();
68
69 protected:
70 void PreDrawSetup();
71 int draw_offset_ = 0;
72 bool lazy_initialized_;
73 FrameBuffer frame_buffer_;
74 bool controller_added_ = false;
75 fl::HeapVector<CRGB> led_buffer_;
76 fl::ScreenMap mScreenMap;
77};
78
79#endif // LED_REPE_TCL_H_
Defines the red, green, and blue (RGB) pixel struct.
Definition color.h:8