set Btn implemented
This commit is contained in:
parent
bb58761e6d
commit
236dc6a9b1
|
@ -2,8 +2,8 @@
|
|||
|
||||
LightMux::LightMux()
|
||||
{
|
||||
temperatur = warmest_temperature;
|
||||
brightness = 0;
|
||||
temperatur = warmest_temperature;
|
||||
brightness = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,20 @@ void LightMux::incBrightness(){
|
|||
}
|
||||
}
|
||||
|
||||
void LightMux::setBrightness(int val){
|
||||
|
||||
brightness = val;
|
||||
|
||||
if(brightness < 0){
|
||||
brightness = 0;
|
||||
}
|
||||
|
||||
if(brightness > 100){
|
||||
brightness = 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LightMux::warm_Temperature(){
|
||||
temperatur = temperatur - steps_temperature;
|
||||
if(temperatur < warmest_temperature){
|
||||
|
@ -35,6 +49,41 @@ void LightMux::cold_Temperature(){
|
|||
}
|
||||
}
|
||||
|
||||
void LightMux::setTemperature(int requested_val){
|
||||
|
||||
int current_temp = warmest_temperature;
|
||||
|
||||
/* out of range */
|
||||
|
||||
if(requested_val < warmest_temperature){
|
||||
temperatur = warmest_temperature;
|
||||
return;
|
||||
}
|
||||
|
||||
if(requested_val > coldest_temperature){
|
||||
temperatur = coldest_temperature;
|
||||
return;
|
||||
}
|
||||
|
||||
/* between range, map to steps */
|
||||
|
||||
while(true){
|
||||
if(requested_val <= current_temp){
|
||||
|
||||
temperatur = current_temp;
|
||||
|
||||
int diff = current_temp - requested_val;
|
||||
|
||||
if(diff > (steps_temperature/2)){
|
||||
warm_Temperature();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
current_temp = current_temp + steps_temperature;
|
||||
}
|
||||
}
|
||||
|
||||
int LightMux::getBrightness(){
|
||||
return brightness;
|
||||
}
|
||||
|
@ -42,3 +91,11 @@ int LightMux::getBrightness(){
|
|||
int LightMux::getTemperature(){
|
||||
return temperatur;
|
||||
}
|
||||
|
||||
int LightMux::getColdest_temperature(){
|
||||
return coldest_temperature;
|
||||
}
|
||||
|
||||
int LightMux::getWarmest_temperature(){
|
||||
return warmest_temperature;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#ifndef LIGHTMUX_H
|
||||
#define LIGHTMUX_H
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
class LightMux
|
||||
{
|
||||
private:
|
||||
|
||||
int brightness; // total power of the LED Panels (both colors) in percent
|
||||
int temperatur; // muxed color temperature of the LED Panels, from coldest to warmest in Kelvin
|
||||
|
@ -19,13 +20,20 @@ public:
|
|||
void incBrightness();
|
||||
void decBrightness();
|
||||
|
||||
void setBrightness(int val); // set total power of the LED Panels (both colors) in percent
|
||||
|
||||
void cold_Temperature();
|
||||
void warm_Temperature();
|
||||
|
||||
void setTemperature(int requested_val); // set muxed color temperature of the LED Panels, from coldest to warmest in Kelvin. Fitted to the nearest value that the steps allow
|
||||
|
||||
int getBrightness();
|
||||
|
||||
int getTemperature();
|
||||
|
||||
int getColdest_temperature();
|
||||
int getWarmest_temperature();
|
||||
|
||||
};
|
||||
|
||||
#endif // LIGHTMUX_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
|
@ -13,6 +13,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
|
||||
ui->lcdBrightness->setDigitCount(3);
|
||||
ui->lcdTemperature->setDigitCount(4);
|
||||
ui->lineBrightness->setValidator(new QIntValidator(0, 100, this));
|
||||
ui->lineTemperature->setValidator(new QIntValidator(lmux->getWarmest_temperature(), lmux->getColdest_temperature(), this));
|
||||
|
||||
updateUI();
|
||||
|
||||
|
@ -26,43 +28,65 @@ MainWindow::~MainWindow()
|
|||
|
||||
void MainWindow::updateUI(){
|
||||
|
||||
ui->lcdBrightness->display(lmux->getBrightness());
|
||||
ui->lcdTemperature->display(lmux->getTemperature());
|
||||
|
||||
ui->lcdBrightness->display(lmux->getBrightness());
|
||||
ui->lcdTemperature->display(lmux->getTemperature());
|
||||
ui->lineTemperature->clear();
|
||||
ui->lineBrightness->clear();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setLablePowerCold(int val){
|
||||
|
||||
//ui->labelPowerCold->setText("Output Power Cold: " + QString::number(val) + " %");
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_BtnIncreaseBrightness_clicked()
|
||||
{
|
||||
//qDebug( "BtnIncreaseBrightness_clicked\n");
|
||||
lmux->incBrightness();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void MainWindow::on_BtnDecreaseBrightness_clicked()
|
||||
{
|
||||
|
||||
lmux->decBrightness();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void MainWindow::on_BtnIncreaseTemperatur_clicked()
|
||||
{
|
||||
|
||||
lmux->cold_Temperature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void MainWindow::on_BtnDecreaseTemperatur_clicked()
|
||||
{
|
||||
|
||||
lmux->warm_Temperature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void MainWindow::on_BtnSetBrightness_clicked()
|
||||
{
|
||||
lmux->setBrightness(ui->lineBrightness->text().toInt());
|
||||
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void MainWindow::on_BtnSetTemperatur_clicked()
|
||||
{
|
||||
lmux->setTemperature(ui->lineTemperature->text().toInt());
|
||||
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::on_lineBrightness_returnPressed()
|
||||
{
|
||||
on_BtnSetBrightness_clicked();
|
||||
}
|
||||
|
||||
void MainWindow::on_lineTemperature_returnPressed()
|
||||
{
|
||||
on_BtnSetTemperatur_clicked();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QIntValidator>
|
||||
#include "lightmux.h"
|
||||
|
||||
namespace Ui {
|
||||
|
@ -30,6 +31,11 @@ private slots:
|
|||
|
||||
void on_BtnSetTemperatur_clicked();
|
||||
|
||||
|
||||
void on_lineBrightness_returnPressed();
|
||||
|
||||
void on_lineTemperature_returnPressed();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
LightMux *lmux;
|
||||
|
|
|
@ -60,26 +60,6 @@
|
|||
<string>Temperature</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBoxBrightness">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>150</y>
|
||||
<width>71</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBoxTemperatur">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>150</y>
|
||||
<width>71</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnIncreaseBrightness">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
|
@ -92,6 +72,15 @@
|
|||
<property name="text">
|
||||
<string>Increase</string>
|
||||
</property>
|
||||
<property name="autoRepeat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRepeatDelay">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="autoRepeatInterval">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnDecreaseBrightness">
|
||||
<property name="geometry">
|
||||
|
@ -105,6 +94,15 @@
|
|||
<property name="text">
|
||||
<string>Decrease</string>
|
||||
</property>
|
||||
<property name="autoRepeat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRepeatDelay">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="autoRepeatInterval">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnIncreaseTemperatur">
|
||||
<property name="geometry">
|
||||
|
@ -118,6 +116,15 @@
|
|||
<property name="text">
|
||||
<string>Increase</string>
|
||||
</property>
|
||||
<property name="autoRepeat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRepeatDelay">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="autoRepeatInterval">
|
||||
<number>70</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnDecreaseTemperatur">
|
||||
<property name="geometry">
|
||||
|
@ -131,6 +138,15 @@
|
|||
<property name="text">
|
||||
<string>Decrease</string>
|
||||
</property>
|
||||
<property name="autoRepeat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRepeatDelay">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="autoRepeatInterval">
|
||||
<number>70</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="BtnSetBrightness">
|
||||
<property name="geometry">
|
||||
|
@ -236,6 +252,26 @@
|
|||
<string>Output Power Warm:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineBrightness">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>150</y>
|
||||
<width>81</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineTemperature">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>150</y>
|
||||
<width>71</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="enabled">
|
||||
|
|
Loading…
Reference in New Issue