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,78 @@
/*---------------------------------------------------------*\
| EspurnaController.cpp |
| |
| Driver for Espurna |
| |
| Adam Honse (calcprogrammer1@gmail.com) 11 Sep 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <fstream>
#include <iostream>
#include <string>
#include <string.h>
#include "EspurnaController.h"
EspurnaController::EspurnaController()
{
}
EspurnaController::~EspurnaController()
{
}
void EspurnaController::Initialize(char* ledstring)
{
LPSTR apikey = NULL;
LPSTR source = NULL;
LPSTR udpport_baud = NULL;
LPSTR next = NULL;
source = strtok_s(ledstring, ",", &next);
//Check for either the UDP port or the serial baud rate
if (strlen(next))
{
udpport_baud = strtok_s(next, ",", &next);
}
//Espurna protocol requires API key
if (strlen(next))
{
apikey = strtok_s(next, ",", &next);
}
InitializeEspurna(source, udpport_baud, apikey);
}
void EspurnaController::InitializeEspurna(char * clientname, char * port, char * apikey)
{
client_name = clientname;
port_name = port;
strcpy(espurna_apikey, apikey);
tcpport = new net_port;
tcpport->tcp_client(client_name.c_str(), port_name.c_str());
}
std::string EspurnaController::GetLocation()
{
return("TCP: " + client_name + ":" + port_name);
}
void EspurnaController::SetLEDs(std::vector<RGBColor> colors)
{
if (tcpport != NULL)
{
RGBColor color = colors[0];
char get_request[1024];
snprintf(get_request, 1024, "GET /api/rgb?apikey=%s&value=%%23%02X%02X%02X HTTP/1.1\r\nHost: %s\r\n\r\n", espurna_apikey, RGBGetRValue(color), RGBGetGValue(color), RGBGetBValue(color), client_name.c_str());
tcpport->tcp_client_connect();
tcpport->tcp_client_write(get_request, (int)strlen(get_request));
tcpport->tcp_close();
}
}
@@ -0,0 +1,47 @@
/*---------------------------------------------------------*\
| EspurnaController.h |
| |
| Driver for Espurna |
| |
| Adam Honse (calcprogrammer1@gmail.com) 11 Sep 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <vector>
#include "RGBController.h"
#include "net_port.h"
#ifndef TRUE
#define TRUE true
#define FALSE false
#endif
#ifndef WIN32
#define LPSTR char *
#define strtok_s strtok_r
#endif
class EspurnaController
{
public:
EspurnaController();
~EspurnaController();
void Initialize(char* ledstring);
void InitializeEspurna(char* clientname, char* port, char * apikey);
std::string GetLocation();
void SetLEDs(std::vector<RGBColor> colors);
private:
std::string port_name;
std::string client_name;
char espurna_apikey[128];
net_port *tcpport;
};
@@ -0,0 +1,80 @@
/*---------------------------------------------------------*\
| EspurnaControllerDetect.cpp |
| |
| Detctor for Espurna |
| |
| Adam Honse (calcprogrammer1@gmail.com) 11 Sep 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "Detector.h"
#include "EspurnaController.h"
#include "RGBController_Espurna.h"
#include "SettingsManager.h"
/******************************************************************************************\
* *
* DetectEspurnaControllers *
* *
* Detect devices supported by the Espurna driver *
* *
\******************************************************************************************/
void DetectEspurnaControllers()
{
json espurna_settings;
/*-------------------------------------------------*\
| Get Espurna settings from settings manager |
\*-------------------------------------------------*/
espurna_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("EspurnaDevices");
/*-------------------------------------------------*\
| If the Espurna settings contains devices, process |
\*-------------------------------------------------*/
if(espurna_settings.contains("devices"))
{
for(unsigned int device_idx = 0; device_idx < espurna_settings["devices"].size(); device_idx++)
{
std::string ip;
std::string port;
std::string apikey;
if(espurna_settings["devices"][device_idx].contains("ip"))
{
ip = espurna_settings["devices"][device_idx]["ip"];
}
if(espurna_settings["devices"][device_idx].contains("port"))
{
if(espurna_settings["devices"][device_idx]["port"].type() == json::value_t::string)
{
port = espurna_settings["devices"][device_idx]["port"];
}
else
{
port = std::to_string((unsigned int)espurna_settings["devices"][device_idx]["port"]);
}
}
if(espurna_settings["devices"][device_idx].contains("apikey"))
{
apikey = espurna_settings["devices"][device_idx]["apikey"];
}
std::string value = ip + "," + port + "," + apikey;
EspurnaController* controller = new EspurnaController();
controller->Initialize((char *)value.c_str());
RGBController_Espurna* rgb_controller = new RGBController_Espurna(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
} /* DetectEspurnaControllers() */
REGISTER_DETECTOR("Espurna", DetectEspurnaControllers);
@@ -0,0 +1,93 @@
/*---------------------------------------------------------*\
| RGBController_Espurna.cpp |
| |
| RGBController for Espurna |
| |
| Adam Honse (calcprogrammer1@gmail.com) 11 Sep 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_Espurna.h"
/**------------------------------------------------------------------*\
@name Espurna
@category Light
@type TCP
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectEspurnaControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_Espurna::RGBController_Espurna(EspurnaController* controller_ptr)
{
controller = controller_ptr;
name = "Espurna";
type = DEVICE_TYPE_LIGHT;
description = "Espurna 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_Espurna::~RGBController_Espurna()
{
delete controller;
}
void RGBController_Espurna::SetupZones()
{
zone led_zone;
led_zone.name = "RGB Light";
led_zone.type = ZONE_TYPE_SINGLE;
led_zone.leds_min = 1;
led_zone.leds_max = 1;
led_zone.leds_count = 1;
led_zone.matrix_map = NULL;
zones.push_back(led_zone);
led new_led;
new_led.name = "RGB Light";
leds.push_back(new_led);
SetupColors();
}
void RGBController_Espurna::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_Espurna::DeviceUpdateLEDs()
{
controller->SetLEDs(colors);
}
void RGBController_Espurna::UpdateZoneLEDs(int /*zone*/)
{
controller->SetLEDs(colors);
}
void RGBController_Espurna::UpdateSingleLED(int /*led*/)
{
controller->SetLEDs(colors);
}
void RGBController_Espurna::DeviceUpdateMode()
{
}
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| RGBController_Espurna.h |
| |
| RGBController for Espurna |
| |
| Adam Honse (calcprogrammer1@gmail.com) 11 Sep 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "EspurnaController.h"
class RGBController_Espurna : public RGBController
{
public:
RGBController_Espurna(EspurnaController* controller_ptr);
~RGBController_Espurna();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
EspurnaController* controller;
};