From 82a486bfb6ee157110ac723b9c5a36946169d0ff Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Fri, 12 Jun 2026 23:14:50 -0500 Subject: [PATCH] Update SMBus tools page to add more SMBus operation commands --- .../OpenRGBSystemInfoPage.cpp | 56 ++++- .../OpenRGBSystemInfoPage.h | 2 +- .../OpenRGBSystemInfoPage.ui | 204 ++++++++++-------- 3 files changed, 165 insertions(+), 97 deletions(-) diff --git a/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.cpp b/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.cpp index 682c6dc8e..22931e7be 100644 --- a/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.cpp +++ b/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.cpp @@ -48,6 +48,14 @@ OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector& 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; + } } } diff --git a/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.h b/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.h index 538ba898e..a32f7a3f3 100644 --- a/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.h +++ b/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.h @@ -34,7 +34,7 @@ private slots: void on_DumpButton_clicked(); - void on_ReadButton_clicked(); + void on_CommandButton_clicked(); private: Ui::OpenRGBSystemInfoPage *ui; diff --git a/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.ui b/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.ui index e8beedf7c..4fc6ea11a 100644 --- a/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.ui +++ b/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.ui @@ -6,7 +6,7 @@ 0 0 - 500 + 520 320 @@ -14,13 +14,6 @@ System Info Page - - - - SMBus Adapters: - - - @@ -28,16 +21,13 @@ - - + + - Read Device + SMBus Adapters: - - - @@ -45,6 +35,107 @@ + + + + Detection Mode: + + + + + + + + + + + + + + Size: + + + + + + + 0x + + + 255 + + + 16 + + + + + + + 0x + + + 255 + + + 16 + + + + + + + + + + Addr: + + + + + + + + + + Reg: + + + + + + + Mode: + + + + + + + Write Data: + + + + + + + + + + + + + + SMBus Detector: + + + + + + + + + @@ -61,26 +152,6 @@ - - - - SMBus Detector: - - - - - - - - - - Detection Mode: - - - - - - @@ -95,66 +166,19 @@ - - + + - SMBus Reader: + SMBus Commands: - - - - - - Addr: - - - - - - - 0x - - - 255 - - - 16 - - - - - - - Reg: - - - - - - - 0x - - - 255 - - - 16 - - - - - - - Size: - - - - - - - + + + + Perform Command + +