mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-07 23:47:35 -04:00
Add Basic I2C to serial settings
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "LEDStripController.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@@ -47,13 +46,6 @@ void LEDStripController::Initialize(char* ledstring, led_protocol proto)
|
||||
serial = FALSE;
|
||||
}
|
||||
|
||||
//I2C includes extra entry - I2C device address
|
||||
if (protocol == LED_PROTOCOL_BASIC_I2C)
|
||||
{
|
||||
udpport_baud = strtok_s(next, ",", &next);
|
||||
i2c_addr = atoi(udpport_baud);
|
||||
}
|
||||
|
||||
//Check for either the UDP port or the serial baud rate
|
||||
if (strlen(next))
|
||||
{
|
||||
@@ -70,6 +62,8 @@ void LEDStripController::Initialize(char* ledstring, led_protocol proto)
|
||||
{
|
||||
if (protocol == LED_PROTOCOL_BASIC_I2C)
|
||||
{
|
||||
//I2C uses the baud field for address
|
||||
i2c_addr = atoi(udpport_baud);
|
||||
InitializeI2C(source);
|
||||
}
|
||||
else if (udpport_baud == NULL)
|
||||
|
||||
@@ -12,6 +12,7 @@ OpenRGBSerialSettingsEntry::OpenRGBSerialSettingsEntry(QWidget *parent) :
|
||||
ui->ProtocolComboBox->addItem("Keyboard Visualizer");
|
||||
ui->ProtocolComboBox->addItem("Adalight");
|
||||
ui->ProtocolComboBox->addItem("TPM2");
|
||||
ui->ProtocolComboBox->addItem("Basic I2C");
|
||||
}
|
||||
|
||||
OpenRGBSerialSettingsEntry::~OpenRGBSerialSettingsEntry()
|
||||
@@ -26,3 +27,16 @@ void OpenRGBSerialSettingsEntry::changeEvent(QEvent *event)
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBSerialSettingsEntry::on_ProtocolComboBox_currentIndexChanged(int index)
|
||||
{
|
||||
if(index == 3)
|
||||
{
|
||||
ui->BaudLabel->setText("Address:");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->BaudLabel->setText("Baud:");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ class Ui::OpenRGBSerialSettingsEntry : public QWidget
|
||||
private slots:
|
||||
void changeEvent(QEvent *event);
|
||||
|
||||
void on_ProtocolComboBox_currentIndexChanged(int index);
|
||||
|
||||
public:
|
||||
explicit OpenRGBSerialSettingsEntry(QWidget *parent = nullptr);
|
||||
~OpenRGBSerialSettingsEntry();
|
||||
|
||||
@@ -62,6 +62,10 @@ OpenRGBSerialSettingsPage::OpenRGBSerialSettingsPage(QWidget *parent) :
|
||||
{
|
||||
entry->ui->ProtocolComboBox->setCurrentIndex(2);
|
||||
}
|
||||
else if(protocol_string == "basic_i2c")
|
||||
{
|
||||
entry->ui->ProtocolComboBox->setCurrentIndex(3);
|
||||
}
|
||||
}
|
||||
|
||||
entries.push_back(entry);
|
||||
@@ -154,6 +158,9 @@ void Ui::OpenRGBSerialSettingsPage::on_SaveSerialConfigurationButton_clicked()
|
||||
case 2:
|
||||
ledstrip_settings["devices"][device_idx]["protocol"] = "tpm2";
|
||||
break;
|
||||
case 3:
|
||||
ledstrip_settings["devices"][device_idx]["protocol"] = "basic_i2c";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user