Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,105 @@
/*---------------------------------------------------------*\
| BlinkyTapeController.cpp |
| |
| Driver for BlinkyTape |
| |
| Matt Mets (matt@blinkinlabs.com) 01 Jul 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include "BlinkyTapeController.h"
#ifndef WIN32
#define LPSTR char *
#define strtok_s strtok_r
#endif
BlinkyTapeController::BlinkyTapeController()
{
}
BlinkyTapeController::~BlinkyTapeController()
{
if(serialport != nullptr)
{
serialport->serial_close();
delete serialport;
}
}
void BlinkyTapeController::Initialize(const std::string &portname)
{
port_name = portname;
serialport = new serial_port();
if(!serialport->serial_open(port_name.c_str(), 115200))
{
delete serialport;
serialport = nullptr;
}
}
std::string BlinkyTapeController::GetLocation()
{
if(serialport == nullptr)
{
return("");
}
return("COM: " + port_name);
}
char* BlinkyTapeController::GetLEDString()
{
return(led_string);
}
void BlinkyTapeController::SetLEDs(std::vector<RGBColor> colors)
{
if(serialport == nullptr)
{
return;
}
/*-------------------------------------------------------------*\
| BlinkyTape Protocol |
| |
| Packet size: Number of data bytes + 1 |
| |
| 0-n: Data Byte (0-254) |
| n+1: Packet End Byte (0xFF) |
\*-------------------------------------------------------------*/
const unsigned int payload_size = ((unsigned int)colors.size() * 3);
const unsigned int packet_size = payload_size + 1;
std::vector<unsigned char> serial_buf(packet_size);
/*-------------------------------------------------------------*\
| Set up end byte |
\*-------------------------------------------------------------*/
serial_buf[packet_size - 1] = 0xFF;
/*-------------------------------------------------------------*\
| Copy in color data in RGB order |
\*-------------------------------------------------------------*/
for(unsigned int color_idx = 0; color_idx < colors.size(); color_idx++)
{
const unsigned int color_offset = color_idx * 3;
serial_buf[0x00 + color_offset] = (unsigned char)std::min((unsigned int)254, RGBGetRValue(colors[color_idx]));
serial_buf[0x01 + color_offset] = (unsigned char)std::min((unsigned int)254, RGBGetGValue(colors[color_idx]));
serial_buf[0x02 + color_offset] = (unsigned char)std::min((unsigned int)254, RGBGetBValue(colors[color_idx]));
}
/*-------------------------------------------------------------*\
| Send the packet |
\*-------------------------------------------------------------*/
serialport->serial_write((char *)serial_buf.data(), packet_size);
}
@@ -0,0 +1,40 @@
/*---------------------------------------------------------*\
| BlinkyTapeController.h |
| |
| Driver for BlinkyTape |
| |
| Matt Mets (matt@blinkinlabs.com) 01 Jul 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "serial_port.h"
struct BlinkyTapeDevice
{
std::string port;
unsigned int num_leds;
};
class BlinkyTapeController
{
public:
BlinkyTapeController();
~BlinkyTapeController();
void Initialize(const std::string &portname);
char* GetLEDString();
std::string GetLocation();
void SetLEDs(std::vector<RGBColor> colors);
private:
char led_string[1024];
std::string port_name;
serial_port *serialport = nullptr;
};
@@ -0,0 +1,51 @@
/*---------------------------------------------------------*\
| BlinkyTapeControllerDetect.cpp |
| |
| Detector for BlinkyTape |
| |
| Matt Mets (matt@blinkinlabs.com) 01 Jul 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <vector>
#include "Detector.h"
#include "BlinkyTapeController.h"
#include "RGBController_BlinkyTape.h"
#include "find_usb_serial_port.h"
/*-----------------------------------------------------*\
| BlinkyTape VID and PID |
\*-----------------------------------------------------*/
#define BLINKINLABS_VID 0x1D50
#define BLINKYTAPE_PID 0x605E
/******************************************************************************************\
* *
* DetectBlinkyTapeControllers *
* *
* Detect BlinkyTape devices *
* *
\******************************************************************************************/
void DetectBlinkyTapeControllers()
{
std::vector<std::string *> device_locations = find_usb_serial_port(BLINKINLABS_VID, BLINKYTAPE_PID);
for(unsigned int device_idx = 0; device_idx < device_locations.size(); device_idx++)
{
BlinkyTapeController* controller = new BlinkyTapeController();
controller->Initialize(*device_locations[device_idx]);
RGBController_BlinkyTape* rgb_controller = new RGBController_BlinkyTape(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_DETECTOR("BlinkyTape", DetectBlinkyTapeControllers);
/*---------------------------------------------------------------------------------------------------------*\
| Entries for dynamic UDEV rules |
| |
| DUMMY_DEVICE_DETECTOR("BlinkyTape", DetectBlinkyTapeControllers, 0x1D50, 0x605E ) |
\*---------------------------------------------------------------------------------------------------------*/
@@ -0,0 +1,146 @@
/*---------------------------------------------------------*\
| RGBController_BlinkyTape.cpp |
| |
| RGBController for BlinkyTape |
| |
| Matt Mets (matt@blinkinlabs.com) 01 Jul 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_BlinkyTape.h"
/**------------------------------------------------------------------*\
@name Blinky Tape
@category LEDStrip
@type Serial
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectBlinkyTapeControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_BlinkyTape::RGBController_BlinkyTape(BlinkyTapeController* controller_ptr)
{
controller = controller_ptr;
name = "BlinkyTape";
vendor = "Blinkinlabs";
type = DEVICE_TYPE_LEDSTRIP;
description = "BlinkyTape Controller Device";
location = controller->GetLocation();
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
RGBController_BlinkyTape::~RGBController_BlinkyTape()
{
delete controller;
}
void RGBController_BlinkyTape::SetupZones()
{
zones.clear();
leds.clear();
zone led_zone;
led_zone.name = "LED Strip";
led_zone.type = ZONE_TYPE_LINEAR;
led_zone.leds_min = 0;
led_zone.leds_max = 512;
led_zone.leds_count = 0;
led_zone.matrix_map = NULL;
zones.push_back(led_zone);
ResizeZone(0, led_zone.leds_count);
}
void RGBController_BlinkyTape::ResizeZone(int zone, int new_size)
{
/*-------------------------------------------------*\
| Explicitly cast these to avoid compiler warnings |
\*-------------------------------------------------*/
const unsigned int zone_u = static_cast<unsigned int>(zone);
const unsigned int new_size_u = static_cast<unsigned int>(new_size);
/*-------------------------------------------------*\
| Check that the zone is in bounds |
\*-------------------------------------------------*/
if((zone_u > zones.size()) || (zone < 0))
{
return;
}
/*-------------------------------------------------*\
| And that the new size is in bounds |
\*-------------------------------------------------*/
if((new_size_u > zones.at(zone).leds_max) || (new_size_u < zones.at(zone).leds_min))
{
return;
}
/*-------------------------------------------------*\
| And that there's actually a change |
\*-------------------------------------------------*/
if(zones.at(zone).leds_count == new_size_u)
{
return;
}
/*-------------------------------------------------*\
| If the new size is less than the current size, |
| just chop off the end |
\*-------------------------------------------------*/
if(leds.size() > new_size_u)
{
leds.resize(new_size);
}
/*-------------------------------------------------*\
| Otherwise, add new LEDs to the end |
\*-------------------------------------------------*/
if(leds.size() < new_size_u)
{
for(size_t led_idx = leds.size(); led_idx < new_size_u; led_idx++)
{
led new_led;
new_led.name = "LED ";
new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led);
}
}
zones.at(zone).leds_count = new_size;
SetupColors();
}
void RGBController_BlinkyTape::DeviceUpdateLEDs()
{
controller->SetLEDs(colors);
}
void RGBController_BlinkyTape::UpdateZoneLEDs(int /*zone*/)
{
controller->SetLEDs(colors);
}
void RGBController_BlinkyTape::UpdateSingleLED(int /*led*/)
{
controller->SetLEDs(colors);
}
void RGBController_BlinkyTape::DeviceUpdateMode()
{
}
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| RGBController_BlinkyTape.h |
| |
| RGBController for BlinkyTape |
| |
| Matt Mets (matt@blinkinlabs.com) 01 Jul 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "serial_port.h"
#include "BlinkyTapeController.h"
class RGBController_BlinkyTape : public RGBController
{
public:
RGBController_BlinkyTape(BlinkyTapeController* controller_ptr);
~RGBController_BlinkyTape();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
BlinkyTapeController* controller;
};