Skip to content
Snippets Groups Projects
Commit 9036f727 authored by fxk8y's avatar fxk8y :spider:
Browse files

Showing UDP colors on LEDs working

parent bb9c7a51
No related branches found
No related tags found
No related merge requests found
......@@ -28,11 +28,11 @@ namespace SiliconTorch {
FxCyanRGB8::FxCyanRGB8(uint16_t leds, uint16_t startIdx) : leds(leds), startIdx(startIdx) {
buffer0 = new Pixel[leds];
buffer1 = new Pixel[leds];
buffer0 = new qthing::RGB[leds];
buffer1 = new qthing::RGB[leds];
std::memset(buffer0, 0x00, leds * sizeof(Pixel));
std::memset(buffer1, 0x00, leds * sizeof(Pixel));
// std::memset(buffer0, 0x00, leds * sizeof(Pixel));
// std::memset(buffer1, 0x00, leds * sizeof(Pixel));
......@@ -60,18 +60,25 @@ namespace SiliconTorch {
ESP_LOGW("Mapping[ X -> X ]", "startIdx[ %d ] packetIdx[ %d ] mapping: localPx[ 0 ] to packetPx[ 0 ]", startIdx, packetStartIdx);
for (uint16_t px = 0; px < std::min(leds, packetPxs); px++)
buffer1[px] = packetPx[px];
for (uint16_t px = 0; px < std::min(leds, packetPxs); px++) {
buffer1[px].r = packetPx[px].r / 255.0f;
buffer1[px].g = packetPx[px].g / 255.0f;
buffer1[px].b = packetPx[px].b / 255.0f;
}
} else if(packetStartIdx > startIdx) {
ESP_LOGW("Mapping[ P > W ]", "startIdx[ %d ] packetIdx[ %d ] mapping: packetPx[ 0 ] to localPx[ %d ]", startIdx, packetStartIdx, packetStartIdx-startIdx);
//ESP_LOGW("Mapping[ P > W ]", "startIdx[ %d ] packetIdx[ %d ] mapping: packetPx[ 0 ] to localPx[ %d ]", startIdx, packetStartIdx, packetStartIdx-startIdx);
ESP_LOGE("Mapping[ P > W ]", "NotImplementedYet");
} else if (packetStartIdx < startIdx) {
// ESP_LOGW("Mapping[ P < W ]", "startIdx[ %d ] packetIdx[ %d ] mapping: localPx[ 0 ] to packetPx[ 0 ]", startIdx, packetStartIdx, );
ESP_LOGE("Mapping[ P < W ]", "NotImplementedYet");
}
requestBufferSwap();
}
void FxCyanRGB8::registerUDPHandler() {
......@@ -88,9 +95,12 @@ namespace SiliconTorch {
// qthing::Animator
qthing::RGB FxCyanRGB8::render(uint16_t addr) {
qthing::RGB out;
return out;
if (addr < leds) {
return buffer0[addr];
} else {
qthing::RGB black;
return black;
}
}
// qthing::Animator
......@@ -104,7 +114,7 @@ namespace SiliconTorch {
void FxCyanRGB8::swapBuffers() {
swapRequested = false;
Pixel* tmp = buffer0;
qthing::RGB* tmp = buffer0;
buffer0 = buffer1;
buffer1 = tmp;
}
......
......@@ -50,8 +50,8 @@ namespace SiliconTorch {
private:
Pixel* buffer0;
Pixel* buffer1;
qthing::RGB* buffer0;
qthing::RGB* buffer1;
bool swapRequested = false;
bool udpHandlerRegistered = false;
......
......@@ -27,29 +27,29 @@ SiliconTorch::CyanBus::CyanBus* cyanBus = NULL;
SiliconTorch::FxCyanRGB8::FxCyanRGB8* cyanRGB = NULL;
qthing::Config cfg;
CyanLight::CyanLightControl* ctrl;
#include "driver/gpio.h"
#include <memory>
void device_main() {
qthing::Config cfg;
// Needed for packet parsing, animation rendering and stuff
qthing::power_managment_max_power();
cyanBus = new SiliconTorch::CyanBus::CyanBus(13, 14, 12, 15, 2000000); // Pinout of CyanStripe
cyanRGB = new SiliconTorch::FxCyanRGB8::FxCyanRGB8(50);
cyanBus = new SiliconTorch::CyanBus::CyanBus(13, 14, 12, 15, 2000000); // Pinout of CyanStripe
auto led0 = cfg.add<qthing::leds::WS2812B_V3>(GPIO_NUM_27, 8);
cyanRGB = new SiliconTorch::FxCyanRGB8::FxCyanRGB8(8);
cyanRGB->registerUDPHandler();
auto bullshitPtr = std::shared_ptr<qthing::Animation<qthing::RGB>>(cyanRGB, [](void*){});
cfg.add<qthing::Animator<qthing::RGBW8>>(led0)->setAnimation(bullshitPtr);
......
......@@ -59,6 +59,17 @@ if __name__ == '__main__':
white
]
FullHour = [
red,
green,
blue
]
fh = 0
while True:
sendPacket(pixel=pixels)
time.sleep(1)
sendPacket(pixel=pixels + [FullHour[fh]])
fh += 1
if fh >= len(FullHour): fh = 0
time.sleep(0.25)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment