mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add brightness setting
Adds a setting to control the device's brightness. Currently I have only the OSTC 3. Will add more afterwards. Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com> Signed-off-by: Thiago Macieira <thiago@macieira.org>
This commit is contained in:
parent
a7a74ae9a6
commit
2432350064
5 changed files with 58 additions and 0 deletions
|
@ -34,6 +34,11 @@ void ConfigureDiveComputer::setDeviceDateAndTime(device_data_t *data, QDateTime
|
|||
writeSettingToDevice(data, "DateAndTime", dateAndTime);
|
||||
}
|
||||
|
||||
void ConfigureDiveComputer::setDeviceBrightness(device_data_t *data, int brighnessLevel)
|
||||
{
|
||||
writeSettingToDevice(data, "Brightness", brighnessLevel);
|
||||
}
|
||||
|
||||
void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState)
|
||||
{
|
||||
currentState = newState;
|
||||
|
@ -151,6 +156,17 @@ void WriteSettingsThread::run()
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (m_settingName == "Brightness") {
|
||||
switch (dc_device_get_type(data->device)) {
|
||||
case DC_FAMILY_HW_OSTC3:
|
||||
qDebug() << "Brightness";
|
||||
supported = true;
|
||||
unsigned char packet[1] = { m_settingValue.toInt() };
|
||||
result = hw_ostc3_device_config_write(data->device, 0x2D, packet, sizeof (packet));
|
||||
break;
|
||||
}
|
||||
}
|
||||
qDebug() << result;
|
||||
if (result != DC_STATUS_SUCCESS) {
|
||||
qDebug() << result;
|
||||
lastError = tr("An error occurred while sending data to the dive computer.");
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
|
||||
void setDeviceName(device_data_t *data, QString newName);
|
||||
void setDeviceDateAndTime(device_data_t *data, QDateTime dateAndTime);
|
||||
void setDeviceBrightness(device_data_t *data, int brighnessLevel);
|
||||
signals:
|
||||
void deviceSettings(QString settings);
|
||||
void message(QString msg);
|
||||
|
|
|
@ -210,3 +210,9 @@ void ConfigureDiveComputerDialog::on_setDateAndTime_clicked()
|
|||
getDeviceData();
|
||||
config->setDeviceDateAndTime(&device_data, QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
void ConfigureDiveComputerDialog::on_setBrightnessButton_clicked()
|
||||
{
|
||||
getDeviceData();
|
||||
config->setDeviceBrightness(&device_data, ui->brightnessComboBox->currentIndex());
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ private slots:
|
|||
|
||||
void on_setDateAndTime_clicked();
|
||||
|
||||
void on_setBrightnessButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::ConfigureDiveComputerDialog *ui;
|
||||
|
||||
|
|
|
@ -110,6 +110,39 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Brightness:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="brightnessComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Eco</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Medium</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>High</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="setBrightnessButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
Loading…
Add table
Reference in a new issue