mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-02-08 06:11:16 -05:00
Automatically create matrix
This commit is contained in:
committed by
Adam Honse
parent
0bbec4dde9
commit
39055f205c
@@ -64,6 +64,11 @@ unsigned int HIDLampArrayController::GetLampCount()
|
||||
return(LampArray.LampCount);
|
||||
}
|
||||
|
||||
std::vector<LampAttributes> HIDLampArrayController::GetLamps()
|
||||
{
|
||||
return(Lamps);
|
||||
}
|
||||
|
||||
void HIDLampArrayController::GetLampArrayAttributesReport()
|
||||
{
|
||||
unsigned char usb_buf[sizeof(LampArrayAttributes) + 1];
|
||||
|
||||
@@ -116,6 +116,8 @@ public:
|
||||
std::string GetSerialString();
|
||||
|
||||
unsigned int GetLampCount();
|
||||
std::vector<LampAttributes> GetLamps();
|
||||
|
||||
void SetLampMultiUpdateReport(unsigned char LampCount, unsigned char LampUpdateFlags, unsigned short * LampIds, LampArrayColor * UpdateColors);
|
||||
|
||||
private:
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include "RGBController_HIDLampArray.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@@ -47,12 +49,36 @@ RGBController_HIDLampArray::~RGBController_HIDLampArray()
|
||||
void RGBController_HIDLampArray::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = "Test Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.name = "LampArray";
|
||||
new_zone.type = ZONE_TYPE_MATRIX;
|
||||
new_zone.leds_count = controller->GetLampCount();
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
new_zone.matrix_map = NULL;
|
||||
|
||||
std::set<unsigned int> columns;
|
||||
std::set<unsigned int> rows;
|
||||
|
||||
for(std::size_t lamp_idx = 0; lamp_idx < controller->GetLamps().size(); lamp_idx++)
|
||||
{
|
||||
rows.insert(controller->GetLamps()[lamp_idx].PositionYInMillimeters);
|
||||
columns.insert(controller->GetLamps()[lamp_idx].PositionXInMillimeters);
|
||||
}
|
||||
|
||||
new_zone.matrix_map.height = rows.size();
|
||||
new_zone.matrix_map.width = columns.size();
|
||||
new_zone.matrix_map.map.resize(rows.size() * columns.size());
|
||||
|
||||
memset(new_zone.matrix_map.map.data(), 0xFF, (new_zone.matrix_map.map.size() * sizeof(unsigned int)));
|
||||
|
||||
for(std::size_t lamp_idx = 0; lamp_idx < controller->GetLamps().size(); lamp_idx++)
|
||||
{
|
||||
//FIXME this assumes that matrix_size is big enough which is only guaranteed when no key possition is doubled
|
||||
size_t idx = std::distance(columns.begin(), columns.find(controller->GetLamps()[lamp_idx].PositionXInMillimeters));
|
||||
size_t idy = std::distance(rows.begin(), rows.find(controller->GetLamps()[lamp_idx].PositionYInMillimeters));
|
||||
|
||||
new_zone.matrix_map.map[idx + idy * new_zone.matrix_map.width] = lamp_idx;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < new_zone.leds_count; led_idx++)
|
||||
|
||||
Reference in New Issue
Block a user