Store name in LEDStripController to avoid setting it in detector
This commit is contained in:
parent
a1f144daf2
commit
0eb34eec25
4 changed files with 22 additions and 16 deletions
|
|
@ -15,9 +15,9 @@
|
||||||
#include "LEDStripController.h"
|
#include "LEDStripController.h"
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
LEDStripController::LEDStripController()
|
LEDStripController::LEDStripController(std::string dev_name)
|
||||||
{
|
{
|
||||||
|
name = dev_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -138,6 +138,11 @@ void LEDStripController::InitializeUDP(char * clientname, char * port)
|
||||||
i2cport = NULL;
|
i2cport = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* LEDStripController::GetLEDString()
|
||||||
|
{
|
||||||
|
return(led_string);
|
||||||
|
}
|
||||||
|
|
||||||
std::string LEDStripController::GetLocation()
|
std::string LEDStripController::GetLocation()
|
||||||
{
|
{
|
||||||
if(serialport != NULL)
|
if(serialport != NULL)
|
||||||
|
|
@ -158,9 +163,9 @@ std::string LEDStripController::GetLocation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* LEDStripController::GetLEDString()
|
std::string LEDStripController::GetName()
|
||||||
{
|
{
|
||||||
return(led_string);
|
return(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LEDStripController::SetLEDs(std::vector<RGBColor> colors)
|
void LEDStripController::SetLEDs(std::vector<RGBColor> colors)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ struct LEDStripDevice
|
||||||
class LEDStripController
|
class LEDStripController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LEDStripController();
|
LEDStripController(std::string dev_name);
|
||||||
~LEDStripController();
|
~LEDStripController();
|
||||||
|
|
||||||
void Initialize(char* ledstring, led_protocol proto);
|
void Initialize(char* ledstring, led_protocol proto);
|
||||||
|
|
@ -60,6 +60,7 @@ public:
|
||||||
|
|
||||||
char* GetLEDString();
|
char* GetLEDString();
|
||||||
std::string GetLocation();
|
std::string GetLocation();
|
||||||
|
std::string GetName();
|
||||||
|
|
||||||
void SetLEDs(std::vector<RGBColor> colors);
|
void SetLEDs(std::vector<RGBColor> colors);
|
||||||
|
|
||||||
|
|
@ -76,6 +77,7 @@ private:
|
||||||
char led_string[1024];
|
char led_string[1024];
|
||||||
std::string port_name;
|
std::string port_name;
|
||||||
std::string client_name;
|
std::string client_name;
|
||||||
|
std::string name;
|
||||||
serial_port *serialport;
|
serial_port *serialport;
|
||||||
net_port *udpport;
|
net_port *udpport;
|
||||||
i2c_smbus_interface *i2cport;
|
i2c_smbus_interface *i2cport;
|
||||||
|
|
|
||||||
|
|
@ -121,11 +121,10 @@ void DetectLEDStripControllers()
|
||||||
|
|
||||||
std::string value = dev.port + "," + std::to_string(dev.baud) + "," + std::to_string(dev.num_leds);
|
std::string value = dev.port + "," + std::to_string(dev.baud) + "," + std::to_string(dev.num_leds);
|
||||||
|
|
||||||
LEDStripController* controller = new LEDStripController();
|
LEDStripController* controller = new LEDStripController(dev.name);
|
||||||
controller->Initialize((char *)value.c_str(), dev.protocol);
|
controller->Initialize((char *)value.c_str(), dev.protocol);
|
||||||
|
|
||||||
RGBController_LEDStrip* rgb_controller = new RGBController_LEDStrip(controller);
|
RGBController_LEDStrip* rgb_controller = new RGBController_LEDStrip(controller);
|
||||||
rgb_controller->name = dev.name;
|
|
||||||
|
|
||||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,18 @@
|
||||||
|
|
||||||
RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* controller_ptr)
|
RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* controller_ptr)
|
||||||
{
|
{
|
||||||
controller = controller_ptr;
|
controller = controller_ptr;
|
||||||
|
|
||||||
name = "LED Strip";
|
name = controller->GetName();
|
||||||
type = DEVICE_TYPE_LEDSTRIP;
|
type = DEVICE_TYPE_LEDSTRIP;
|
||||||
description = "Serial LED Strip Device";
|
description = "Serial LED Strip Device";
|
||||||
location = controller->GetLocation();
|
location = controller->GetLocation();
|
||||||
|
|
||||||
mode Direct;
|
mode Direct;
|
||||||
Direct.name = "Direct";
|
Direct.name = "Direct";
|
||||||
Direct.value = 0;
|
Direct.value = 0;
|
||||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||||
modes.push_back(Direct);
|
modes.push_back(Direct);
|
||||||
|
|
||||||
SetupZones();
|
SetupZones();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue