Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| OpenRGBSystemInfoPage.cpp |
|
||||
| |
|
||||
| User interface entry for OpenRGB system information page|
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "OpenRGBSystemInfoPage.h"
|
||||
#include "ui_OpenRGBSystemInfoPage.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "i2c_tools.h"
|
||||
|
||||
static void UpdateBusListCallback(void * this_ptr)
|
||||
{
|
||||
OpenRGBSystemInfoPage * this_obj = (OpenRGBSystemInfoPage *)this_ptr;
|
||||
|
||||
QMetaObject::invokeMethod(this_obj, "UpdateBusList", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector<i2c_smbus_interface *>& bus, QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::OpenRGBSystemInfoPage),
|
||||
busses(bus)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Use a monospace font for the text box |
|
||||
\*-----------------------------------------------------*/
|
||||
QFont MonoFont("monospace");
|
||||
MonoFont.setStyleHint(QFont::Monospace);
|
||||
ui->SMBusDataText->setFont(MonoFont);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Register I2C bus list change callback |
|
||||
\*-----------------------------------------------------*/
|
||||
ResourceManager::get()->RegisterI2CBusListChangeCallback(UpdateBusListCallback, this);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Update the bus list |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateBusList();
|
||||
|
||||
ui->SMBusDetectionModeBox->addItem("Auto");
|
||||
ui->SMBusDetectionModeBox->addItem("Quick");
|
||||
ui->SMBusDetectionModeBox->addItem("Read");
|
||||
ui->SMBusDetectionModeBox->addItem("Read Data");
|
||||
|
||||
ui->CommandModeComboBox->addItem("Read Byte");
|
||||
ui->CommandModeComboBox->addItem("Read Byte Data");
|
||||
ui->CommandModeComboBox->addItem("Read Word Data");
|
||||
ui->CommandModeComboBox->addItem("Write Quick");
|
||||
ui->CommandModeComboBox->addItem("Write Byte");
|
||||
ui->CommandModeComboBox->addItem("Write Byte Data");
|
||||
ui->CommandModeComboBox->addItem("Write Word Data");
|
||||
|
||||
ui->SMBusDetectionModeBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
OpenRGBSystemInfoPage::~OpenRGBSystemInfoPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OpenRGBSystemInfoPage::changeEvent(QEvent *event)
|
||||
{
|
||||
if(event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBSystemInfoPage::UpdateBusList()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in the combo boxes with device information |
|
||||
\*-----------------------------------------------------*/
|
||||
ui->SMBusAdaptersBox->clear();
|
||||
|
||||
for (std::size_t i = 0; i < busses.size(); i++)
|
||||
{
|
||||
ui->SMBusAdaptersBox->addItem(busses[i]->device_name);
|
||||
}
|
||||
|
||||
ui->SMBusAdaptersBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void OpenRGBSystemInfoPage::on_DetectButton_clicked()
|
||||
{
|
||||
int current_index = ui->SMBusAdaptersBox->currentIndex();
|
||||
|
||||
if(current_index < 0)
|
||||
{
|
||||
current_index = 0;
|
||||
}
|
||||
|
||||
if((int)(busses.size()) > current_index)
|
||||
{
|
||||
i2c_smbus_interface* bus = busses[current_index];
|
||||
|
||||
switch(ui->SMBusDetectionModeBox->currentIndex())
|
||||
{
|
||||
case 0:
|
||||
ui->SMBusDataText->setPlainText(i2c_detect(bus, MODE_AUTO).c_str());
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ui->SMBusDataText->setPlainText(i2c_detect(bus, MODE_QUICK).c_str());
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ui->SMBusDataText->setPlainText(i2c_detect(bus, MODE_READ).c_str());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
ui->SMBusDataText->setPlainText(i2c_detect(bus, MODE_READ_DATA).c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBSystemInfoPage::on_DumpButton_clicked()
|
||||
{
|
||||
int current_index = ui->SMBusAdaptersBox->currentIndex();
|
||||
|
||||
if(current_index < 0)
|
||||
{
|
||||
current_index = 0;
|
||||
}
|
||||
|
||||
if((int)(busses.size()) > current_index)
|
||||
{
|
||||
i2c_smbus_interface* bus = busses[current_index];
|
||||
unsigned char address = ui->DumpAddressBox->value();
|
||||
|
||||
ui->SMBusDataText->setPlainText(i2c_dump(bus, address).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBSystemInfoPage::on_CommandButton_clicked()
|
||||
{
|
||||
int current_index = ui->SMBusAdaptersBox->currentIndex();
|
||||
|
||||
if(current_index < 0)
|
||||
{
|
||||
current_index = 0;
|
||||
}
|
||||
|
||||
if((int)(busses.size()) > current_index)
|
||||
{
|
||||
i2c_smbus_interface* bus = busses[current_index];
|
||||
unsigned char address = ui->CommandAddressBox->value();
|
||||
unsigned char regaddr = ui->CommandRegisterBox->value();
|
||||
unsigned char size = ui->CommandSizeBox->value();
|
||||
unsigned short write_data = ui->CommandWriteDataLineEdit->text().toInt(nullptr, 0);
|
||||
unsigned short read_data = 0xFFFF;
|
||||
|
||||
ui->SMBusDataText->clear();
|
||||
|
||||
switch(ui->CommandModeComboBox->currentIndex())
|
||||
{
|
||||
case 0:
|
||||
read_data = bus->i2c_smbus_read_byte(address);
|
||||
ui->SMBusDataText->setPlainText(QString::number(read_data, 16));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
read_data = bus->i2c_smbus_read_byte_data(address, regaddr);
|
||||
ui->SMBusDataText->setPlainText(QString::number(read_data, 16));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
read_data = bus->i2c_smbus_read_word_data(address, regaddr);
|
||||
ui->SMBusDataText->setPlainText(QString::number(read_data, 16));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
bus->i2c_smbus_write_byte(address, write_data);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
bus->i2c_smbus_write_byte_data(address, regaddr, write_data);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
bus->i2c_smbus_write_word_data(address, regaddr, write_data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| OpenRGBSystemInfoPage.h |
|
||||
| |
|
||||
| User interface entry for OpenRGB system information page|
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class OpenRGBSystemInfoPage;
|
||||
}
|
||||
|
||||
class OpenRGBSystemInfoPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBSystemInfoPage(std::vector<i2c_smbus_interface *>& bus, QWidget *parent = nullptr);
|
||||
~OpenRGBSystemInfoPage();
|
||||
|
||||
public slots:
|
||||
void UpdateBusList();
|
||||
|
||||
private slots:
|
||||
void changeEvent(QEvent *event);
|
||||
void on_DetectButton_clicked();
|
||||
|
||||
void on_DumpButton_clicked();
|
||||
|
||||
void on_CommandButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBSystemInfoPage *ui;
|
||||
std::vector<i2c_smbus_interface *>& busses;
|
||||
};
|
||||
@@ -0,0 +1,195 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBSystemInfoPage</class>
|
||||
<widget class="QFrame" name="OpenRGBSystemInfoPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>520</width>
|
||||
<height>320</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">System Info Page</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="DumpAddressLabel">
|
||||
<property name="text">
|
||||
<string>Address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="SMBusAdaptersLabel">
|
||||
<property name="text">
|
||||
<string>SMBus Adapters:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="SMBusDumpLabel">
|
||||
<property name="text">
|
||||
<string>SMBus Dumper:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="SMBusDetectModeLabel">
|
||||
<property name="text">
|
||||
<string>Detection Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="SMBusAdaptersBox"/>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="CommandSizeLabel">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSpinBox" name="CommandRegisterBox">
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="CommandAddressBox">
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QSpinBox" name="CommandSizeBox"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="CommandAddressLabel">
|
||||
<property name="text">
|
||||
<string>Addr:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="CommandModeComboBox"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="CommandRegisterLabel">
|
||||
<property name="text">
|
||||
<string>Reg:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="CommandModeLabel">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="CommandWriteDataLabel">
|
||||
<property name="text">
|
||||
<string>Write Data:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="CommandWriteDataLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="SMBusDetectorLabel">
|
||||
<property name="text">
|
||||
<string>SMBus Detector:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="4">
|
||||
<widget class="QPlainTextEdit" name="SMBusDataText"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="SMBusDetectionModeBox"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSpinBox" name="DumpAddressBox">
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="DetectButton">
|
||||
<property name="text">
|
||||
<string>Detect Devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QPushButton" name="DumpButton">
|
||||
<property name="text">
|
||||
<string>Dump Device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="SMBusCommandLabel">
|
||||
<property name="text">
|
||||
<string>SMBus Commands:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QPushButton" name="CommandButton">
|
||||
<property name="text">
|
||||
<string>Perform Command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>SMBusAdaptersBox</tabstop>
|
||||
<tabstop>SMBusDetectionModeBox</tabstop>
|
||||
<tabstop>DetectButton</tabstop>
|
||||
<tabstop>DumpAddressBox</tabstop>
|
||||
<tabstop>DumpButton</tabstop>
|
||||
<tabstop>SMBusDataText</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user