implemented adaptive brightness

This commit is contained in:
Hendrik Schutter 2019-02-10 17:55:09 +01:00
parent 790a09f255
commit 46fcc4d63c
3 changed files with 58 additions and 4 deletions

View File

@ -3,18 +3,27 @@
LightMux::LightMux()
{
temperatur = warmest_temperature;
brightness = 50;
brightness = 100;
power_cold = 0;
power_warm = 0;
power_combined = 0;
adaptive_brightness = false;
fullCommonColor = ((warmest_temperature + coldest_temperature) / 2);
qDebug("full common color: %i\n", fullCommonColor);
}
void LightMux::mux(){
if(adaptive_brightness == true){
qDebug("adaptiv\n");
mux_adaptiv();
} else {
qDebug("linear\n");
mux_linear();
}
}
int fullCommonColor = ((warmest_temperature + coldest_temperature) / 2);
qDebug("full common color: %i\n", fullCommonColor);
void LightMux::mux_linear() {
if(temperatur == fullCommonColor){
qDebug("same as full common color\n");
@ -50,6 +59,44 @@ void LightMux::mux(){
}
void LightMux::mux_adaptiv(){
if(temperatur == fullCommonColor){
qDebug("same as full common color\n");
power_cold = 50;
power_warm = 50;
} else if(temperatur < fullCommonColor) {
qDebug("lower as full common color\n");
// warm led dominant
// cold led recessive
double a = double((temperatur) - (warmest_temperature));
double b = double((-warmest_temperature + coldest_temperature));
double c = a / b * 100;
power_cold = static_cast<int>(c + .5);
power_warm = 100 - power_cold;
} else if(temperatur > fullCommonColor) {
qDebug("higher as full common color\n");
// cold led dominant
// warm led recessive
double a = double((temperatur) - (coldest_temperature));
double b = double((-coldest_temperature + warmest_temperature));
double c = a / b * 100;
power_warm = static_cast<int>(c + .5);
power_cold = 100 - power_warm;
}
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);
power_combined = static_cast<int>(double(power_cold+power_warm) / 2.0);
}
void LightMux::decBrightness(){
brightness--;
if(brightness < 0){

View File

@ -17,6 +17,8 @@ private:
int power_warm; // power of the warm LEDs of Panels in percent
int power_combined; //combined power of both LEDs in percent
int fullCommonColor; // color mix with both LED´s at same brightess
bool adaptive_brightness; // true indecates adaptive brightness is enabled
public:
@ -48,6 +50,9 @@ public:
void toogleAdaptiveBrightness();
private:
void mux_linear(); // brightness will vary by different color temperature
void mux_adaptiv(); // same brightness by different color temperature
};
#endif // LIGHTMUX_H

View File

@ -114,4 +114,6 @@ void MainWindow::on_lineTemperature_returnPressed()
void MainWindow::on_checkBox_stateChanged()
{
lmux->toogleAdaptiveBrightness();
lmux->mux();
updateUI();
}