Start work on Information page and add information fields to RGBController API

This commit is contained in:
Adam Honse 2019-12-20 00:54:37 -06:00
parent 0d38154134
commit 7dddb9d111
25 changed files with 363 additions and 44 deletions

View file

@ -82,11 +82,21 @@ AuraController::~AuraController()
}
char * AuraController::GetDeviceName()
std::string AuraController::GetDeviceName()
{
return(device_name);
}
std::string AuraController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned char AuraController::GetChannel(unsigned int led)
{
return(config_table[channel_cfg + led]);
@ -245,4 +255,4 @@ void AuraController::AuraRegisterWriteBlock(aura_register reg, unsigned char * d
//Write Aura block data
bus->i2c_smbus_write_block_data(dev, 0x03, sz, data);
}
}

View file

@ -7,6 +7,7 @@
| Adam Honse (CalcProgrammer1) 8/19/2018 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
@ -93,7 +94,8 @@ public:
AuraController(i2c_smbus_interface* bus, aura_dev_id dev);
~AuraController();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned char GetChannel(unsigned int led);
const char* GetChannelName(unsigned int led);
unsigned int GetLEDCount();
@ -120,4 +122,4 @@ private:
i2c_smbus_interface * bus;
aura_dev_id dev;
};
};

View file

@ -24,11 +24,21 @@ CorsairController::~CorsairController()
}
char * CorsairController::GetDeviceName()
std::string CorsairController::GetDeviceName()
{
return(device_name);
}
std::string CorsairController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned int CorsairController::GetLEDCount()
{
return(led_count);
@ -55,4 +65,4 @@ void CorsairController::SetLEDColor(unsigned int led, unsigned char red, unsigne
void CorsairController::SetMode(unsigned char mode)
{
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
}
}

View file

@ -7,6 +7,7 @@
| Adam Honse (CalcProgrammer1) 3/8/2019 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
@ -38,7 +39,8 @@ public:
CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev);
~CorsairController();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
void SetMode(unsigned char mode);
@ -50,4 +52,4 @@ private:
unsigned int led_count;
i2c_smbus_interface * bus;
corsair_dev_id dev;
};
};

View file

@ -42,11 +42,21 @@ CorsairProController::~CorsairProController()
}
char* CorsairProController::GetDeviceName()
std::string CorsairProController::GetDeviceName()
{
return(device_name);
}
std::string CorsairProController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned int CorsairProController::GetLEDCount()
{
return(led_count);
@ -134,4 +144,4 @@ bool CorsairProController::WaitReady()
}
return false;
}
}

View file

@ -7,6 +7,7 @@
| Adam Honse (CalcProgrammer1) 6/30/2019 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
@ -65,7 +66,8 @@ public:
CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev);
~CorsairProController();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
void SetEffect(unsigned char mode);
void SetCustom();
@ -85,4 +87,4 @@ private:
i2c_smbus_interface* bus;
corsair_dev_id dev;
};
};

View file

@ -24,11 +24,21 @@ HyperXController::~HyperXController()
}
char* HyperXController::GetDeviceName()
std::string HyperXController::GetDeviceName()
{
return(device_name);
}
std::string HyperXController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned int HyperXController::GetLEDCount()
{
return(led_count);
@ -99,4 +109,4 @@ void HyperXController::SetMode(unsigned char mode)
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
}

View file

@ -7,6 +7,7 @@
| Adam Honse (CalcProgrammer1) 6/29/2019 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
@ -61,7 +62,8 @@ public:
HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev);
~HyperXController();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
void SetMode(unsigned char mode);
@ -73,4 +75,4 @@ private:
unsigned int led_count;
i2c_smbus_interface* bus;
hyperx_dev_id dev;
};
};

View file

@ -29,11 +29,21 @@ RGBFusionController::~RGBFusionController()
}
char* RGBFusionController::GetDeviceName()
std::string RGBFusionController::GetDeviceName()
{
return(device_name);
}
std::string RGBFusionController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned int RGBFusionController::GetLEDCount()
{
return(led_count);
@ -158,4 +168,4 @@ void RGBFusionController::set_mode_ch_1(unsigned char mode)
void RGBFusionController::switch_bank(unsigned char bank)
{
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_SWITCH_REG, bank);
}
}

