Add COM:, UDP:, and TCP: prefixes to location string for Espurna, LED Strip, and NZXT Hue Plus controllers
This commit is contained in:
parent
d3aefcfdf4
commit
210591aa39
8 changed files with 58 additions and 28 deletions
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue