added light mux class and some ui interaction

This commit is contained in:
Hendrik Schutter 2019-02-09 11:53:27 +01:00
parent 5aa92bbf57
commit bb58761e6d
6 changed files with 105 additions and 9 deletions

View File

@ -26,10 +26,12 @@ CONFIG += c++11
SOURCES += \
main.cpp \
mainwindow.cpp
mainwindow.cpp \
lightmux.cpp
HEADERS += \
mainwindow.h
mainwindow.h \
lightmux.h
FORMS += \
mainwindow.ui

View File

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

View File

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

View File

@ -9,6 +9,13 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);
setFixedSize(400,360);
lmux = new LightMux();
ui->lcdBrightness->setDigitCount(3);
ui->lcdTemperature->setDigitCount(4);
updateUI();
}
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){
ui->labelPowerCold->setText("Output Power Cold: " + QString::number(val) + " %");
//ui->labelPowerCold->setText("Output Power Cold: " + QString::number(val) + " %");
}
void MainWindow::on_BtnIncreaseBrightness_clicked()
{
//qDebug( "BtnIncreaseBrightness_clicked\n");
}
void MainWindow::on_BtnDecreaseBrightness_clicked()

View File

@ -2,6 +2,7 @@
#define MAINWINDOW_H
#include <QMainWindow>
#include "lightmux.h"
namespace Ui {
class MainWindow;
@ -31,6 +32,9 @@ private slots:
private:
Ui::MainWindow *ui;
LightMux *lmux;
void updateUI();
};
#endif // MAINWINDOW_H

View File

@ -17,7 +17,7 @@
<widget class="QLCDNumber" name="lcdBrightness">
<property name="geometry">
<rect>
<x>260</x>
<x>30</x>
<y>20</y>
<width>111</width>
<height>61</height>
@ -27,7 +27,7 @@
<widget class="QLCDNumber" name="lcdTemperature">
<property name="geometry">
<rect>
<x>30</x>
<x>250</x>
<y>20</y>
<width>111</width>
<height>61</height>
@ -50,10 +50,10 @@
<widget class="QLabel" name="labelTemperature">
<property name="geometry">
<rect>
<x>280</x>
<x>270</x>
<y>0</y>
<width>71</width>
<height>18</height>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="text">