View file

@ -7,6 +7,7 @@
| Adam Honse (CalcProgrammer1) 12/10/2019 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
@ -42,7 +43,8 @@ public:
RGBFusionController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
~RGBFusionController();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned char GetMode();
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
@ -66,4 +68,4 @@ private:
i2c_smbus_interface* bus;
rgb_fusion_dev_id dev;
};
};

View file

@ -22,6 +22,7 @@ INCLUDEPATH += \
SOURCES += \
main.cpp \
OpenAuraSDK.cpp \
qt/OpenRGBDeviceInfoPage.cpp \
qt/OpenRGBDevicePage.cpp \
qt/OpenRGBDialog.cpp \
i2c_smbus/i2c_smbus.cpp \
@ -52,6 +53,8 @@ SOURCES += \
RGBController/RGBController_RGBFusion.cpp
HEADERS += \
Controllers/RGBFusionController/RGBFusionController.h \
qt/OpenRGBDeviceInfoPage.h \
qt/OpenRGBDevicePage.h \
qt/OpenRGBDialog.h \
i2c_smbus/i2c_smbus.h \
@ -76,6 +79,7 @@ RESOURCES += \
qt/resources.qrc
FORMS += \
qt/OpenRGBDeviceInfoPage.ui \
qt/OpenRGBDevicePage.ui \
qt/OpenRGBDialog.ui \
qt/OpenRGBDialog2.ui

View file

@ -65,12 +65,16 @@ typedef struct
class RGBController
{
public:
std::string name; /* controller name */
std::vector<led> leds; /* LEDs */
std::vector<zone> zones; /* Zones */
std::vector<mode> modes; /* Modes */
std::vector<RGBColor> colors; /* Color buffer */
device_type type; /* device type */
std::string name; /* controller name */
std::string description; /* controller description */
std::string version; /* controller version */
std::string serial; /* controller serial number */
std::string location; /* controller location */
std::vector<led> leds; /* LEDs */
std::vector<zone> zones; /* Zones */
std::vector<mode> modes; /* Modes */
std::vector<RGBColor> colors; /* Color buffer */
device_type type; /* device type */
virtual int GetMode() = 0;
virtual void SetMode(int mode) = 0;

View file

@ -118,15 +118,17 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
aura = aura_ptr;
name = aura->GetDeviceName();
description = aura->GetDeviceName();
location = aura->GetDeviceLocation();
if((name.rfind("DIMM_LED", 0) == 0) || (name.rfind("AUDA", 0) == 0) )
{
type = DEVICE_TYPE_DRAM;
name = "ASUS Aura DRAM";
}
else
{
type = DEVICE_TYPE_MOTHERBOARD;
name = "ASUS Aura Motherboard";
}
mode aura_modes[AURA_NUMBER_MODES + 1];

View file

@ -67,6 +67,7 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
corsair = corsair_ptr;
name = corsair->GetDeviceName();
location = corsair->GetDeviceLocation();
type = DEVICE_TYPE_DRAM;

View file

@ -26,4 +26,4 @@ public:
private:
CorsairController* corsair;
};
};

View file

@ -103,6 +103,7 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
corsair = corsair_ptr;
name = corsair->GetDeviceName();
location = corsair->GetDeviceLocation();
type = DEVICE_TYPE_DRAM;

View file

@ -67,6 +67,7 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
hyperx = hyperx_ptr;
name = hyperx->GetDeviceName();
location = hyperx->GetDeviceLocation();
type = DEVICE_TYPE_DRAM;

View file

@ -74,6 +74,8 @@ RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion
rgb_fusion = rgb_fusion_ptr;
name = rgb_fusion->GetDeviceName();
description = "RGB Fusion 1.0";
location = rgb_fusion->GetDeviceLocation();
type = DEVICE_TYPE_MOTHERBOARD;

View file

