Add Basic I2C to serial settings

This commit is contained in:
Adam Honse
2022-11-27 05:00:14 -06:00
parent 7a6faeddf3
commit 520c8a8938
4 changed files with 25 additions and 8 deletions

View File

@@ -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)

View File

@@ -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:");
}
}

View File

@@ -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();

View File

@@ -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;
}
}