add light mixer
This commit is contained in:
parent
236dc6a9b1
commit
67d7f64610
|
@ -3,7 +3,49 @@
|
||||||
LightMux::LightMux()
|
LightMux::LightMux()
|
||||||
{
|
{
|
||||||
temperatur = warmest_temperature;
|
temperatur = warmest_temperature;
|
||||||
brightness = 0;
|
brightness = 50;
|
||||||
|
power_cold = 0;
|
||||||
|
power_warm = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LightMux::mux(){
|
||||||
|
|
||||||
|
int fullCommonColor = ((warmest_temperature + coldest_temperature) / 2);
|
||||||
|
|
||||||
|
qDebug("full common color: %i\n", fullCommonColor);
|
||||||
|
|
||||||
|
if(temperatur == fullCommonColor){
|
||||||
|
qDebug("same as full common color\n");
|
||||||
|
power_cold = 100;
|
||||||
|
power_warm = 100;
|
||||||
|
} else if(temperatur < fullCommonColor) {
|
||||||
|
qDebug("lower as full common color\n");
|
||||||
|
// warm led dominant
|
||||||
|
// cold led recessive
|
||||||
|
power_warm = 100;
|
||||||
|
double a = double(((temperatur * (power_warm/100)) - ((power_warm/100) * warmest_temperature)));
|
||||||
|
double b = double((coldest_temperature - temperatur));
|
||||||
|
double c = a / b * 100;
|
||||||
|
power_cold = static_cast<int>(c + .5);
|
||||||
|
} else if(temperatur > fullCommonColor) {
|
||||||
|
qDebug("higher as full common color\n");
|
||||||
|
// cold led dominant
|
||||||
|
// warm led recessive
|
||||||
|
power_cold = 100;
|
||||||
|
double a = double(((temperatur * (power_cold/100)) - ((power_cold/100) * coldest_temperature)));
|
||||||
|
double b = double((warmest_temperature - temperatur));
|
||||||
|
double c = a / b * 100;
|
||||||
|
power_warm = static_cast<int>(c + .5);
|
||||||
|
}
|
||||||
|
|
||||||
|
power_cold = static_cast<int>(double(power_cold * (double(brightness/100.0))) + .5);
|
||||||
|
power_warm = static_cast<int>(double(power_warm * (double(brightness/100.0))) + .5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
qDebug("cold color: %i\nwarm color: %i\n", power_cold, power_warm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,3 +141,11 @@ int LightMux::getColdest_temperature(){
|
||||||
int LightMux::getWarmest_temperature(){
|
int LightMux::getWarmest_temperature(){
|
||||||
return warmest_temperature;
|
return warmest_temperature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LightMux::getPowerCold(){
|
||||||
|
return power_cold;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LightMux::getPowerWarm(){
|
||||||
|
return power_warm;
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ private:
|
||||||
int warmest_temperature = 2700; // warmest possible temperature in Kelvin --> the warm LEDs
|
int warmest_temperature = 2700; // warmest possible temperature in Kelvin --> the warm LEDs
|
||||||
int steps_temperature = 100; // steps to change the temperature in Kelvin
|
int steps_temperature = 100; // steps to change the temperature in Kelvin
|
||||||
|
|
||||||
|
int power_cold; // power of the cold LEDs of Panels in percent
|
||||||
|
int power_warm; // power of the warm LEDs of Panels in percent
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LightMux();
|
LightMux();
|
||||||
|
@ -34,6 +36,11 @@ public:
|
||||||
int getColdest_temperature();
|
int getColdest_temperature();
|
||||||
int getWarmest_temperature();
|
int getWarmest_temperature();
|
||||||
|
|
||||||
|
void mux();
|
||||||
|
|
||||||
|
int getPowerCold();
|
||||||
|
int getPowerWarm();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LIGHTMUX_H
|
#endif // LIGHTMUX_H
|
||||||
|
|
|
@ -16,6 +16,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
ui->lineBrightness->setValidator(new QIntValidator(0, 100, this));
|
ui->lineBrightness->setValidator(new QIntValidator(0, 100, this));
|
||||||
ui->lineTemperature->setValidator(new QIntValidator(lmux->getWarmest_temperature(), lmux->getColdest_temperature(), this));
|
ui->lineTemperature->setValidator(new QIntValidator(lmux->getWarmest_temperature(), lmux->getColdest_temperature(), this));
|
||||||
|
|
||||||
|
lmux->mux();
|
||||||
|
|
||||||
updateUI();
|
updateUI();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,61 +28,71 @@ MainWindow::~MainWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::updateUI(){
|
void MainWindow::updateUI()
|
||||||
|
{
|
||||||
ui->lcdBrightness->display(lmux->getBrightness());
|
ui->lcdBrightness->display(lmux->getBrightness());
|
||||||
ui->lcdTemperature->display(lmux->getTemperature());
|
ui->lcdTemperature->display(lmux->getTemperature());
|
||||||
ui->lineTemperature->clear();
|
ui->lineTemperature->clear();
|
||||||
ui->lineBrightness->clear();
|
ui->lineBrightness->clear();
|
||||||
|
|
||||||
|
setLablePowerCold(lmux->getPowerCold());
|
||||||
|
setLablePowerWarm(lmux->getPowerWarm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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::setLablePowerWarm(int val)
|
||||||
|
{
|
||||||
|
ui->labelPowerWarm->setText("Output Power Warm: " + QString::number(val) + " %");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_BtnIncreaseBrightness_clicked()
|
void MainWindow::on_BtnIncreaseBrightness_clicked()
|
||||||
{
|
{
|
||||||
lmux->incBrightness();
|
lmux->incBrightness();
|
||||||
|
lmux->mux();
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_BtnDecreaseBrightness_clicked()
|
void MainWindow::on_BtnDecreaseBrightness_clicked()
|
||||||
{
|
{
|
||||||
lmux->decBrightness();
|
lmux->decBrightness();
|
||||||
|
lmux->mux();
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_BtnIncreaseTemperatur_clicked()
|
void MainWindow::on_BtnIncreaseTemperatur_clicked()
|
||||||
{
|
{
|
||||||
lmux->cold_Temperature();
|
lmux->cold_Temperature();
|
||||||
|
lmux->mux();
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_BtnDecreaseTemperatur_clicked()
|
void MainWindow::on_BtnDecreaseTemperatur_clicked()
|
||||||
{
|
{
|
||||||
lmux->warm_Temperature();
|
lmux->warm_Temperature();
|
||||||
|
lmux->mux();
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_BtnSetBrightness_clicked()
|
void MainWindow::on_BtnSetBrightness_clicked()
|
||||||
{
|
{
|
||||||
lmux->setBrightness(ui->lineBrightness->text().toInt());
|
lmux->setBrightness(ui->lineBrightness->text().toInt());
|
||||||
|
lmux->mux();
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_BtnSetTemperatur_clicked()
|
void MainWindow::on_BtnSetTemperatur_clicked()
|
||||||
{
|
{
|
||||||
lmux->setTemperature(ui->lineTemperature->text().toInt());
|
lmux->setTemperature(ui->lineTemperature->text().toInt());
|
||||||
|
lmux->mux();
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_lineBrightness_returnPressed()
|
void MainWindow::on_lineBrightness_returnPressed()
|
||||||
{
|
{
|
||||||
on_BtnSetBrightness_clicked();
|
on_BtnSetBrightness_clicked();
|
||||||
|
@ -90,3 +102,5 @@ void MainWindow::on_lineTemperature_returnPressed()
|
||||||
{
|
{
|
||||||
on_BtnSetTemperatur_clicked();
|
on_BtnSetTemperatur_clicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
void setLablePowerCold(int val);
|
void setLablePowerCold(int val);
|
||||||
|
void setLablePowerWarm(int val);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_BtnIncreaseBrightness_clicked();
|
void on_BtnIncreaseBrightness_clicked();
|
||||||
|
@ -31,7 +32,6 @@ private slots:
|
||||||
|
|
||||||
void on_BtnSetTemperatur_clicked();
|
void on_BtnSetTemperatur_clicked();
|
||||||
|
|
||||||
|
|
||||||
void on_lineBrightness_returnPressed();
|
void on_lineBrightness_returnPressed();
|
||||||
|
|
||||||
void on_lineTemperature_returnPressed();
|
void on_lineTemperature_returnPressed();
|
||||||
|
|
|
@ -231,7 +231,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>220</y>
|
<y>220</y>
|
||||||
<width>131</width>
|
<width>201</width>
|
||||||
<height>18</height>
|
<height>18</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -244,7 +244,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>250</y>
|
<y>250</y>
|
||||||
<width>131</width>
|
<width>211</width>
|
||||||
<height>18</height>
|
<height>18</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue