System information page with i2c detect
This commit is contained in:
parent
7dddb9d111
commit
b06f384350
8 changed files with 245 additions and 87 deletions
|
|
@ -319,84 +319,6 @@ void DetectI2CBusses()
|
|||
|
||||
#endif /* WIN32 */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectI2C *
|
||||
* *
|
||||
* Prints a list of all detected I2C addresses on the given bus *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface to scan *
|
||||
* mode - one of AUTO, QUICK, READ, FUNC - method of access *
|
||||
* *
|
||||
* Code adapted from i2cdetect.c from i2c-tools Linux package *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#define MODE_AUTO 0
|
||||
#define MODE_QUICK 1
|
||||
#define MODE_READ 2
|
||||
#define MODE_FUNC 3
|
||||
|
||||
std::string DetectI2C(i2c_smbus_interface * bus, int mode)
|
||||
{
|
||||
int i, j;
|
||||
int res;
|
||||
int slave_addr;
|
||||
char line[128];
|
||||
std::string text;
|
||||
|
||||
sprintf(line, " 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
text.append(line);
|
||||
|
||||
for (i = 0; i < 128; i += 16)
|
||||
{
|
||||
sprintf(line, "%02x: ", i);
|
||||
text.append(line);
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
/* Set slave address */
|
||||
slave_addr = i + j;
|
||||
|
||||
/* Probe this address */
|
||||
switch (mode)
|
||||
{
|
||||
case MODE_QUICK:
|
||||
res = bus->i2c_smbus_write_quick(slave_addr, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
case MODE_READ:
|
||||
res = bus->i2c_smbus_read_byte(slave_addr);
|
||||
break;
|
||||
default:
|
||||
if ((i + j >= 0x30 && i + j <= 0x37)
|
||||
|| (i + j >= 0x50 && i + j <= 0x5F))
|
||||
res = bus->i2c_smbus_read_byte(slave_addr);
|
||||
else
|
||||
res = bus->i2c_smbus_write_quick(slave_addr, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
sprintf(line, "-- ");
|
||||
text.append(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(line, "%02x ", i + j);
|
||||
text.append(line);
|
||||
}
|
||||
}
|
||||
sprintf(line, "\r\n");
|
||||
text.append(line);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
} /* DetectI2C() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DumpAuraRegisters *
|
||||
|
|
|
|||
24
OpenRGB.pro
24
OpenRGB.pro
|
|
@ -7,6 +7,7 @@ TEMPLATE = app
|
|||
|
||||
INCLUDEPATH += \
|
||||
i2c_smbus/ \
|
||||
i2c_tools/ \
|
||||
net_port/ \
|
||||
serial_port/ \
|
||||
Controllers/AuraController/ \
|
||||
|
|
@ -22,13 +23,15 @@ INCLUDEPATH += \
|
|||
SOURCES += \
|
||||
main.cpp \
|
||||
OpenAuraSDK.cpp \
|
||||
qt/OpenRGBDeviceInfoPage.cpp \
|
||||
qt/OpenRGBDevicePage.cpp \
|
||||
qt/OpenRGBDeviceInfoPage.cpp \
|
||||
qt/OpenRGBDevicePage.cpp \
|
||||
qt/OpenRGBDialog.cpp \
|
||||
i2c_smbus/i2c_smbus.cpp \
|
||||
i2c_tools/i2c_tools.cpp \
|
||||
net_port/net_port.cpp \
|
||||
qt/OpenRGBDialog2.cpp \
|
||||
qt/hsv.cpp \
|
||||
qt/OpenRGBDialog2.cpp \
|
||||
qt/OpenRGBSystemInfoPage.cpp \
|
||||
qt/hsv.cpp \
|
||||
serial_port/serial_port.cpp \
|
||||
Controllers/AuraController/AuraController.cpp \
|
||||
Controllers/AuraController/AuraControllerDetect.cpp \
|
||||
|
|
@ -53,13 +56,15 @@ SOURCES += \
|
|||
RGBController/RGBController_RGBFusion.cpp
|
||||
|
||||
HEADERS += \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
qt/OpenRGBDialog.h \
|
||||
i2c_smbus/i2c_smbus.h \
|
||||
i2c_tools/i2c_tools.h \
|
||||
net_port/net_port.h \
|
||||
qt/OpenRGBDialog2.h \
|
||||
qt/OpenRGBDialog2.h \
|
||||
qt/OpenRGBSystemInfoPage.h \
|
||||
serial_port/serial_port.h \
|
||||
Controllers/AuraController/AuraController.h \
|
||||
Controllers/CorsairController/CorsairController.h \
|
||||
|
|
@ -82,7 +87,8 @@ FORMS += \
|
|||
qt/OpenRGBDeviceInfoPage.ui \
|
||||
qt/OpenRGBDevicePage.ui \
|
||||
qt/OpenRGBDialog.ui \
|
||||
qt/OpenRGBDialog2.ui
|
||||
qt/OpenRGBDialog2.ui \
|
||||
qt/OpenRGBSystemInfoPage.ui
|
||||
|
||||
#-----------------------------------------------
|
||||
# Windows specific project configuration
|
||||
|
|
|
|||
72
i2c_tools/i2c_tools.cpp
Normal file
72
i2c_tools/i2c_tools.cpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#include "i2c_tools.h"
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* i2c_detect *
|
||||
* *
|
||||
* Prints a list of all detected I2C addresses on the given bus *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface to scan *
|
||||
* mode - one of AUTO, QUICK, READ, FUNC - method of access *
|
||||
* *
|
||||
* Code adapted from i2cdetect.c from i2c-tools Linux package *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
std::string i2c_detect(i2c_smbus_interface * bus, int mode)
|
||||
{
|
||||
int i, j;
|
||||
int res;
|
||||
int slave_addr;
|
||||
char line[128];
|
||||
std::string text;
|
||||
|
||||
sprintf(line, " 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
text.append(line);
|
||||
|
||||
for (i = 0; i < 128; i += 16)
|
||||
{
|
||||
sprintf(line, "%02x: ", i);
|
||||
text.append(line);
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
/* Set slave address */
|
||||
slave_addr = i + j;
|
||||
|
||||
/* Probe this address */
|
||||
switch (mode)
|
||||
{
|
||||
case MODE_QUICK:
|
||||
res = bus->i2c_smbus_write_quick(slave_addr, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
case MODE_READ:
|
||||
res = bus->i2c_smbus_read_byte(slave_addr);
|
||||
break;
|
||||
default:
|
||||
if ((i + j >= 0x30 && i + j <= 0x37)
|
||||
|| (i + j >= 0x50 && i + j <= 0x5F))
|
||||
res = bus->i2c_smbus_read_byte(slave_addr);
|
||||
else
|
||||
res = bus->i2c_smbus_write_quick(slave_addr, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
sprintf(line, "-- ");
|
||||
text.append(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(line, "%02x ", i + j);
|
||||
text.append(line);
|
||||
}
|
||||
}
|
||||
sprintf(line, "\r\n");
|
||||
text.append(line);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
} /* i2c_detect() */
|
||||
9
i2c_tools/i2c_tools.h
Normal file
9
i2c_tools/i2c_tools.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#define MODE_AUTO 0
|
||||
#define MODE_QUICK 1
|
||||
#define MODE_READ 2
|
||||
#define MODE_FUNC 3
|
||||
|
||||
std::string i2c_detect(i2c_smbus_interface * bus, int mode);
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#include "OpenRGBDialog2.h"
|
||||
#include "OpenRGBDevicePage.h"
|
||||
#include "OpenRGBDeviceInfoPage.h"
|
||||
#include "OpenRGBSystemInfoPage.h"
|
||||
#include "OpenAuraSDK.h"
|
||||
#include <QLabel>
|
||||
#include <QTabBar>
|
||||
|
|
@ -117,6 +118,25 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
|||
|
||||
InformationTabBar->setTabButton(dev_idx, QTabBar::LeftSide, NewTabLabel);
|
||||
}
|
||||
|
||||
OpenRGBSystemInfoPage *SysInfoPage = new OpenRGBSystemInfoPage(bus);
|
||||
ui->InformationTabBar->addTab(SysInfoPage, "");
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| 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 SystemLabelString = "<html><table><tr><td width='30'><img src='";
|
||||
SystemLabelString += ":/keyboard.svg";
|
||||
SystemLabelString += "' height='15' width='15'></td><td>System</td></tr></table></html>";
|
||||
|
||||
QLabel *SystemTabLabel = new QLabel();
|
||||
SystemTabLabel->setText(SystemLabelString);
|
||||
SystemTabLabel->setIndent(20);
|
||||
SystemTabLabel->setGeometry(0, 0, 200, 20);
|
||||
|
||||
InformationTabBar->setTabButton(control.size(), QTabBar::LeftSide, SystemTabLabel);
|
||||
}
|
||||
|
||||
OpenRGBDialog2::~OpenRGBDialog2()
|
||||
|
|
|
|||
36
qt/OpenRGBSystemInfoPage.cpp
Normal file
36
qt/OpenRGBSystemInfoPage.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "OpenRGBSystemInfoPage.h"
|
||||
#include "i2c_tools.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector<i2c_smbus_interface *>& bus, QWidget *parent) :
|
||||
QFrame(parent),
|
||||
busses(bus),
|
||||
ui(new Ui::OpenRGBSystemInfoPageUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in the combo boxes with device information |
|
||||
\*-----------------------------------------------------*/
|
||||
ui->SMBusAdaptersBox->clear();
|
||||
|
||||
for (int i = 0; i < busses.size(); i++)
|
||||
{
|
||||
ui->SMBusAdaptersBox->addItem(busses[i]->device_name);
|
||||
}
|
||||
|
||||
ui->SMBusAdaptersBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
OpenRGBSystemInfoPage::~OpenRGBSystemInfoPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Ui::OpenRGBSystemInfoPage::on_DetectButton_clicked()
|
||||
{
|
||||
i2c_smbus_interface* bus = busses[ui->SMBusAdaptersBox->currentIndex()];
|
||||
|
||||
ui->SMBusDataText->setPlainText(i2c_detect(bus, MODE_QUICK).c_str());
|
||||
}
|
||||
28
qt/OpenRGBSystemInfoPage.h
Normal file
28
qt/OpenRGBSystemInfoPage.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef OPENRGBSYSTEMINFOPAGE_H
|
||||
#define OPENRGBSYSTEMINFOPAGE_H
|
||||
|
||||
#include <QFrame>
|
||||
#include "ui_OpenRGBSystemInfoPage.h"
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
namespace Ui {
|
||||
class OpenRGBSystemInfoPage;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBSystemInfoPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBSystemInfoPage(std::vector<i2c_smbus_interface *>& bus, QWidget *parent = nullptr);
|
||||
~OpenRGBSystemInfoPage();
|
||||
|
||||
private slots:
|
||||
void on_DetectButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBSystemInfoPageUi *ui;
|
||||
std::vector<i2c_smbus_interface *>& busses;
|
||||
};
|
||||
|
||||
#endif // OPENRGBSYSTEMINFOPAGE_H
|
||||
65
qt/OpenRGBSystemInfoPage.ui
Normal file
65
qt/OpenRGBSystemInfoPage.ui
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBSystemInfoPageUi</class>
|
||||
<widget class="QFrame" name="OpenRGBSystemInfoPageUi">
|
||||
<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="SMBusAdaptersLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>100</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SMBus Adapters:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="SMBusAdaptersBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>10</y>
|
||||
<width>200</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPlainTextEdit" name="SMBusDataText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>60</y>
|
||||
<width>400</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="DetectButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>10</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detect Devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue