Update SMBus tools page to add more SMBus operation commands

This commit is contained in:
Adam Honse
2026-06-12 23:14:50 -05:00
parent ad06e733f8
commit 82a486bfb6
3 changed files with 165 additions and 97 deletions

View File

@@ -48,6 +48,14 @@ OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector<i2c_smbus_interface *>&
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);
}
@@ -131,7 +139,7 @@ void OpenRGBSystemInfoPage::on_DumpButton_clicked()
}
}
void OpenRGBSystemInfoPage::on_ReadButton_clicked()
void OpenRGBSystemInfoPage::on_CommandButton_clicked()
{
int current_index = ui->SMBusAdaptersBox->currentIndex();
@@ -142,11 +150,47 @@ void OpenRGBSystemInfoPage::on_ReadButton_clicked()
if((int)(busses.size()) > current_index)
{
i2c_smbus_interface* bus = busses[current_index];
unsigned char address = ui->ReadAddressBox->value();
unsigned char regaddr = ui->ReadRegisterBox->value();
unsigned char size = ui->ReadSizeBox->value();
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, 16);
unsigned short read_data = 0xFFFF;
ui->SMBusDataText->setPlainText(i2c_read(bus, address, regaddr, size).c_str());
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;
}
}
}

View File

@@ -34,7 +34,7 @@ private slots:
void on_DumpButton_clicked();
void on_ReadButton_clicked();
void on_CommandButton_clicked();
private:
Ui::OpenRGBSystemInfoPage *ui;

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<width>520</width>
<height>320</height>
</rect>
</property>
@@ -14,13 +14,6 @@
<string notr="true">System Info Page</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="SMBusAdaptersLabel">
<property name="text">
<string>SMBus Adapters:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="DumpAddressLabel">
<property name="text">
@@ -28,16 +21,13 @@
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="ReadButton">
<item row="0" column="0">
<widget class="QLabel" name="SMBusAdaptersLabel">
<property name="text">
<string>Read Device</string>
<string>SMBus Adapters:</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<widget class="QPlainTextEdit" name="SMBusDataText"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="SMBusDumpLabel">
<property name="text">
@@ -45,6 +35,107 @@
</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">
@@ -61,26 +152,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="SMBusDetectorLabel">
<property name="text">
<string>SMBus Detector:</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="SMBusAdaptersBox"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="SMBusDetectModeLabel">
<property name="text">
<string>Detection Mode:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="SMBusDetectionModeBox"/>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="DetectButton">
<property name="text">
@@ -95,66 +166,19 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="SMBusReaderLabel">
<item row="4" column="0">
<widget class="QLabel" name="SMBusCommandLabel">
<property name="text">
<string>SMBus Reader:</string>
<string>SMBus Commands:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="ReadAddressLabel">
<property name="text">
<string>Addr:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="ReadAddressBox">
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ReadRegisterLabel">
<property name="text">
<string>Reg:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="ReadRegisterBox">
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ReadSizeLabel">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="ReadSizeBox"/>
</item>
</layout>
<item row="4" column="3">
<widget class="QPushButton" name="CommandButton">
<property name="text">
<string>Perform Command</string>
</property>
</widget>
</item>
</layout>
</widget>