From bb58761e6db8725f359186d1bcef93d71ed02740 Mon Sep 17 00:00:00 2001 From: localhorst Date: Sat, 9 Feb 2019 11:53:27 +0100 Subject: [PATCH] added light mux class and some ui interaction --- FilmLightController/FilmLightController.pro | 6 ++- FilmLightController/lightmux.cpp | 44 +++++++++++++++++++++ FilmLightController/lightmux.h | 31 +++++++++++++++ FilmLightController/mainwindow.cpp | 19 ++++++++- FilmLightController/mainwindow.h | 4 ++ FilmLightController/mainwindow.ui | 10 ++--- 6 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 FilmLightController/lightmux.cpp create mode 100644 FilmLightController/lightmux.h diff --git a/FilmLightController/FilmLightController.pro b/FilmLightController/FilmLightController.pro index d98c835..bba53dc 100644 --- a/FilmLightController/FilmLightController.pro +++ b/FilmLightController/FilmLightController.pro @@ -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 diff --git a/FilmLightController/lightmux.cpp b/FilmLightController/lightmux.cpp new file mode 100644 index 0000000..28ad9fb --- /dev/null +++ b/FilmLightController/lightmux.cpp @@ -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; +} diff --git a/FilmLightController/lightmux.h b/FilmLightController/lightmux.h new file mode 100644 index 0000000..1215ad0 --- /dev/null +++ b/FilmLightController/lightmux.h @@ -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 diff --git a/FilmLightController/mainwindow.cpp b/FilmLightController/mainwindow.cpp index e00a4ce..0bc10c5 100644 --- a/FilmLightController/mainwindow.cpp +++ b/FilmLightController/mainwindow.cpp @@ -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() diff --git a/FilmLightController/mainwindow.h b/FilmLightController/mainwindow.h index f786d38..d72b83d 100644 --- a/FilmLightController/mainwindow.h +++ b/FilmLightController/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include "lightmux.h" namespace Ui { class MainWindow; @@ -31,6 +32,9 @@ private slots: private: Ui::MainWindow *ui; + LightMux *lmux; + + void updateUI(); }; #endif // MAINWINDOW_H diff --git a/FilmLightController/mainwindow.ui b/FilmLightController/mainwindow.ui index 37c3cc7..7d3b46b 100644 --- a/FilmLightController/mainwindow.ui +++ b/FilmLightController/mainwindow.ui @@ -17,7 +17,7 @@ - 260 + 30 20 111 61 @@ -27,7 +27,7 @@ - 30 + 250 20 111 61 @@ -50,10 +50,10 @@ - 280 + 270 0 - 71 - 18 + 81 + 20