mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-03-27 10:21:08 -04:00
Add COM:, UDP:, and TCP: prefixes to location string for Espurna, LED Strip, and NZXT Hue Plus controllers
This commit is contained in:
@@ -46,11 +46,17 @@ void EspurnaController::Initialize(char* ledstring)
|
||||
|
||||
void EspurnaController::InitializeEspurna(char * clientname, char * port, char * apikey)
|
||||
{
|
||||
strcpy(client_name, clientname);
|
||||
strcpy(port_name, port);
|
||||
client_name = clientname;
|
||||
port_name = port;
|
||||
|
||||
strcpy(espurna_apikey, apikey);
|
||||
tcpport = new net_port;
|
||||
tcpport->tcp_client(client_name, port_name);
|
||||
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)
|
||||
@@ -60,7 +66,7 @@ void EspurnaController::SetLEDs(std::vector<RGBColor> colors)
|
||||
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);
|
||||
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, strlen(get_request));
|
||||
tcpport->tcp_close();
|
||||
|
||||
@@ -28,16 +28,19 @@ public:
|
||||
EspurnaController();
|
||||
~EspurnaController();
|
||||
|
||||
void Initialize(char* ledstring);
|
||||
void InitializeEspurna(char* clientname, char* port, char * apikey);
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
void Initialize(char* ledstring);
|
||||
void InitializeEspurna(char* clientname, char* port, char * apikey);
|
||||
|
||||
std::string GetLocation();
|
||||
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
int baud_rate;
|
||||
|
||||
char led_string[1024];
|
||||
char port_name[128];
|
||||
char client_name[1024];
|
||||
std::string port_name;
|
||||
std::string client_name;
|
||||
char espurna_apikey[128];
|
||||
|
||||
net_port *tcpport;
|
||||
|
||||
@@ -15,6 +15,7 @@ RGBController_Espurna::RGBController_Espurna(EspurnaController* espurna_ptr)
|
||||
name = "Espurna";
|
||||
type = DEVICE_TYPE_LIGHT;
|
||||
description = "Espurna Device";
|
||||
location = espurna->GetLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
|
||||
@@ -86,21 +86,37 @@ void LEDStripController::Initialize(char* ledstring)
|
||||
void LEDStripController::InitializeSerial(char* portname, int baud)
|
||||
{
|
||||
portname = strtok(portname, "\r");
|
||||
strcpy(port_name, portname);
|
||||
port_name = portname;
|
||||
baud_rate = baud;
|
||||
serialport = new serial_port(port_name, baud_rate);
|
||||
serialport = new serial_port(port_name.c_str(), baud_rate);
|
||||
udpport = NULL;
|
||||
}
|
||||
|
||||
void LEDStripController::InitializeUDP(char * clientname, char * port)
|
||||
{
|
||||
strcpy(client_name, clientname);
|
||||
strcpy(port_name, port);
|
||||
client_name = clientname;
|
||||
port_name = port;
|
||||
|
||||
udpport = new net_port(client_name, port_name);
|
||||
udpport = new net_port(client_name.c_str(), port_name.c_str());
|
||||
serialport = NULL;
|
||||
}
|
||||
|
||||
std::string LEDStripController::GetLocation()
|
||||
{
|
||||
if(serialport != NULL)
|
||||
{
|
||||
return("COM: " + port_name);
|
||||
}
|
||||
else if(udpport != NULL)
|
||||
{
|
||||
return("UDP: " + client_name + ":" + port_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return("");
|
||||
}
|
||||
}
|
||||
|
||||
char* LEDStripController::GetLEDString()
|
||||
{
|
||||
return(led_string);
|
||||
@@ -143,4 +159,4 @@ void LEDStripController::SetLEDs(std::vector<RGBColor> colors)
|
||||
}
|
||||
|
||||
delete[] serial_buf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,14 @@ public:
|
||||
LEDStripController();
|
||||
~LEDStripController();
|
||||
|
||||
void Initialize(char* ledstring);
|
||||
void InitializeSerial(char* portname, int baud);
|
||||
void InitializeUDP(char* clientname, char* port);
|
||||
char* GetLEDString();
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
void Initialize(char* ledstring);
|
||||
void InitializeSerial(char* portname, int baud);
|
||||
void InitializeUDP(char* clientname, char* port);
|
||||
|
||||
char* GetLEDString();
|
||||
std::string GetLocation();
|
||||
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
int num_leds;
|
||||
|
||||
@@ -48,8 +51,8 @@ private:
|
||||
int baud_rate;
|
||||
|
||||
char led_string[1024];
|
||||
char port_name[128];
|
||||
char client_name[1024];
|
||||
std::string port_name;
|
||||
std::string client_name;
|
||||
serial_port *serialport;
|
||||
net_port *udpport;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
|
||||
name = "LED Strip";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "Keyboard Visualizer Arduino LED Strip Device";
|
||||
location = strip->GetLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
|
||||
@@ -24,17 +24,17 @@ HuePlusController::~HuePlusController()
|
||||
|
||||
void HuePlusController::Initialize(char* port)
|
||||
{
|
||||
strcpy(port_name, port);
|
||||
port_name = port;
|
||||
|
||||
serialport = new serial_port(port_name, HUE_PLUS_BAUD);
|
||||
serialport = new serial_port(port_name.c_str(), HUE_PLUS_BAUD);
|
||||
|
||||
channel_leds[HUE_PLUS_CHANNEL_1_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_1);
|
||||
channel_leds[HUE_PLUS_CHANNEL_2_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_2);
|
||||
}
|
||||
|
||||
char* HuePlusController::GetLocation()
|
||||
std::string HuePlusController::GetLocation()
|
||||
{
|
||||
return(port_name);
|
||||
return("COM: " + port_name);
|
||||
}
|
||||
|
||||
unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
~HuePlusController();
|
||||
|
||||
void Initialize(char* port);
|
||||
char* GetLocation();
|
||||
std::string GetLocation();
|
||||
unsigned int GetLEDsOnChannel(unsigned int channel);
|
||||
|
||||
void SetChannelEffect
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
unsigned int channel_leds[HUE_PLUS_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
char port_name[128];
|
||||
std::string port_name;
|
||||
serial_port *serialport;
|
||||
|
||||
void SendPacket
|
||||
|
||||
Reference in New Issue
Block a user