forked from ForsakenNGS/PicoLED
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPioStrip.cpp
More file actions
34 lines (27 loc) · 765 Bytes
/
PioStrip.cpp
File metadata and controls
34 lines (27 loc) · 765 Bytes
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
#include "PicoLed.hpp"
#include "PioStrip.hpp"
#include <stdio.h>
namespace PicoLed {
PioStrip::PioStrip(
PIO pioBlock, uint stateMachine, uint dataPin, uint numLeds, DataByte b1, DataByte b2, DataByte b3, DataByte b4
):
PicoLedTarget(numLeds, b1, b2, b3, b4), pioBlock(pioBlock), stateMachine(stateMachine), dataPin(dataPin)
{
data = new uint32_t[numLeds];
fill(RGB(0, 0, 0), 0, numLeds);
}
PioStrip::~PioStrip() {
delete data;
}
uint32_t PioStrip::getData(uint index) {
return data[index];
}
void PioStrip::setData(uint index, uint32_t value) {
data[index] = value;
}
void PioStrip::show() {
for (uint i = 0; i < numLeds; i++) {
pio_sm_put_blocking(pioBlock, stateMachine, scalePixelData(data[i], brightness));
}
}
}