Store name in LEDStripController to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-11 20:23:07 -05:00
parent a1f144daf2
commit 0eb34eec25
4 changed files with 22 additions and 16 deletions

View file

@ -15,9 +15,9 @@
#include "LEDStripController.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;
}
char* LEDStripController::GetLEDString()
{
return(led_string);
}
std::string LEDStripController::GetLocation()
{
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)

View file

@ -49,7 +49,7 @@ struct LEDStripDevice
class LEDStripController
{
public:
LEDStripController();
LEDStripController(std::string dev_name);
~LEDStripController();
void Initialize(char* ledstring, led_protocol proto);
@ -60,6 +60,7 @@ public:
char* GetLEDString();
std::string GetLocation();
std::string GetName();
void SetLEDs(std::vector<RGBColor> colors);
@ -76,6 +77,7 @@ private:
char led_string[1024];
std::string port_name;
std::string client_name;
std::string name;
serial_port *serialport;
net_port *udpport;
i2c_smbus_interface *i2cport;

View file

@ -121,11 +121,10 @@ void DetectLEDStripControllers()
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);
RGBController_LEDStrip* rgb_controller = new RGBController_LEDStrip(controller);
rgb_controller->name = dev.name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}

View file

@ -24,18 +24,18 @@
RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "LED Strip";
type = DEVICE_TYPE_LEDSTRIP;
description = "Serial LED Strip Device";
location = controller->GetLocation();
name = controller->GetName();
type = DEVICE_TYPE_LEDSTRIP;
description = "Serial LED Strip 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;
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();