@ -22,9 +22,11 @@ RGBController_RazerChromaSDK::RGBController_RazerChromaSDK(unsigned int device_t
for (int i = 0; i < RAZER_NUM_DEVICES; i++)
{
if (device_list[i]->type == device_type)
if (device_list[i]->razer_type == device_type)
{
name = device_list[i]->name;
type = device_list[i]->type;
location = "Razer Chroma SDK";
for (int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
{
@ -115,7 +117,7 @@ void RGBController_RazerChromaSDK::SetLED(int led, RGBColor color)
void RGBController_RazerChromaSDK::UpdateLEDs()
{
switch (device->type)
switch (device->razer_type)
{
case RAZER_GENERIC_MOUSE:
{
@ -186,4 +188,4 @@ void RGBController_RazerChromaSDK::UpdateLEDs()
}
break;
}
}
}

View file

@ -59,6 +59,7 @@ typedef struct
typedef struct
{
std::string name;
unsigned int razer_type;
unsigned int type;
const razer_zone* zones[RAZER_MAX_ZONES];
} razer_device;
@ -136,6 +137,7 @@ static const razer_device mouse_device =
{
"Razer Generic Mouse",
RAZER_GENERIC_MOUSE,
DEVICE_TYPE_MOUSE,
{
&mouse_left_zone,
&mouse_right_zone,
@ -164,6 +166,7 @@ static const razer_device mousepad_device =
{
"Razer Generic Mousepad",
RAZER_GENERIC_MOUSEPAD,
DEVICE_TYPE_MOUSE,
{
&mousepad_zone,
NULL,
@ -204,6 +207,7 @@ static const razer_device chromahdk_device =
{
"Razer Chroma HDK",
RAZER_CHROMA_HDK,
DEVICE_TYPE_LEDSTRIP,
{
&chromahdk_zone,
&chromahdk_zone,
@ -242,4 +246,4 @@ private:
static CREATEMOUSEPADEFFECT CreateMousepadEffect;
static CREATEHEADSETEFFECT CreateHeadsetEffect;
static CREATECHROMALINKEFFECT CreateChromaLinkEffect;
};
};

View file

@ -0,0 +1,49 @@
#include "OpenRGBDeviceInfoPage.h"
using namespace Ui;
OpenRGBDeviceInfoPage::OpenRGBDeviceInfoPage(RGBController *dev, QWidget *parent) :
QFrame(parent),
ui(new Ui::OpenRGBDeviceInfoPageUi)
{
ui->setupUi(this);
switch(dev->type)
{
case DEVICE_TYPE_MOTHERBOARD:
ui->TypeValue->setText("Motherboard");
break;
case DEVICE_TYPE_DRAM:
ui->TypeValue->setText("DRAM");
break;
case DEVICE_TYPE_GPU:
ui->TypeValue->setText("GPU");
break;
case DEVICE_TYPE_COOLER:
ui->TypeValue->setText("Cooler");
break;
case DEVICE_TYPE_LEDSTRIP:
ui->TypeValue->setText("LED Strip");
break;
case DEVICE_TYPE_KEYBOARD:
ui->TypeValue->setText("Keyboard");
break;
case DEVICE_TYPE_MOUSE:
ui->TypeValue->setText("Mouse");
break;
case DEVICE_TYPE_HEADSET:
ui->TypeValue->setText("Headset");
break;
default:
ui->TypeValue->setText("Unknown");
}
ui->DescriptionValue->setText(QString::fromStdString(dev->description));
ui->VersionValue->setText(QString::fromStdString(dev->version));
ui->LocationValue->setText(QString::fromStdString(dev->location));
}
OpenRGBDeviceInfoPage::~OpenRGBDeviceInfoPage()
{
delete ui;
}

View file

@ -0,0 +1,24 @@
#ifndef OPENRGBDEVICEINFOPAGE_H
#define OPENRGBDEVICEINFOPAGE_H
#include <QFrame>
#include "RGBController.h"
#include "ui_OpenRGBDeviceInfoPage.h"
namespace Ui {
class OpenRGBDeviceInfoPage;
}
class Ui::OpenRGBDeviceInfoPage : public QFrame
{
Q_OBJECT
public:
explicit OpenRGBDeviceInfoPage(RGBController *dev, QWidget *parent = nullptr);
~OpenRGBDeviceInfoPage();
private:
Ui::OpenRGBDeviceInfoPageUi *ui;
};
#endif // OPENRGBDEVICEINFOPAGE_H

123
qt/OpenRGBDeviceInfoPage.ui Normal file
View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBDeviceInfoPageUi</class>
<widget class="QFrame" name="OpenRGBDeviceInfoPageUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<widget class="QLabel" name="TypeLabel">
<property name="geometry">
<rect>
<x>100</x>
<y>80</y>
<width>60</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>Type:</string>
</property>
</widget>
<widget class="QLabel" name="TypeValue">
<property name="geometry">
<rect>
<x>180</x>
<y>80</y>
<width>240</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>Type Value</string>
</property>
</widget>
<widget class="QLabel" name="DescriptionValue">
<property name="geometry">
<rect>
<x>180</x>
<y>100</y>
<width>240</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>Description Value</string>
</property>
</widget>
<widget class="QLabel" name="DescriptionLabel">
<property name="geometry">
<rect>
<x>100</x>
<y>100</y>
<width>60</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>Description:</string>
</property>
</widget>
<widget class="QLabel" name="VersionValue">
<property name="geometry">
<rect>
<x>180</x>
<y>120</y>
<width>240</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>Version Value</string>
</property>
</widget>
<widget class="QLabel" name="VersionLabel">
<property name="geometry">
<rect>
<x>100</x>
<y>120</y>
<width>60</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>Version:</string>
</property>
</widget>
<widget class="QLabel" name="LocationLabel">
<property name="geometry">
<rect>
<x>100</x>
<y>140</y>
<width>60</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>Location:</string>
</property>
</widget>
<widget class="QLabel" name="LocationValue">
<property name="geometry">
<rect>
<x>180</x>
<y>140</y>
<width>240</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>Location Value</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -1,5 +1,6 @@
#include "OpenRGBDialog2.h"
#include "OpenRGBDevicePage.h"
#include "OpenRGBDeviceInfoPage.h"
#include "OpenAuraSDK.h"
#include <QLabel>
#include <QTabBar>
@ -65,6 +66,57 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
DevicesTabBar->setTabButton(dev_idx, QTabBar::LeftSide, NewTabLabel);
}
/*-----------------------------------------------------*\
| Set up list of information |
\*-----------------------------------------------------*/
QTabBar *InformationTabBar = ui->InformationTabBar->tabBar();
for(int dev_idx = 0; dev_idx < control.size(); dev_idx++)
{
OpenRGBDeviceInfoPage *NewPage = new OpenRGBDeviceInfoPage(control[dev_idx]);
ui->InformationTabBar->addTab(NewPage, "");
/*-----------------------------------------------------*\
| Use Qt's HTML capabilities to display both icon and |
| text in the tab label. Choose icon based on device |
| type and append device name string. |
\*-----------------------------------------------------*/
QString NewLabelString = "<html><table><tr><td width='30'><img src='";
switch(control[dev_idx]->type)
{
case DEVICE_TYPE_MOTHERBOARD:
NewLabelString += ":/motherboard.svg";
break;
case DEVICE_TYPE_DRAM:
NewLabelString += ":/ram.svg";
break;
case DEVICE_TYPE_GPU:
NewLabelString += ":/graphics-card.svg";
break;
case DEVICE_TYPE_COOLER:
NewLabelString += ":/fan.svg";
break;
case DEVICE_TYPE_LEDSTRIP:
//break;
case DEVICE_TYPE_KEYBOARD:
//break;
case DEVICE_TYPE_MOUSE:
//break;
case DEVICE_TYPE_HEADSET:
//break;
case DEVICE_TYPE_UNKNOWN:
NewLabelString += ":/keyboard.svg";
break;
}
NewLabelString += "' height='15' width='15'></td><td>" + QString::fromStdString(control[dev_idx]->name) + "</td></tr></table></html>";
QLabel *NewTabLabel = new QLabel();
NewTabLabel->setText(NewLabelString);
NewTabLabel->setIndent(20);
NewTabLabel->setGeometry(0, 0, 200, 20);
InformationTabBar->setTabButton(dev_idx, QTabBar::LeftSide, NewTabLabel);
}
}
OpenRGBDialog2::~OpenRGBDialog2()

View file

@ -101,18 +101,8 @@
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>-1</number>
</property>
<widget class="QWidget" name="TabSystemInfo">
<attribute name="title">
<string>System</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</widget>
</widget>