added light mux class and some ui interaction
This commit is contained in:
parent
5aa92bbf57
commit
bb58761e6d
|
@ -26,10 +26,12 @@ CONFIG += c++11
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp
|
mainwindow.cpp \
|
||||||
|
lightmux.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
mainwindow.h
|
mainwindow.h \
|
||||||
|
lightmux.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include "lightmux.h"
|
||||||
|
|
||||||
|
LightMux::LightMux()
|
||||||
|
{
|
||||||
|
temperatur = warmest_temperature;
|
||||||
|
brightness = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LightMux::decBrightness(){
|
||||||
|
brightness--;
|
||||||
|
if(brightness < 0){
|
||||||
|
brightness = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightMux::incBrightness(){
|
||||||
|
brightness++;
|
||||||
|
if(brightness > 100){
|
||||||
|
brightness = 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightMux::warm_Temperature(){
|
||||||
|
temperatur = temperatur - steps_temperature;
|
||||||
|
if(temperatur < warmest_temperature){
|
||||||
|
temperatur = warmest_temperature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightMux::cold_Temperature(){
|
||||||
|
temperatur = temperatur + steps_temperature;
|
||||||
|
if(temperatur > coldest_temperature){
|
||||||
|
temperatur = coldest_temperature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int LightMux::getBrightness(){
|
||||||
|
return brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LightMux::getTemperature(){
|
||||||
|
return temperatur;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef LIGHTMUX_H
|
||||||
|
#define LIGHTMUX_H
|
||||||
|
|
||||||
|
|
||||||
|
class LightMux
|
||||||
|
{
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
int coldest_temperature = 6500; // coldest possible temperature in Kelvin --> the cold LEDs
|
||||||
|
int warmest_temperature = 2700; // warmest possible temperature in Kelvin --> the warm LEDs
|
||||||
|
int steps_temperature = 100; // steps to change the temperature in Kelvin
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
LightMux();
|
||||||
|
|
||||||
|
void incBrightness();
|
||||||
|
void decBrightness();
|
||||||
|
|
||||||
|
void cold_Temperature();
|
||||||
|
void warm_Temperature();
|
||||||
|
|
||||||
|
int getBrightness();
|
||||||
|
|
||||||
|
int getTemperature();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIGHTMUX_H
|
|
@ -9,6 +9,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setFixedSize(400,360);
|
setFixedSize(400,360);
|
||||||
|
|
||||||
|
lmux = new LightMux();
|
||||||
|
|
||||||
|
ui->lcdBrightness->setDigitCount(3);
|
||||||
|
ui->lcdTemperature->setDigitCount(4);
|
||||||
|
|
||||||
|
updateUI();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -17,14 +24,22 @@ MainWindow::~MainWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::updateUI(){
|
||||||
|
|
||||||
|
ui->lcdBrightness->display(lmux->getBrightness());
|
||||||
|
ui->lcdTemperature->display(lmux->getTemperature());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::setLablePowerCold(int val){
|
void MainWindow::setLablePowerCold(int val){
|
||||||
|
|
||||||
ui->labelPowerCold->setText("Output Power Cold: " + QString::number(val) + " %");
|
//ui->labelPowerCold->setText("Output Power Cold: " + QString::number(val) + " %");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_BtnIncreaseBrightness_clicked()
|
void MainWindow::on_BtnIncreaseBrightness_clicked()
|
||||||
{
|
{
|
||||||
|
//qDebug( "BtnIncreaseBrightness_clicked\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_BtnDecreaseBrightness_clicked()
|
void MainWindow::on_BtnDecreaseBrightness_clicked()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include "lightmux.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
@ -31,6 +32,9 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
LightMux *lmux;
|
||||||
|
|
||||||
|
void updateUI();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<widget class="QLCDNumber" name="lcdBrightness">
|
<widget class="QLCDNumber" name="lcdBrightness">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>260</x>
|
<x>30</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>111</width>
|
<width>111</width>
|
||||||
<height>61</height>
|
<height>61</height>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<widget class="QLCDNumber" name="lcdTemperature">
|
<widget class="QLCDNumber" name="lcdTemperature">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>250</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>111</width>
|
<width>111</width>
|
||||||
<height>61</height>
|
<height>61</height>
|
||||||
|
@ -50,10 +50,10 @@
|
||||||
<widget class="QLabel" name="labelTemperature">
|
<widget class="QLabel" name="labelTemperature">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>280</x>
|
<x>270</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>71</width>
|
<width>81</width>
|
||||||
<height>18</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
Loading…
Reference in New Issue