-
Notifications
You must be signed in to change notification settings - Fork 0
/
apa102c.h
66 lines (51 loc) · 1.47 KB
/
apa102c.h
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
/*
* APA102C.h
*
* Created on: Feb 24, 2020
* Author: mh
*/
#include <ColorUtil.h>
#include <ti/drivers/SPI.h>
#ifndef APA102C_H_
#define APA102C_H_
#define BRIGHTNESS_MASK 0xe0
#define INITIAL_BRIGHTNESS 1.0f
using namespace colorUtil;
class APA102C {
public:
typedef struct FloatLed {
float brightness;
rgbColorFloat color;
} FloatLed;
typedef struct EightBitLed {
uint8_t brightness;
rgbColor color;
} EightBitLed;
APA102C(uint_least8_t spiIndex, uint16_t ledCount);
virtual ~APA102C();
void setBrightness(float brightness);
void setLed(rgbColorFloat *color, uint16_t ledIndex);
void setLed(FloatLed *led, uint16_t ledIndex);
void setAllLeds(FloatLed *led);
void setAllLeds(rgbColorFloat *color);
FloatLed *getLed(uint16_t ledIndex);
EightBitLed getEightBitLed(uint16_t ledIndex);
rgbColorFloat getLedColor(void);
void capture();
void capture(rgbColorFloat *c);
FloatLed *getCaptureBuffer();
void output();
private:
SPI_Handle spi;
SPI_Transaction transaction;
uint16_t ledCount;
uint16_t frameLength;
FloatLed *backBuffer;
FloatLed *captureBuffer;
EightBitLed *outputBuffer;
EightBitLed frameStart[4] = {0x00, 0x00, 0x00, 0x00};
EightBitLed frameEnd[4] = {0xff, 0xff, 0xff, 0xff};
float brightness = INITIAL_BRIGHTNESS;
void backBufferToOutputBuffer();
};
#endif