Welcome to mirror list, hosted at ThFree Co, Russian Federation.

smartmatrix_t3.h - github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ba77d149f5bb71fa43eb4d88acbbc96d117f0813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef __INC_SMARTMATRIX_T3_H
#define __INC_SMARTMATRIX_T3_H

#ifdef SmartMatrix_h
#include<SmartMatrix.h>

extern SmartMatrix *pSmartMatrix;

// note - dmx simple must be included before FastSPI for this code to be enabled
class CSmartMatrixController : public CLEDController {
  SmartMatrix matrix;

public:
  // initialize the LED controller
  virtual void init() {
      // Initialize 32x32 LED Matrix
    matrix.begin();
    matrix.setBrightness(255);
    matrix.setColorCorrection(ccNone);

    // Clear screen
    clearLeds(0);
    matrix.swapBuffers();
    pSmartMatrix = &matrix;
  }

  // clear out/zero out the given number of leds.
  virtual void clearLeds(int nLeds) {
    const rgb24 black = {0,0,0};
    matrix.fillScreen(black);
    matrix.swapBuffers();
  }

  // set all the leds on the controller to a given color
  virtual void showColor(const struct CRGB & data, int nLeds,CRGB scale) {
    PixelController<RGB> pixels(data, nLeds, scale, getDither());
    rgb24 *md = matrix.backBuffer();
    while(nLeds--) {
      md->red = pixels.loadAndScale0();
      md->green = pixels.loadAndScale1();
      md->blue = pixels.loadAndScale2();
      md++;
      pixels.stepDithering();
    }
    matrix.swapBuffers();
  }

  // note that the uint8_ts will be in the order that you want them sent out to the device.
  // nLeds is the number of RGB leds being written to
  virtual void show(const struct CRGB *data, int nLeds, CRGB scale) {
    PixelController<RGB> pixels(data, nLeds, scale, getDither());
#ifdef SMART_MATRIX_CAN_TRIPLE_BUFFER
    rgb24 *md = matrix.getRealBackBuffer();
#else
    rgb24 *md = matrix.backBuffer();
#endif
    while(nLeds--) {
      md->red = pixels.loadAndScale0();
      md->green = pixels.loadAndScale1();
      md->blue = pixels.loadAndScale2();
      md++;
      pixels.advanceData();
      pixels.stepDithering();
    }
    matrix.swapBuffers();
#ifdef SMART_MATRIX_CAN_TRIPLE_BUFFER
    matrix.setBackBuffer((rgb24*)data);
#endif
  }

#ifdef SUPPORT_ARGB
  // as above, but every 4th uint8_t is assumed to be alpha channel data, and will be skipped
  virtual void show(const struct CARGB *data, int nLeds, CRGB scale) = 0;
#endif
};

#endif

#endif