RGBController API Overhaul

* Reorganize and clean up RGBController API functions
    * Add functions to get protected RGBController member values
    * Make NetworkClient, ProfileManager, and ResourceManager friend classes so they can access protected members
    * Protected previously-public RGBController members
        * Information strings (name, vendor, description, version, serial location)
        * Device type
        * Active mode
        * Flags
        * LEDs vector
        * LED alternate names vector
        * Modes vector
        * Colors vector
        * Zones vector
    * Add CONTROLLER_FLAG_HIDDEN to allow plugins to hide controllers from control GUI
    * Add update reason codes to RGBController update callback and signal updates on more RGBController events
    * Add loop zone types and segmented zone type
    * Add matrix map field to segments
    * Rework matrix_map_type from using pointers to vector to prevent memory leaks
    * Rework KeyboardLayoutManager to return new matrix_map_type
    * Add access mutex to RGBController API
    * Add per-zone modes ot RGBController API
    * Add JSON description functions to RGBController API
This commit is contained in:
Adam Honse
2025-09-23 20:38:37 -05:00
parent 6deaf2f4fd
commit fdaf2eee6c
657 changed files with 9060 additions and 8801 deletions

View File

@@ -203,90 +203,90 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
if(devices[device_idx].type == ZONE_TYPE_MATRIX)
{
unsigned int led_idx = 0;
matrix_map_type * new_map = new matrix_map_type;
matrix_map_type new_map;
new_map->width = devices[device_idx].matrix_width;
new_map->height = devices[device_idx].matrix_height;
new_map->map = new unsigned int[devices[device_idx].matrix_width * devices[device_idx].matrix_height];
new_map.width = devices[device_idx].matrix_width;
new_map.height = devices[device_idx].matrix_height;
new_map.map.resize(devices[device_idx].matrix_width * devices[device_idx].matrix_height);
switch(devices[device_idx].matrix_order)
{
case E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT:
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < new_map.height; y++)
{
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < new_map.width; x++)
{
new_map->map[(y * new_map->width) + x] = led_idx;
new_map.map[(y * new_map.width) + x] = led_idx;
led_idx++;
}
}
break;
case E131_MATRIX_ORDER_HORIZONTAL_TOP_RIGHT:
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < new_map.height; y++)
{
for(int x = new_map->width - 1; x >= 0; x--)
for(int x = new_map.width - 1; x >= 0; x--)
{
new_map->map[(y * new_map->width) + x] = led_idx;
new_map.map[(y * new_map.width) + x] = led_idx;
led_idx++;
}
}
break;
case E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_LEFT:
for(int y = new_map->height; y >= 0; y--)
for(int y = new_map.height; y >= 0; y--)
{
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < new_map.width; x++)
{
new_map->map[(y * new_map->width) + x] = led_idx;
new_map.map[(y * new_map.width) + x] = led_idx;
led_idx++;
}
}
break;
case E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_RIGHT:
for(int y = new_map->height; y >= 0; y--)
for(int y = new_map.height; y >= 0; y--)
{
for(int x = new_map->width - 1; x >= 0; x--)
for(int x = new_map.width - 1; x >= 0; x--)
{
new_map->map[(y * new_map->width) + x] = led_idx;
new_map.map[(y * new_map.width) + x] = led_idx;
led_idx++;
}
}
break;
case E131_MATRIX_ORDER_VERTICAL_TOP_LEFT:
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < new_map.width; x++)
{
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < new_map.height; y++)
{
new_map->map[(y * new_map->width) + x] = led_idx;
new_map.map[(y * new_map.width) + x] = led_idx;
led_idx++;
}
}
break;
case E131_MATRIX_ORDER_VERTICAL_TOP_RIGHT:
for(int x = new_map->width - 1; x >= 0; x--)
for(int x = new_map.width - 1; x >= 0; x--)
{
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < new_map.height; y++)
{
new_map->map[(y * new_map->width) + x] = led_idx;
new_map.map[(y * new_map.width) + x] = led_idx;
led_idx++;
}
}
break;
case E131_MATRIX_ORDER_VERTICAL_BOTTOM_LEFT:
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < new_map.width; x++)
{
for(int y = new_map->height - 1; y >= 0; y--)
for(int y = new_map.height - 1; y >= 0; y--)
{
new_map->map[(y * new_map->width) + x] = led_idx;
new_map.map[(y * new_map.width) + x] = led_idx;
led_idx++;
}
}
break;
case E131_MATRIX_ORDER_VERTICAL_BOTTOM_RIGHT:
for(int x = new_map->width - 1; x >= 0; x--)
for(int x = new_map.width - 1; x >= 0; x--)
{
for(int y = new_map->height - 1; y >= 0; y--)
for(int y = new_map.height - 1; y >= 0; y--)
{
new_map->map[(y * new_map->width) + x] = led_idx;
new_map.map[(y * new_map.width) + x] = led_idx;
led_idx++;
}
}
@@ -316,22 +316,6 @@ RGBController_E131::~RGBController_E131()
keepalive_thread->join();
delete keepalive_thread;
}
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
if(zones[zone_index].matrix_map->map != NULL)
{
delete zones[zone_index].matrix_map->map;
}
delete zones[zone_index].matrix_map;
}
}
}
void RGBController_E131::SetupZones()
@@ -347,8 +331,6 @@ void RGBController_E131::SetupZones()
led_zone.leds_min = devices[zone_idx].num_leds;
led_zone.leds_max = devices[zone_idx].num_leds;
led_zone.leds_count = devices[zone_idx].num_leds;
led_zone.matrix_map = NULL;
zones.push_back(led_zone);
}
@@ -371,13 +353,6 @@ void RGBController_E131::SetupZones()
SetupColors();
}
void RGBController_E131::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_E131::DeviceUpdateLEDs()
{
int color_idx = 0;
@@ -442,12 +417,12 @@ void RGBController_E131::DeviceUpdateLEDs()
}
}
void RGBController_E131::UpdateZoneLEDs(int /*zone*/)
void RGBController_E131::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_E131::UpdateSingleLED(int /*led*/)
void RGBController_E131::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
@@ -463,7 +438,7 @@ void RGBController_E131::KeepaliveThreadFunction()
{
if((std::chrono::steady_clock::now() - last_update_time) > ( keepalive_delay * 0.95f ) )
{
UpdateLEDs();
UpdateLEDsInternal();
}
std::this_thread::sleep_for(keepalive_delay / 2);
}

View File

@@ -66,11 +66,9 @@ public:
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();