-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht3a33brg.h
104 lines (87 loc) · 2.34 KB
/
t3a33brg.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
/*!
* \file t3a33brg.h
*/
#include "hardware/spi.h"
#include "pico/stdlib.h"
#include <cstdlib>
#include <string.h>
class SPI_T3A33BRG
{
public:
/*!
* \brief Constructor for use with SPI instance
*
* \param num How many LEDs there are
* \param mosi_pin Master Out Slave In pin
* \param sck_pin Clock pin
* \param spi SPI instance specifier, either \ref spi0 or \ref spi1
*/
SPI_T3A33BRG(uint16_t num, uint8_t mosi_pin, uint8_t sck_pin, spi_inst_t *spi);
/*!
* \brief Release memory (as needed):
*/
~SPI_T3A33BRG();
/*!
* \brief Activate SPI
*/
void begin(void);
/*!
* \brief Shows the pixels
*/
void show(void);
/*!
* \brief Set pixel color from separate 8-bit R, G, B components
*
* \param led Pixel to set
* \param red Red value
* \param green Green value
* \param blue Blue value
*/
void setPixelColor(uint16_t led, uint8_t red, uint8_t green, uint8_t blue);
/*!
* \brief Set pixel color from 'packed' 32-bit RGB value
*
* \param led Pixel to set
* \param color packed 32-bit RGB value to set the pixel
*/
void setPixelColor(uint16_t led, uint32_t color);
/*!
* \brief Clear the entire string
*/
void clear();
/*!
* \brief Change pin assignment post-constructor, using arbitrary pins
*
* \param mosi_pin Data pin
* \param sck_pin Clock pin
*/
void updatePins(uint8_t mosi_pin, uint8_t sck_pin);
/*!
* \brief Change strand length
*
* \param numLEDs Length to change to
*/
void updateLength(uint16_t num);
/*!
* \brief Returns the number of pixels currently connected
*
* \return Returns the number of connected pixels
*/
uint16_t numPixels(void);
/*!
* \brief Query color from previously-set pixel
* \param n Pixel to query
* \return Returns packed 32-bit RGB value
*/
uint32_t getPixelColor(uint16_t n);
private:
uint16_t numLEDs;
uint8_t *pixels, // Holds color values for each LED (3 bytes each)
sckpin, mosipin; // Clock & data pin numbers
uint8_t startFrame[4], endFrame[4];
uint8_t ledParam = 0xFF;
// SPI instance specifier, either spi0 or spi1
spi_inst_t *spi_interface;
void alloc(uint16_t n);
};